Completed
Push — master ( f08276...333f55 )
by Richard
06:54 queued 34s
created

Definition   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 28
ccs 0
cts 10
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A explain() 0 5 1
A explanation() 0 3 1
A setExplanation() 0 4 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\Definition;
12
13
/**
14
 * Base class for all definitions. 
15
 */
16
abstract class Definition {
17
    /**
18
     * @var string|null
19
     */
20
    private $explanation = null;
21
22
    /**
23
     * @param   string
24
     * return   self
25
     */
26
    public function explain($explanation) {
27
        $clone = clone $this;
28
        $clone->explanation = $explanation;
29
        return $clone;
30
    }
31
32
    /**
33
     * @return  string
34
     */
35
    public function explanation() {
36
        return $this->explanation;
37
    }
38
39
    protected function setExplanation($explanation) {
40
        assert('is_string($explanation)');
41
        $this->explanation = $explanation;
42
    }
43
}
44
45