Skip to content

Commit

Permalink
Add LabelInterface to AbstractChoice. (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 21, 2023
1 parent a3e1c04 commit bb89d48
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Input/Base/AbstractChoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use PHPForge\Html\Attribute;
use PHPForge\Html\Input\Hidden;
use PHPForge\Html\Input\InputInterface;
use PHPForge\Html\Input\LabelInterface;
use PHPForge\Html\Label;
use PHPForge\Html\Tag;
use PHPForge\Widget\Element;
Expand All @@ -16,7 +17,7 @@
use function is_iterable;
use function is_object;

abstract class AbstractChoice extends Element implements InputInterface
abstract class AbstractChoice extends Element implements InputInterface, LabelInterface
{
use Attribute\Aria\HasAriaDescribedBy;
use Attribute\Aria\HasAriaLabel;
Expand Down
61 changes: 61 additions & 0 deletions src/Input/LabelInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Input;

use PHPForge\Widget\ElementInterface;

interface LabelInterface
{
/**
* Set the `HTML` attributes for the label.
*
* @param array $values Attribute values indexed by attribute names.
*
* @return static A new instance of the current class with the specified label attributes.
*/
public function labelAttributes(array $values): static;

/**
* Set the `CSS` class for the label.
*
* @param string $value The value of the class attribute.
* @param bool $override If `true` the value will be overridden.
*
* @return static A new instance of the current class with the specified label class.
*/
public function labelClass(string $value, bool $override = false): static;

/**
* Set the `HTML` label content.
*
* @param ElementInterface|string $values The `HTML` label content value.
*
* @return static A new instance of the current class with the specified `HTML` label content.
*/
public function labelContent(string|ElementInterface ...$values): static;

/**
* Set the `for` attribute for the label.
*
* @param string|null $value The value for the `for` attribute.
*
* @return static A new instance of the current class with the specified label `for` attribute.
*/
public function labelFor(string|null $value): static;

/**
* Disable the label rendering.
*
* @return static A new instance of the current class with the label disabled.
*/
public function notLabel(): static;

/**
* Determine if the label is disabled or not.
*
* @return bool `true` if the label is disabled, `false` otherwise.
*/
public function isNotLabel(): bool;
}

0 comments on commit bb89d48

Please sign in to comment.