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.
Test Setup Failed
Push — master ( c5ade0...e039e4 )
by Gabriel
05:51
created

ContainerArrayAccessTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 70
rs 10
c 0
b 0
f 0
wmc 6
lcom 0
cbo 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetExists() 0 4 1
A offsetGet() 0 4 1
A offsetSet() 0 4 1
A offsetUnset() 0 4 1
A __get() 0 4 1
A __set() 0 4 1
1
<?php
2
3
namespace Nip\Container\Traits;
4
5
/**
6
 * Class ContainerPersistenceTrait
7
 * @package Nip\Container
8
 */
9
trait ContainerArrayAccessTrait
10
{
11
    /**
12
     * Determine if a given offset exists.
13
     *
14
     * @param  string $key
15
     * @return bool
16
     */
17
    public function offsetExists($key)
18
    {
19
        return $this->has($key);
0 ignored issues
show
Bug introduced by
It seems like has() 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...
20
    }
21
22
    /**
23
     * Get the value at a given offset.
24
     *
25
     * @param  string $key
26
     * @return mixed
27
     */
28
    public function offsetGet($key)
29
    {
30
        return $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...
31
    }
32
33
    /**
34
     * Set the value at a given offset.
35
     *
36
     * @param  string $key
37
     * @param  mixed $value
38
     * @return void
39
     */
40
    public function offsetSet($key, $value)
41
    {
42
        $this->add($key, $value);
0 ignored issues
show
Bug introduced by
It seems like add() 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...
43
    }
44
45
    /**
46
     * Unset the value at a given offset.
47
     *
48
     * @param  string $key
49
     * @return void
50
     */
51
    public function offsetUnset($key)
52
    {
53
        $this->remove($key);
0 ignored issues
show
Bug introduced by
It seems like remove() 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...
54
    }
55
56
    /**
57
     * Dynamically access container services.
58
     *
59
     * @param  string $key
60
     * @return mixed
61
     */
62
    public function __get($key)
63
    {
64
        return $this[$key];
65
    }
66
67
    /**
68
     * Dynamically set container services.
69
     *
70
     * @param  string $key
71
     * @param  mixed $value
72
     * @return void
73
     */
74
    public function __set($key, $value)
75
    {
76
        $this[$key] = $value;
77
    }
78
}