Passed
Push — master ( ed15f8...e9a477 )
by Richard
08:13 queued 11s
created

ImageTransformation::__toString()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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