Completed
Push — master ( e82759...2ca52b )
by Joschi
05:55
created

AbstractRelation::getSignature()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
/**
4
 * apparat-object
5
 *
6
 * @category    Apparat
7
 * @package     Apparat\Object
8
 * @subpackage  Apparat\Object\<Layer>
9
 * @author      Joschi Kuphal <[email protected]> / @jkphl
10
 * @copyright   Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
11
 * @license     http://opensource.org/licenses/MIT The MIT License (MIT)
12
 */
13
14
/***********************************************************************************
15
 *  The MIT License (MIT)
16
 *
17
 *  Copyright © 2016 Joschi Kuphal <[email protected]> / @jkphl
18
 *
19
 *  Permission is hereby granted, free of charge, to any person obtaining a copy of
20
 *  this software and associated documentation files (the "Software"), to deal in
21
 *  the Software without restriction, including without limitation the rights to
22
 *  use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
23
 *  the Software, and to permit persons to whom the Software is furnished to do so,
24
 *  subject to the following conditions:
25
 *
26
 *  The above copyright notice and this permission notice shall be included in all
27
 *  copies or substantial portions of the Software.
28
 *
29
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
30
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
31
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
32
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
33
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
34
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
35
 ***********************************************************************************/
36
37
namespace Apparat\Object\Domain\Model\Relation;
38
use Apparat\Object\Domain\Factory\RelationFactory;
39
use Apparat\Object\Domain\Model\Path\Url;
40
41
/**
42
 * Abstract base relation
43
 *
44
 * @package Apparat\Object
45
 * @subpackage Apparat\Object\Domain
46
 */
47
abstract class AbstractRelation implements RelationInterface
48
{
49
    /**
50
     * Relation type
51
     *
52
     * @var string
53
     */
54
    protected $type = null;
55
    /**
56
     * Relation URL
57
     *
58
     * @var string
59
     */
60
    protected $url = null;
61
    /**
62
     * Relation label
63
     *
64
     * @var string
65
     */
66
    protected $label = null;
67
    /**
68
     * Relation email
69
     *
70
     * @var string
71
     */
72
    protected $email = null;
73
    /**
74
     * Coupling
75
     *
76
     * @var int
77
     */
78
    protected $coupling = self::LOOSE_COUPLING;
79
80
    /**
81
     * @param string $type Relation type
0 ignored issues
show
Bug introduced by
There is no parameter named $type. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
82
     * @param Url $url Relation URL
83
     * @param string $label Relation label
84
     * @param string $email Relation email
85
     * @param int $coupling Coupling
86
     * @throws OutOfBoundsException If the object type is invalid
87
     * @throws OutOfBoundsException If the object coupling is invalid
88
     */
89 14
    public function __construct(
90
        Url $url,
91
        $label,
92
        $email,
93
        $coupling
94
    ) {
95
        // If the coupling type is invalid
96
//        if (($coupling !== self::LOOSE_COUPLING) && ($coupling !== self::TIGHT_COUPLING)) {
97
//            throw new InvalidArgumentException(
98
//                sprintf('Invalid object coupling "%s"', $coupling),
99
//                InvalidArgumentException::INVALID_OBJECT_COUPLING
100
//            );
101
//        }
102
103 14
        $this->url = $url;
0 ignored issues
show
Documentation Bug introduced by
It seems like $url of type object<Apparat\Object\Domain\Model\Path\Url> is incompatible with the declared type string of property $url.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
104 14
        $this->label = $label;
105 14
        $this->email = $email;
106 14
        $this->coupling = $coupling;
107 14
    }
108
109
    /**
110
     * Return the relation type
111
     *
112
     * @return string Relation type
113
     */
114 14
    public function getType()
115
    {
116 14
        return $this->type;
117
    }
118
119
    /**
120
     * Return the unique relation signature
121
     *
122
     * @return string Relation signature
123
     */
124 14
    public function getSignature()
125
    {
126 14
        return md5($this->url);
127
    }
128
}
129