Completed
Push — master ( 4a68ab...01a40f )
by Song
03:24
created

InlineEditing::year()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Column;
4
5
use Encore\Admin\Grid\Column;
6
use Encore\Admin\Grid\Displayers;
7
8
trait InlineEditing
9
{
10
    /**
11
     * @param string $selectable
12
     *
13
     * @return $this
14
     */
15 View Code Duplication
    public function belongsTo($selectable)
0 ignored issues
show
Duplication introduced by
This method 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
        if (method_exists($selectable, 'display')) {
18
            $this->display($selectable::display());
0 ignored issues
show
Bug introduced by
It seems like display() 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...
19
        }
20
21
        return $this->displayUsing(Displayers\BelongsTo::class, [$selectable]);
0 ignored issues
show
Bug introduced by
It seems like displayUsing() 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
    /**
25
     * @param string $selectable
26
     *
27
     * @return $this
28
     */
29 View Code Duplication
    public function belongsToMany($selectable)
0 ignored issues
show
Duplication introduced by
This method 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...
30
    {
31
        if (method_exists($selectable, 'display')) {
32
            $this->display($selectable::display());
0 ignored issues
show
Bug introduced by
It seems like display() 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...
33
        }
34
35
        return $this->displayUsing(Displayers\BelongsToMany::class, [$selectable]);
0 ignored issues
show
Bug introduced by
It seems like displayUsing() 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
    }
37
38
    /**
39
     * Upload file.
40
     *
41
     * @return $this
42
     */
43
    public function upload()
44
    {
45
        return $this->displayUsing(Displayers\Upload::class);
0 ignored issues
show
Bug introduced by
It seems like displayUsing() 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...
46
    }
47
48
    /**
49
     * Upload many files.
50
     *
51
     * @return $this
52
     */
53
    public function uplaodMany()
54
    {
55
        return $this->displayUsing(Displayers\Upload::class, [true]);
0 ignored issues
show
Bug introduced by
It seems like displayUsing() 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...
56
    }
57
58
    /**
59
     * Grid inline datetime picker.
60
     *
61
     * @param string $format
62
     *
63
     * @return $this
64
     */
65
    public function datetime($format = 'YYYY-MM-DD HH:mm:ss')
66
    {
67
        return $this->displayUsing(Displayers\Datetime::class, [$format]);
0 ignored issues
show
Bug introduced by
It seems like displayUsing() 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...
68
    }
69
70
    /**
71
     * Grid inline date picker.
72
     *
73
     * @param string $format
0 ignored issues
show
Bug introduced by
There is no parameter named $format. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
74
     *
75
     * @return $this
76
     */
77
    public function date()
78
    {
79
        return $this->datetime('YYYY-MM-DD');
80
    }
81
82
    /**
83
     * Grid inline time picker.
84
     *
85
     * @param string $format
0 ignored issues
show
Bug introduced by
There is no parameter named $format. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
86
     *
87
     * @return $this
88
     */
89
    public function time()
90
    {
91
        return $this->datetime('HH:mm:ss');
92
    }
93
94
    public function year()
95
    {
96
        return $this->datetime('YYYY');
97
    }
98
99
    public function month()
100
    {
101
        return $this->datetime('MM');
102
    }
103
104
    public function day()
105
    {
106
        return $this->datetime('DD');
107
    }
108
109
    public function input($mask = [])
110
    {
111
        return $this->displayUsing(Displayers\Input::class, [$mask]);
0 ignored issues
show
Bug introduced by
It seems like displayUsing() 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...
112
    }
113
114
    public function ip()
115
    {
116
        return $this->input(['alias' => 'ip']);
117
    }
118
119
    public function email()
120
    {
121
        return $this->input(['alias' => 'email']);
122
    }
123
}
124