Completed
Push — master ( 1f981d...cc2765 )
by Richard
06:42
created

Combinator::left()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 * 
5
 * Copyright (c) 2016, 2015 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\Variables;
12
13
abstract class Combinator extends Variable {
14
    /**
15
     * @var Variable
16
     */
17
    private $left;
18
19
    /**
20
     * @var Variable
21
     */
22
    private $right;
23
24 319
    public function __construct($name, Variable $left, Variable $right) {
25 319
        parent::__construct($name);
26 319
        $this->left = $left;
27 319
        $this->right = $right;
28 319
    }
29
30
    /**
31
     * Get an id for this combinator.
32
     *
33
     * This must return a string without whitespaces.
34
     *
35
     * @return  string
36
     */
37
    abstract public function id();
38
39
40
    /**
41
     * @inheritdocs
42
     */
43 98
    public function meaning() {
44 98
        $cb = str_replace("_", " ", $this->id());
45 98
        return $this->left()->meaning()." $cb ".$this->right()->meaning();
46
    }
47
48
    /**
49
     * @return  Variable
50
     */
51 119
    public function left() {
52 119
        return $this->left;
53
    }
54
55
    /**
56
     * @return  Variable
57
     */
58 119
    public function right() {
59 119
        return $this->right;
60
    }
61
}
62