PanaceaMobileMessage::toArray()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 0
1
<?php
2
3
namespace NotificationChannels\PanaceaMobile;
4
5
use Illuminate\Contracts\Support\Arrayable;
6
7
class PanaceaMobileMessage implements Arrayable
8
{
9
    /**
10
     * The phone number the message should be sent from.
11
     *
12
     * @var string
13
     */
14
    public $from;
15
16
    /**
17
     * The message content.
18
     *
19
     * @var string
20
     */
21
    public $content;
22
23
    /**
24
     * Create a new message instance.
25
     *
26
     * @param  string $content
27
     * @return static
28
     */
29
    public static function create($content = '')
30
    {
31
        return new static($content);
32
    }
33
34
    /**
35
     * @param  string  $content
36
     */
37
    public function __construct($content = '')
38
    {
39
        $this->content = $content;
40
    }
41
42
    /**
43
     * Set the message content.
44
     *
45
     * @param  string  $content
46
     *
47
     * @return $this
48
     */
49
    public function content($content)
50
    {
51
        $this->content = $content;
52
53
        return $this;
54
    }
55
56
    /**
57
     * Set the phone number or from name the message should be sent from.
58
     *
59
     * @param  string  $from
60
     *
61
     * @return $this
62
     */
63
    public function from($from)
64
    {
65
        $this->from = $from;
66
67
        return $this;
68
    }
69
	
70
    /**
71
     * Set the phone number or from name the message should be sent from.
72
     *
73
     * @param  string  $from
0 ignored issues
show
Bug introduced by
There is no parameter named $from. 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 recipient($to)
78
    {
79
        $this->to = $to;
0 ignored issues
show
Bug introduced by
The property to does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
80
81
        return $this;
82
    }
83
84
    /**
85
     * @return array
86
     */
87
    public function toArray()
88
    {
89
        $params = [
90
            'text' => $this->content,
91
            'charset' => 'utf-8',
92
        ];
93
94
        if (! empty($this->from)) {
95
            $params = array_merge($params, ['from' => $this->from]);
96
        }
97
98
        return $params;
99
    }
100
}
101