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
Push — master ( 4e0f46...61af64 )
by Marceau
03:34
created

FieldWithOptions::getOption()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Akibatech\Crud\Traits;
4
5
/**
6
 * Class FieldWithOptions
7
 *
8
 * @package Akibatech\Crud\Traits
9
 */
10
trait FieldWithOptions
11
{
12
    /**
13
     * @var array
14
     */
15
    protected $options;
16
17
    /**
18
     * @param   array $options
19
     * @return  self
20
     */
21
    public function withOptions($options = [])
22
    {
23
        $this->options = $options;
24
25
        $this->addRule('in:' . implode(',', array_keys($this->getOptionsKeys())));
0 ignored issues
show
Bug introduced by
It seems like addRule() 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...
26
27
        return $this;
28
    }
29
30
    /**
31
     * @param   mixed $identifier
32
     * @return  bool
33
     */
34
    public function hasOption($identifier)
35
    {
36
        return array_key_exists($identifier, $this->getOptions());
37
    }
38
39
    /**
40
     * @param   void
41
     * @return  array
42
     */
43
    public function getOptions()
44
    {
45
        return $this->options;
46
    }
47
48
    /**
49
     * @param   void
50
     * @return  array
51
     */
52
    public function getOptionsKeys()
53
    {
54
        return array_keys($this->options);
55
    }
56
57
    /**
58
     * @param   void
59
     * @return  string|null
60
     */
61
    public function getOption($identifier)
62
    {
63
        return $this->hasOption($identifier) ? $this->options[$identifier] : null;
64
    }
65
66
    /**
67
     * @param   void
68
     * @return  string|null
69
     */
70
    public function getTableValue()
71
    {
72
        return $this->getOption($this->getValue());
0 ignored issues
show
Bug introduced by
It seems like getValue() 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...
73
    }
74
}
75