Completed
Pull Request — master (#556)
by
unknown
33:10
created

InvalidatePath::setPaths()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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
     * Handle path given without explicit key.
41 5
     *
42 5
     * @param string $data
43
     */
44
    public function setValue($data)
45
    {
46
        $this->setPaths((is_array($data) ? $data : [$data]));
47 4
    }
48
49 4
    /**
50
     * @param array $paths
51
     */
52
    public function setPaths($paths)
53
    {
54
        $this->paths = $paths;
55 4
    }
56
57 4
    /**
58
     * @return array
59
     */
60
    public function getPaths()
61
    {
62
        return $this->paths;
63 4
    }
64
65 4
    /**
66
     * {@inheritdoc}
67
     */
68
    public function getAliasName()
69
    {
70
        return 'invalidate_path';
71
    }
72
73
    /**
74
     * {@inheritdoc}
75
     */
76
    public function allowArray()
77
    {
78
        return true;
79
    }
80
}
81