Completed
Push — master ( b2bf8f...b90fcd )
by Pierre
03:08
created

Config::getById()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Component\Auth\Adapters;
4
5
use Nymfonya\Component\Config as AppConfig;
6
use Nymfonya\Component\Container;
7
use App\Component\Auth\AdapterInterface;
8
use App\Model\Users;
9
10
/**
11
 * Adapter Config let auth from config accounts entries
12
 * No decryption required on clear password.
13
 */
14
class Config implements AdapterInterface
15
{
16
17
    /**
18
     * container
19
     *
20
     * @var Container
21
     */
22
    protected $container;
23
24
    /**
25
     * user model
26
     *
27
     * @var Users
28
     */
29
    protected $modelUsers;
30
31
    /**
32
     * instanciate
33
     *
34
     * @param Container $container
35
     */
36 4
    public function __construct(Container $container)
37
    {
38 4
        $this->container = $container;
39 4
        $this->modelUsers = new Users(
40 4
            $this->container->getService(AppConfig::class)
41
        );
42
    }
43
44
    /**
45
     * auth process
46
     *
47
     * @param string $login
48
     * @param string $password
49
     * @return array
50
     */
51 2
    public function auth(string $login, string $password): array
52
    {
53 2
        return $this->modelUsers->auth($login, $password);
54
    }
55
56
    /**
57
     * get user by id
58
     *
59
     * @param integer $id
60
     * @return array
61
     */
62 1
    public function getById(int $id): array
63
    {
64 1
        return $this->modelUsers->getById($id);
65
    }
66
}
67