MappingRepository   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 50%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 23
ccs 5
cts 10
cp 0.5
rs 10
wmc 6

2 Methods

Rating   Name   Duplication   Size   Complexity  
A initFromCache() 0 10 5
A generateCache() 0 3 1
1
<?php
2
3
namespace Nip\Records\Mapping;
4
5
use Nip\Collections\Collection;
6
7
/**
8
 * Class MappingRepository
9
 * @package Nip\Records\Mapping
10
 */
11
class MappingRepository extends Collection
12
{
13
    /**
14
     * @param $data
15
     */
16 1
    public function initFromCache($data)
17
    {
18 1
        if (!is_string($data) || strlen($data) < 1) {
19 1
            return;
20
        }
21
        $data = unserialize($data);
22
        if (!is_array($data) || count($data) < 1) {
23
            return;
24
        }
25
        $this->setItems($data);
26
    }
27
28
    /**
29
     * @return string
30
     */
31 1
    public function generateCache()
32
    {
33 1
        return serialize($this->all());
34
    }
35
}
36