LoopTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 41
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
hasVertexStart() 0 1 ?
getVertexStart() 0 1 ?
hasVertexEnd() 0 1 ?
getVertexEnd() 0 1 ?
A isLoop() 0 5 3
1
<?php
2
3
/*
4
 * This file is part of the bisarca/graph package.
5
 *
6
 * (c) Emanuele Minotto <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Bisarca\Graph\Edge\Descriptor;
13
14
use Bisarca\Graph\Vertex\VertexInterface;
15
16
trait LoopTrait
17
{
18
    /**
19
     * Checks if the edge has a starting vertex.
20
     *
21
     * @return bool
22
     */
23
    abstract public function hasVertexStart(): bool;
24
25
    /**
26
     * Gets the starting vertex.
27
     *
28
     * @return VertexInterface
29
     */
30
    abstract public function getVertexStart(): VertexInterface;
31
32
    /**
33
     * Checks if the edge has an ending vertex.
34
     *
35
     * @return bool
36
     */
37
    abstract public function hasVertexEnd(): bool;
38
39
    /**
40
     * Gets the ending vertex.
41
     *
42
     * @return VertexInterface
43
     */
44
    abstract public function getVertexEnd(): VertexInterface;
45
46
    /**
47
     * Checks if the edge is a loop.
48
     *
49
     * @return bool
50
     */
51
    public function isLoop(): bool
52
    {
53
        return $this->hasVertexStart() && $this->hasVertexEnd() &&
54
            $this->getVertexStart() === $this->getVertexEnd();
55
    }
56
}
57