ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
Image.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2016 Timon Amstutz <timon.amstutz@ilub.unibe.ch> Extended GPL, see docs/LICENSE */
4
6
9
14class Image implements C\Image\Image
15{
17
21 private $type;
22
26 private $src;
27
31 private $alt;
32
36 protected $url = '';
37
41 private static $types = [
42 self::STANDARD,
43 self::RESPONSIVE
44 ];
45
49 public function __construct($type, $source, $alt)
50 {
51 $this->checkStringArg("src", $source);
52 $this->checkStringArg("alt", $alt);
53 $this->checkArgIsElement("type", $type, self::$types, "image type");
54
55 $this->type = $type;
56 $this->src = $source;
57 $this->alt = $alt;
58 }
59
63 public function getType()
64 {
65 return $this->type;
66 }
67
71 public function withSource($source)
72 {
73 $this->checkStringArg("src", $source);
74
75 $clone = clone $this;
76 $clone->src = $source;
77 return $clone;
78 }
79
83 public function getSource()
84 {
85 return $this->src;
86 }
87
91 public function withAlt($alt)
92 {
93 $this->checkStringArg("alt", $alt);
94
95 $clone = clone $this;
96 $clone->alt = $alt;
97 return $clone;
98 }
99
103 public function getAlt()
104 {
105 return $this->alt;
106 }
107
111 public function withAction($url)
112 {
113 $this->checkStringArg("url", $url);
114
115 $clone = clone $this;
116 $clone->url = $url;
117
118 return $clone;
119 }
120
124 public function getAction()
125 {
126 return $this->url;
127 }
128}
$source
Definition: linkback.php:22
An exception for terminatinating execution or to throw for unit testing.
checkStringArg($which, $value)
Throw an InvalidArgumentException if $value is no string.
trait ComponentHelper
Provides common functionality for component implementations.
checkArgIsElement($which, $value, $array, $name)
Throw an InvalidArgumentException if $value is not an element of array.