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.
Add HasLabelItemClass trait and corresponding test. (#210)
- Loading branch information
1 parent
3deded7
commit 8677a7d
Showing
8 changed files
with
357 additions
and
260 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Attribute\Custom; | ||
|
||
/** | ||
* Is used by widgets that implement label item class method. | ||
*/ | ||
trait HasLabelItemClass | ||
{ | ||
protected string $labelItemClass = ''; | ||
|
||
/** | ||
* Set a new label item class that will be used for the label item. | ||
* | ||
* @param string $value The label item class to be used for the label item. | ||
* | ||
* @return static A new instance of the current class with the specified label item class. | ||
*/ | ||
public function labelItemClass(string $value): static | ||
{ | ||
$new = clone $this; | ||
$new->labelItemClass = $value; | ||
|
||
return $new; | ||
} | ||
} |
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,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Tests\Attribute\Custom; | ||
|
||
use PHPForge\Html\Attribute\Custom\HasLabelItemClass; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
final class HasLabelItemClassTest extends TestCase | ||
{ | ||
public function testImmutability(): void | ||
{ | ||
$instance = new class () { | ||
use HasLabelItemClass; | ||
}; | ||
|
||
$this->assertNotSame($instance, $instance->labelItemClass('')); | ||
} | ||
} |
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
Oops, something went wrong.