diff --git a/src/HtmlBuilder.php b/src/HtmlBuilder.php index 44954d3..1e9f797 100755 --- a/src/HtmlBuilder.php +++ b/src/HtmlBuilder.php @@ -96,6 +96,25 @@ class HtmlBuilder { return 'attributes($attributes).'>'; } + + /** + * Generate a link to a Favicon file. + * + * @param string $url + * @param array $attributes + * @param bool $secure + * @return string + */ + public function favicon($url, $attributes = array(), $secure = null) + { + $defaults = array('rel' => 'shortcut icon', 'type' => 'image/x-icon'); + + $attributes = $attributes + $defaults; + + $attributes['href'] = $this->url->asset($url, $secure); + + return 'attributes($attributes).'>'.PHP_EOL; + } /** * Generate a HTML link. diff --git a/tests/HtmlBuilderTest.php b/tests/HtmlBuilderTest.php index 2f2cc75..9e32201 100644 --- a/tests/HtmlBuilderTest.php +++ b/tests/HtmlBuilderTest.php @@ -55,4 +55,13 @@ class HtmlBuilderTest extends PHPUnit_Framework_TestCase { $this->assertEquals(''.PHP_EOL, $result); } -} \ No newline at end of file + public function testFavicon() + { + $this->urlGenerator->forceRootUrl('http://foo.com'); + $target = $this->urlGenerator->to('bar.ico'); + $result = $this->htmlBuilder->favicon('http://foo.com/bar.ico'); + + $this->assertEquals('' . PHP_EOL, $result); + } + +}