1 <?php
2
3 /*
4 * This file is part of the Brickrouge package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Brickrouge;
13
14 /**
15 * A `<A>` element.
16 */
17 class A extends Element
18 {
19 /**
20 * @param string|Element $label Defines the content of the element. If `$label` is not
21 * a {@link Element} instance it is escaped.
22 * @param string $href URI for linked resource.
23 * @param array $attributes Optional attributes.
24 *
25 * @example
26 *
27 * <?php echo new A('Brickrouge', 'http://brickrouge.org');
28 */
29 public function __construct($label, $href='#', array $attributes=array())
30 {
31 if (!($label instanceof HTMLStringInterface))
32 {
33 $label = escape(t($label));
34 }
35
36 parent::__construct
37 (
38 'a', $attributes + array
39 (
40 'href' => $href,
41
42 self::INNER_HTML => $label
43 )
44 );
45 }
46 }
47