Skip to content

Commit aadc887

Browse files
authored
Feature/refactor create class (#51)
* chore: address test autoloading, and improve coverage * chore: rebuild classes --------- Co-authored-by: Erik Pöhler <admin@teuton.mx>
1 parent 1908e15 commit aadc887

164 files changed

Lines changed: 3821 additions & 1515 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

clover.xml

Lines changed: 199 additions & 120 deletions
Large diffs are not rendered by default.

src/Command/CreateClassCommand.php

Lines changed: 8 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
namespace Html\Command;
66

77
use Html\Helper\Helper;
8+
use Html\Helper\NamingHelper;
9+
use Html\Helper\TypeMapper;
10+
use Html\Helper\CommentHelper;
811
use Silly\Input\InputArgument;
912
use Silly\Input\InputOption;
1013
use Symfony\Component\Console\Command\Command;
@@ -590,81 +593,27 @@ private function filterAndSortUses(array $uses, string $ignoreClass): array
590593
// String manipulation utilities
591594
private function toVariableName(string $string): string
592595
{
593-
$string = str_replace(['-', '_'], ' ', $string);
594-
$words = explode(' ', $string);
595-
$string = implode('', array_map('ucfirst', $words));
596-
return lcfirst($string);
596+
return NamingHelper::toVariableName($string);
597597
}
598598

599599
private function toKebapCase(string $string): string
600600
{
601-
$string = str_replace(['-', '_'], ' ', $string);
602-
$string = ucwords($string);
603-
return str_replace(' ', '', $string);
601+
return NamingHelper::toKebapCase($string);
604602
}
605603

606604
private function getClassName(string $classname): string
607605
{
608-
$reserved = Helper::getReservedWords();
609-
if (in_array(strtolower($classname), $reserved, true)) {
610-
return $classname . 'Element';
611-
}
612-
return $classname;
606+
return NamingHelper::getClassName($classname);
613607
}
614608

615609
private function getAttributeComment(array $details): string
616610
{
617-
$lines = [];
618-
$lines[] = $details['description'] ?? '';
619-
$lines[] = '@category HTML attribute';
620-
621-
if (isset($details['deprecated']) && $details['deprecated']) {
622-
$lines[] = '@deprecated' . \PHP_EOL . ' ';
623-
}
624-
if (isset($details['defaultValue'])) {
625-
$lines[] = '@example ' . $details['defaultValue'] . \PHP_EOL . ' ';
626-
}
627-
if (isset($details['required']) && $details['required']) {
628-
$lines[] = '@required' . \PHP_EOL . ' ';
629-
}
630-
631-
$comment = '/** ';
632-
if (count($lines) > 2) {
633-
$comment .= \PHP_EOL . ' * ' . implode(\PHP_EOL . ' * ', $lines);
634-
} else {
635-
$comment .= $lines[0];
636-
}
637-
638-
return $comment . ' */' . \PHP_EOL;
611+
return CommentHelper::getAttributeComment($details);
639612
}
640613

641614
private function mapToPhpType(string $string): string
642615
{
643-
return match ($string) {
644-
'string' => 'string',
645-
'integer' => 'int',
646-
'boolean' => 'bool',
647-
'uri' => 'string',
648-
'language_iso' => 'string',
649-
'color' => 'string',
650-
'datetime' => 'string',
651-
'datetime-local' => 'string',
652-
'date' => 'string',
653-
'time' => 'string',
654-
'month' => 'string',
655-
'week' => 'string',
656-
'number' => 'int',
657-
'float' => 'float',
658-
'script' => 'string',
659-
'url' => 'string',
660-
'email' => 'string',
661-
'tel' => 'string',
662-
'password' => 'string',
663-
'hidden' => 'bool|string',
664-
'image' => 'string',
665-
'file' => 'string',
666-
default => $string,
667-
};
616+
return TypeMapper::mapToPhpType($string);
668617
}
669618

670619
// Method signature templates

src/Element/Block/Article.php

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* This file is auto-generated. Do not edit manually.
44
*
5-
* @generated 2025-12-30 13:44:50
5+
* @generated 2025-12-30 23:54:09
66
* @category HTML
77
* @package vardumper/extended-htmldocument
88
* @subpackage Html\Element\Block
@@ -211,16 +211,24 @@ class Article extends BlockElement
211211
];
212212

213213

214-
/** Defines the semantic purpose of an element for assistive technologies. */
214+
/**
215+
* Defines the semantic purpose of an element for assistive technologies.
216+
* @category HTML attribute */
215217
protected ?RoleEnum $role = null;
216218

