Code Snippets
Login
Mapping sanitiser
New method to sanitise using LaundryRoom via AbstractMapping
Label
protected function testAndClean(string $type, $data, bool $json = false) { if($data === null) return null; switch ($type) { case "int": if (!$this->verifyInt($data)) { throw new Exception("Input data must be an integer"); } return $this->intClean($data); case "date": if (is_string($data)) { return $this->dateClean($data); } return $this->dateClean($data); case "trim": case "email": case "string": if (!$this->verifyString($data)) { throw new Exception("Input data must be a string"); } switch ($type) { case "trim": return $this->simpleTrim($data); case "email": return $this->emailClean($data); case "string": return $json ? $this->jsonClean($data) : $this->standardClean($data); default: return null; } default: throw new Exception("Invalid type specified for testAndClean"); } }
Copy to clipboard
Copied!
©
Leerlandais 2024