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

RuleMode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 83.33%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 2
c 3
b 0
f 0
lcom 0
cbo 3
dl 0
loc 17
ccs 5
cts 6
cp 0.8333
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 0 8 2
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