for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Bdf\Form\Leaf\View;
use Bdf\Form\View\FieldViewInterface;
use Bdf\Form\View\FieldViewRendererInterface;
use Bdf\Form\View\HtmlRenderer;
/**
* Default renderer for @see BooleanElementView
*
* @implements FieldViewRendererInterface<BooleanElementView>
*/
final class CheckboxHtmlRenderer implements FieldViewRendererInterface
{
* @var CheckboxHtmlRenderer|null
private static $instance;
* {@inheritdoc}
* @param BooleanElementView $view
public function render(FieldViewInterface $view, array $attributes): string
if (!isset($attributes['type'])) {
$attributes['type'] = 'checkbox';
}
$attributes['name'] = $view->name();
$attributes['value'] = $view->httpValue();
httpValue()
Bdf\Form\View\FieldViewInterface
__call
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
/** @scrutinizer ignore-call */
$attributes['checked'] = $view->checked();
checked()
return HtmlRenderer::element('input', $attributes);
* Get the renderer instance
* @return self
public static function instance(): self
if (self::$instance) {
return self::$instance;
return self::$instance = new self;