Test Setup Failed
Branch 0.x (13f0ad)
by Pavel
13:06 queued 01:31
created

CacheLocator::locate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Veslo project <https://github.com/symfony-doge/veslo>.
5
 *
6
 * (C) 2019 Pavel Petrov <[email protected]>.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @license https://opensource.org/licenses/GPL-3.0 GPL-3.0
12
 */
13
14
declare(strict_types=1);
15
16
namespace Veslo\AppBundle\Http\Proxy\Locator;
17
18
use Veslo\AppBundle\Cache\CacherInterface;
19
use Veslo\AppBundle\Http\Proxy\LocatorInterface;
20
21
/**
22
 * Uses cache to locate a proxy list
23
 */
24
class CacheLocator implements LocatorInterface
25
{
26
    /**
27
     * Saves a proxy list in the cache and invalidates it by demand
28
     *
29
     * @var CacherInterface
30
     */
31
    private $proxyCacher;
32
33
    /**
34
     * CacheLocator constructor.
35
     *
36
     * @param CacherInterface $proxyCacher Saves a proxy list in the cache and invalidates it by demand
37
     */
38
    public function __construct(CacherInterface $proxyCacher)
39
    {
40
        $this->proxyCacher = $proxyCacher;
41
    }
42
43
    /**
44
     * {@inheritdoc}
45
     */
46
    public function locate(): iterable
47
    {
48
        $proxyList = $this->proxyCacher->get();
49
50
        return $proxyList ?? [];
51
    }
52
}
53