Completed
Push — master ( b4ccca...781bd5 )
by Jean-Christophe
03:50
created

HtmlImage::avatar()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 3
nc 1
nop 3
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\common\html\html5\HtmlImg;
6
use Ajax\semantic\html\base\HtmlSemDoubleElement;
7
use Ajax\semantic\html\base\constants\Size;
8
9
class HtmlImage extends HtmlSemDoubleElement {
10
11
	public function __construct($identifier, $src="", $alt="", $size=NULL) {
12
		$image=new HtmlImg("img-", $src, $alt);
13
		parent::__construct($identifier, "div", "ui image", $image);
14
		if (isset($size))
15
			$this->setSize($size);
16
	}
17
18
	public function setCircular() {
19
		return $this->addToProperty("class", "circular");
20
	}
21
22
	public function asAvatar($caption=NULL) {
23
		if (isset($caption))
24
			$this->wrap("", $caption);
25
		return $this->addToProperty("class", "avatar");
26
	}
27
28
	public static function small($identifier, $src="", $alt="") {
29
		return new HtmlImage($identifier, $src, $alt, Size::SMALL);
30
	}
31
32
	public static function avatar($identifier, $src="", $caption=NULL) {
33
		$img=new HtmlImage($identifier, $src);
34
		return $img->asAvatar($caption);
35
	}
36
}