Passed
Push — bugfix/which-portal ( 090ab7 )
by Tristan
35:14 queued 19:21
created

WhichPortal   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A isManagerPortal() 0 4 1
A isApplicantPortal() 0 3 1
A urlIsManagerPortal() 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 25
    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 25
        return !$this->isManagerPortal();
14
    }
15
16 30
    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 30
        $url = URL::current();
19 30
        return $this->urlIsManagerPortal($url);
20
    }
21
22 32
    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...
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