Skip to content

Commit

Permalink
fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
carloscarucce committed Feb 17, 2022
1 parent 400b40c commit b65f50c
Showing 1 changed file with 23 additions and 19 deletions.
42 changes: 23 additions & 19 deletions src/Mvc/Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ abstract class Model implements \JsonSerializable
/**
* @return Query
*/
public static function createQuery() : Query
public static function createQuery(): Query
{
$query = self::getConnection()->createQuery();
$query->from(self::getTable());
Expand All @@ -68,7 +68,7 @@ public static function createQuery() : Query
*
* @return static[]
*/
public static function find(\Closure $filterFn = null, bool $applySetters = false) : array
public static function find(\Closure $filterFn = null, bool $applySetters = false): array
{
$connection = self::getConnection();
$table = self::getModelProperty('table');
Expand All @@ -95,7 +95,9 @@ public static function find(\Closure $filterFn = null, bool $applySetters = fals
$rowData = $row->getData();

foreach (self::getDateFields() as $dateField) {
if (empty($rowData[$dateField])) continue;
if (empty($rowData[$dateField])) {
continue;
}

$rowData[$dateField] = date_create_from_format(
$connection->getDateFormat(),
Expand All @@ -115,47 +117,47 @@ public static function find(\Closure $filterFn = null, bool $applySetters = fals
/**
* @return Connection
*/
final public static function getConnection() : Connection
final public static function getConnection(): Connection
{
return self::getModelProperty('connection');
}

/**
* @return array
*/
final public static function getDateFields() : array
final public static function getDateFields(): array
{
return self::getModelProperty('dateFields');
}

/**
* @return array
*/
final public static function getFields() : array
final public static function getFields(): array
{
return self::getModelProperty('fields');
}

/**
* @return array
*/
final public static function getPrimaryKeys() : array
final public static function getPrimaryKeys(): array
{
return self::getModelProperty('primaryKeys');
}

/**
* @return string
*/
final public static function getTable() : string
final public static function getTable(): string
{
return self::getModelProperty('table');
}

/**
* @return bool
*/
final public static function hasTimestamps() : bool
final public static function hasTimestamps(): bool
{
return self::getModelProperty('timestamps');
}
Expand Down Expand Up @@ -186,7 +188,9 @@ public static function load($primary, bool $applySetters = false)
$rowData = $result->fetch()->getData();

foreach (self::getDateFields() as $dateField) {
if (empty($rowData[$dateField])) continue;
if (empty($rowData[$dateField])) {
continue;
}

$rowData[$dateField] = date_create_from_format(
$connection->getDateFormat(),
Expand Down Expand Up @@ -251,7 +255,7 @@ private static function initModelProperties()
*
* @return array
*/
private static function normalizePrimaryKeys($primary) : array
private static function normalizePrimaryKeys($primary): array
{
$pks = self::getPrimaryKeys();

Expand All @@ -269,7 +273,7 @@ private static function normalizePrimaryKeys($primary) : array
*
* @return bool
*/
public function delete() : bool
public function delete(): bool
{
$result = self::getConnection()->delete($this);

Expand All @@ -281,7 +285,7 @@ public function delete() : bool
*
* @return bool
*/
public function exists() : bool
public function exists(): bool
{
$query = static::createQuery();
$pks = static::getPrimaryKeys();
Expand Down Expand Up @@ -336,7 +340,7 @@ final public function fill(array $data, $applySetters = true)
/**
* @return array
*/
final public function getData() : array
final public function getData(): array
{
return $this->data;
}
Expand All @@ -347,7 +351,7 @@ final public function getData() : array
*
* @return array
*/
final public function getPrimaryKeyValues() : array
final public function getPrimaryKeyValues(): array
{
$keys = static::getPrimaryKeys();
$values = array_intersect_key($this->data, array_flip($keys));
Expand All @@ -360,7 +364,7 @@ final public function getPrimaryKeyValues() : array
*
* @return Result
*/
public function insert() : Result
public function insert(): Result
{
$result = self::getConnection()->insert($this);

Expand Down Expand Up @@ -454,7 +458,7 @@ public function relatedToOne(
*
* @return bool
*/
public function save(array $data = []) : bool
public function save(array $data = []): bool
{
$this->fill($data);
$result = null;
Expand All @@ -473,7 +477,7 @@ public function save(array $data = []) : bool
*
* @return Result
*/
public function update() : Result
public function update(): Result
{
return self::getConnection()->update($this);
}
Expand All @@ -498,7 +502,7 @@ private function applyModifier(string $fieldName, &$value, $methodPrefix)
*
* @return string
*/
private function fieldNameToUpperCamelCase(string $fieldName) : string
private function fieldNameToUpperCamelCase(string $fieldName): string
{
$handler = function ($matches) {
return strtoupper($matches[0][1]);
Expand Down

0 comments on commit b65f50c

Please sign in to comment.