From 0e7d6f8fbd88412079bc60d45b64b3235580b2fd Mon Sep 17 00:00:00 2001 From: yassine belkaid Date: Mon, 18 Sep 2017 19:25:37 +0100 Subject: [PATCH 1/3] param in the contsructor can be null --- src/WebSitemapItem.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/WebSitemapItem.php b/src/WebSitemapItem.php index a9a2920..a3fb26d 100644 --- a/src/WebSitemapItem.php +++ b/src/WebSitemapItem.php @@ -40,9 +40,11 @@ class WebSitemapItem * WebSitemapItem constructor. * @param string $location */ - public function __construct($location) + public function __construct($location = null) { - $this->location = $location; + if (null !== $location) { + $this->location = $location; + } } /** @@ -55,10 +57,14 @@ public function getLocation() /** * @param string $location + * + * @return object $this */ public function setLocation($location) { $this->location = $location; + + return $this; } /** From 0079ffedb20d479bdc91b83946a6223a37914401 Mon Sep 17 00:00:00 2001 From: yassine belkaid Date: Mon, 18 Sep 2017 19:35:42 +0100 Subject: [PATCH 2/3] sanitize location property --- src/WebSitemapItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebSitemapItem.php b/src/WebSitemapItem.php index a3fb26d..f2fd117 100644 --- a/src/WebSitemapItem.php +++ b/src/WebSitemapItem.php @@ -62,7 +62,7 @@ public function getLocation() */ public function setLocation($location) { - $this->location = $location; + $this->location = rtrim(strtolower($location)); return $this; } From b1e2269a2c2c311369b9869a70244a52eaf54e4e Mon Sep 17 00:00:00 2001 From: yassine belkaid Date: Mon, 18 Sep 2017 19:37:57 +0100 Subject: [PATCH 3/3] trim last slash location property that might be added by user --- src/WebSitemapItem.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/WebSitemapItem.php b/src/WebSitemapItem.php index f2fd117..330bd28 100644 --- a/src/WebSitemapItem.php +++ b/src/WebSitemapItem.php @@ -62,7 +62,7 @@ public function getLocation() */ public function setLocation($location) { - $this->location = rtrim(strtolower($location)); + $this->location = rtrim(strtolower($location), '/'); return $this; }