Passed
Push — new-version ( b26f83...154590 )
by Jeroen
02:38
created

VCardException::forNotSupportedNode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 1
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace JeroenDesloovere\VCard\Exception;
4
5
use JeroenDesloovere\VCard\Property\NodeInterface;
6
use JeroenDesloovere\VCard\Property\Parameter\Kind;
7
use JeroenDesloovere\VCard\Property\Parameter\PropertyParameterInterface;
8
use JeroenDesloovere\VCard\Property\PropertyInterface;
9
use JeroenDesloovere\VCard\VCard;
10
11
class VCardException extends \Exception
12
{
13
    public static function forExistingProperty(PropertyInterface $property): self
14
    {
15
        return new self(
16
            'The property "' . get_class($property) . '" you are trying to add can only be added once.'
17
        );
18
    }
19
20
    public static function forExistingPropertyParameter(PropertyParameterInterface $parameter): self
21
    {
22
        return new self(
23
            'The property parameter "' . get_class($parameter) . '" you are trying to add can only be added once.'
24
        );
25
    }
26
27
    public static function forNotAllowedPropertyOnVCardKind(PropertyInterface $property, Kind $kind): self
28
    {
29
        return new self(
30
            'The property "' . get_class($property) . '" you are trying to add can only be added to vCard\'s of the ' . $kind->__toString() . ' kind.'
31
        );
32
    }
33
34
    public static function forNotSupportedNode(NodeInterface $node): self
35
    {
36
        return new self(
37
            'The node "' . get_class($node) . '" you are trying to add is not supported. Possible values are: '
38
            . implode(', ', VCard::POSSIBLE_VALUES)
39
        );
40
    }
41
}
42