LabelName   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 1
dl 0
loc 33
c 0
b 0
f 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 27 5
1
<?php
2
3
namespace CultuurNet\UDB3\Label\ValueObjects;
4
5
use ValueObjects\StringLiteral\StringLiteral;
6
7
/**
8
 * Class LabelName
9
 * @package CultuurNet\UDB3\Label\ValueObjects
10
 */
11
class LabelName extends StringLiteral
12
{
13
    /**
14
     * @param string $value
15
     */
16
    public function __construct($value)
17
    {
18
        if (is_string($value)) {
19
            $value = trim($value);
20
        }
21
22
        parent::__construct($value);
23
24
        if (false !== strpos($value, ';')) {
25
            throw new \InvalidArgumentException(
26
                "Value for argument $value should not contain semicolons."
27
            );
28
        }
29
30
        $length = mb_strlen($value);
31
        if ($length < 2) {
32
            throw new \InvalidArgumentException(
33
                "Value for argument $value should not be shorter than 2 chars."
34
            );
35
        }
36
37
        if ($length > 255) {
38
            throw new \InvalidArgumentException(
39
                "Value for argument $value should not be longer than 255 chars."
40
            );
41
        }
42
    }
43
}
44