Skip to content

Commit

Permalink
Ajustes no input para pegar dados inclusive se vier por json
Browse files Browse the repository at this point in the history
  • Loading branch information
toninho09 committed May 27, 2016
1 parent 23ae9c1 commit 49f4187
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/Molecular/Http/Input.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@

class Input
{
private $jsonValues;
/**
* Input constructor.
*/
public function __construct()
{
$this->jsonValues = $this->json();
}

/**
* @param $value
Expand All @@ -20,6 +28,7 @@ class Input
public function get($value, $default = null){
if(isset($_GET[$value])) return $_GET[$value];
if(isset($_POST[$value])) return $_POST[$value];
if(isset($this->jsonValues[$value])) return $this->jsonValues[$value];
return $default;
}

Expand All @@ -45,8 +54,8 @@ public function cookie($value, $default = null){
/**
* @return mixed
*/
public function json(){
return json_decode($this->getPHPInput());
public function json($assoc = true){
return json_decode($this->getPHPInput(),$assoc);
}

/**
Expand Down

0 comments on commit 49f4187

Please sign in to comment.