Authorizable::abortIfCant()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
c 1
b 0
f 0
dl 0
loc 7
ccs 0
cts 4
cp 0
rs 10
cc 2
nc 2
nop 2
crap 6
1
<?php
2
3
namespace Ianrizky\Illuminate\Foundation\Auth\Access;
4
5
use Illuminate\Foundation\Auth\Access\Authorizable as BaseAuthorizable;
6
use Illuminate\Http\Response;
7
8
trait Authorizable
9
{
10
    use BaseAuthorizable;
11
12
    /**
13
     * Throw an HttpException if the entity has the given abilities.
14
     *
15
     * @param  iterable|string  $abilities
16
     * @param  array|mixed  $arguments
17
     * @return $this
18
     *
19
     * @throws \Symfony\Component\HttpKernel\Exception\HttpException
20
     */
21
    public function abortIfCant($abilities, $arguments = [])
22
    {
23
        if ($this->cant($abilities, $arguments)) {
24
            abort(Response::HTTP_FORBIDDEN);
25
        }
26
27
        return $this;
28
    }
29
}
30