Name::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Isolate\LazyObjects\Proxy\Property;
4
5
use Isolate\LazyObjects\Exception\InvalidArgumentException;
6
7
/**
8
 * @api
9
 */
10
class Name
11
{
12
    /**
13
     * @var string
14
     */
15
    private $name;
16
17
    /**
18
     * @param $name
19
     * @throws InvalidArgumentException
20
     */
21 View Code Duplication
    public function __construct($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
22
    {
23
        if (!is_string($name)) {
24
            throw new InvalidArgumentException("Property name must be a valid string.");
25
        }
26
27
        if (empty($name)) {
28
            throw new InvalidArgumentException("Property name can not be empty.");
29
        }
30
31
        $this->name = $name;
32
    }
33
34
    public function __toString()
35
    {
36
        return $this->name;
37
    }
38
}
39