Completed
Push — master ( 0ba4b1...2affe6 )
by Jean-Christophe
03:09
created

HtmlLabel::asLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Ajax\semantic\html\elements;
4
5
use Ajax\semantic\html\base\HtmlSemDoubleElement;
6
use Ajax\common\html\html5\HtmlImg;
7
use Ajax\common\html\HtmlDoubleElement;
8
use Ajax\semantic\html\base\constants\Direction;
9
use Ajax\semantic\html\base\traits\LabeledIconTrait;
10
11
class HtmlLabel extends HtmlSemDoubleElement {
12
	use LabeledIconTrait;
13
	public function __construct($identifier,$caption="",$tagName="div") {
14
		parent::__construct($identifier,$tagName,"ui label");
15
		$this->content=$caption;
16
	}
17
18
	/**
19
	 * @param string $side
0 ignored issues
show
Bug introduced by
There is no parameter named $side. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
20
	 * @return \Ajax\semantic\html\elements\HtmlLabel
21
	 */
22
	public function setPointing($value=Direction::NONE){
23
		return $this->addToPropertyCtrl("class", $value." pointing",Direction::getConstantValues("pointing"));
24
	}
25
26
	/**
27
	 * @param string $side
28
	 * @return \Ajax\semantic\html\elements\HtmlLabel
29
	 */
30
	public function toCorner($side="left"){
31
		return $this->addToPropertyCtrl("class", $side." corner",array("right corner","left corner"));
32
	}
33
34
	/**
35
	 * @return \Ajax\semantic\html\elements\HtmlLabel
36
	 */
37
	public function asTag(){
38
		return $this->addToProperty("class", "tag");
39
	}
40
41
	/**
42
	 * @return \Ajax\semantic\html\elements\HtmlLabel
43
	 */
44
	public function asLink(){
45
		return $this->setTagName("a");
46
	}
47
48
	public function setBasic(){
49
		return $this->addToProperty("class", "basic");
50
	}
51
52
	/**
53
	 * Adds an image to emphasize
54
	 * @param string $src
55
	 * @param string $alt
56
	 * @param string $before
57
	 * @return \Ajax\semantic\html\elements\HtmlLabel
58
	 */
59
	public function addImage($src,$alt="",$before=true){
60
		$this->addToProperty("class", "image");
61
		return $this->addContent(new HtmlImg("image-".$this->identifier,$src,$alt),$before);
0 ignored issues
show
Bug introduced by
It seems like $before defined by parameter $before on line 59 can also be of type string; however, Ajax\common\html\HtmlDoubleElement::addContent() does only seem to accept boolean, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
62
	}
63
64
	/**
65
	 * @param string $detail
66
	 * @return \Ajax\common\html\HtmlDoubleElement
67
	 */
68 View Code Duplication
	public function addDetail($detail){
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
69
		$div=new HtmlDoubleElement("detail-".$this->identifier,$this->tagName);
70
		$div->setClass("detail");
71
		$div->setContent($detail);
72
		$this->addContent($div);
73
		return $div;
74
	}
75
}