Passed
Push — master ( 661b73...ccb1dd )
by Sebastian
08:54 queued 05:17
created

CssRule   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 50
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 4 1
A __construct() 0 5 1
A addDirective() 0 3 1
1
<?php
2
/*
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
3
 * citeproc-php
4
 *
5
 * @link        http://github.com/seboettg/citeproc-php for the source repository
6
 * @copyright   Copyright (c) 2017 Sebastian Böttger.
7
 * @license     https://opensource.org/licenses/MIT
8
 */
9
10
namespace Seboettg\CiteProc\Styles\Css;
11
12
use Seboettg\Collection\ArrayList;
13
14
/**
15
 * Class CssRule
16
 * @package Seboettg\CiteProc\Styles\Css
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
17
 * @author Sebastian Böttger <[email protected]>
1 ignored issue
show
Coding Style introduced by
Tag value for @author tag indented incorrectly; expected 2 spaces but found 1
Loading history...
18
 */
3 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
19
class CssRule
20
{
21
    const SELECTOR_TYPE_ID = "#";
22
23
    const SELECTOR_TYPE_CLASS = ".";
24
25
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
26
     * @var string
27
     */
28
    private $selectorType;
0 ignored issues
show
Coding Style introduced by
Private member variable "selectorType" must be prefixed with an underscore
Loading history...
29
30
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
31
     * @var string
32
     */
33
    private $selector;
0 ignored issues
show
Coding Style introduced by
Private member variable "selector" must be prefixed with an underscore
Loading history...
34
35
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
36
     * @var ArrayList
37
     */
38
    private $directives;
0 ignored issues
show
Coding Style introduced by
Private member variable "directives" must be prefixed with an underscore
Loading history...
39
40
    /**
41
     * CssRule constructor.
42
     * @param string $selector
2 ignored issues
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
Coding Style introduced by
Missing parameter comment
Loading history...
43
     * @param string $selectorType
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
44
     */
45 3
    public function __construct($selector, $selectorType = self::SELECTOR_TYPE_CLASS)
46
    {
47 3
        $this->selector = $selector;
48 3
        $this->selectorType = $selectorType;
49 3
        $this->directives = new ArrayList();
50 3
    }
51
52
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
53
     *
54
     * @param string $property
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
55
     * @param string $value
1 ignored issue
show
Coding Style introduced by
Missing parameter comment
Loading history...
56
     */
0 ignored issues
show
Coding Style introduced by
Missing @return tag in function comment
Loading history...
57 3
    public function addDirective($property, $value)
58
    {
59 3
        $this->directives->append("$property: $value;");
60 3
    }
61
62
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
63
     * @return string
64
     */
65 3
    public function __toString()
66
    {
67 3
        $directives = "\t" . implode("\n\t", $this->directives->toArray());
68 3
        return $this->selectorType . $this->selector . " {\n" . $directives . "\n}\n";
69
    }
70
}