Code Duplication    Length = 41-42 lines in 2 locations

src/Definition/Rules/DependOn.php 1 location

@@ 14-54 (lines=41) @@
11
namespace Lechimp\Dicto\Definition\Rules;
12
use Lechimp\Dicto\Definition\Variables as Vars;
13
14
class DependOn extends Rule {
15
    /**
16
     * @var Vars\Variable
17
     */
18
    private $dependency;
19
20
    /**
21
     * @param string $mode
22
     */
23
    public function __construct($mode, Vars\Variable $left, Vars\Variable $dependency) {
24
        parent::__construct($mode, $left);
25
        $this->dependency = $dependency;
26
    }
27
28
    /**
29
     * @var Variable
30
     */
31
    public function dependency() {
32
        return $this->dependency;
33
    }
34
35
    public function invoke(Functions $fun) {
36
        return InvokeRule($this, $fun);
37
    }
38
39
    /**
40
     * @inheritdoc
41
     */
42
    public function explain($text) {
43
        $r = new DependOnRule($this->mode(), $this->subject(), $this->dependency);
44
        $r->setExplanation($text);
45
        return $r;
46
    }
47
48
    /**
49
     * @inheritdoc
50
     */
51
    public function variables() {
52
        return array($this->subject(), $this->dependency);
53
    }
54
}
55

src/Definition/Rules/Invoke.php 1 location

@@ 14-55 (lines=42) @@
11
namespace Lechimp\Dicto\Definition\Rules;
12
use Lechimp\Dicto\Definition\Variables as Vars;
13
14
class Invoke extends Rule {
15
    /**
16
     * @var Vars\Variable
17
     */
18
    private $invokes;
19
20
    /**
21
     * @param string $mode
22
     */
23
    public function __construct($mode, Vars\Variable $left, Vars\Variable $invokes) {
24
        parent::__construct($mode, $left);
25
        $this->invokes = $invokes;
26
    }
27
28
    // TODO: This seems odd. Its part of a fluid interface, right?
29
    public function invoke(Functions $fun) {
30
        return InvokeRule($this, $fun);
31
    }
32
33
    /**
34
     * @return Vars\Variable
35
     */
36
    public function invokes() {
37
        return $this->invokes;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function explain($text) {
44
        $r = new InvokeRule($this->mode(), $this->subject(), $this->invokes);
45
        $r->setExplanation($text);
46
        return $r;
47
    }
48
49
    /**
50
     * @inheritdoc
51
     */
52
    public function variables() {
53
        return array($this->subject(), $this->invokes);
54
    }
55
}
56
57