diff --git a/src/Backup.php b/src/Backup.php index 37bcb8e..57ae5e9 100644 --- a/src/Backup.php +++ b/src/Backup.php @@ -12,10 +12,6 @@ class Backup */ protected $backupLocation; - - //-------------------------------------------------------------------- - - /** * $config * @@ -24,10 +20,6 @@ class Backup */ protected $config; - - //-------------------------------------------------------------------- - - /** * $database * @@ -35,10 +27,6 @@ class Backup */ protected $database; - - //-------------------------------------------------------------------- - - /** * __construct * @@ -63,10 +51,6 @@ public function __construct($backupLocation = '', Database $database) } } - - //-------------------------------------------------------------------- - - /** * save() * @@ -84,10 +68,6 @@ public function create() throw new \Exception('Error backing up database.'); } - - //-------------------------------------------------------------------- - - /** * find() * @@ -109,10 +89,6 @@ public function find() return $backups; } - - //-------------------------------------------------------------------- - - /** * clean() * @@ -124,10 +100,6 @@ public function clean() return array_map('unlink', glob(realpath($this->backupLocation)."/*.zip")); } - - //-------------------------------------------------------------------- - - /** * rollback() * @@ -144,10 +116,6 @@ public function rollback() return $this->extract($restore, $this->config->dir); } - - //-------------------------------------------------------------------- - - /** * extract() * @@ -172,10 +140,6 @@ protected function extract($source = '', $target = '') return false; } - - //-------------------------------------------------------------------- - - /** * zip() * @@ -218,13 +182,11 @@ protected function zip($source = '', $target = '') $zip->addFromString(str_replace($source . '/', '', $file), file_get_contents($file)); } } - + } return $zip->close(); - - } - + } } diff --git a/src/Cache.php b/src/Cache.php index 47090f3..7eaa710 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -26,9 +26,6 @@ class Cache */ protected $key; - - //-------------------------------------------------------------------- - /** * __construct() * @@ -44,10 +41,6 @@ public function __construct(Database $database) ]); } - - //-------------------------------------------------------------------- - - /** * setKey() * @@ -60,10 +53,6 @@ public function setKey($key) $this->key = md5($key); } - - //-------------------------------------------------------------------- - - /** * getKey() * @@ -73,10 +62,6 @@ public function getKey() return $this->key; } - - //-------------------------------------------------------------------- - - /** * flush() * @@ -86,10 +71,6 @@ public function flush() $this->cache_database->flush(true); } - - //-------------------------------------------------------------------- - - /** * expired() * @@ -106,10 +87,6 @@ public function expired($time) return true; } - - //-------------------------------------------------------------------- - - /** * getDocuments() * @@ -125,10 +102,6 @@ public function getDocuments($documents) return $d; } - - //-------------------------------------------------------------------- - - /** * get() * @@ -155,10 +128,6 @@ public function get() return $this->getDocuments($cache_doc->toArray()); } - - //-------------------------------------------------------------------- - - /** * store() * @@ -173,8 +142,4 @@ public function store($data) return $this->cache_database->get( $this->getKey() )->set($data)->save(); } - - //-------------------------------------------------------------------- - - } diff --git a/src/Config.php b/src/Config.php index 304f931..56c2d3b 100644 --- a/src/Config.php +++ b/src/Config.php @@ -11,7 +11,6 @@ class Config */ public $dir = __DIR__; - /** * $format * Format Class @@ -19,7 +18,6 @@ class Config */ public $format = \Filebase\Format\Json::class; - /** * $cache * Caching for queries @@ -28,7 +26,6 @@ class Config */ public $cache = true; - /** * $cache_time * When should cache be cleared? @@ -37,7 +34,6 @@ class Config */ public $cache_expires = 1800; - /** * $safe_filename * (if true) Be sure to automatically change the file name if it does not fit validation @@ -47,7 +43,6 @@ class Config */ public $safe_filename = true; - /** * $read_only * (if true) We will not attempt to create the database directory or allow the user to create anything @@ -57,7 +52,6 @@ class Config */ public $read_only = false; - /** * $backupLocation * The location to store backups @@ -66,7 +60,6 @@ class Config */ public $backupLocation = ''; - /** * $pretty * @@ -77,17 +70,12 @@ class Config */ public $pretty = true; - /** * $validate * */ public $validate = []; - - //-------------------------------------------------------------------- - - /** * __construct * @@ -110,10 +98,6 @@ public function __construct($config) $this->validateFormatClass(); } - - //-------------------------------------------------------------------- - - /** * format * @@ -138,8 +122,4 @@ protected function validateFormatClass() throw new \Exception('Filebase Error: Format Class must be an instance of Filebase\Format\FormatInterface'); } } - - - //-------------------------------------------------------------------- - } diff --git a/src/Database.php b/src/Database.php index 7be2a65..559b8cb 100644 --- a/src/Database.php +++ b/src/Database.php @@ -17,9 +17,6 @@ class Database */ const VERSION = '1.0.23'; - - //-------------------------------------------------------------------- - /** * $config * @@ -28,7 +25,6 @@ class Database */ protected $config; - /** * Database constructor. * @@ -57,10 +53,6 @@ public function __construct(array $config = []) } } - - //-------------------------------------------------------------------- - - /** * version * @@ -73,10 +65,6 @@ public function version() return self::VERSION; } - - //-------------------------------------------------------------------- - - /** * findAll() * @@ -117,10 +105,6 @@ public function findAll($include_documents = true, $data_only = false) return $items; } - - //-------------------------------------------------------------------- - - /** * get * @@ -148,10 +132,6 @@ public function get($id) return $document; } - - //-------------------------------------------------------------------- - - /** * has * @@ -169,10 +149,6 @@ public function has($id) return $record ? true : false; } - - //-------------------------------------------------------------------- - - /** * backup * @@ -190,10 +166,6 @@ public function backup($location = '') return new Backup($this->config->backupLocation, $this); } - - //-------------------------------------------------------------------- - - /** * set * @@ -216,10 +188,6 @@ public function set(Document $document, $data) return $document; } - - //-------------------------------------------------------------------- - - /** * count * @@ -231,10 +199,6 @@ public function count() return count($this->findAll(false)); } - - //-------------------------------------------------------------------- - - /** * @param Document $document * @param string $wdata @@ -286,10 +250,6 @@ public function save(Document $document, $wdata = '') return false; } - - //-------------------------------------------------------------------- - - /** * query * @@ -300,10 +260,6 @@ public function query() return new Query($this); } - - //-------------------------------------------------------------------- - - /** * Read and return Document from filesystem by name. * If doesn't exists return new empty Document. @@ -330,10 +286,6 @@ protected function read($name) return null; } - - //-------------------------------------------------------------------- - - /** * delete * @@ -356,9 +308,6 @@ public function delete(Document $document) return $d; } - - //-------------------------------------------------------------------- - /** * truncate * @@ -371,10 +320,6 @@ public function truncate() return $this->flush(true); } - - //-------------------------------------------------------------------- - - /** * flush * @@ -410,10 +355,6 @@ public function flush($confirm = false) throw new Exception("Could not delete all database files in ".$this->config->dir); } - - //-------------------------------------------------------------------- - - /** * flushCache * @@ -428,10 +369,6 @@ public function flushCache() } } - - //-------------------------------------------------------------------- - - /** * toArray * @@ -443,10 +380,6 @@ public function toArray(Document $document) return $this->objectToArray( $document->getData() ); } - - //-------------------------------------------------------------------- - - /** * objectToArray * @@ -467,10 +400,6 @@ public function objectToArray($obj) return $arr; } - - //-------------------------------------------------------------------- - - /** * getConfig * @@ -481,16 +410,22 @@ public function getConfig() return $this->config; } + /** + * __call + * + * Magic method to give us access to query methods on db class + * + */ public function __call($method,$args) { - if(method_exists($this,$method)) - { + if(method_exists($this,$method)) { return $this->$method(...$args); } - if(method_exists(Query::class,$method)) - { + + if(method_exists(Query::class,$method)) { return (new Query($this))->$method(...$args); } + throw new \BadMethodCallException("method {$method} not found on 'Database::class' and 'Query::class'"); } diff --git a/src/Document.php b/src/Document.php index 53513ad..0fcf27d 100644 --- a/src/Document.php +++ b/src/Document.php @@ -25,10 +25,6 @@ public function __construct($database) $this->__database = $database; } - - //-------------------------------------------------------------------- - - /** * saveAs * @@ -47,10 +43,6 @@ public function saveAs() return $data; } - - //-------------------------------------------------------------------- - - /** * save() * @@ -66,10 +58,6 @@ public function save($data = '') return $this->__database->save($this, $data); } - - //-------------------------------------------------------------------- - - /** * delete * @@ -82,10 +70,6 @@ public function delete() return $this->__database->delete($this); } - - //-------------------------------------------------------------------- - - /** * set * @@ -95,10 +79,6 @@ public function set($data) return $this->__database->set($this, $data); } - - //-------------------------------------------------------------------- - - /** * toArray * @@ -108,10 +88,6 @@ public function toArray() return $this->__database->toArray($this); } - - //-------------------------------------------------------------------- - - /** * __set * @@ -121,10 +97,6 @@ public function __set($name, $value) $this->data[$name] = $value; } - - //-------------------------------------------------------------------- - - /** * __get * @@ -139,10 +111,6 @@ public function &__get($name) return $this->data[$name]; } - - //-------------------------------------------------------------------- - - /** * __isset * @@ -152,10 +120,6 @@ public function __isset($name) return isset($this->data[$name]); } - - //-------------------------------------------------------------------- - - /** * __unset * @@ -181,10 +145,6 @@ public function filter($field = 'data', $paramOne = '', $paramTwo = '') return $this->customFilter($field, $paramOne, $paramTwo); } - - //-------------------------------------------------------------------- - - /** * customFilter * @@ -235,10 +195,6 @@ public function customFilter($field = 'data', $paramOne = '', $paramTwo = '') } - - //-------------------------------------------------------------------- - - /** * getDatabase * @@ -249,10 +205,6 @@ public function getDatabase() return $this->__database; } - - //-------------------------------------------------------------------- - - /** * getId * @@ -263,10 +215,6 @@ public function getId() return $this->__id; } - - //-------------------------------------------------------------------- - - /** * getData * @@ -277,10 +225,6 @@ public function getData() return $this->data; } - - //-------------------------------------------------------------------- - - /** * setId * @@ -293,10 +237,6 @@ public function setId($id) return $this; } - - //-------------------------------------------------------------------- - - /** * setCache * @@ -309,10 +249,6 @@ public function setFromCache($cache = true) return $this; } - - //-------------------------------------------------------------------- - - /** * isCache * @@ -322,11 +258,6 @@ public function isCache() return $this->__cache; } - - - //-------------------------------------------------------------------- - - /** * createdAt * @@ -350,10 +281,6 @@ public function createdAt($format = 'Y-m-d H:i:s') return $this->__created_at; } - - //-------------------------------------------------------------------- - - /** * updatedAt * @@ -377,10 +304,6 @@ public function updatedAt($format = 'Y-m-d H:i:s') return $this->__updated_at; } - - //-------------------------------------------------------------------- - - /** * setCreatedAt * @@ -393,10 +316,6 @@ public function setCreatedAt($created_at) return $this; } - - //-------------------------------------------------------------------- - - /** * setuUpdatedAt * @@ -409,10 +328,6 @@ public function setUpdatedAt($updated_at) return $this; } - - //-------------------------------------------------------------------- - - /** * field * diff --git a/src/Filesystem.php b/src/Filesystem.php index de16f24..307358d 100644 --- a/src/Filesystem.php +++ b/src/Filesystem.php @@ -23,11 +23,6 @@ public static function read($path) return $contents; } - - - //-------------------------------------------------------------------- - - /** * Writes data to the filesystem. * @@ -53,10 +48,6 @@ public static function write($path, $contents) return $result !== false; } - - //-------------------------------------------------------------------- - - /** * delete * @@ -73,10 +64,6 @@ public static function delete($path) return unlink($path); } - - //-------------------------------------------------------------------- - - /** * Validates the name of the file to ensure it can be stored in the * filesystem. @@ -107,10 +94,6 @@ public static function validateName($name, $safe_filename) return $name; } - - //-------------------------------------------------------------------- - - /** * Get an array containing the path of all files in this repository * @@ -128,7 +111,4 @@ public static function getAllFiles($path = '',$ext = 'json') return $files; } - - //-------------------------------------------------------------------- - } diff --git a/src/Format/Json.php b/src/Format/Json.php index 337ed38..6642208 100644 --- a/src/Format/Json.php +++ b/src/Format/Json.php @@ -11,10 +11,6 @@ public static function getFileExtension() return 'json'; } - - //-------------------------------------------------------------------- - - /** * @param array $data * @param bool $pretty @@ -41,10 +37,6 @@ public static function encode($data = [], $pretty = true) return $encoded; } - - //-------------------------------------------------------------------- - - /** * @param $data * @return mixed @@ -65,9 +57,4 @@ public static function decode($data) return $decoded; } - - - //-------------------------------------------------------------------- - - } diff --git a/src/Format/Yaml.php b/src/Format/Yaml.php index e43bc8c..10793ea 100644 --- a/src/Format/Yaml.php +++ b/src/Format/Yaml.php @@ -12,10 +12,6 @@ public static function getFileExtension() return 'yaml'; } - - //-------------------------------------------------------------------- - - /** * @param array $data * @param bool $pretty @@ -28,10 +24,6 @@ public static function encode($data = [], $pretty = true) return $encoded; } - - //-------------------------------------------------------------------- - - /** * @param $data * @return mixed @@ -42,9 +34,4 @@ public static function decode($data) $decoded = YamlParser::parse($data); return $decoded; } - - - //-------------------------------------------------------------------- - - } diff --git a/src/Predicate.php b/src/Predicate.php index 02071f1..2d15ed5 100644 --- a/src/Predicate.php +++ b/src/Predicate.php @@ -34,10 +34,6 @@ class Predicate */ protected $predicates = []; - - //-------------------------------------------------------------------- - - /** * add * @@ -82,9 +78,6 @@ public function add($logic,$arg) $this->predicates[$logic][] = $arg; } - - //-------------------------------------------------------------------- - /** * formatWhere * @@ -94,10 +87,6 @@ protected function formatWhere($key, $value) return [$key,'==',$value]; } - - //-------------------------------------------------------------------- - - /** * get * @@ -106,8 +95,4 @@ public function get() { return array_filter($this->predicates); } - - - //-------------------------------------------------------------------- - } diff --git a/src/QueryLogic.php b/src/QueryLogic.php index 0516fee..53e1c38 100644 --- a/src/QueryLogic.php +++ b/src/QueryLogic.php @@ -12,7 +12,6 @@ class QueryLogic */ protected $database; - /** * $predicate * @@ -28,10 +27,6 @@ class QueryLogic */ protected $cache = false; - - //-------------------------------------------------------------------- - - /** * __construct * @@ -47,10 +42,6 @@ public function __construct(Database $database) } } - - //-------------------------------------------------------------------- - - /** * run * @@ -122,10 +113,6 @@ public function run() return $this; } - - //-------------------------------------------------------------------- - - /** * filter * @@ -167,10 +154,6 @@ protected function filter($documents, $predicates) return $results; } - - //-------------------------------------------------------------------- - - /** * offsetLimit * @@ -183,10 +166,6 @@ protected function offsetLimit() } } - - //-------------------------------------------------------------------- - - /** * sort * @@ -202,10 +181,6 @@ protected function sort() usort($this->documents, [$sortlogic, 'sort']); } - - //-------------------------------------------------------------------- - - /** * match * @@ -252,8 +227,4 @@ public function match($document, $field, $operator, $value) } - - //-------------------------------------------------------------------- - - } diff --git a/src/Validate.php b/src/Validate.php index 15d2b59..5d29ae9 100644 --- a/src/Validate.php +++ b/src/Validate.php @@ -19,10 +19,6 @@ public static function valid(Document $object) return true; } - - //-------------------------------------------------------------------- - - /** * getValidateRules * @@ -34,10 +30,6 @@ public static function getValidateRules(Document $object) return $object->getDatabase()->getConfig()->validate; } - - //-------------------------------------------------------------------- - - /** * validateLoop * @@ -62,10 +54,6 @@ protected static function validateLoop($document,$object,$rules) } } - - //-------------------------------------------------------------------- - - /** * validateRules * @@ -104,10 +92,6 @@ protected static function validateRules($document,$key,$rules,$object) return $object; } - - //-------------------------------------------------------------------- - - /** * checkType * @@ -152,9 +136,4 @@ protected static function checkType($variable, $type) return false; } - - - //-------------------------------------------------------------------- - - }