Skip to content

Commit

Permalink
BaseModel/Model - Updated PHPDoc Comments
Browse files Browse the repository at this point in the history
  • Loading branch information
najdanovicivan committed Dec 7, 2020
1 parent 885f39d commit 9ba8b72
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 38 deletions.
63 changes: 28 additions & 35 deletions system/BaseModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ abstract class BaseModel
protected $tempData = [];

/**
* Model constructor.
* BaseModel constructor.
*
* @param object|null $db DB Connection
* @param ValidationInterface|null $validation Validation
Expand All @@ -317,12 +317,11 @@ public function __construct(object &$db = null, ValidationInterface $validation
//--------------------------------------------------------------------

/**
* Fetches the row of database from $this->table with a primary key
* matching $id.
* Fetches the row of database
*
* @param array|integer|string|null $id One primary key or an array of primary keys
*
* @return array|object|null The resulting row of data, or null.
* @return array|object|null The resulting row of data, or null.
*/
public function find($id = null)
{
Expand Down Expand Up @@ -363,19 +362,18 @@ public function find($id = null)
}

/**
* Fetches the row of database from $this->table with a primary key
* matching $id. This methods works only with dbCalls
* Fetches the row of database
* This methods works only with dbCalls
*
* @param boolean $singleton Single or multiple results
* @param array|integer|string|null $id One primary key or an array of primary keys
*
* @return array|object|null The resulting row of data, or null.
* @return array|object|null The resulting row of data, or null.
*/
abstract protected function doFind(bool $singleton, $id = null);

/**
* Fetches the column of database from $this->table
* Fetches the column of database
*
* @param string $columnName Column Name
*
Expand All @@ -395,7 +393,7 @@ public function findColumn(string $columnName)
}

/**
* Fetches the column of database from $this->table
* Fetches the column of database
* This methods works only with dbCalls
*
* @param string $columnName Column Name
Expand All @@ -406,8 +404,7 @@ public function findColumn(string $columnName)
abstract protected function doFindColumn(string $columnName);

/**
* Works with the current Query Builder instance to return
* all results, while optionally limiting them.
* Fetches all results, while optionally limiting them.
*
* @param integer $limit Limit
* @param integer $offset Offset
Expand Down Expand Up @@ -453,8 +450,7 @@ public function findAll(int $limit = 0, int $offset = 0)
}

/**
* Works with the current Query Builder instance to return
* all results, while optionally limiting them.
* Fetches all results, while optionally limiting them.
* This methods works only with dbCalls
*
* @param integer $limit Limit
Expand All @@ -465,8 +461,7 @@ public function findAll(int $limit = 0, int $offset = 0)
abstract protected function doFindAll(int $limit = 0, int $offset = 0);

/**
* Returns the first row of the result set. Will take any previous
* Query Builder calls into account when determining the result set.
* Returns the first row of the result set.
*
* @return array|object|null
*/
Expand Down Expand Up @@ -505,8 +500,7 @@ public function first()
}

