Conditions | 1 |
Paths | 1 |
Total Lines | 25 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Changes | 10 | ||
Bugs | 0 | Features | 0 |
1 | <?php namespace GeneaLabs\LaravelImagery; |
||
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 | } |
||
34 |