Files
simple-php-router/src/Pecee/Http/Input/InputItem.php
T
Simon Sessingø ce63e247b1 Bugfixes
- Fixed `Url` not outputting correct class when used in json_encode.
- Fixed `IInputItem` being too strict about strings which may be nullable.
2018-03-30 05:22:41 +02:00

80 lines
1.4 KiB
PHP

<?php
namespace Pecee\Http\Input;
class InputItem implements IInputItem
{
public $index;
public $name;
public $value;
public function __construct(string $index, ?string $value = null)
{
$this->index = $index;
$this->value = $value;
// Make the name human friendly, by replace _ with space
$this->name = ucfirst(str_replace('_', ' ', strtolower($this->index)));
}
/**
* @return string
*/
public function getIndex(): string
{
return $this->index;
}
public function setIndex(string $index): IInputItem
{
$this->index = $index;
return $this;
}
/**
* @return string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* Set input name
* @param string $name
* @return static
*/
public function setName(string $name): IInputItem
{
$this->name = $name;
return $this;
}
/**
* @return string
*/
public function getValue(): ?string
{
return $this->value;
}
/**
* Set input value
* @param string $value
* @return static
*/
public function setValue(string $value): IInputItem
{
$this->value = $value;
return $this;
}
public function __toString(): string
{
return (string)$this->value;
}
}