ResizableTrait   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 13
c 2
b 0
f 0
dl 0
loc 50
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSizes() 0 3 1
A getResizables() 0 3 1
A getResizableObjects() 0 21 5
1
<?php
2
3
namespace Rvdlee\ZfImageResizer\Traits;
4
5
use Doctrine\Common\Collections\ArrayCollection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\ArrayCollection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Doctrine\Common\Collections\Collection;
0 ignored issues
show
Bug introduced by
The type Doctrine\Common\Collections\Collection was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
7
use GamersGalaxy\Entity\AbstractFile;
0 ignored issues
show
Bug introduced by
The type GamersGalaxy\Entity\AbstractFile was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Rvdlee\ZfImageResizer\Model\Image;
9
10
trait ResizableTrait
11
{
12
    /**
13
     * This will return all the objects from resizable properties
14
     *
15
     * @param null $property
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $property is correct as it would always require null to be passed?
Loading history...
16
     *
17
     * @return array
18
     */
19
    public function getResizableObjects($property = null) : array
0 ignored issues
show
Unused Code introduced by
The parameter $property is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

19
    public function getResizableObjects(/** @scrutinizer ignore-unused */ $property = null) : array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21
        $objects = [];
22
23
        foreach ($this::RESIZEABLES as $resizable) {
0 ignored issues
show
Bug introduced by
The constant Rvdlee\ZfImageResizer\Tr...zableTrait::RESIZEABLES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
24
            if (!property_exists($this, $resizable)) {
25
                continue;
26
            }
27
28
            $collectionOrEntity = $this->{$resizable};
29
30
            if ($collectionOrEntity instanceof Collection) {
31
                $objects = array_merge($objects, $collectionOrEntity->getValues());
32
            }
33
34
            if ($collectionOrEntity instanceof AbstractFile) {
35
                $objects = array_merge($objects, [$collectionOrEntity]);
36
            }
37
        }
38
39
        return $objects;
40
    }
41
42
    /**
43
     * This function will return the properties that are resizable.
44
     *
45
     * @return array
46
     */
47
    public function getResizables(): array
48
    {
49
        return self::RESIZEABLES;
0 ignored issues
show
Bug introduced by
The constant Rvdlee\ZfImageResizer\Tr...zableTrait::RESIZEABLES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
50
    }
51
52
    /**
53
     * This function will return the sizes that are accepted by the resize service.
54
     *
55
     * @return array
56
     */
57
    public function getSizes(): array
58
    {
59
        return self::SIZES;
0 ignored issues
show
Bug introduced by
The constant Rvdlee\ZfImageResizer\Traits\ResizableTrait::SIZES was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
60
    }
61
}