Config::auth()   A
last analyzed

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