Completed
Push — master ( 9753fc...bb535b )
by Tijs
03:33
created

Property::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace TijsVerkoyen\CssToInlineStyles\Css\Property;
4
5
use Symfony\Component\CssSelector\Node\Specificity;
6
7
final class Property
8
{
9
    /**
10
     * @var string
11
     */
12
    private $name;
13
14
    /**
15
     * @var string
16
     */
17
    private $value;
18
19
    /**
20
     * @var Specificity
21
     */
22
    private $originalSpecificity;
23
24
    /**
25
     * Property constructor.
26
     * @param                  $name
27
     * @param                  $value
28
     * @param Specificity|null $specificity
29
     */
30
    public function __construct($name, $value, Specificity $specificity = null)
31
    {
32
        $this->name = $name;
33
        $this->value = $value;
34
        $this->originalSpecificity = $specificity;
35
    }
36
37
    /**
38
     * Get name
39
     *
40
     * @return string
41
     */
42
    public function getName()
43
    {
44
        return $this->name;
45
    }
46
47
    /**
48
     * Get value
49
     *
50
     * @return string
51
     */
52
    public function getValue()
53
    {
54
        return $this->value;
55
    }
56
57
    /**
58
     * Get originalSpecificity
59
     *
60
     * @return Specificity
61
     */
62
    public function getOriginalSpecificity()
63
    {
64
        return $this->originalSpecificity;
65
    }
66
67
    /**
68
     * Is this property important?
69
     *
70
     * @return bool
71
     */
72
    public function isImportant()
73
    {
74
        return (stripos($this->value, '!important') !== false);
75
    }
76
77
    /**
78
     * Get the textual representation of the property
79
     *
80
     * @return string
81
     */
82
    public function toString()
83
    {
84
        return sprintf(
85
            '%1$s: %2$s;',
86
            $this->name,
87
            $this->value
88
        );
89
    }
90
}
91