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

Connection   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 5
c 2
b 0
f 0
lcom 0
cbo 1
dl 0
loc 22
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 4
A __get() 0 4 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