Completed
Push — master ( dca6dc...178b4a )
by Richard
06:29
created

RuleMode::__call()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0185

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 5
cts 6
cp 0.8333
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 2.0185
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 *
5
 * Copyright (c) 2016 Richard Klees <[email protected]>
6
 *
7
 * This software is licensed under The MIT License. You should have received
8
 * a copy of the license along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Definition\Fluid;
12
use Lechimp\Dicto\Definition as Def;
13
14
/**
15
 * Provides fluid interface to only()..can(), must() and cannot().
16
 */
17
class RuleMode extends BaseWithNameAndMode  {
18
    /**
19
     * Tell which schema to use.
20
     *
21
     * @throws  \InvalidArgumentException when schema is unknown
22
     * @throws  \InvalidArgumentException when there are arguments
23
     * @return  Base|null
24
     */
25 186
    public function __call($name, $arguments) {
26
        # ToDo: This is used in Definition\Fluid\Means as well.
27 186
        $schema = $this->rt->get_schema($name);
28 186
        if ($schema === null) {
29
            throw new \InvalidArgumentException("Unknown rule '$name'.");
30
        }
31 186
        return $schema->fluid_interface($this->rt, $this->name, $this->mode, $arguments);
32 1
    }
33
}
34