RecordBag::set()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 2
1
<?php
2
3
namespace Thruster\Component\Dns;
4
5
/**
6
 * Class RecordBag
7
 *
8
 * @package Thruster\Component\Dns
9
 * @author  Aurimas Niekis <[email protected]>
10
 */
11
class RecordBag
12
{
13
    /**
14
     * @var array
15
     */
16
    private $records;
17
18
    public function __construct()
19
    {
20
        $this->records = [];
21
    }
22
23
    public function set(int $currentTime, Record $record)
24
    {
25
        $this->records[$record->getData()] = [$currentTime + $record->getTtl(), $record];
26
    }
27
28
    public function all() : array
29
    {
30
        return array_values(
31
            array_map(
32
                function ($value) {
33
                    list($expiresAt, $record) = $value;
0 ignored issues
show
Unused Code introduced by
The assignment to $expiresAt is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
34
35
                    return $record;
36
                },
37
                $this->records
38
            )
39
        );
40
    }
41
}
42