IdentifiersProvider::setProvider()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 2
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
}