1: <?php
2:
3: namespace SellerLabs\Snagshout\Normalizer;
4:
5: use Joli\Jane\Runtime\Reference;
6: use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
7: use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
8: use Symfony\Component\Serializer\Normalizer\SerializerAwareNormalizer;
9: class PromoCodeNormalizer extends SerializerAwareNormalizer implements DenormalizerInterface, NormalizerInterface
10: {
11: public function supportsDenormalization($data, $type, $format = null)
12: {
13: if ($type !== 'SellerLabs\\Snagshout\\Model\\PromoCode') {
14: return false;
15: }
16: return true;
17: }
18: public function supportsNormalization($data, $format = null)
19: {
20: if ($data instanceof \SellerLabs\Snagshout\Model\PromoCode) {
21: return true;
22: }
23: return false;
24: }
25: public function denormalize($data, $class, $format = null, array $context = array())
26: {
27: $object = new \SellerLabs\Snagshout\Model\PromoCode();
28: if (property_exists($data, 'promoCode')) {
29: $object->setPromoCode($data->{'promoCode'});
30: }
31: if (property_exists($data, 'oneTime')) {
32: $object->setOneTime($data->{'oneTime'});
33: }
34: return $object;
35: }
36: public function normalize($object, $format = null, array $context = array())
37: {
38: $data = new \stdClass();
39: if (null !== $object->getPromoCode()) {
40: $data->{'promoCode'} = $object->getPromoCode();
41: }
42: if (null !== $object->getOneTime()) {
43: $data->{'oneTime'} = $object->getOneTime();
44: }
45: return $data;
46: }
47: }