217-
/** Identifies the element(s) whose contents or presence are controlled by this element. Value is a list of IDs separated by a space */
219+
/**
220+
* Identifies the element(s) whose contents or presence are controlled by this element. Value is a list of IDs separated by a space
221+
* @category HTML attribute */
218222
protected ?string $ariaControls = null;
219223

220-
/** Identifies the element(s) that describes the object. Value is a list of IDs separated by a space */
224+
/**
225+
* Identifies the element(s) that describes the object. Value is a list of IDs separated by a space
226+
* @category HTML attribute */
221227
protected ?string $ariaDescribedby = null;
222228

223-
/** Identifies the element(s) that labels the current element. Value is a list of IDs separated by a space */
229+
/**
230+
* Identifies the element(s) that labels the current element. Value is a list of IDs separated by a space
231+
* @category HTML attribute */
224232
protected ?string $ariaLabelledby = null;
225233

226234
/**
@@ -230,13 +238,19 @@ class Article extends BlockElement
230238
*/
231239
protected ?AriaBusyEnum $ariaBusy = null;
232240

233-
/** References an element that provides additional details about the current element. */
241+
/**
242+
* References an element that provides additional details about the current element.
243+
* @category HTML attribute */
234244
protected ?string $ariaDetails = null;
235245

236-
/** Defines keyboard shortcuts available for the element. */
246+
/**
247+
* Defines keyboard shortcuts available for the element.
248+
* @category HTML attribute */
237249
protected ?string $ariaKeyshortcuts = null;
238250

239-
/** Provides a human-readable custom role description for assistive technologies. */
251+
/**
252+
* Provides a human-readable custom role description for assistive technologies.
253+
* @category HTML attribute */
240254
protected ?string $ariaRoledescription = null;
241255

242256
/**
@@ -260,7 +274,9 @@ class Article extends BlockElement
260274
*/
261275
protected ?AriaAtomicEnum $ariaAtomic = null;
262276

263-
/** Establishes ownership relationships between elements. Value is a space-separated list of IDs. */
277+
/**
278+
* Establishes ownership relationships between elements. Value is a space-separated list of IDs.
279+
* @category HTML attribute */
264280
protected ?string $ariaOwns = null;
265281

266282

src/Element/Block/Aside.php

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* This file is auto-generated. Do not edit manually.
44
*
5-
* @generated 2025-12-30 13:44:50
5+
* @generated 2025-12-30 23:54:09
66
* @category HTML
77
* @package vardumper/extended-htmldocument
88
* @subpackage Html\Element\Block
@@ -231,16 +231,24 @@ class Aside extends BlockElement
231231
];
232232

233233

234-
/** Defines the semantic purpose of an element for assistive technologies. */
234+
/**
235+
* Defines the semantic purpose of an element for assistive technologies.
236+
* @category HTML attribute */
235237
protected ?RoleEnum $role = null;
236238

237-
/** Identifies the element(s) whose contents or presence are controlled by this element. Value is a list of IDs separated by a space */
239+
/**
240+
* Identifies the element(s) whose contents or presence are controlled by this element. Value is a list of IDs separated by a space
241+
* @category HTML attribute */
238242
protected ?string $ariaControls = null;
239243

240-
/** Identifies the element(s) that describes the object. Value is a list of IDs separated by a space */
244+
/**
245+
* Identifies the element(s) that describes the object. Value is a list of IDs separated by a space
246+
* @category HTML attribute */
241247
protected ?string $ariaDescribedby = null;
242248

243-
/** Identifies the element(s) that labels the current element. Value is a list of IDs separated by a space */
249+
/**
250+
* Identifies the element(s) that labels the current element. Value is a list of IDs separated by a space
251+
* @category HTML attribute */
244252
protected ?string $ariaLabelledby = null;
245253

246254
/**
@@ -250,16 +258,24 @@ class Aside extends BlockElement
250258
*/
251259
protected ?AriaBusyEnum $ariaBusy = null;
252260

253-
/** Defines a string value that labels the current element for assistive technologies. */
261+
/**
262+
* Defines a string value that labels the current element for assistive technologies.
263+
* @category HTML attribute */
254264
protected ?string $ariaLabel = null;
255265

256-
/** References an element that provides additional details about the current element. */
266+
/**
267+
* References an element that provides additional details about the current element.
268+
* @category HTML attribute */
257269
protected ?string $ariaDetails = null;
258270

259-
/** Defines keyboard shortcuts available for the element. */
271+
/**
272+
* Defines keyboard shortcuts available for the element.
273+
* @category HTML attribute */
260274
protected ?string $ariaKeyshortcuts = null;
261275

