for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* This file is part of the BEAR.JwtAuthModule package.
*
* @license http://opensource.org/licenses/MIT MIT
*/
namespace BEAR\JwtAuth\Generator;
use BEAR\JwtAuth\Annotation\Ttl;
use BEAR\JwtAuth\Encoder\JwtEncoderInject;
class JwtGenerator implements JwtGeneratorInterface
{
use JwtEncoderInject;
* @var int
private $ttl;
* @Ttl("ttl")
public function __construct(string $ttl)
$this->ttl = $ttl;
$ttl
integer
string
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
}
public function create(array $payload) : string
$now = time();
$payload['exp'] = $now + $this->ttl;
$payload['iat'] = $now;
$token = $this->jwtEncoder->encode($payload);
return $token;
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.