RecordBag   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 31
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A set() 0 4 1
A all() 0 13 1
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