blob: b0cf1c69bec0cc809a00af238267a8a378dc86f9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
<?php
namespace JsonApi\Routes\StockImages;
trait ValidationHelpers
{
protected static function getAttributeUpdates($json, iterable $keys): iterable
{
return array_reduce(
$keys,
function ($memo, $key) use ($json) {
$path = 'data.attributes.' . $key;
if (self::arrayHas($json, $path)) {
$memo[$key] = self::arrayGet($json, $path);
}
return $memo;
},
[]
);
}
protected static function getTags($json): iterable
{
return ['tags' => json_encode(self::arrayGet($json, 'data.attributes.tags', []))];
}
}
|