Skip to content

Commit

Permalink
Switched to static
Browse files Browse the repository at this point in the history
  • Loading branch information
omnilight committed Jun 5, 2015
1 parent b7d957b commit e069fdd
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Token.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ public static function create($type, $name, $algorithm = null, $expire = null)
$algorithm = new RandomString();
}

$token = self::findOne(['type' => $type, 'name' => $name]);
$token = static::findOne(['type' => $type, 'name' => $name]);
if ($token == null) {
$token = new Token();
$token = new static();
}
$token->type = $type;
$token->name = $name;
Expand Down Expand Up @@ -114,7 +114,7 @@ public static function create($type, $name, $algorithm = null, $expire = null)
*/
public static function exists($type, $name)
{
$token = self::findOne(['type' => $type, 'name' => $name]);
$token = static::findOne(['type' => $type, 'name' => $name]);

if ($token === null)
return null;
Expand All @@ -129,7 +129,7 @@ public static function exists($type, $name)

if (mt_rand(0, 10) > 8) {
// 20% chance of deleting old tokens
self::deleteAll('expire_at < NOW()');
static::deleteAll('expire_at < NOW()');
}

return $token;
Expand All @@ -143,7 +143,7 @@ public static function exists($type, $name)
*/
public static function compare($type, $name, $value)
{
if (($token = self::exists($type, $name)) === null)
if (($token = static::exists($type, $name)) === null)
return null;
if ($token->token != $value)
return null;
Expand All @@ -156,6 +156,6 @@ public static function compare($type, $name, $value)
*/
public static function remove($type, $name)
{
self::deleteAll(['type' => $type, 'name' => $name]);
static::deleteAll(['type' => $type, 'name' => $name]);
}
}

0 comments on commit e069fdd

Please sign in to comment.