DataProvider   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 13
c 1
b 0
f 0
dl 0
loc 24
ccs 13
cts 13
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A get() 0 14 3
1
<?php
2
3
4
namespace Lexuss1979\Validol;
5
6
7
class DataProvider
8
{
9
10
    private $data;
11
12 156
    public function __construct($data)
13
    {
14 156
        $this->data = $data;
15 156
    }
16
17 156
    public function get($key)
18
    {
19 156
        if (preg_match("/^(\S*)\s*as\s*(\S*)$/", $key, $matches)) {
20 1
            $name = $matches[1];
21 1
            $alias = $matches[2];
22
        } else {
23 155
            $name = $key;
24 155
            $alias = $key;
25
        }
26 156
        if (!isset($this->data[$name])) return new NullValueObject($name, null);
27
28 153
        $value = new ValueObject($name, $this->data[$name]);
29 153
        $value->setAlias($alias);
30 153
        return $value;
31
    }
32
33
34
}