for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace lloc\Msls\Component\Input;
use lloc\Msls\Component\InputInterface;
/**
* Class Option
* @package lloc\Msls\Component\Input
*/
class Option implements InputInterface {
* @var string
protected $key;
protected $value;
protected $selected;
* @param string $key
* @param string|null $value
* @param string|null $selected
public function __construct( string $key, $value, $selected = null ) {
$this->key = esc_attr( $key );
$this->value = esc_attr( $value );
$this->selected = selected( $key, esc_attr( $selected ), false );
}
* @return string
public function render(): string {
return sprintf( '<option value="%s" %s>%s</option>', $this->key, $this->selected, $this->value );