Passed
Push — feature/redux-claim-job ( b0411b )
by Tristan
11:52
created

WhichPortal::urlIsHrPortal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 4
dl 0
loc 6
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Services;
4
5
use Illuminate\Support\Facades\URL;
6
7
class WhichPortal
8
{
9
10
    public function isApplicantPortal()
2 ignored issues
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...
11
    {
12
        return !$this->isManagerPortal() && !$this->isHrPortal() && !$this->isAdminPortal();
13
    }
14
15
    public function isManagerPortal()
2 ignored issues
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...
16
    {
17
        $url = URL::current();
18
        return $this->urlIsManagerPortal($url);
19
    }
20
21
    public function isHrPortal()
2 ignored issues
show
introduced by
Method \App\Services\WhichPortal::isHrPortal() 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 isHrPortal()
Loading history...
22
    {
23
        $url = URL::current();
24
        return $this->urlIsHrPortal($url);
25
    }
26
27
    public function isAdminPortal()
2 ignored issues
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...
28
    {
29
        $url = URL::current();
30
        return $this->urlIsAdminPortal($url);
31
    }
32
33
    public function urlIsManagerPortal($url): bool
1 ignored issue
show
Coding Style Documentation introduced by
Missing doc comment for function urlIsManagerPortal()
Loading history...
introduced by
Method \App\Services\WhichPortal::urlIsManagerPortal() does not have parameter type hint nor @param annotation for its parameter $url.
Loading history...
34
    {
35
        $baseUrl = config('app.url');
36
        $managerPrefix = config('app.manager_prefix');
37
        $managerPattern = "#^$baseUrl/(\w+/)?$managerPrefix(/.*)?$#";
38
        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...
39
    }
40
41
    public function urlIsHrPortal($url): bool
1 ignored issue
show
introduced by
Method \App\Services\WhichPortal::urlIsHrPortal() 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 urlIsHrPortal()
Loading history...
42
    {
43
        $baseUrl = config('app.url');
44
        $hrPrefix = config('app.hr_prefix');
45
        $hrPattern = "#^$baseUrl/(\w+/)?$hrPrefix(/.*)?$#";
46
        return preg_match($hrPattern, $url);
0 ignored issues
show
Bug Best Practice introduced by
The expression return preg_match($hrPattern, $url) returns the type integer which is incompatible with the type-hinted return boolean.
Loading history...
47
    }
48
49
    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...
50
    {
51
        $baseUrl = config('app.url');
52
        $adminPrefix = config('backpack.base.route_prefix', 'admin');
53
        $adminPattern = "#^$baseUrl/(\w+/)?$adminPrefix(/.*)?$#";
54
        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...
55
    }
56
}
57