Completed
Push — master ( 69f641...8fff44 )
by Richard
05:35
created

Entities::meaning()   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 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
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 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\Graph\Node;
14
15
abstract class Entities extends Variable {
16 86
    public function __construct($name= null) {
17 86
        if ($name === null) {
18 68
            $name = ucfirst($this->meaning());
19 68
        }
20 86
        parent::__construct($name);
21 86
    }
22
23
    /**
24
     * Get an id for the type of entity.
25
     *
26
     * @return  string
27
     */
28
    abstract public function id();
29
30
    /**
31
     * @inheritdocs
32
     */
33
    public function compile() {
34 34
        return function(Node $n) {
35 33
            return $n->type() == $this->id()
36 33
                || $n->type() == $this->id()." reference";
37 34
        };
38
    }
39
}
40
41