/**
* Returns the first row of the result set. Will take any previous
* Query Builder calls into account when determining the result set.
* Returns the first row of the result set.
* This methods works only with dbCalls
*
* @return array|object|null
Expand All @@ -523,6 +517,8 @@ abstract protected function doFirst();
* @param boolean $escape Whether to escape values and identifiers
*
* @return $this
*
* @todo check if should be moved to Model
*/
public function set($key, ?string $value = '', bool $escape = null)
{
Expand Down Expand Up @@ -566,6 +562,8 @@ public function save($data): bool
* @param array|object $data Data
*
* @return boolean
*
* @todo: to be reworked
*/
abstract protected function doSave($data): bool;

Expand Down Expand Up @@ -783,7 +781,7 @@ public function insert($data = null, bool $returnID = true)
abstract protected function doInsert($data, ?bool $escape = null);

/**
* Compiles batch insert strings and runs the queries, validating each row prior.
* Compiles batch insert runs the queries, validating each row prior.
*
* @param array|null $set An associative array of insert values
* @param boolean $escape Whether to escape values and identifiers
Expand Down Expand Up @@ -844,7 +842,7 @@ public function insertBatch(array $set = null, bool $escape = null, int $batchSi
}

/**
* Compiles batch insert strings and runs the queries, validating each row prior.
* Compiles batch insert and runs the queries, validating each row prior.
* This methods works only with dbCalls
*
* @param array|null $set An associative array of insert values
Expand All @@ -863,7 +861,7 @@ abstract protected function doInsertBatch(
);

/**
* Updates a single record in $this->table. If an object is provided,
* Updates a single record in the database. If an object is provided,
* it will attempt to convert it into an array.
*
* @param integer|array|string|null $id ID
Expand Down Expand Up @@ -957,20 +955,19 @@ public function update($id = null, $data = null): bool
}

/**
* Updates a single record in $this->table. If an object is provided,
* it will attempt to convert it into an array.
* Updates a single record in the database.
* This methods works only with dbCalls
*
* @param integer|array|string|null $id ID
* @param array|object|null $data Data
* @param array|null $data Data
* @param boolean|null $escape Escape
*
* @return boolean
*/
abstract protected function doUpdate($id = null, $data = null, ?bool $escape = null): bool;

/**
* Compiles an update string and runs the query
* Compiles an update and runs the query
*
* @param array|null $set An associative array of update values
* @param string|null $index The where key
Expand Down Expand Up @@ -1033,7 +1030,7 @@ public function updateBatch(array $set = null, string $index = null, int $batchS
}

/**
* Compiles an update string and runs the query
* Compiles an update and runs the query
* This methods works only with dbCalls
*
* @param array|null $set An associative array of update values
Expand All @@ -1053,8 +1050,7 @@ abstract protected function doUpdateBatch(
);

/**
* Deletes a single record from $this->table where $id matches
* the table's primaryKey
* Deletes a single record from the database where $id matches
*
* @param integer|string|array|null $id The rows primary key(s)
* @param boolean $purge Allows overriding the soft deletes setting.
Expand Down Expand Up @@ -1097,8 +1093,7 @@ public function delete($id = null, bool $purge = false)
}

/**
* Deletes a single record from $this->table where $id matches
* the table's primaryKey
* Deletes a single record from the database where $id matches
* This methods works only with dbCalls
*
* @param integer|string|array|null $id The rows primary key(s)
Expand Down Expand Up @@ -1136,7 +1131,7 @@ abstract protected function doPurgeDeleted();

/**
* Sets $useSoftDeletes value so that we can temporarily override
* the softdeletes settings. Can be used for all find* methods.
* the soft deletes settings. Can be used for all find* methods.
*
* @param boolean $val Value
*
Expand Down Expand Up @@ -1173,7 +1168,7 @@ public function onlyDeleted()
abstract protected function doOnlyDeleted();

/**
* Compiles a replace into string and runs the query
* Compiles a replace and runs the query
*
* @param array|null $data Data
* @param boolean $returnSQL Set to true to return Query String
Expand All @@ -1192,7 +1187,7 @@ public function replace(array $data = null, bool $returnSQL = false)
}

/**
* Compiles a replace into string and runs the query
* Compiles a replace and runs the query
* This methods works only with dbCalls
*
* @param array|null $data Data
Expand Down Expand Up @@ -1237,8 +1232,6 @@ public function asObject(string $class = 'object')

/**
* Loops over records in batches, allowing you to operate on them.
* Works with $this->builder to get the Compiled select to
* determine the rows to operate on.
* This methods works only with dbCalls
*
* @param integer $size Size
Expand All @@ -1251,7 +1244,7 @@ public function asObject(string $class = 'object')
public abstract function chunk(int $size, Closure $userFunc);

/**
* Works with $this->builder to get the Compiled Select to operate on.
* Works with Pager to get the size and offset parameters.
* Expects a GET variable (?page=2) that specifies the page of results
* to display.
*
Expand Down
7 changes: 4 additions & 3 deletions system/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ protected function doFirst()
* @param array|object $data Data
*
* @return boolean
*
* @todo rework to be in BaseModel
*/
protected function doSave($data): bool
{
Expand Down Expand Up @@ -362,12 +364,11 @@ protected function doInsertBatch(
}

/**
* Updates a single record in $this->table. If an object is provided,
* it will attempt to convert it into an array.
* Updates a single record in $this->table.
* This methods works only with dbCalls
*
* @param integer|array|string|null $id ID
* @param array|object|null $data Data
* @param array|null $data Data
* @param boolean|null $escape Escape
*
* @return boolean
Expand Down

0 comments on commit 9ba8b72

Please sign in to comment.