Completed
Push — master ( 470c23...605cf4 )
by Richard
08:11
created

LanguageConstruct::compile()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
crap 1
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\Variables;
12
13
use Lechimp\Dicto\Regexp;
14
use Lechimp\Dicto\Graph\PredicateFactory;
15
16
abstract class LanguageConstruct extends Variable {
17
    /**
18
     * @var string
19
     */
20
    private $construct_name;
21
22 47
    public function __construct($construct_name, $name = null) {
23 47
        parent::__construct($name);
24 47
        assert('is_string($construct_name)');
25 47
        $this->construct_name = $construct_name;     
26 47
    }
27
28
    /**
29
     * @return  string
30
     */
31 113
    public function construct_name() {
32 113
        return $this->construct_name;
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38 108
    public function meaning() {
39 108
        return $this->construct_name();
40
    }
41
42
    /**
43
     * @inheritdocs
44
     */
45 5
    public function compile(PredicateFactory $f) {
46 5
        return $f->_and
47 5
            ([$f->_type_is(Variable::LANGUAGE_CONSTRUCT_TYPE)
48 5
            , $f->_property("name")->_equals($this->construct_name())
49 5
            ]);
50
    }
51
}
52
53