for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the XabbuhPandaClient package.
*
* (c) Christian Flothmann <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Xabbuh\PandaClient\Transformer;
use Symfony\Component\HttpFoundation\ParameterBag;
use Xabbuh\PandaClient\Model\Profile;
/**
* Transform various data representation formats into profiles and vice versa.
* @author Christian Flothmann <[email protected]>
class ProfileTransformer extends BaseTransformer implements ProfileTransformerInterface
{
* {@inheritDoc}
public function stringToProfile($jsonString)
return $this->serializer->deserialize($jsonString, 'Profile');
}
public function stringToProfileCollection($jsonString)
public function toRequestParams(Profile $profile)
$params = new ParameterBag();
foreach (get_class_methods(get_class($profile)) as $method) {
if ('get' === substr($method, 0, 3)) {
$property = strtolower(preg_replace(
'/([a-z])([A-Z])/',
'\$1_\$2',
substr($method, 3)
));
$params->set($property, $profile->$method());
return $params;