Completed
Push — master ( d404ac...fc4cfb )
by Alexander
10:24 queued 07:21
created

UserFluentDemo::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/*
3
 * Go! AOP framework
4
 *
5
 * @copyright Copyright 2013, Lisachenko Alexander <[email protected]>
6
 *
7
 * This source file is subject to the license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Demo\Example;
12
13
use Demo\Aspect\FluentInterface;
14
15
/**
16
 * Example class to show fluent interface in action
17
 */
18
class UserFluentDemo implements FluentInterface
19
{
20
    protected $name;
21
    protected $surname;
22
    protected $password;
23
24
    public function setName($name)
25
    {
26
        echo "Set user name to ", $name, PHP_EOL;
27
        $this->name = $name;
28
    }
29
30
    public function setSurname($surname)
31
    {
32
        echo "Set user surname to ", $surname, PHP_EOL;
33
        $this->surname = $surname;
34
    }
35
36
    public function setPassword($password)
37
    {
38
        if (!$password) {
39
            throw new \InvalidArgumentException("Password shouldn't be empty");
40
        }
41
        echo "Set user password to ", $password, PHP_EOL;
42
        $this->password = $password;
43
    }
44
}
45