Completed
Push — master ( c889ea...14eda7 )
by Pierre
03:04
created

Users::auth()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Model\Repository;
4
5
use Nymfonya\Component\Container;
6
use App\Component\Model\Orm\IOrm;
7
use App\Component\Model\Orm\Orm;
8
9
class Users extends Orm implements IOrm
10
{
11
12
    /**
13
     * table name
14
     * @var string
15
     */
16
    protected $tablename = 'users';
17
18
    /**
19
     * table primary key
20
     * @var string
21
     */
22
    protected $primary = 'id';
23
24
    /**
25
     * database name
26
     * @var string
27
     */
28
    protected $database = 'nymfonya';
29
30
    /**
31
     * pool name
32
     * @var string
33
     */
34
    protected $slot = 'test';
35
36
    /**
37
     * instanciate
38
     *
39
     * @param Container $container
40
     * @return self
41
     */
42 4
    public function __construct(Container $container)
43
    {
44 4
        parent::__construct($container);
45
    }
46
47
    /**
48
     * find a user for a given id
49
     *
50
     * @param integer $uid
51
     * @return Users
52
     */
53 1
    public function getById(int $uid): Users
54
    {
55 1
        $this->find(['*'], ['id' => $uid]);
56 1
        return $this;
57
    }
58
59
    /**
60
     * find a user for a given email
61
     *
62
     * @param integer $uid
63
     * @return Users
64
     */
65 1
    public function getByEmail(string $email): Users
66
    {
67 1
        $this->find(['*'], ['email' => $email]);
68 1
        return $this;
69
    }
70
71
    /**
72
     * auth from username and password
73
     *
74
     * @param string $email
75
     * @param string $password
76
     * @return array
77
     */
78
    public function auth(string $email, string $password): Users
0 ignored issues
show
Unused Code introduced by
The parameter $password is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

78
    public function auth(string $email, /** @scrutinizer ignore-unused */ string $password): Users

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
79
    {
80
        $where = ['email' => $email];
81
        $this->find(['*'], $where);
82
        return $this;
83
    }
84
}
85