Completed
Pull Request — master (#345)
by
unknown
25:32 queued 12:36
created

Title   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 0
loc 29
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A jsonSerialize() 0 4 1
A fromUdb3ModelTitle() 0 5 1
1
<?php
2
3
namespace CultuurNet\UDB3;
4
5
use CultuurNet\UDB3\Model\ValueObject\Text\Title as Udb3ModelTitle;
6
7
/**
8
 * @todo Replace by CultuurNet\UDB3\Model\ValueObject\Text\Title.
9
 */
10
class Title extends TrimmedString implements \JsonSerializable
11
{
12
    public function __construct($value)
13
    {
14
        parent::__construct($value);
15
16
        if ($this->isEmpty()) {
17
            throw new \InvalidArgumentException('Title can not be empty.');
18
        }
19
    }
20
21
    /**
22
     * @inheritdoc
23
     */
24
    public function jsonSerialize()
25
    {
26
        return (string)$this;
27
    }
28
29
    /**
30
     * @param Udb3ModelTitle $title
31
     * @return Title
32
     */
33
    public static function fromUdb3ModelTitle(Udb3ModelTitle $title)
34
    {
35
        $string = $title->toString();
36
        return new self($string);
37
    }
38
}
39