Completed
Push — master ( 51084e...d852c9 )
by Yaro
07:57
created

Inline   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 0
dl 0
loc 37
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A inline() 0 7 1
A isInline() 0 4 2
A getInlineOptions() 0 4 1
A setInlineUrl() 0 4 1
A getInlineUrl() 0 4 1
1
<?php
2
3
namespace Yaro\Jarboe\Table\Fields\Traits;
4
5
trait Inline
6
{
7
    protected $inline = false;
8
    protected $inlineOptions = [];
9
    protected $inlineUrl = '';
10
11 12
    public function inline(bool $enabled = true, array $options = [])
12
    {
13 12
        $this->inline = $enabled;
14 12
        $this->inlineOptions = $options;
15
16 12
        return $this;
17
    }
18
19 12
    public function isInline(): bool
20
    {
21 12
        return !$this->isReadonly() && $this->inline;
0 ignored issues
show
Bug introduced by
It seems like isReadonly() 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...
22
    }
23
24 4
    public function getInlineOptions(): array
25
    {
26 4
        return $this->inlineOptions;
27
    }
28
29 4
    public function setInlineUrl(string $url)
30
    {
31 4
        $this->inlineUrl = $url;
32 4
    }
33
34
    /**
35
     * @return string
36
     */
37 4
    public function getInlineUrl(): string
38
    {
39 4
        return $this->inlineUrl;
40
    }
41
}
42