Completed
Push — develop ( 969b3c...da2fc5 )
by Enea
01:58
created

UncompletedOperationException   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
dl 0
loc 20
ccs 6
cts 8
cp 0.75
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A makeMessage() 0 3 1
A getGrantable() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * Created on 18/03/18 by enea dhack.
7
 */
8
9
namespace Enea\Authorization\Exceptions;
10
11
use Enea\Authorization\Contracts\Grantable;
12
use Throwable;
13
14
abstract class UncompletedOperationException extends AuthorizationException
15
{
16
    private $grantable;
17
18 4
    public function __construct(Grantable $grantable, Throwable $previous = null)
19
    {
20 4
        parent::__construct($this->makeMessage($grantable), 0, $previous);
21 4
        $this->grantable = $grantable;
22 4
    }
23
24
    abstract protected function getOperationName(): string;
25
26
    public function getGrantable(): Grantable
27
    {
28
        return $this->grantable;
29
    }
30
31 4
    private function makeMessage(Grantable $grantable): string
32
    {
33 4
        return "The authorization '{$grantable->getSecretName()}' could not be {$this->getOperationName()}";
34
    }
35
}
36