Passed
Branch master (ae7cfb)
by Php Easy Api
03:47 queued 59s
created

UrlParseException   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 28
rs 10
c 0
b 0
f 0
wmc 7

1 Method

Rating   Name   Duplication   Size   Complexity  
B exception() 0 23 7
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
}