diff --git a/CHANGELOG.md b/CHANGELOG.md index ed4f799..23a501a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,8 @@ - `Innmind\Html\Node\Document` no longer implement any interface - `Innmind\Html\Reader\Reader` now return an `Innmind\Immutable\Attempt` - `Innmind\Html\Visitor\Elements` now return a `Innmind\Immutable\Sequence` +- `Innmind\Html\Reader\Reader` has been renamed `Innmind\Html\Reader` +- `Innmind\Html\Node\Document` has been renamed `Innmind\Html\Document` ### Removed diff --git a/README.md b/README.md index b04164c..cdfa686 100644 --- a/README.md +++ b/README.md @@ -18,8 +18,8 @@ composer require innmind/html ```php use Innmind\Html\{ - Reader\Reader, - Node\Document, + Reader, + Document, }; use Innmind\Xml\{ Node, diff --git a/src/Node/Document.php b/src/Document.php similarity index 85% rename from src/Node/Document.php rename to src/Document.php index b6dbfe3..6a1dce4 100644 --- a/src/Node/Document.php +++ b/src/Document.php @@ -1,7 +1,7 @@ */ - private Sequence $children; - /** - * @param Sequence|null $children + * @param Sequence $children */ - private function __construct(Type $type, ?Sequence $children = null) - { - $this->type = $type; - $this->children = $children ?? Sequence::of(); + private function __construct( + private Type $type, + private Sequence $children, + ) { } /** @@ -42,7 +38,7 @@ private function __construct(Type $type, ?Sequence $children = null) */ public static function of(Type $type, ?Sequence $children = null): self { - return new self($type, $children); + return new self($type, $children ?? Sequence::of()); } public function type(): Type diff --git a/src/Element/A.php b/src/Element/A.php index 8af124f..8dc374b 100644 --- a/src/Element/A.php +++ b/src/Element/A.php @@ -18,13 +18,10 @@ */ final class A implements Custom { - private Element $element; - private Url $href; - - private function __construct(Url $href, Element $element) - { - $this->element = $element; - $this->href = $href; + private function __construct( + private Url $href, + private Element $element, + ) { } /** diff --git a/src/Element/Base.php b/src/Element/Base.php index 50f2de3..2e96406 100644 --- a/src/Element/Base.php +++ b/src/Element/Base.php @@ -17,13 +17,10 @@ */ final class Base implements Custom { - private Element $element; - private Url $href; - - private function __construct(Url $href, Element $element) - { - $this->element = $element; - $this->href = $href; + private function __construct( + private Url $href, + private Element $element, + ) { } /** diff --git a/src/Element/Img.php b/src/Element/Img.php index bfbd0e4..0fd08ef 100644 --- a/src/Element/Img.php +++ b/src/Element/Img.php @@ -17,13 +17,10 @@ */ final class Img implements Custom { - private Element $element; - private Url $src; - - private function __construct(Url $src, Element $element) - { - $this->element = $element; - $this->src = $src; + private function __construct( + private Url $src, + private Element $element, + ) { } /** diff --git a/src/Element/Link.php b/src/Element/Link.php index 536697d..2d10097 100644 --- a/src/Element/Link.php +++ b/src/Element/Link.php @@ -17,22 +17,14 @@ */ final class Link implements Custom { - private Element $element; - private Url $href; - /** @var non-empty-string */ - private string $relationship; - /** * @param non-empty-string $relationship */ private function __construct( - Url $href, - string $relationship, - Element $element, + private Url $href, + private string $relationship, + private Element $element, ) { - $this->element = $element; - $this->href = $href; - $this->relationship = $relationship; } /** diff --git a/src/Reader/Reader.php b/src/Reader.php similarity index 83% rename from src/Reader/Reader.php rename to src/Reader.php index 2e37dff..6ea4630 100644 --- a/src/Reader/Reader.php +++ b/src/Reader.php @@ -1,12 +1,8 @@ translate = $translate; } /** diff --git a/src/Translator.php b/src/Translator.php index b585b20..3bbb353 100644 --- a/src/Translator.php +++ b/src/Translator.php @@ -3,13 +3,12 @@ namespace Innmind\Html; -use Innmind\Html\{ - Element\A, - Element\Base, - Element\Img, - Element\Link, - Element\Script, - Node\Document, +use Innmind\Html\Element\{ + A, + Base, + Img, + Link, + Script, }; use Innmind\Xml\{ Element, diff --git a/src/Visitor/Element.php b/src/Visitor/Element.php index 7c6be14..8af36dd 100644 --- a/src/Visitor/Element.php +++ b/src/Visitor/Element.php @@ -3,7 +3,7 @@ namespace Innmind\Html\Visitor; -use Innmind\Html\Node\Document; +use Innmind\Html\Document; use Innmind\Xml\{ Node, Element as Model, @@ -20,15 +20,11 @@ */ final class Element { - /** @var non-empty-string */ - private string $name; - /** * @param non-empty-string $name */ - private function __construct(string $name) + private function __construct(private string $name) { - $this->name = $name; } /** diff --git a/src/Visitor/Elements.php b/src/Visitor/Elements.php index e7c8bf6..fa7e659 100644 --- a/src/Visitor/Elements.php +++ b/src/Visitor/Elements.php @@ -3,7 +3,7 @@ namespace Innmind\Html\Visitor; -use Innmind\Html\Node\Document; +use Innmind\Html\Document; use Innmind\Xml\{ Node, Element, @@ -16,15 +16,11 @@ */ final class Elements { - /** @var non-empty-string */ - private string $name; - /** * @param non-empty-string $name */ - private function __construct(string $name) + private function __construct(private string $name) { - $this->name = $name; } /** diff --git a/tests/Node/DocumentTest.php b/tests/DocumentTest.php similarity index 98% rename from tests/Node/DocumentTest.php rename to tests/DocumentTest.php index 8dd0bab..6506631 100644 --- a/tests/Node/DocumentTest.php +++ b/tests/DocumentTest.php @@ -1,9 +1,9 @@