Completed
Push — master ( eaa085...85b293 )
by Jonathan
02:25
created

Password   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0
Metric Value
dl 0
loc 29
rs 10
wmc 4
lcom 0
cbo 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getPassword() 0 4 1
A getId() 0 4 1
1
<?php
2
namespace Iron;
3
4
use InvalidArgumentException as Iae;
5
6
final class Password implements PasswordInterface
7
{
8
    const MIN_LENGTH = 32;
9
10
    private $password;
11
    private $id;
12
13
    public function __construct(string $password, string $id = '')
14
    {
15
        if (strlen($password) < self::MIN_LENGTH)
16
        {
17
            throw new Iae('Passwords must be strings at least '
18
                . self::MIN_LENGTH . ' characters long.');
19
        }
20
21
        $this->password = $password;
22
        $this->id = $id;
23
    }
24
25
    public function getPassword(): string
26
    {
27
        return $this->password;
28
    }
29
30
    public function getId(): string
31
    {
32
        return $this->id;
33
    }
34
}
35