Completed
Push — master ( ed33ab...f2b55d )
by Simone
02:26
created

Resource::fromConfiguration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 10
nc 1
nop 2
1
<?php
2
3
/**
4
 * This file is part of sensorario/resources repository
5
 *
6
 * (c) Simone Gentili <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sensorario\Resources;
13
14
use RuntimeException;
15
use Sensorario\Resources\Validators\ResourcesValidator;
16
17
class Resource
18
    extends MagicResource
0 ignored issues
show
Coding Style introduced by
The extends keyword must be on the same line as the class name
Loading history...
Coding Style introduced by
Expected 0 spaces between "MagicResource" and comma; 1 found
Loading history...
19
    implements Interfaces\ResourceInterface
0 ignored issues
show
Coding Style introduced by
The implements keyword must be on the same line as the class name
Loading history...
20
{
21
    protected $allowed = [];
22
23
    protected $allowedValues = [];
24
25
    protected $mandatory = [];
26
27
    protected $defaults = [];
28
29
    protected $rules = [];
30
31
    public function mandatory()
32
    {
33
        return $this->mandatory;
34
    }
35
36
    public function allowed()
37
    {
38
        return $this->allowed;
39
    }
40
41
    public function allowedValues()
42
    {
43
        return $this->allowedValues;
44
    }
45
46
    public function rules()
47
    {
48
        return $this->rules;
49
    }
50
51
    public function defaults()
52
    {
53
        return $this->defaults;
54
    }
55
56
    public function applyConfiguration(
57
        Configurator $configurator
58
    ) {
59
        $this->allowed       = $configurator->allowed();
60
        $this->mandatory     = $configurator->mandatory();
61
        $this->defaults      = $configurator->defaults();
62
        $this->rules         = $configurator->rules();
63
        $this->allowedValues = $configurator->allowedValues();
64
    }
65
}
66