Record   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 2
Metric Value
eloc 10
c 2
b 0
f 2
dl 0
loc 57
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getGraph() 0 3 1
A __construct() 0 5 2
A __toString() 0 3 1
A getVertex() 0 3 1
A setVertex() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of the doctrineviz package
5
 *
6
 * Copyright (c) 2017 Pierre Hennequart
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Pierre Hennequart <[email protected]>
14
 */
15
16
declare(strict_types=1);
17
18
namespace Janalis\Doctrineviz\Graphviz;
19
20
class Record extends Element implements RecordInterface
21
{
22
    use Edgeable;
23
24
    /** @var Vertex */
25
    protected $vertex;
26
27
    /**
28
     * @return string
29
     */
30
    public function __toString()
31
    {
32
        return sprintf('<%s> %s\\l', explode(' ', $this->getId())[0], $this->getId());
33
    }
34
35
    /**
36
     * Get graph.
37
     *
38
     * @return GraphInterface|null
39
     */
40
    public function getGraph(): ?GraphInterface
41
    {
42
        return $this->graph;
43
    }
44
45
    /**
46
     * Record constructor.
47
     *
48
     * @param null|string          $id
49
     * @param null|VertexInterface $vertex
50
     */
51
    public function __construct(string $id = null, VertexInterface $vertex = null)
52
    {
53
        $this->id = $id;
54
        if ($vertex) {
55
            $vertex->addRecord($this);
56
        }
57
    }
58
59
    /**
60
     * Get vertex.
61
     *
62
     * @return VertexInterface
63
     */
64
    public function getVertex(): ?VertexInterface
65
    {
66
        return $this->vertex;
67
    }
68
69
    /**
70
     * Set vertex.
71
     *
72
     * @param VertexInterface $vertex
73
     */
74
    public function setVertex(VertexInterface $vertex): void
75
    {
76
        $this->vertex = $vertex;
0 ignored issues
show
Documentation Bug introduced by
$vertex is of type Janalis\Doctrineviz\Graphviz\VertexInterface, but the property $vertex was declared to be of type Janalis\Doctrineviz\Graphviz\Vertex. Are you sure that you always receive this specific sub-class here, or does it make sense to add an instanceof check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.

Either this assignment is in error or an instanceof check should be added for that assignment.

class Alien {}

class Dalek extends Alien {}

class Plot
{
    /** @var  Dalek */
    public $villain;
}

$alien = new Alien();
$plot = new Plot();
if ($alien instanceof Dalek) {
    $plot->villain = $alien;
}
Loading history...
77
    }
78
}
79