Completed
Push — master ( 07fc20...4efd3c )
by David de
34:38
created

InvalidatePath::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 3
cts 3
cp 1
rs 9.8666
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCacheBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\HttpCacheBundle\Configuration;
13
14
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
15
16
/**
17
 * @Annotation
18
 */
19
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_CLASS | \Attribute::TARGET_METHOD)]
20
class InvalidatePath extends ConfigurationAnnotation
21
{
22
    /**
23
     * @var array
24
     */
25
    private $paths;
26
27
    public function __construct(
28
        $data = []
29
    ) {
30
        $values = [];
31 5
        if (is_string($data)) {
32
            $values['value'] = $data;
33 5
        } else {
34 5
            $values = $data;
35
        }
36
37
        parent::__construct($values);
38
    }
39 5
40
    /**
41 5
     * Handle path given without explicit key.
42 5
     *
43
     * @param string $data
44
     */
45
    public function setValue($data)
46
    {
47 4
        $this->setPaths((is_array($data) ? $data : [$data]));
48
    }
49 4
50
    /**
51
     * @param array $paths
52
     */
53
    public function setPaths($paths)
54
    {
55 4
        $this->paths = $paths;
56
    }
57 4
58
    /**
59
     * @return array
60
     */
61
    public function getPaths()
62
    {
63 4
        return $this->paths;
64
    }
65 4
66
    /**
67
     * {@inheritdoc}
68
     */
69
    public function getAliasName()
70
    {
71
        return 'invalidate_path';
72
    }
73
74
    /**
75
     * {@inheritdoc}
76
     */
77
    public function allowArray()
78
    {
79
        return true;
80
    }
81
}
82