Passed
Push — master ( 3df783...ae7cfb )
by Php Easy Api
02:32
created

UrlParseException::exception()   B

Complexity

Conditions 7
Paths 5

Size

Total Lines 23
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 9
nc 5
nop 1
dl 0
loc 23
rs 8.8333
c 0
b 0
f 0
1
<?php
2
3
namespace Resta\Url;
4
5
use DomainException;
6
use Resta\Foundation\PathManager\StaticPathModel;
7
8
class UrlParseException
9
{
10
    /**
11
     * @param array $data
12
     */
13
    public function exception($data=array())
14
    {
15
        if(!isset($data['project']) and !isset($data['version'])){
16
            throw new DomainException('No Project or Version');
17
        }
18
19
        //get app path for checking
20
        $appPath = StaticPathModel::appPath().'/'.$data['project'];
21
22
        //If there is no project on the url
23
        //we throw an exception
24
        if($data['project']===null OR !file_exists($appPath)){
25
            throw new DomainException('No Project');
26
        }
27
28
        if(!in_array($data['version'],UrlVersionIdentifier::supportedVersions())){
29
            throw new DomainException('Version Number is not supported');
30
        }
31
32
        //If there is no endpoint on the url
33
        //we throw an exception
34
        if($data['endpoint']===null){
35
            throw new DomainException('No Endpoint');
36
        }
37
    }
38
}