Skip to content

Commit

Permalink
Corregir phpdocs, refactorizar etiqueta nav. (#7)
Browse files Browse the repository at this point in the history
* Corregir phpdocs, refactorizar etiqueta nav.
  • Loading branch information
terabytesoftw committed May 31, 2022
1 parent 6c6de76 commit 2b13d24
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 32 deletions.
12 changes: 7 additions & 5 deletions src/Tag/Element/A.php
Expand Up @@ -7,17 +7,19 @@
use Forge\Html\Attribute\Attributes;
use Forge\Html\Tag\Tag;

/**
* The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email
* addresses, locations in the same page, or anything else a URL can address.
*
* @link https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element
*/
final class A
{
/**
* The <a> HTML element (or anchor element), with its href attribute, creates a hyperlink to web pages, files, email
* addresses, locations in the same page, or anything else a URL can address.
*
* @link https://html.spec.whatwg.org/multipage/text-level-semantics.html#the-a-element
* The created <a> HTML element.
*
* @param array $attributes The tag attributes in terms of name-value pairs. These will be rendered as the
* attributes of the resulting tag. The values will be HTML-encoded using {@see Attributes::encode()}.
*
* See {@see Attributes::render()} for details on how attributes are being rendered.
* @param string $content The content of the tag.
*
Expand Down
18 changes: 10 additions & 8 deletions src/Tag/Element/Li.php
Expand Up @@ -7,21 +7,23 @@
use Forge\Html\Attribute\Attributes;
use Forge\Html\Tag\Tag;

/**
* The <li> HTML element is used to represent an item in a list.
* It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>).
* In menus and unordered lists, list items are usually displayed using bullet points.
* In ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.
*
* @link https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element
*/
final class Li
{
/**
* The <li> HTML element is used to represent an item in a list.
* It must be contained in a parent element: an ordered list (<ol>), an unordered list (<ul>), or a menu (<menu>).
* In menus and unordered lists, list items are usually displayed using bullet points.
* In ordered lists, they are usually displayed with an ascending counter on the left, such as a number or letter.
*
* @link https://html.spec.whatwg.org/multipage/grouping-content.html#the-li-element
* The created <li> HTML element.
*
* @param array $attributes The tag attributes in terms of name-value pairs. These will be rendered as the
* attributes of the resulting tag. The values will be HTML-encoded using {@see Attributes::encode()}.
* @param string $content The content of the tag.
*
* See {@see Attributes::render()} for details on how attributes are being rendered.
* @param string $content The content of the tag.
*
* @return string The generated li tag.
*
Expand Down
29 changes: 20 additions & 9 deletions src/Tag/Element/Nav.php
Expand Up @@ -7,25 +7,36 @@
use Forge\Html\Attribute\Attributes;
use Forge\Html\Tag\Tag;

/**
* The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within
* the current document or to other documents. Common examples of navigation sections are menus, tables of contents,
* and indexes.
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-nav-element
*/
final class Nav
{
/**
* The <nav> HTML element represents a section of a page whose purpose is to provide navigation links, either within
* the current document or to other documents. Common examples of navigation sections are menus, tables of contents,
* and indexes.
*
* @link https://html.spec.whatwg.org/multipage/sections.html#the-nav-element
* The begin <nav> HTML element.
*
* @param array $attributes The tag attributes in terms of name-value pairs. These will be rendered as the
* attributes of the resulting tag. The values will be HTML-encoded using {@see Attributes::encode()}.
* @param string $content The content of the tag.
*
* See {@see Attributes::render()} for details on how attributes are being rendered.
*
* @return string The generated nav tag.
*/
public function create(array $attributes = [], string $content = ''): string
public function begin(array $attributes = []): string
{
return (new Tag())->begin('nav', $attributes) . PHP_EOL;
}

/**
* The end <nav> HTML element.
*
* @return string The generated end nav tag.
*/
public function end(): string
{
return (new Tag())->create('nav', $content, $attributes);
return (new Tag())->end('nav');
}
}
12 changes: 7 additions & 5 deletions src/Tag/Element/Ul.php
Expand Up @@ -7,21 +7,23 @@
use Forge\Html\Attribute\Attributes;
use Forge\Html\Tag\Tag;

/**
* The <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.
*
* @link https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element
*/
final class Ul
{
/**
* The <ul> HTML element represents an unordered list of items, typically rendered as a bulleted list.
*
* @link https://html.spec.whatwg.org/multipage/grouping-content.html#the-ul-element
* The created <ul> HTML element.
*
* @param array $attributes The tag attributes in terms of name-value pairs. These will be rendered as the
* attributes of the resulting tag. The values will be HTML-encoded using {@see Attributes::encode()}.
* See {@see Attributes::render()} for details on how attributes are being rendered.
* @param array $items The list items. Each item is an array with the following keys:
* - content: (required) The content of the list item.
* - attributes: The HTML attributes of the list item.
*
* See {@see Attributes::render()} for details on how attributes are being rendered.
*
* @return string The generated ul tag.
*/
public function create(array $attributes = [], array $items = []): string
Expand Down
10 changes: 5 additions & 5 deletions tests/Tag/Element/NavTest.php
Expand Up @@ -14,10 +14,10 @@ final class NavTest extends TestCase
public function createProvider(): array
{
return [
[[], '', '<nav></nav>'],
[['class' => 'class'], '', '<nav class="class"></nav>'],
[[], 'Content', '<nav>' . PHP_EOL . 'Content' . PHP_EOL . '</nav>'],
[['disabled' => true], '', '<nav disabled></nav>'],
[[], '', '<nav>' . PHP_EOL . '</nav>'],
[['class' => 'class'], '', '<nav class="class">' . PHP_EOL . '</nav>'],
[[], 'Content' . PHP_EOL, '<nav>' . PHP_EOL . 'Content' . PHP_EOL . '</nav>'],
[['disabled' => true], '', '<nav disabled>' . PHP_EOL . '</nav>'],
];
}

Expand All @@ -33,6 +33,6 @@ public function testCreate(array $attributes, string $content, string $expected)
$a = new A();
$assert = new Assert();
$nav = new Nav();
$assert->equalsWithoutLE($expected, $nav->create($attributes, $content));
$assert->equalsWithoutLE($expected, $nav->begin($attributes) . $content . $nav->end());
}
}

0 comments on commit 2b13d24

Please sign in to comment.