Base   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 75
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 5
c 3
b 1
f 1
lcom 1
cbo 1
dl 0
loc 75
ccs 15
cts 15
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A get() 0 4 1
A setOptions() 0 5 1
A setOption() 0 5 1
A getOptions() 0 4 1
run() 0 1 ?
1
<?php
2
3
namespace GFG\Mapper\Data\Type;
4
5
use GFG\Mapper\Data\MapperInterface;
6
use GFG\Mapper\Data\Manager;
7
8
/**
9
 * Base class for Types
10
 */
11
abstract class Base
12
{
13
    /**
14
     * @var Manager
15
     */
16
    protected $manager;
17
18
    /**
19
     * @var MapperInterface
20
     */
21
    protected $mapper;
22
23
    /**
24
     * @var array specific options for this type
25
     */
26
    protected $options;
27
28
    /**
29
     * @var Manager         $manager
30
     * @var MapperInterface $mapper
31
     * @var array           $options
32
     */
33 10
    public function __construct(
34
        Manager $manager,
35
        MapperInterface $mapper,
36
        array $options
37
    ) {
38 10
        $this->manager = $manager;
39 10
        $this->mapper  = $mapper;
40 10
        $this->options = $options;
41 10
    }
42
43
    /**
44
     * @param string $key Key to be retrived from user-defined mapper
45
     */
46 6
    public function get($key)
47
    {
48 6
        return $this->mapper->get($this->options['prefix'] . '_' . $key);
49
    }
50
51
    /**
52
     * @param array $options
53
     * @return $this
54
     */
55 1
    public function setOptions(array $options)
56
    {
57 1
        $this->options = $options;
58 1
        return $this;
59
    }
60
61
    /**
62
     * @param string $option Option key
63
     * @param mixed $value Option value
64
     */
65 3
    public function setOption($option, $value)
66
    {
67 3
        $this->options[$option] = $value;
68 3
        return $this;
69
    }
70
71
    /**
72
     * @return array
73
     */
74 3
    public function getOptions()
75
    {
76 3
        return $this->options;
77
    }
78
79
    /**
80
     * Every type must run!
81
     * @param mixed $data
82
     * @param string $key
83
     */
84
    abstract public function run(&$data, $key = null);
85
}
86