Completed
Pull Request — master (#17)
by John
03:40
created

FilepathGraphicResolver::__invoke()   A

Complexity

Conditions 2
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 3
Bugs 1 Features 0
Metric Value
c 3
b 1
f 0
dl 0
loc 9
ccs 0
cts 4
cp 0
rs 9.6666
cc 2
eloc 6
nc 3
nop 1
crap 6
1
<?php
2
3
namespace Graze\CiffRenderer\GraphicResolver;
4
5
use Graze\CiffRenderer\GraphicResolver\GraphicResolverInterface;
6
use Graze\CiffRenderer\Exception\RuntimeException;
7
use Urbanplum\PhpBmp\PhpBmp;
8
9
/**
10
 * Resolves an image resource from it's file path
11
 */
12
class FilepathGraphicResolver implements GraphicResolverInterface
13
{
14
    /**
15
     * @param string $filePath
16
     *
17
     * @return Resource
18
     */
19
    public function __invoke($filePath)
20
    {
21
        try {
22
            $phpBmp = new PhpBmp();
23
            return $phpBmp->create($filePath);
24
        } catch (\Exception $e) {
25
            throw new RuntimeException($e);
26
        }
27
    }
28
}
29