Phonenumber::toNative()   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
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Domain\Repository\Tests\Fixtures;
12
13
use Cubiche\Domain\Model\NativeValueObject;
14
15
/**
16
 * Phonenumber.
17
 *
18
 * @author Karel Osorio Ramírez <[email protected]>
19
 */
20
class Phonenumber extends NativeValueObject
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $number;
26
27
    /**
28
     * @param string $number
29
     *
30
     * @return static
31
     */
32
    public static function fromNative($number)
33
    {
34
        return new static($number);
35
    }
36
37
    /**
38
     * @param string $number
39
     *
40
     * @throws \InvalidArgumentException
41
     */
42
    public function __construct($number)
43
    {
44
        if (\is_string($number) === false || empty($number)) {
45
            throw new \InvalidArgumentException(sprintf(
46
                'Argument "%s" is invalid or empty. Allowed types for argument are "string".',
47
                $number
48
            ));
49
        }
50
51
        $this->number = $number;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function toNative()
58
    {
59
        return $this->number;
60
    }
61
62
    /**
63
     * @return string
64
     */
65
    public function number()
66
    {
67
        return $this->number;
68
    }
69
}
70