Completed
Push — master ( 14784f...87aa66 )
by Richard
05:56
created

With   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 85.71%

Importance

Changes 4
Bugs 1 Features 1
Metric Value
wmc 2
lcom 1
cbo 4
dl 0
loc 18
ccs 6
cts 7
cp 0.8571
rs 10
c 4
b 1
f 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A name() 0 10 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 licence along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Definition\Fluid;
12
use Lechimp\Dicto\Definition\Variables as Vars;
13
14
/**
15
 * Provides fluid interface for with().
16
 */
17
class With extends Base {
18
    /**
19
     * Say to mean only artifacts whose name matches the provided regexp.
20
     *
21
     * @param   string  $regexp
22
     * @return  ExistingVar
23
     */
24 9
    public function name($regexp) {
25 9
        $subject = $this->rt->get_current_var();
26 9
        if (!($subject instanceof Vars\Variable)) {
27
            throw new \RuntimeException("Could not get current var from runtime.");
28
        }
29 9
        $this->rt->current_var_is(
30 9
            new Vars\WithName($regexp, $subject));
31
32 8
        return new ExistingVar($this->rt);
33
    }
34
}
35