ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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 
7 use ILIAS\UI\Component as C;
9 
14 class Image implements C\Image\Image {
15  use ComponentHelper;
16 
20  private $type;
21 
25  private $src;
26 
30  private $alt;
31 
35  private static $types = [
36  self::STANDARD,
37  self::RESPONSIVE
38  ];
39 
43  public function __construct($type, $source, $alt) {
44  $this->checkStringArg("src", $source);
45  $this->checkStringArg("alt", $alt);
46  $this->checkArgIsElement("type", $type, self::$types, "image type");
47 
48  $this->type = $type;
49  $this->src = $source;
50  $this->alt = $alt;
51 
52  }
53 
57  public function getType() {
58  return $this->type;
59  }
60 
64  public function withSource($source){
65  $this->checkStringArg("src", $source);
66 
67  $clone = clone $this;
68  $clone->src = $source;
69  return $clone;
70  }
71 
75  public function getSource() {
76  return $this->src;
77  }
78 
82  public function withAlt($alt){
83  $this->checkStringArg("alt", $alt);
84 
85  $clone = clone $this;
86  $clone->alt = $alt;
87  return $clone;
88  }
89 
93  public function getAlt() {
94  return $this->alt;
95  }
96 }
97 ?>