Test Failed
Pull Request — master (#494)
by
unknown
03:32
created

IdentityRepository::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 2
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Modules\Auth;
6
7
use Cycle\ORM\Select;
8
use Throwable;
9
use Yiisoft\Auth\IdentityRepositoryInterface;
10
use Yiisoft\Yii\Cycle\Data\Writer\EntityWriter;
11
12
final class IdentityRepository extends Select\Repository implements IdentityRepositoryInterface
13
{
14
    public function __construct(private EntityWriter $entityWriter, Select $select)
15
    {
16
        parent::__construct($select);
17
    }
18
19
    /**
20
     * @param string $id
21
     *
22
     * @return Identity|null
23
     */
24
    public function findIdentity(string $id): ?Identity
25
    {
26
        return $this->findOne(['user_id' => $id]);
27
    }
28
29
    /**
30
     * @throws Throwable
31
     */
32
    public function save(Identity $identity): void
33
    {
34
        $this->entityWriter->write([$identity]);
35
    }
36
}
37