Completed
Pull Request — master (#364)
by Alessandro
04:31
created

Symfony::refresh()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 7
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 7
loc 7
ccs 0
cts 6
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 2
crap 2
1
<?php
2
3
/*
4
 * This file is part of the FOSHttpCache 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\HttpCache\ProxyClient;
13
14
use FOS\HttpCache\ProxyClient\Invalidation\PurgeCapable;
15
use FOS\HttpCache\ProxyClient\Invalidation\RefreshCapable;
16
use FOS\HttpCache\SymfonyCache\PurgeListener;
17
18
/**
19
 * Symfony HttpCache invalidator.
20
 *
21
 * Additional constructor options:
22
 * - purge_method:         HTTP method that identifies purge requests.
23
 *
24
 * @author David de Boer <[email protected]>
25
 * @author David Buchmann <[email protected]>
26
 */
27
class Symfony extends HttpProxyClient implements PurgeCapable, RefreshCapable
28
{
29
    const HTTP_METHOD_REFRESH = 'GET';
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function purge($url, array $headers = [])
35
    {
36
        $this->queueRequest($this->options['purge_method'], $url, $headers);
37
38
        return $this;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 View Code Duplication
    public function refresh($url, array $headers = [])
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
45
    {
46
        $headers = array_merge($headers, ['Cache-Control' => 'no-cache']);
47
        $this->queueRequest(self::HTTP_METHOD_REFRESH, $url, $headers);
48
49
        return $this;
50
    }
51
52
    protected function configureOptions()
53
    {
54
        $resolver = parent::configureOptions();
55
        $resolver->setDefaults([
56
            'purge_method' => PurgeListener::DEFAULT_PURGE_METHOD,
57
        ]);
58
59
        return $resolver;
60
    }
61
}
62