GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Cache::refresh()   A
last analyzed

Complexity

Conditions 2
Paths 1

Size

Total Lines 14

Duplication

Lines 14
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 14
loc 14
c 0
b 0
f 0
ccs 0
cts 9
cp 0
rs 9.7998
cc 2
nc 1
nop 0
crap 6
1
<?php
2
declare(strict_types=1);
3
4
namespace ApiClients\Client\Travis\Resource\Async;
5
6
use ApiClients\Client\Travis\CommandBus\Command\CachesCommand;
7
use ApiClients\Client\Travis\Resource\Cache as BaseCache;
8
use ApiClients\Client\Travis\Resource\CacheInterface;
9
use React\Promise\PromiseInterface;
10
use Rx\React\Promise;
11
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
12
use function React\Promise\reject;
13
use function React\Promise\resolve;
14
15 View Code Duplication
class Cache extends BaseCache
0 ignored issues
show
Duplication introduced by
This class 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...
16
{
17
    public function refresh(): PromiseInterface
18
    {
19
        return Promise::fromObservable(unwrapObservableFromPromise($this->handleCommand(
20
            new CachesCommand($this->repositoryId())
21
        ))->filter(function (CacheInterface $cache) {
22
            return $this->slug() === $cache->slug();
23
        }))->then(function ($cache) {
24
            if ($cache === null) {
25
                return reject();
26
            }
27
28
            return resolve($cache);
29
        });
30
    }
31
}
32