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

FastyBird / json-api / 10239548501

04 Aug 2024 09:53PM UTC coverage: 4.133% (-0.08%) from 4.214%
10239548501

push

github

web-flow
Merge pull request #3 from FastyBird/feature/drop-annotations

Drop doctrine annotations

0 of 67 new or added lines in 2 files covered. (0.0%)

2 existing lines in 2 files now uncovered.

41 of 992 relevant lines covered (4.13%)

0.12 hits per line

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

0.0
/src/Helpers/CrudReader.php
1
<?php declare(strict_types = 1);
2

3
/**
4
 * CrudReader.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     Helpers
11
 * @since          0.2.0
12
 *
13
 * @date           20.05.21
14
 */
15

16
namespace FastyBird\JsonApi\Helpers;
17

18
use IPub\DoctrineCrud;
19
use ReflectionAttribute;
20
use ReflectionProperty;
21
use function array_reduce;
22
use function assert;
23

24
/**
25
 * Doctrine CRUD annotation reader
26
 *
27
 * @package            FastyBird:JsonApi!
28
 * @subpackage         Helpers
29
 *
30
 * @author             Adam Kadlec <adam.kadlec@fastybird.com>
31
 */
32
class CrudReader
33
{
34

35
        /**
36
         * @return array<bool>
37
         */
38
        public function read(ReflectionProperty $rp): array
39
        {
NEW
40
                $crudAttribute = array_reduce(
×
NEW
41
                        $rp->getAttributes(),
×
NEW
42
                        static function (ReflectionAttribute|null $carry, ReflectionAttribute $attribute): ReflectionAttribute|null {
×
NEW
43
                                if ($carry === null && $attribute->getName() === DoctrineCrud\Mapping\Attribute\Crud::class) {
×
NEW
44
                                        return $attribute;
×
45
                                }
46

NEW
47
                                return $carry;
×
NEW
48
                        },
×
NEW
49
                );
×
50

NEW
51
                if ($crudAttribute === null) {
×
NEW
52
                        return [false, false];
×
53
                }
54

NEW
55
                $crud = $crudAttribute->newInstance();
×
NEW
56
                assert($crud instanceof DoctrineCrud\Mapping\Attribute\Crud);
×
57

UNCOV
58
                return [$crud->isRequired(), $crud->isWritable()];
×
59
        }
60

61
}
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