Skip to content

Commit

Permalink
Cleaning up the lins
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Matthews committed Oct 6, 2010
1 parent 575e60f commit e22ca76
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions Link.php
Expand Up @@ -38,7 +38,8 @@ public function __construct()
* @access public
* @return string the url
*/
public function getUrl() {
public function getUrl()
{
return $this->url;
}

Expand All @@ -48,7 +49,8 @@ public function getUrl() {
* @access public
* @return array of tags
*/
public function getTags() {
public function getTags()
{
return $this->tags;
}

Expand All @@ -59,7 +61,8 @@ public function getTags() {
* @access public
* @return void
*/
public function setUrl($url) {
public function setUrl($url)
{
$this->url = (string) $url;
}

Expand All @@ -70,7 +73,8 @@ public function setUrl($url) {
* @access public
* @return void
*/
public function addTag($tag) {
public function addTag($tag)
{
$this->tags[] = (string) $tag;
}

Expand All @@ -82,7 +86,8 @@ public function addTag($tag) {
* @return boolean true if the tag was found and removed false if
* the tag didn't exist
*/
public function removeTag($tag) {
public function removeTag($tag)
{
$success = false;
// look through the current tags for the specified tag
foreach ($this->tags as $key => $tagName) {
Expand All @@ -101,7 +106,8 @@ public function removeTag($tag) {
* @access public
* @return string the string description of the link
*/
public function __toString() {
public function __toString()
{
// example: http://www.google.com/ [usa, search]
return sprintf('%s [%s]', $this->url, implode(', ', $this->tags));
}
Expand All @@ -112,7 +118,8 @@ public function __toString() {
* @access public
* @return array the link representation
*/
public function toArray() {
public function toArray()
{
return array(
// _id is the name of the url in this case as it makes it easier
// for interoperability with the Database
Expand All @@ -131,7 +138,8 @@ public function toArray() {
* @throws Exception
* @return this object
*/
public function fromArray($link) {
public function fromArray($link)
{
// Ensure the url is set
if (empty($link['url']) || !is_string($link['url'])) {
throw new Exception('Incorrect data supplied');
Expand Down

0 comments on commit e22ca76

Please sign in to comment.