Passed
Push — dev ( 39070a...d6bbaa )
by Chris
08:00
created

WhichPortal   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
eloc 14
dl 0
loc 34
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isManagerPortal() 0 4 1
A urlIsManagerPortal() 0 6 1
A isAdminPortal() 0 4 1
A isApplicantPortal() 0 3 2
A urlIsAdminPortal() 0 6 1
1
<?php
2
3
namespace App\Services;
4
5
use Illuminate\Support\Facades\Route;
6
use Illuminate\Support\Facades\URL;
7
8
class WhichPortal
9
{
10
11 27
    public function isApplicantPortal()
1 ignored issue
show
introduced by
Method \App\Services\WhichPortal::isApplicantPortal() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function isApplicantPortal()
Loading history...
12
    {
13 27
        return !$this->isManagerPortal() && !$this->isAdminPortal();
14
    }
15
16 32
    public function isManagerPortal()
1 ignored issue
show
introduced by
Method \App\Services\WhichPortal::isManagerPortal() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function isManagerPortal()
Loading history...
17
    {
18 32
        $url = URL::current();
19 32
        return $this->urlIsManagerPortal($url);
20
    }
21
22 34
    public function isAdminPortal()
1 ignored issue
show
introduced by
Method \App\Services\WhichPortal::isAdminPortal() does not have return type hint nor @return annotation for its return value.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function isAdminPortal()
Loading history...
23
    {
24 34
        $url = URL::current();
25 34
        return $this->urlIsAdminPortal($url);
26 34
    }
27 34
28
    public function urlIsManagerPortal($url): bool
1 ignored issue
show
introduced by
Method \App\Services\WhichPortal::urlIsManagerPortal() does not have parameter type hint nor @param annotation for its parameter $url.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function urlIsManagerPortal()
Loading history...
29
    {
30
        $baseUrl = config('app.url');
31
        $managerPrefix = config('app.manager_prefix');
32
        $managerPattern = "#^$baseUrl/(\w+/)?$managerPrefix(/.*)?$#";
33
        return preg_match($managerPattern, $url);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match($managerPattern, $url) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
34
    }
35
36
    public function urlIsAdminPortal($url): bool
1 ignored issue
show
introduced by
Method \App\Services\WhichPortal::urlIsAdminPortal() does not have parameter type hint nor @param annotation for its parameter $url.
Loading history...
Coding Style Documentation introduced by
Missing doc comment for function urlIsAdminPortal()
Loading history...
37
    {
38
        $baseUrl = config('app.url');
39
        $adminPrefix = config('backpack.base.route_prefix', 'admin');
40
        $adminPattern = "#^$baseUrl/(\w+/)?$adminPrefix(/.*)?$#";
41
        return preg_match($adminPattern, $url);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match($adminPattern, $url) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
42
    }
43
}
44