ExceptionThrow::getExceptionClass()   A
last analyzed

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
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Amock\MockMethod;
4
5
class ExceptionThrow extends Handler
6
{
7 2
    public function handle(): bool
8
    {
9 2
        if (!$this->canHandle()) {
10
            return false;
11
        }
12
13 2
        $exceptionClass = $this->getExceptionClass();
14 2
        $this->initialStub->method($this->methodName)
15 2
            ->will($this->testCase->throwException(new $exceptionClass));
16
17 2
        return true;
18
    }
19
20 2
    private function canHandle(): bool
21
    {
22 2
        return is_string($this->methodMockConfig)
23 2
            && substr($this->methodMockConfig, 0, 11) === '@exception:';
24
    }
25
26 2
    private function getExceptionClass(): string
27
    {
28 2
        return substr($this->methodMockConfig, 11);
29
    }
30
}
31