-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Tom Wright <[email protected]>
- Loading branch information
1 parent
81484f9
commit 27adc3c
Showing
11 changed files
with
299 additions
and
43 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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
## v0.1.0 (2024-06-19) | ||
* Built initial implementation | ||
* Built initial Verifier implementation | ||
* Built basic Renderer system |
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,19 @@ | ||
<?php | ||
|
||
/** | ||
* @package Scrutiny | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DecodeLabs\Scrutiny; | ||
|
||
use DecodeLabs\Tagged\Element; | ||
|
||
interface Renderer | ||
{ | ||
public function render( | ||
Verifier $verifier | ||
): Element; | ||
} |
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,38 @@ | ||
<?php | ||
|
||
/** | ||
* @package Scrutiny | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DecodeLabs\Scrutiny\Renderer; | ||
|
||
use Closure; | ||
use DecodeLabs\Scrutiny\Renderer; | ||
use DecodeLabs\Scrutiny\Verifier; | ||
use DecodeLabs\Tagged\Element; | ||
|
||
class Custom implements Renderer | ||
{ | ||
/** | ||
* @var Closure(Verifier):Element | ||
*/ | ||
protected Closure $renderer; | ||
|
||
/** | ||
* @param Closure(Verifier):Element $renderer | ||
*/ | ||
public function __construct( | ||
Closure $renderer | ||
) { | ||
$this->renderer = $renderer; | ||
} | ||
|
||
public function render( | ||
Verifier $verifier | ||
): Element { | ||
return ($this->renderer)($verifier); | ||
} | ||
} |
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,36 @@ | ||
<?php | ||
|
||
/** | ||
* @package Scrutiny | ||
* @license http://opensource.org/licenses/MIT | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace DecodeLabs\Scrutiny\Renderer; | ||
|
||
use DecodeLabs\Dictum; | ||
use DecodeLabs\Scrutiny\Renderer; | ||
use DecodeLabs\Scrutiny\Verifier; | ||
use DecodeLabs\Tagged; | ||
use DecodeLabs\Tagged\Element; | ||
use ReflectionClass; | ||
|
||
class Generic implements Renderer | ||
{ | ||
public function render( | ||
Verifier $verifier | ||
): Element { | ||
$name = strtolower( | ||
(new ReflectionClass($verifier))->getShortName() | ||
); | ||
|
||
$attributes = []; | ||
|
||
foreach ($verifier->getComponentData() as $key => $value) { | ||
$attributes[Dictum::slug($key)] = $value; | ||
} | ||
|
||
return Tagged::{'scrutiny-' . $name}(null, $attributes); | ||
} | ||
} |
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
Oops, something went wrong.