generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
08c5d6d
commit cec598d
Showing
13 changed files
with
567 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Base; | ||
|
||
use PHPForge\Html\Attribute; | ||
use PHPForge\Html\Helper\Encode; | ||
use PHPForge\Html\HtmlBuilder; | ||
use PHPForge\Html\Ul; | ||
use PHPForge\Widget\Element; | ||
|
||
/** | ||
* Provides a foundation for creating HTML `<li>` elements with various attributes and content. | ||
*/ | ||
abstract class AbstractLi extends Element | ||
{ | ||
use Attribute\Custom\HasAttributes; | ||
use Attribute\HasClass; | ||
use Attribute\HasId; | ||
use Attribute\HasLang; | ||
use Attribute\HasStyle; | ||
use Attribute\HasTabindex; | ||
use Attribute\HasTitle; | ||
use Attribute\Input\HasName; | ||
use Attribute\Input\HasValue; | ||
|
||
protected array $attributes = []; | ||
protected string $content = ''; | ||
|
||
|
||
/** | ||
* Set the `HTML` content value. | ||
* | ||
* @param string|Ul|self ...$values The `HTML` content value. | ||
* | ||
* @return static A new instance of the current class with the specified content value. | ||
*/ | ||
public function content(string|Ul|self ...$values): static | ||
{ | ||
$content = ''; | ||
|
||
foreach ($values as $value) { | ||
$content .= "$value\n"; | ||
} | ||
|
||
$new = clone $this; | ||
$new->content = trim(Encode::create()->santizeXSS($content)); | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Generate the HTML representation of the element. | ||
* | ||
* @return string The HTML representation of the element. | ||
*/ | ||
protected function run(): string | ||
{ | ||
return HtmlBuilder::create('li', $this->content, $this->attributes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Base; | ||
|
||
use PHPForge\Html\Attribute; | ||
use PHPForge\Html\Helper\Encode; | ||
use PHPForge\Html\HtmlBuilder; | ||
use PHPForge\Html\Li; | ||
use PHPForge\Widget\Element; | ||
|
||
use function trim; | ||
|
||
/** | ||
* Provides a foundation for creating HTML `<ul>` elements with various attributes and content. | ||
*/ | ||
abstract class AbstractUl extends Element | ||
{ | ||
use Attribute\Custom\HasAttributes; | ||
use Attribute\HasClass; | ||
use Attribute\HasId; | ||
use Attribute\HasLang; | ||
use Attribute\HasStyle; | ||
use Attribute\HasTabindex; | ||
use Attribute\HasTitle; | ||
use Attribute\Input\HasName; | ||
use Attribute\Input\HasType; | ||
|
||
protected array $attributes = []; | ||
protected string $content = ''; | ||
|
||
/** | ||
* Set the `HTML` content value. | ||
* | ||
* @param string|Li|self ...$values The `HTML` content value. | ||
* | ||
* @return static A new instance of the current class with the specified content value. | ||
*/ | ||
public function content(string|Li|self ...$values): static | ||
{ | ||
$content = ''; | ||
|
||
foreach ($values as $value) { | ||
$content .= "$value\n"; | ||
} | ||
|
||
$new = clone $this; | ||
$new->content = trim(Encode::create()->santizeXSS($content)); | ||
|
||
return $new; | ||
} | ||
|
||
/** | ||
* Generate the HTML representation of the element. | ||
* | ||
* @return string The HTML representation of the element. | ||
*/ | ||
protected function run(): string | ||
{ | ||
return HtmlBuilder::create('ul', $this->content, $this->attributes); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html; | ||
|
||
/** | ||
* 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 extends Base\AbstractLi | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html; | ||
|
||
/** | ||
* 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 extends Base\AbstractUl | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Tests\Li; | ||
|
||
use PHPForge\Html\Li; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
final class ImmutableTest extends TestCase | ||
{ | ||
public function testImmutable(): void | ||
{ | ||
$li = Li::widget(); | ||
|
||
$this->assertNotSame($li, $li->content('')); | ||
} | ||
} |
Oops, something went wrong.