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

Users   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Test Coverage

Coverage 66.67%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
dl 0
loc 74
ccs 8
cts 12
cp 0.6667
rs 10
c 2
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getById() 0 4 1
A getByEmail() 0 4 1
A auth() 0 5 1
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