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

UncompletedOperationException::makeMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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