ImageTransformation::offsetGet()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Riclep\Storyblok\Support;
4
5
use ArrayAccess;
6
7
class ImageTransformation implements ArrayAccess
8
{
9
10
	/**
11
	 * @param array $transformation
12
	 */
13
	public function __construct(protected array $transformation) {
14
	}
15
16
	/**
17
	 * @param $offset
18
	 * @return bool
19
	 */
20
	public function offsetExists($offset): bool
21
	{
22
		return isset($this->$transformation[$offset]);
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $transformation seems to be never defined.
Loading history...
23
	}
24
25
	/**
26
	 * @param $offset
27
	 * @return mixed|null
28
	 */
29
	public function offsetGet($offset): mixed
30
	{
31
		return $this->transformation[$offset] ?? null;
32
	}
33
34
	/**
35
	 * @param $offset
36
	 * @param $value
37
	 * @return void
38
	 */
39
	public function offsetSet($offset, $value): void
40
	{
41
		if (is_null($offset)) {
42
			$this->transformation[] = $value;
43
		} else {
44
			$this->transformation[$offset] = $value;
45
		}
46
	}
47
48
	/**
49
	 * @param $offset
50
	 * @return void
51
	 */
52
	public function offsetUnset($offset): void
53
	{
54
		unset($this->transformation[$offset]);
55
	}
56
57
	/**
58
	 * Allows direct access to the Image Transformer object and it’s __toString
59
	 *
60
	 * @return string
61
	 */
62
	public function __toString(): string
63
	{
64
		return (string) $this->transformation['src'];
65
	}
66
}