From 99aaf0be8a94ed3e25fd0150f12c91a4279f591d Mon Sep 17 00:00:00 2001 From: lucas Date: Wed, 27 Sep 2017 15:41:44 -0300 Subject: [PATCH] Improving Frogg documentation --- Controller.php | 2 +- Crypto/WT.php | 2 +- Model.php | 30 ++++++++++++++++++++---------- Time.php | 2 +- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/Controller.php b/Controller.php index 7de9746..4a0027a 100644 --- a/Controller.php +++ b/Controller.php @@ -19,7 +19,7 @@ public function isAllowed($actionName, $auth) return in_array($actionName, $this->publicActions) || $auth; } - public function isMobile() + public function isMobile(): bool { $mobileDetector = new MobileDetect(); diff --git a/Crypto/WT.php b/Crypto/WT.php index 828912f..6a3507c 100644 --- a/Crypto/WT.php +++ b/Crypto/WT.php @@ -8,7 +8,7 @@ class WT private static $encrypt_method = ENCRYPTION_TYPE; private static $iv = WT_IV; - public static function encode($object, $key = WT_KEY) + public static function encode($object, $key = WT_KEY): string { $json = json_encode($object); diff --git a/Model.php b/Model.php index 6e864b5..3971f54 100644 --- a/Model.php +++ b/Model.php @@ -5,15 +5,15 @@ use Frogg\Crypto\WT; use Phalcon\Mvc\Model as PhalconModel; +/** + * Class Model + * @package Frogg + * + * @method static static findFirstById(int $id) + */ class Model extends PhalconModel { - /** @return static */ - public static function findFirstById($id) - { - return parent::findFirstById($id); - } - public function columnMap() { $columnMap = []; @@ -30,14 +30,24 @@ public function columnMap() return $columnMap; } - public function permalinkFor($attribute) + /** + * @param string $attribute Name of the attribute that will be used to create a permalink + * + * @return string A permalink formatted string + */ + public function permalinkFor(string $attribute): string { $tmp = new Permalink($this->$attribute); return $this->getNumeration($tmp->create()); } - public function permalinkForValues($values) + /** + * @param array $values Values that will be used to create a permalink + * + * @return string A permalink formatted string + */ + public function permalinkForValues(array $values): string { for ($i = 0; $i < count($values); $i++) { $values[$i] = Permalink::createSlug($values[$i]); @@ -47,7 +57,7 @@ public function permalinkForValues($values) return $this->getNumeration($value); } - public function tokenId($key) + public function tokenId($key): string { return WT::encode(['id' => $this->id], $key); } @@ -59,7 +69,7 @@ public static function getByTokenId($token, $key) return isset($data->id) ? static::findFirstById($data->id) : false; } - private function getNumeration($slug) + private function getNumeration($slug): string { $resultset = $this->getReadConnection()->query("SELECT `permalink` FROM `".$this->getSource()."` diff --git a/Time.php b/Time.php index 4237c43..0824b7c 100644 --- a/Time.php +++ b/Time.php @@ -17,7 +17,7 @@ class Time /** * Constructor * - * @param type $time Unix timestamp OR a string timestamp (YYYY-MM-DD) + * @param int|null $time Unix timestamp OR a string timestamp (YYYY-MM-DD) */ public function __construct($time = 0) {