Skip to content

Commit

Permalink
Add Date::class, Datetime::class, DatetimeLocal::class, Month::class,…
Browse files Browse the repository at this point in the history
… Time::class widgets. (#171)
  • Loading branch information
terabytesoftw committed Dec 22, 2023
1 parent 348b00e commit fc90d04
Show file tree
Hide file tree
Showing 15 changed files with 2,191 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Input/Date.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Input;

/**
* The input element with a type attribute whose value is "date" represents a control for setting the element’s value to
* a string representing a date.
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.date.html#input.date
*/
final class Date extends Base\AbstractControl
{
protected string $type = 'date';
}
16 changes: 16 additions & 0 deletions src/Input/Datetime.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Input;

/**
* The input element with a type attribute whose value is "datetime" represents a control for setting the element’s
* value to a string representing a global date and time (with timezone information).
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.datetime.html#input.datetime
*/
final class Datetime extends Base\AbstractControl
{
protected string $type = 'datetime';
}
16 changes: 16 additions & 0 deletions src/Input/DatetimeLocal.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Input;

/**
* The input element with a type attribute whose value is "datetime-local" represents a control for setting the
* element’s value to a string representing a local date and time (with no timezone information).
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.datetime-local.html#input.datetime-local
*/
final class DatetimeLocal extends Base\AbstractControl
{
protected string $type = 'datetime-local';
}
16 changes: 16 additions & 0 deletions src/Input/Month.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Input;

/**
* The input element with a type attribute whose value is "month" represents a control for setting the element’s value
* to a string representing a month.
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.month.html#input.month
*/
final class Month extends Base\AbstractControl
{
protected string $type = 'month';
}
16 changes: 16 additions & 0 deletions src/Input/Time.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Input;

/**
* The input element with a type attribute whose value is "time" represents a control for setting the element’s value to
* a string representing a time (with no timezone information).
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.time.html#input.time
*/
final class Time extends Base\AbstractControl
{
protected string $type = 'time';
}
23 changes: 23 additions & 0 deletions tests/Input/Date/ExceptionTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php

declare(strict_types=1);

namespace PHPForge\Html\Tests\Input\Date;

use InvalidArgumentException;
use PHPForge\Html\Input\Date;
use PHPUnit\Framework\TestCase;

/**
* @psalm-suppress PropertyNotSetInConstructor
*/
final class ExceptionTest extends TestCase
{
public function testValue(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage('Date::class widget must be a string or null value.');

Date::widget()->value([])->render();
}
}

0 comments on commit fc90d04

Please sign in to comment.