Skip to content

Commit

Permalink
Improving Frogg documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
magroski committed Sep 27, 2017
1 parent 9f4a74c commit 99aaf0b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion Crypto/WT.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
30 changes: 20 additions & 10 deletions Model.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [];
Expand All @@ -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]);
Expand All @@ -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);
}
Expand All @@ -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()."`
Expand Down
2 changes: 1 addition & 1 deletion Time.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down

0 comments on commit 99aaf0b

Please sign in to comment.