Add addAnchor() for chaining.
authorJan Schneider <jan@horde.org>
Tue, 20 Jul 2010 20:44:33 +0000 (22:44 +0200)
committerJan Schneider <jan@horde.org>
Mon, 26 Jul 2010 21:34:07 +0000 (23:34 +0200)
framework/Url/lib/Horde/Url.php
framework/Url/test/Horde/Url/AddTest.php

index 9ba6adb..a844531 100644 (file)
@@ -184,6 +184,19 @@ class Horde_Url
     }
 
     /**
+     * Adds an anchor.
+     *
+     * @param string $anchor  An anchor to add.
+     *
+     * @return Horde_Url  This (modified) object, to allow chaining.
+     */
+    public function addAnchor($anchor)
+    {
+        $this->anchor = $anchor;
+        return $this;
+    }
+
+    /**
      * Sets the $raw value.  This call can be chained.
      *
      * @param boolean $raw  Whether to output the URL in the raw URL format or
index 3cc4af7..42a6f11 100644 (file)
@@ -23,6 +23,8 @@ class Horde_Url_AddTest extends PHPUnit_Framework_TestCase
 
         $url->anchor = 'boo';
         $this->assertEquals('test?foo=1&amp;bar=2&amp;baz=3&amp;fez#boo', (string)$url);
+        $url->addAnchor('bee');
+        $this->assertEquals('test?foo=1&amp;bar=2&amp;baz=3&amp;fez#bee', (string)$url);
     }
 
     public function testAddArray()