• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

FastyBird / json-api / 7822169728

07 Feb 2024 10:39PM UTC coverage: 4.32%. Remained the same
7822169728

push

github

akadlec
Removed unused package

41 of 949 relevant lines covered (4.32%)

0.13 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Hydrators/Fields/ArrayField.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * ArrayField.php
5
 *
6
 * @license        More in LICENSE.md
7
 * @copyright      https://www.fastybird.com
8
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
9
 * @package        FastyBird:JsonApi!
10
 * @subpackage     Hydrators
11
 * @since          0.1.0
12
 *
13
 * @date           26.05.20
14
 */
15

16
namespace FastyBird\JsonApi\Hydrators\Fields;
17

18
use IPub\JsonAPIDocument;
19

20
/**
21
 * Entity array field
22
 *
23
 * @package        FastyBird:JsonApi!
24
 * @subpackage     Hydrators
25
 *
26
 * @author         Adam Kadlec <adam.kadlec@fastybird.com>
27
 */
28
final class ArrayField extends Field
29
{
30

31
        public function __construct(
32
                private readonly bool $isNullable,
33
                string $mappedName,
34
                string $fieldName,
35
                bool $isRequired,
36
                bool $isWritable,
37
        )
38
        {
39
                parent::__construct($mappedName, $fieldName, $isRequired, $isWritable);
×
40
        }
41

42
        /**
43
         * @param JsonAPIDocument\Objects\IStandardObject<string, mixed> $attributes
44
         *
45
         * @return Array<mixed>|null
46
         */
47
        public function getValue(JsonAPIDocument\Objects\IStandardObject $attributes): array|null
48
        {
49
                $value = $attributes->get($this->getMappedName());
×
50

51
                if ($value instanceof JsonAPIDocument\Objects\IStandardObject) {
×
52
                        return $value->toArray();
×
53
                }
54

55
                return $value === null ? ($this->isNullable ? [] : null) : (array) $value;
×
56
        }
57

58
        public function isNullable(): bool
59
        {
60
                return $this->isNullable;
×
61
        }
62

63
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc