Passed
Push — master ( 27ca4d...8d618a )
by Ondřej
02:45 queued 10s
created

AsyncResult::getResult()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
namespace Ivory\Result;
4
5
class AsyncResult implements IAsyncResult
6
{
7
    private $resultFetcher;
8
9
    public function __construct(\Closure $resultFetcher)
10
    {
11
        $this->resultFetcher = $resultFetcher;
12
    }
13
14
    public function getResult(): IResult
15
    {
16
        $result = ($this->resultFetcher)();
17
        if ($result instanceof IResult) {
18
            return $result;
19
        } else {
20
            throw new \LogicException('The result fetcher did not return an expected result.');
21
        }
22
    }
23
}
24