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

Password::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 2
eloc 6
nc 2
nop 2
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