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

HtmlImage   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 7
c 4
b 0
f 0
lcom 1
cbo 2
dl 0
loc 28
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 2
A setCircular() 0 3 1
A asAvatar() 0 5 2
A small() 0 3 1
A avatar() 0 4 1
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
}