LRUNode   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 14
c 2
b 0
f 0
dl 0
loc 26
rs 10

2 Methods

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