LRUNode::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 2
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace leetcode\util;
6
7
/**
8
 * @method \leetcode\util\LRUNode setKey(int $key)
9
 * @method int                    getKey()
10
 * @method \leetcode\util\LRUNode setVal(int $val)
11
 * @method int|string             getVal()
12
 * @method \leetcode\util\LRUNode setPrev(\leetcode\util\LRUNode $node)
13
 * @method \leetcode\util\LRUNode getPrev()
14
 * @method \leetcode\util\LRUNode setNext(\leetcode\util\LRUNode $node)
15
 * @method \leetcode\util\LRUNode getNext()
16
 */
17
class LRUNode
18
{
19
    private int $key;
20
    private $val;
21
    private ?LRUNode $prev;
22
    private ?LRUNode $next;
23
24
    public function __construct(int $key, $val)
25
    {
26
        $this->key = $key;
27
        $this->val = $val;
28
    }
29
30
    public function __call(string $name, $arguments = null)
31
    {
32
        if (false !== $pos = strpos($name, 'set')) {
33
            $name = strtolower(substr($name, $pos + 3));
34
            $this->{$name} = $arguments[0];
35
36
            return $this;
37
        }
38
39
        if (false !== $pos = strpos($name, 'get')) {
40
            $name = strtolower(substr($name, $pos + 3));
41
42
            return $this->{$name};
43
        }
44
    }
45
}
46