for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of Payload.
*
* (c) DraperStudio <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DraperStudio\Payload\Utils;
/**
* Class Mapper.
class Mapper
{
* @param $input
* @param $class
* @return mixed
public function map($input, $class)
if (is_array($input)) {
$input = $this->arrayToObject($input);
}
return (new \JsonMapper())->map($input, new $class());
private function arrayToObject($input)
return json_decode(json_encode($input));