Completed
Push — master ( 389cae...29b40e )
by Richard
06:27
created

Variable   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 60%

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
c 3
b 0
f 0
lcom 0
cbo 1
dl 0
loc 46
ccs 9
cts 15
cp 0.6
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A is_type() 0 11 1
A __construct() 0 4 1
A name() 0 3 1
A _with() 0 3 1
A cannot() 0 3 1
A must() 0 3 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 licence along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Variables;
12
use Lechimp\Dicto\Definition as Def;
13
14
15
abstract class Variable extends Def\Definition {
16
    const CLASS_TYPE = "class";
17
    const FILE_TYPE = "file";
18
    const GLOBAL_TYPE = "global";
19
    const FUNCTION_TYPE = "function";
20
    const METHOD_TYPE = "method";
21
    const LANGUAGE_CONSTRUCT_TYPE = "language_construct";
22
23 67
    static public function is_type($t) {
0 ignored issues
show
Coding Style introduced by
As per PSR2, the static declaration should come after the visibility declaration.
Loading history...
24
        static $types = array
25
            ( "class"
26
            , "file"
27
            , "global"
28
            , "function"
29
            , "method"
30
            , "language_construct"
31 67
            );
32 67
        return in_array($t, $types);
33
    }
34
35
    /**
36
     * @var string
37
     */
38
    private $name;
39
40 341
    public function __construct($name) {
41 341
        assert('is_string($name)');
42 341
        $this->name = $name;
43 341
    }
44
45 50
    public function name() {
46 50
        return $this->name;
47
    }
48
49
    public function _with() {
50
        return new WithFluid($this);
51
    } 
52
53
    public function cannot() {
54
        return new CannotFluid($this);
55
    }
56
57
    public function must() {
58
        return new MustFluid($this);
59
    }
60
}
61
62