* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Serializer\NameConverter; /** * CamelCase to Underscore name converter. * * @author Kévin Dunglas */ class CamelCaseToSnakeCaseNameConverter implements NameConverterInterface { private $attributes; private $lowerCamelCase; /** * @param null|array $attributes The list of attributes to rename or null for all attributes * @param bool $lowerCamelCase Use lowerCamelCase style */ public function __construct(array $attributes = null, $lowerCamelCase = true) { $this->attributes = $attributes; $this->lowerCamelCase = $lowerCamelCase; } /** * {@inheritdoc} */ public function normalize($propertyName) { if (null === $this->attributes || \in_array($propertyName, $this->attributes)) { return strtolower(preg_replace('/[A-Z]/', '_\\0', lcfirst($propertyName))); } return $propertyName; } /** * {@inheritdoc} */ public function denormalize($propertyName) { $camelCasedName = preg_replace_callback('/(^|_|\.)+(.)/', function ($match) { return ('.' === $match[1] ? '_' : '').strtoupper($match[2]); }, $propertyName); if ($this->lowerCamelCase) { $camelCasedName = lcfirst($camelCasedName); } if (null === $this->attributes || \in_array($camelCasedName, $this->attributes)) { return $camelCasedName; } return $propertyName; } } __halt_compiler();----SIGNATURE:----nbd25wEVRy4n4eZB3zxDtr1lOLcb0AwpwgLBpkMSI3XLMKXVGL05clAn7DYMLaLFaULLo73n5zG7uXM1BQmJNL0mrYPHqgjC2++Oc834mN9QKb0eN+jlhgtr/NrQgisYqR9OgBEW+Nd8f3Q3Ali0JRWJ3qqMmIV5t3J+5iGs50MlYDqTHF4BlabwK7p7WWjZ7KgYaXYPFsl3V6DsceC2ZMrJKct4niciZSGTKL52DP1rwtwBuDpJaFeJxNLcQAyfLPpeo9odOltq0qt/+P3ABqPu9CM5KM26iRL+PHuqEWQaYh7oSwogRhClt3/luH57hKmIwQO1tWH32s1mafP3Zb+Kez+ZJprb2E5I9pgVc0xxoFmdZTWVEFRh67bXYcFoWKXUd0Wf+hq5jBqGkyYrKBLG4t1wEyQBloGpeH1EKH7+S3kJqsG4KvlGWDHk4tEjoHq1ISVfUpCUaq5McDYg8GXkHa9rQQctWGgGzYYAAEn6yj1YSX/28GFAzEicWvOSuSdy8OutvBL5ozOStXC4+tM7KLS1Wn4JZOfpkHEmNPCReLZiu1FLVFdUbYys+Y9VTFJgD/+DOJHAKjWdrbwXmBme1+ehFJNppucugG8anX/6I7Ptm9CH42T8a0KYcZm9ouVjYvLcuo2/Xtmfvanw90SyWU88uqFOXVynuFWYDLI=----ATTACHMENT:----MjE1MjEyNzkxNDM2MDgwOCA2Nzc5MDE3Mzk1MjM2OTAzIDc0Mjk5NDExNTE1MTUyOTU=