Commit a7e0cebe authored by Alex Ne's avatar Alex Ne

Input fix

parent 0384f319
<?php
/**
*
*/
class X_Input
{
*
*/
class X_Input {
protected $Value;
protected $Default = false;
function __construct()
{
}
public function lower_string()
{
function __construct() {}
public function lower_string() {
return strtolower($this->string());
}
public function bool()
{
if (!is_string($this->Value)) return (bool) $this->Value;
switch ( strtolower( trim( $this->Value ) ) )
{
public function bool() {
if ( ! is_string($this->Value)) {
return (bool) $this->Value;
}
switch (strtolower(trim($this->Value))) {
case 'true':
case 'on':
case 'yes':
case 'y':
case '1':
case '1':
return true;
break;
default:
......@@ -34,81 +29,75 @@ class X_Input
}
}
public function str_replace($search, $replace)
{
return (is_string($this->Value))?str_replace($search, $replace, $this->Value):"";
public function str_replace($search, $replace) {
return (is_string($this->Value)) ? str_replace($search, $replace, $this->Value) : "";
}
public function explode($delimiter)
{
return (is_string($this->Value))?explode($delimiter, $this->Value):[];
public function explode($delimiter) {
return (is_string($this->Value)) ? explode($delimiter, $this->Value) : [];
}
public function int()
{
if($this->Default === false) $this->Default = 0;
public function int() {
if ($this->Default === false) {
$this->Default = 0;
}
return intval($this->Value);
}
public function numeric()
{
public function numeric() {
return (is_numeric($this->Value)) ? $this->Value : 0;
}
public function float()
{
public function float() {
return floatval($this->Value);
}
public function string()
{
public function string() {
return strval($this->Value);
}
public function json_decode()
{
if($this->Value == null) return null;
if($this->Value == false) return false;
return json_decode($this->Value,true);
public function json_decode() {
if ($this->Value == null) {
return null;
}
if ($this->Value == false) {
return false;
}
return json_decode($this->Value, true);
}
public function RequestValue( $Name, $Default=false )
{
return $this->Request( $Name, $Default )->Value;
public function RequestValue($Name, $Default = false) {
return $this->Request($Name, $Default)->Value;
}
public function Request( $Name, $Default=false )
{
public function Request($Name, $Default = false) {
return (new X_Input_RequestItem($Name, $Default));
}
public function PostValue( $Name, $Default=false )
{
return $this->Request( $Name, $Default )->Value;
public function PostValue($Name, $Default = false) {
return $this->Post($Name, $Default)->Value;
}
public function Post( $Name, $Default=false )
{
public function Post($Name, $Default = false) {
return (new X_Input_MethodPostItem($Name, $Default));
}
public function GetValue( $Name, $Default=false )
{
return $this->Get( $Name, $Default )->Value;
public function GetValue($Name, $Default = false) {
return $this->Get($Name, $Default)->Value;
}
public function Get( $Name, $Default=false )
{
public function Get($Name, $Default = false) {
return (new X_Input_MethodGetItem($Name, $Default));
}
public function CookieValue( $Name, $Default=false )
{
return $this->Cookie( $Name, $Default )->Value;
public function CookieValue($Name, $Default = false) {
return $this->Cookie($Name, $Default)->Value;
}
public function Cookie( $Name, $Default=false )
{
public function Cookie($Name, $Default = false) {
return (new X_Input_MethodCookieItem($Name, $Default));
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment