IdentifiersProvider::getIdentifiers()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
namespace rtens\domin\parameters;
3
4
class IdentifiersProvider {
5
6
    /** @var array|callable[] */
7
    private $providers = [];
8
9
    public function getIdentifiers($class) {
10
        if (!array_key_exists($class, $this->providers)) {
11
            throw new \Exception("No identifier provider registered for [$class]");
12
        }
13
14
        return call_user_func($this->providers[$class]);
15
    }
16
17
    public function setProvider($class, callable $provider) {
18
        $this->providers[$class] = $provider;
19
    }
20
}