262-
/** Provides a human-readable custom role description for assistive technologies. */
276+
/**
277+
* Provides a human-readable custom role description for assistive technologies.
278+
* @category HTML attribute */
263279
protected ?string $ariaRoledescription = null;
264280

265281
/**
@@ -283,7 +299,9 @@ class Aside extends BlockElement
283299
*/
284300
protected ?AriaAtomicEnum $ariaAtomic = null;
285301

286-
/** Establishes ownership relationships between elements. Value is a space-separated list of IDs. */
302+
/**
303+
* Establishes ownership relationships between elements. Value is a space-separated list of IDs.
304+
* @category HTML attribute */
287305
protected ?string $ariaOwns = null;
288306

289307

src/Element/Block/Audio.php

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* This file is auto-generated. Do not edit manually.
44
*
5-
* @generated 2025-12-30 13:44:50
5+
* @generated 2025-12-30 23:54:09
66
* @category HTML
77
* @package vardumper/extended-htmldocument
88
* @subpackage Html\Element\Block
@@ -103,22 +103,34 @@ class Audio extends BlockElement
103103
];
104104

105105

106-
/** When present, it specifies that the audio or video will automatically start playing as soon as it can do so without stopping. */
106+
/**
107+
* When present, it specifies that the audio or video will automatically start playing as soon as it can do so without stopping.
108+
* @category HTML attribute */
107109
protected ?bool $autoplay = null;
108110

109-
/** When present, it specifies that audio or video controls should be displayed (such as play, pause, and volume). */
111+
/**
112+
* When present, it specifies that audio or video controls should be displayed (such as play, pause, and volume).
113+
* @category HTML attribute */
110114
protected ?bool $controls = null;
111115

112-
/** Specifies how the element handles cross-origin requests. */
116+
/**
117+
* Specifies how the element handles cross-origin requests.
118+
* @category HTML attribute */
113119
protected ?CrossoriginEnum $crossorigin = null;
114120

115-
/** When present, it specifies that the audio or video will start over again every time it is finished. */
121+
/**
122+
* When present, it specifies that the audio or video will start over again every time it is finished.
123+
* @category HTML attribute */
116124
protected ?bool $loop = null;
117125

118-
/** When present, it specifies that the audio output of the video should be muted. */
126+
/**
127+
* When present, it specifies that the audio output of the video should be muted.
128+
* @category HTML attribute */
119129
protected ?bool $muted = null;
120130

121-
/** */
131+
/**
132+
*
133+
* @category HTML attribute */
122134
protected ?PreloadEnum $preload = null;
123135

124136
/**
@@ -128,16 +140,24 @@ class Audio extends BlockElement
128140
*/
129141
protected ?string $src = null;
130142

131-
/** Defines the semantic purpose of an element for assistive technologies. */
143+
/**
144+
* Defines the semantic purpose of an element for assistive technologies.
145+
* @category HTML attribute */
132146
protected ?RoleEnum $role = null;
133147

134-
/** Identifies the element(s) whose contents or presence are controlled by this element. Value is a list of IDs separated by a space */
148+
/**
149+
* Identifies the element(s) whose contents or presence are controlled by this element. Value is a list of IDs separated by a space
150+
* @category HTML attribute */
135151
protected ?string $ariaControls = null;
136152

137-
/** Identifies the element(s) that describes the object. Value is a list of IDs separated by a space */
153+
/**
154+
* Identifies the element(s) that describes the object. Value is a list of IDs separated by a space
155+
* @category HTML attribute */
138156
protected ?string $ariaDescribedby = null;
139157

140-
/** Identifies the element(s) that labels the current element. Value is a list of IDs separated by a space */
158+
/**
159+
* Identifies the element(s) that labels the current element. Value is a list of IDs separated by a space
160+
* @category HTML attribute */
141161
protected ?string $ariaLabelledby = null;
142162

143163
/**
@@ -147,13 +167,19 @@ class Audio extends BlockElement
147167
*/
148168
protected ?AriaBusyEnum $ariaBusy = null;
149169

150-
/** References an element that provides additional details about the current element. */
170+
/**
171+
* References an element that provides additional details about the current element.
172+
* @category HTML attribute */
151173
protected ?string $ariaDetails = null;
152174

153-
/** Defines keyboard shortcuts available for the element. */
175+
/**
176+
* Defines keyboard shortcuts available for the element.
177+
* @category HTML attribute */
154178
protected ?string $ariaKeyshortcuts = null;
155179

156-
/** Provides a human-readable custom role description for assistive technologies. */
180+
/**
181+
* Provides a human-readable custom role description for assistive technologies.
182+
* @category HTML attribute */
157183
protected ?string $ariaRoledescription = null;
158184

159185
/**

0 commit comments

Comments
 (0)