Completed
Push — master ( 48558e...694c49 )
by Marcel
04:18
created

Attachment::getExtras()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 8
Ratio 100 %

Importance

Changes 0
Metric Value
dl 8
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace BotMan\BotMan\Messages\Attachments;
4
5
use Illuminate\Support\Collection;
6
use BotMan\BotMan\Interfaces\WebAccess;
7
8
abstract class Attachment implements WebAccess
9
{
10
    /** @var mixed */
11
    protected $payload;
12
13
    /** @var array */
14
    protected $extras = [];
15
16
    /**
17
     * Attachment constructor.
18
     * @param mixed $payload
19
     */
20
    public function __construct($payload)
21
    {
22
        $this->payload = $payload;
23
    }
24
25
    /**
26
     * @return mixed
27
     */
28
    public function getPayload()
29
    {
30
        return $this->payload;
31
    }
32
33
    /**
34
     * @param string $key
35
     * @param mixed $value
36
     * @return Attachment
37
     */
38
    public function addExtras($key, $value)
39
    {
40
        $this->extras[$key] = $value;
41
42
        return $this;
43
    }
44
45
    /**
46
     * @param string|null $key
47
     * @return array
48
     */
49 View Code Duplication
    public function getExtras($key = null)
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...
50
    {
51
        if (! is_null($key)) {
52
            return Collection::make($this->extras)->get($key);
53
        }
54
55
        return $this->extras;
56
    }
57
}
58