Completed
Pull Request — master (#119)
by Toby
65:37 queued 63:37
created

MetaTrait::replaceMeta()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of JSON-API.
5
 *
6
 * (c) Toby Zerner <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tobscure\JsonApi;
13
14
trait MetaTrait
15
{
16
    /**
17
     * The meta data.
18
     *
19
     * @var array
20
     */
21
    protected $meta = [];
22
23
    /**
24
     * Get the meta data.
25
     *
26
     * @return array
27
     */
28
    public function getMeta()
29
    {
30
        return $this->meta;
31
    }
32
33
    /**
34
     * Set the meta data.
35
     *
36
     * @param array $meta
37
     */
38 3
    public function replaceMeta(array $meta)
39
    {
40 3
        $this->meta = $meta;
41 3
    }
42
43
    /**
44
     * Set a piece of meta data.
45
     *
46
     * @param string $key
47
     * @param mixed $value
48
     */
49
    public function setMeta($key, $value)
50
    {
51
        $this->meta[$key] = $value;
52
    }
53
54
    /**
55
     * Remove a piece of meta data.
56
     *
57
     * @param string $key
58
     * @param mixed $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. 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...
59
     */
60
    public function removeMeta($key)
61
    {
62
        unset($this->meta[$key]);
63
    }
64
}
65