Passed
Push — master ( a95b22...baf23d )
by Antonio Carlos
06:21
created

Message::getMessages()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace PragmaRX\Firewall\Repositories;
4
5
class Message
6
{
7
    /**
8
     * Saved messages.
9
     *
10
     * @var array
11
     */
12
    private $messages;
13
14
    public function __construct()
15
    {
16
        $this->messages = collect();
0 ignored issues
show
Documentation Bug introduced by
It seems like collect() of type Illuminate\Support\Collection is incompatible with the declared type array of property $messages.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
17
    }
18
19
    /**
20
     * Add a message to the messages list.
21
     *
22
     * @param $message
23
     */
24
    public function addMessage($message)
25
    {
26
        collect((array) $message)->each(function($item) {
27
            collect($item)->flatten()->each(function($flattened) {
28
                $this->messages->push($flattened);
29
            });
30
        });
31
    }
32
33
    /**
34
     * Get the messages.
35
     *
36
     * @return array
37
     */
38
    public function getMessages()
39
    {
40
        return $this->messages;
41
    }
42
}
43