Item::addReference()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
/* (c) Anton Medvedev <[email protected]>
3
 *
4
 * For the full copyright and license information, please view the LICENSE
5
 * file that was distributed with this source code.
6
 */
7
8
namespace Deployer\Support\Changelog;
9
10
class Item
11
{
12
    /** @var string */
13
    private $message;
14
15
    /**
16
     * @var int[]
17
     */
18
    private $references = [];
19
20 1
    public function __toString()
21
    {
22 1
        sort($this->references, SORT_NUMERIC);
23
24 1
        $references = implode('', array_map(function ($ref) {
25 1
            return " [#$ref]";
26 1
        }, $this->references));
27
28 1
        return "{$this->message}$references";
29
    }
30
31 2
    public function setMessage(string $message)
32
    {
33 2
        $this->message = $message;
34 2
    }
35
36 2
    public function addReference(int $reference)
37
    {
38 2
        $this->references[] = $reference;
39 2
    }
40
}
41