From 6d94c2d4c19bb8f87d1755c4f7bbfec1baf88b9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Lucas?= Date: Tue, 26 Mar 2013 20:54:05 +0100 Subject: [PATCH] Fix a warning in case the book has no tag or author --- book.php | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/book.php b/book.php index 65a6083..8c8b9b8 100644 --- a/book.php +++ b/book.php @@ -138,17 +138,7 @@ class Book extends Base { } public function getAuthorsName () { - $authorList = null; - foreach ($this->getAuthors () as $author) { - if ($authorList) { - $authorList = $authorList . ", " . $author->name; - } - else - { - $authorList = $author->name; - } - } - return $authorList; + return implode (", ", array_map (function ($author) { return $author->name; }, $this->getAuthors ())); } public function getSerie () { @@ -220,17 +210,7 @@ class Book extends Base { public function getTagsName () { - $tagList = null; - foreach ($this->getTags () as $tag) { - if ($tagList) { - $tagList = $tagList . ", " . $tag->name; - } - else - { - $tagList = $tag->name; - } - } - return $tagList; + return implode (", ", array_map (function ($tag) { return $tag->name; }, $this->getTags ())); } public function getRating () {