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
Pull Request — master (#58)
by Lukas
07:53 queued 14s
created

ButtonHelpers   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 3
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setWebButton() 0 4 1
A setWebButtons() 0 8 1
A setButton() 0 4 1
A setButtons() 0 8 1
1
<?php
2
3
namespace NotificationChannels\OneSignal\Traits\Categories;
4
5
use NotificationChannels\OneSignal\OneSignalButton;
6
use NotificationChannels\OneSignal\OneSignalWebButton;
7
8
trait ButtonHelpers
9
{
10
    /**
11
     * Add a web button to the message.
12
     *
13
     * @param OneSignalWebButton $button
14
     *
15
     * @return $this
16
     */
17
    public function setWebButton(OneSignalWebButton $button)
18
    {
19
        return $this->setParameter('web_buttons', array_merge($this->getParameter('web_buttons', []), [$button->toArray()]));
0 ignored issues
show
Bug introduced by
It seems like getParameter() 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...
Bug introduced by
It seems like setParameter() 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
     * Adds more than one web button to the message.
24
     *
25
     * @param array[OnSignalWebButton] $buttons
0 ignored issues
show
Documentation introduced by
The doc-type array[OnSignalWebButton] could not be parsed: Expected "]" at position 2, but found "OnSignalWebButton". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
26
     *
27
     * @return $this
28
     */
29
    public function setWebButtons(array $buttons)
30
    {
31
        collect($buttons)->map(function ($button) {
32
            $this->setWebButton($button);
33
        });
34
35
        return $this;
36
    }
37
38
    /**
39
     * Add a native button to the message.
40
     *
41
     * @param OneSignalButton $button
42
     *
43
     * @return $this
44
     */
45
    public function setButton(OneSignalButton $button)
46
    {
47
        return $this->setParameter('buttons', array_merge($this->getParameter('buttons', []), [$button->toArray()]));
0 ignored issues
show
Bug introduced by
It seems like getParameter() 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...
Bug introduced by
It seems like setParameter() 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...
48
    }
49
50
    /**
51
     * Adds more than one native button to the message.
52
     *
53
     * @param array $buttons
54
     *
55
     * @return $this
56
     */
57
    public function setButtons(array $buttons)
58
    {
59
        collect($buttons)->map(function ($button) {
60
            $this->setButton($button);
61
        });
62
63
        return $this;
64
    }
65
}
66