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.
Completed
Branch v2 (a88462)
by Hilari
02:38
created

MultiCacheTrait::setItems()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
ccs 6
cts 6
cp 1
cc 3
eloc 5
nc 3
nop 2
crap 3
1
<?php
2
3
namespace Cmp\Cache\Traits;
4
5
/**
6
 * Interface MultiCacheTrait
7
 *
8
 * Apply to a non multi cache backend to convert it
9
 *
10
 * @package Cmp\Cache
11
 * @mixin \Cmp\Cache\Traits
12
 */
13
trait MultiCacheTrait
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 1
    public function setItems(array $items, $timeToLive = null)
19
    {
20 1
        $success = true;
21 1
        foreach ($items as $key => $item) {
22 1
            $success = $success && $this->set($key, $item, $timeToLive);
0 ignored issues
show
Bug introduced by
It seems like set() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
23 1
        }
24
25 1
        return $success;
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31 1
    public function getItems(array $keys)
32
    {
33 1
        $items = [];
34 1
        foreach ($keys as $key) {
35 1
            $items[$key] = $this->get($key);
0 ignored issues
show
Bug introduced by
It seems like get() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
36 1
        }
37
38 1
        return $items;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44 1
    public function deleteItems(array $keys)
45
    {
46 1
        $success = true;
47 1
        foreach ($keys as $key) {
48 1
            $success = $success && $this->delete($key);
0 ignored issues
show
Bug introduced by
The method delete() does not exist on Cmp\Cache\Traits\MultiCacheTrait. Did you maybe mean deleteItems()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
49 1
        }
50
51 1
        return $success;
52
    }
53
}
54