GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

ImageController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
namespace HtImgModule\Controller;
3
4
use Zend\Mvc\Controller\AbstractActionController;
5
use HtImgModule\Service\ImageServiceInterface;
6
use HtImgModule\View\Model\ImageModel;
7
use HtImgModule\Exception;
8
9
class ImageController extends AbstractActionController
10
{
11
    /**
12
     * @var ImageServiceInterface
13
     */
14
    protected $imageService;
15
16
    /**
17
     * Constructor
18
     *
19
     * @param ImageServiceInterface $imageService
20
     */
21 4
    public function __construct(ImageServiceInterface $imageService)
22
    {
23 4
        $this->imageService = $imageService;
24 4
    }
25
26
    /**
27
     * Displays image
28
     */
29 3
    public function displayAction()
30
    {
31 3
        $relativePath = $this->plugin('params')->fromQuery('relativePath');
0 ignored issues
show
Bug introduced by
The method fromQuery() does not seem to exist on object<Zend\Stdlib\DispatchableInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
32 3
        $filter       = $this->plugin('params')->fromRoute('filter');
0 ignored issues
show
Bug introduced by
The method fromRoute() does not seem to exist on object<Zend\Stdlib\DispatchableInterface>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
33 3
        if (!$relativePath || !$filter) {
34
            return $this->notFoundAction();
35
        }
36
        try {
37 3
            $imageData = $this->imageService->getImage($relativePath, $filter);
38 2
        } catch (Exception\ImageNotFoundException $e) {
39 1
            return $this->notFoundAction();
40 1
        } catch (Exception\FilterNotFoundException $e) {
41 1
            return $this->notFoundAction();
42
        }
43
44 1
        if (!$imageData) {
0 ignored issues
show
Bug Best Practice introduced by
The expression $imageData of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using empty($expr) instead to make it clear that you intend to check for an array without elements.

This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.

Consider making the comparison explicit by using empty(..) or ! empty(...) instead.

Loading history...
45
            return $this->notFoundAction();
46
        }
47
48 1
        return new ImageModel($imageData['image'], $imageData['format'], $imageData['imageOutputOptions']);
49
    }
50
}
51