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

Title::fromUdb3ModelTitle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 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