-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: src/Ciconia/Ciconia.php
- Loading branch information
Showing
14 changed files
with
151 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,7 @@ | |
"bin": ["bin/ciconia"], | ||
"extra": { | ||
"branch-alias": { | ||
"dev-master": "1.0.x-dev" | ||
"dev-master": "1.1.x-dev" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,21 @@ | |
namespace Ciconia\Common; | ||
|
||
/** | ||
* HTML/XHTML/XML tag definition | ||
* | ||
* @author Kazuyuki Hayashi <[email protected]> | ||
*/ | ||
class Tag | ||
{ | ||
|
||
const TYPE_BLOCK = 'block'; | ||
/** | ||
* Block level tag | ||
*/ | ||
const TYPE_BLOCK = 'block'; | ||
|
||
/** | ||
* Inline level tag | ||
*/ | ||
const TYPE_INLINE = 'inline'; | ||
|
||
/** | ||
|
@@ -37,19 +46,23 @@ class Tag | |
private $emptyTagSuffix = '>'; | ||
|
||
/** | ||
* Constructor | ||
* | ||
* @param string $name The name of the tag | ||
*/ | ||
public function __construct($name) | ||
{ | ||
$this->name = $name; | ||
$this->name = $name; | ||
$this->attributes = new Collection(); | ||
$this->text = new Text(); | ||
$this->text = new Text(); | ||
} | ||
|
||
/** | ||
* @param \Ciconia\Common\Text|string $text | ||
* Sets the inner text | ||
* | ||
* @return $this | ||
* @param Text|string $text A string to set | ||
* | ||
* @return Tag | ||
*/ | ||
public function setText($text) | ||
{ | ||
|
@@ -63,15 +76,19 @@ public function setText($text) | |
} | ||
|
||
/** | ||
* @return \Ciconia\Common\Text | ||
* Gets the inner text | ||
* | ||
* @return Text | ||
*/ | ||
public function getText() | ||
{ | ||
return $this->text; | ||
} | ||
|
||
/** | ||
* @param string $name | ||
* Sets the name of the tag | ||
* | ||
* @param string $name The name of the tag | ||
* | ||
* @return $this | ||
*/ | ||
|
@@ -83,6 +100,8 @@ public function setName($name) | |
} | ||
|
||
/** | ||
* Returns the name of the tag | ||
* | ||
* @return string | ||
*/ | ||
public function getName() | ||
|
@@ -91,9 +110,11 @@ public function getName() | |
} | ||
|
||
/** | ||
* @param string $emptyTagSuffix | ||
* Sets the empty tag suffix | ||
* | ||
* @return $this | ||
* @param string $emptyTagSuffix The suffix | ||
* | ||
* @return Tag | ||
*/ | ||
public function setEmptyTagSuffix($emptyTagSuffix) | ||
{ | ||
|
@@ -103,17 +124,21 @@ public function setEmptyTagSuffix($emptyTagSuffix) | |
} | ||
|
||
/** | ||
* @return string | ||
* Returns the empty tag suffix | ||
* | ||
* @return string The suffix | ||
*/ | ||
public function getEmptyTagSuffix() | ||
{ | ||
return $this->emptyTagSuffix; | ||
} | ||
|
||
/** | ||
* @param string $type | ||
* Sets the type of the tag (Tag::TYPE_BLOCK or Tag::TYPE_INLINE) | ||
* | ||
* @return $this | ||
* @param string $type The type of the tag | ||
* | ||
* @return Tag | ||
*/ | ||
public function setType($type) | ||
{ | ||
|
@@ -123,6 +148,8 @@ public function setType($type) | |
} | ||
|
||
/** | ||
* Returns the type of the tag | ||
* | ||
* @return string | ||
*/ | ||
public function getType() | ||
|
@@ -131,10 +158,12 @@ public function getType() | |
} | ||
|
||
/** | ||
* @param $attribute | ||
* @param $value | ||
* Sets an attribute | ||
* | ||
* @return $this | ||
* @param string $attribute The name of an attribute | ||
* @param string $value [optional] The value of an attribute | ||
* | ||
* @return Tag | ||
*/ | ||
public function setAttribute($attribute, $value = null) | ||
{ | ||
|
@@ -144,8 +173,11 @@ public function setAttribute($attribute, $value = null) | |
} | ||
|
||
/** | ||
* @param array $attributes | ||
* @return $this | ||
* Sets attributes | ||
* | ||
* @param array $attributes An array of attributes | ||
* | ||
* @return Tag | ||
*/ | ||
public function setAttributes(array $attributes) | ||
{ | ||
|
@@ -157,6 +189,8 @@ public function setAttributes(array $attributes) | |
} | ||
|
||
/** | ||
* Returns a collection of attributes | ||
* | ||
* @return Collection | ||
*/ | ||
public function getAttributes() | ||
|
@@ -165,7 +199,9 @@ public function getAttributes() | |
} | ||
|
||
/** | ||
* @return string | ||
* Renders the tag | ||
* | ||
* @return string The HTML string | ||
*/ | ||
public function render() | ||
{ | ||
|
@@ -185,13 +221,13 @@ public function render() | |
|
||
if ($this->text->isEmpty()) { | ||
if ($this->type == self::TYPE_BLOCK) { | ||
return (string) $html->append('>')->append('</')->append($this->getName())->append('>'); | ||
return (string)$html->append('>')->append('</')->append($this->getName())->append('>'); | ||
} else { | ||
return (string) $html->append($this->emptyTagSuffix); | ||
return (string)$html->append($this->emptyTagSuffix); | ||
} | ||
} | ||
|
||
return (string) $html | ||
return (string)$html | ||
->append('>') | ||
->append($this->text) | ||
->append('</') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.