Completed
Push — master ( d791dd...2d8ee5 )
by Ventaquil
02:14
created

Point::Point2D()   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 2
1
<?php
2
3
namespace PHPAlgorithms\GraphTools;
4
5
use PHPAlgorithms\GraphTools\Exceptions\PointException;
6
7
abstract class Point {
8
    public static function create()
9
    {
10
        switch (func_num_args()) {
11
            case 0:
12
                return self::AbstractPoint();
13
            case 1:
14
                return self::Point1D(func_get_arg(0));
15
            case 2:
16
                return self::Point2D(func_get_arg(0), func_get_arg(1));
17
            case 3:
18
                return self::Point3D(func_get_arg(0), func_get_arg(1), func_get_arg(2));
19
            case 4:
20
                return self::Point4D(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3));
21
            default:
22
                throw new PointException('Unknown constructor');
23
        }
24
    }
25
26
    public static function AbstractPoint()
27
    {
28
        return new AbstractPoint();
29
    }
30
31
    public static function Point1D($x)
32
    {
33
        return new Point1D($x);
34
    }
35
36
    public static function Point2D($x, $y)
37
    {
38
        return new Point2D($x, $y);
39
    }
40
41
    public static function Point3D($x, $y, $z)
42
    {
43
        return new Point3D($x, $y, $z);
44
    }
45
46
    public static function Point4D($x, $y, $z, $t)
47
    {
48
        return new Point4D($x, $y, $z, $t);
49
    }
50
}
51