From 79f7a8b63f6fc18ad7be9136d42331e2bc2840cf Mon Sep 17 00:00:00 2001 From: Maxime Beaudoin Date: Wed, 5 Jul 2017 12:23:19 +0000 Subject: [PATCH] Put resource key value for serializer into class constant --- composer.json | 2 +- src/Serializer/Serializer.php | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/composer.json b/composer.json index 85f3436..19600b7 100644 --- a/composer.json +++ b/composer.json @@ -38,7 +38,7 @@ }, "extra": { "branch-alias": { - "dev-master": "0.14-dev" + "dev-master": "0.15-dev" } } } diff --git a/src/Serializer/Serializer.php b/src/Serializer/Serializer.php index 91bf0b6..dc9a001 100644 --- a/src/Serializer/Serializer.php +++ b/src/Serializer/Serializer.php @@ -11,6 +11,8 @@ */ class Serializer extends ArraySerializer { + const RESOURCE_KEY = 'data'; + /** * Serialize a collection. * @@ -21,7 +23,7 @@ class Serializer extends ArraySerializer */ public function collection($resourceKey, array $data) { - return [$resourceKey ? $resourceKey: 'data' => $data]; + return [$resourceKey ? $resourceKey: static::RESOURCE_KEY => $data]; } /** @@ -34,6 +36,6 @@ public function collection($resourceKey, array $data) */ public function item($resourceKey, array $data) { - return [$resourceKey ? $resourceKey: 'data' => $data]; + return [$resourceKey ? $resourceKey: static::RESOURCE_KEY => $data]; } }