teresko /
ignis
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Ignis\Mapper; |
||
| 4 | |||
| 5 | use Memcached; |
||
| 6 | use Ignis\Entity; |
||
| 7 | use Ignis\Exception; |
||
| 8 | |||
| 9 | class Mapper |
||
| 10 | { |
||
| 11 | private $storage; |
||
| 12 | private $lifetime; |
||
| 13 | private $burndown; |
||
| 14 | |||
| 15 | public function __construct(Memecached $storage, int $lifetime, int $burndown) |
||
|
0 ignored issues
–
show
|
|||
| 16 | { |
||
| 17 | $this->storage = $storage; |
||
| 18 | $this->lifetime = $lifetime; |
||
| 19 | $this->burndown = $burndown; |
||
| 20 | } |
||
| 21 | |||
| 22 | public function store(Entity\Identity $identity) |
||
| 23 | { |
||
| 24 | $data = [ |
||
| 25 | 'payload' => $identity->getPayload(), |
||
| 26 | 'account' => $identity->getAccountId(), |
||
| 27 | 'token' => $identity->getToken(), |
||
| 28 | 'createdOn' => null, |
||
| 29 | 'activatedOn' => null, |
||
| 30 | ]; |
||
| 31 | |||
| 32 | if ($identity->getCreationTime()) { |
||
| 33 | $data['createdOn'] = $identity->getCreationTime()->getTimestamp(); |
||
| 34 | $expires = $identity->getCreationTime()->getTimestamp() + $this->lifetime; |
||
| 35 | } |
||
| 36 | |||
| 37 | if ($identity->getActivationTime()) { |
||
| 38 | $data['activatedOn'] = $identity->getActivationTime()->getTimestamp(); |
||
| 39 | $expires = $identity->getActivationTime()->getTimestamp() + $this->burndown; |
||
| 40 | } |
||
| 41 | |||
| 42 | $this->storage->set($identity->getKey(), $data, $expires); |
||
|
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
|
|||
| 43 | } |
||
| 44 | |||
| 45 | public function fetch(Entity\Identity $identity) |
||
| 46 | { |
||
| 47 | $data = $this->storage->get($identity->getKey()); |
||
| 48 | |||
| 49 | if (false === $data) { |
||
| 50 | throw new Exception\EntityNotFound; |
||
| 51 | } |
||
| 52 | |||
| 53 | $identity->setPayload($data['payload']); |
||
| 54 | $identity->setAccountId($data['account']); |
||
| 55 | $identity->setToken($data['token']); |
||
| 56 | $identity->setCreationTime((new DateTimeImmutable)->setTimestamp($data['createdOn'])); |
||
|
0 ignored issues
–
show
|
|||
| 57 | |||
| 58 | if ($data['activatedOn']) { |
||
| 59 | $identity->setActivationTime((new DateTimeImmutable)->setTimestamp($data['activatedOn'])); |
||
| 60 | } |
||
| 61 | } |
||
| 62 | } |
||
| 63 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths