Completed
Push — master ( 84d6ef...f4a207 )
by Ventaquil
02:51
created

Connection::__get()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace Algorithms\GraphTools;
3
4
class Connection
5
{
6
    private $from;
7
    private $to;
8
    private $distance;
9
10
    public function __construct(Point $from, Point $to, $distance)
11
    {
12
        if (!(filter_var($distance, FILTER_VALIDATE_INT) || is_numeric($distance)) && ($distance > 0)) {
13
            throw new ConnectionException('Distance must be positive number');
14
        }
15
16
        $this->from = $from;
17
        $this->to = $to;
18
        $this->distance = $distance;
19
    }
20
21
    public function __get($name)
22
    {
23
        return $this->{$name};
24
    }
25
}
26