Imagery   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 11
Bugs 0 Features 0
Metric Value
eloc 18
c 11
b 0
f 0
dl 0
loc 27
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A conjure() 0 25 1
1
<?php namespace GeneaLabs\LaravelImagery;
2
3
class Imagery
4
{
5
    public function conjure(
6
        string $source,
7
        string $width = null,
8
        string $height = null,
9
        array $htmlAttributes = [],
10
        array $options = []
11
    ) : Image {
12
        $options = collect($options);
13
        $htmlAttributes = collect($htmlAttributes);
14
        $keyElements = collect([
15
            $source,
16
            $width,
17
            $height,
18
            $_COOKIE['screenWidth'] ?? '',
19
            $_COOKIE['screenHeight'] ?? '',
20
            $options->get('alwaysPreserveAspectRatio', true),
21
            $options->get('overrideScreenConstraint', false),
22
            $options->get('screenConstraintMethod', 'contain'),
23
        ])->concat($htmlAttributes)->toArray();
24
25
        return  cache()->remember(
26
            implode('-', $keyElements),
27
            9999999999,
28
            function () use ($source, $width, $height, $htmlAttributes, $options) {
29
                return new Image($source, $width, $height, $htmlAttributes, $options);
30
            }
31
        );
32
    }
33
}
34