SharedMemoryAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 43
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 14 3
A getClient() 0 4 1
1
<?php namespace AdammBalogh\KeyValueStore\Adapter;
2
3
use AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter\ShmProxy;
4
use AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter\KeyTrait;
5
use AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter\ValueTrait;
6
use AdammBalogh\KeyValueStore\Adapter\SharedMemoryAdapter\ServerTrait;
7
8
class SharedMemoryAdapter extends AbstractAdapter
9
{
10
    use KeyTrait, ValueTrait, ServerTrait;
11
12
    /**
13
     * @var resource
14
     */
15
    protected $client;
16
17
    /**
18
     * @var ShmProxy
19
     */
20
    protected $shmProxy;
21
22
    /**
23
     * @param resource $client
24
     * @param ShmProxy $shmProxy
25
     *
26
     * @throws \InvalidArgumentException
27
     */
28
    public function __construct($client, ShmProxy $shmProxy = null)
29
    {
30
        if (!is_resource($client)) {
31
            throw new \InvalidArgumentException();
32
        }
33
34
        if (is_null($shmProxy)) {
35
            $this->shmProxy = new ShmProxy();
36
        } else {
37
            $this->shmProxy = $shmProxy;
38
        }
39
40
        $this->client = $client;
41
    }
42
43
    /**
44
     * @return resource
45
     */
46
    public function getClient()
47
    {
48
        return $this->client;
49
    }
50
}
51