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

WhichPortal::urlIsAdminPortal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
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