ImageTransformation   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 5
Bugs 0 Features 1
Metric Value
eloc 9
c 5
b 0
f 1
dl 0
loc 58
rs 10
wmc 7

6 Methods

Rating   Name   Duplication   Size   Complexity  
A offsetUnset() 0 3 1
A __toString() 0 3 1
A __construct() 0 1 1
A offsetExists() 0 3 1
A offsetGet() 0 3 1
A offsetSet() 0 6 2
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
}