TagEditor final class
Minn\Runtime\TagEditor · public/minn/src/Minn/Runtime/TagEditor.php · 152 lines
Edits one start tag's attributes in place the way the reference's tag processor does: a replaced value keeps its position, a new attribute goes right after the tag name (after any earlier insertion), and a removal takes only the attribute's own text.
Constants and properties
| private | array $attrs | |
| private | string $tag | |
| private | int $insertAt |
Public
| new | __construct(string $tag, array $attrs)# |
| |||
| method | get(string $name): ?string# | An attribute's value, or null. | |||
| method | has(string $name): bool# | Whether the tag has an attribute. | |||
| method | set(string $name, string|bool $value): void# | true sets a bare boolean attribute; a URL attribute (href, src, ...) keeps only a URL whose scheme is allowed, as the reference's set_attribute keeps it. | |||
| method | remove(string $name): void# | Removes an attribute. | |||
| method | addClass(string $class): void# | Adds or removes a class. | |||
| method | removeClass(string $class): void# | Removes a class, and the attribute when it was the last one. | |||
| method | setStyle(string $property, ?string $value): void# | Sets or removes one inline style property. | |||
| method | html(): string# | The tag as edited. |
Internals 3
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
Nothing matches.