Passed
Push — feature/job-builder/step-03 ( 781974...f4292a )
by Yonathan
19:44 queued 12:21
created

WhichPortal::urlIsManagerPortal()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 10
cc 1
nc 1
nop 1
crap 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 25
    public function isApplicantPortal()
12
    {
13 25
        return !$this->isManagerPortal();
14
    }
15
16 30
    public function isManagerPortal()
17
    {
18 30
        $url = URL::current();
19 30
        return $this->urlIsManagerPortal($url);
20
    }
21
22 32
    public function urlIsManagerPortal($url): bool
23
    {
24 32
        $baseUrl = config('app.url');
25 32
        $managerPrefix = config('app.manager_prefix');
26 32
        $managerPattern = "#^$baseUrl/(\w+/)?$managerPrefix(/.*)?$#";
27 32
        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...
28
    }
29
}
30