Skip to content

Commit

Permalink
Update KeyInfo.php
Browse files Browse the repository at this point in the history
  • Loading branch information
daycry committed Aug 29, 2022
1 parent 65276de commit 15967ef
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions src/Commands/KeyInfo.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,19 +154,22 @@ private function _getKeyLocks( \Daycry\RestServer\Entities\KeyEntity $row )
// @codeCoverageIgnoreEnd

$r = $limit->{$this->config->configRestPetitionsTable};
// @codeCoverageIgnoreStart
if (!$r instanceof PetitionEntity) {
$r = new PetitionEntity((array)$r);
}
// @codeCoverageIgnoreEnd

$timeLimit = ( isset( $r->time ) ) ? $r->time : 3600;
if( $limit->count >= $r->limit && $limit->hour_started > (time() - $timeLimit) )
if($r)
{
$timeLeft = $this->_getTimeLeft($limit->hour_started - (time() - $timeLimit));

$limit->hour_started = date('Y-m-d H:i:s', $limit->hour_started);
array_push( $body, array( $timeLeft, $limit->id, $r->{$this->config->restNamespaceTable}->controller, $limit->uri, $limit->count, $limit->hour_started, $limit->created_at, $limit->updated_at, $limit->deleted_at ) );
// @codeCoverageIgnoreStart
if (!$r instanceof PetitionEntity) {
$r = new PetitionEntity((array)$r);
}
// @codeCoverageIgnoreEnd

$timeLimit = ( isset( $r->time ) ) ? $r->time : 3600;
if( $limit->count >= $r->limit && $limit->hour_started > (time() - $timeLimit) )
{
$timeLeft = $this->_getTimeLeft($limit->hour_started - (time() - $timeLimit));

$limit->hour_started = date('Y-m-d H:i:s', $limit->hour_started);
array_push( $body, array( $timeLeft, $limit->id, $r->{$this->config->restNamespaceTable}->controller, $limit->uri, $limit->count, $limit->hour_started, $limit->created_at, $limit->updated_at, $limit->deleted_at ) );
}
}
}

Expand Down

0 comments on commit 15967ef

Please sign in to comment.