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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

91.3
/src/Util/AttributesExtractor.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\Util;
15

16
/**
17
 * Extracts data used by the library form given attributes.
18
 *
19
 * @author Antoine Bluchet <soyuka@gmail.com>
20
 *
21
 * @internal
22
 */
23
final class AttributesExtractor
24
{
25
    private function __construct()
26
    {
27
    }
×
28

29
    /**
30
     * Extracts resource class, operation name and format request attributes. Returns an empty array if the request does
31
     * not contain required attributes.
32
     */
33
    public static function extractAttributes(array $attributes): array
34
    {
35
        if (($attributes['_api_operation'] ?? null) && !isset($attributes['_api_resource_class'])) {
360✔
36
            $attributes['_api_resource_class'] = $attributes['_api_operation']->getClass();
×
37
        }
38

39
        $result = ['resource_class' => $attributes['_api_resource_class'] ?? null, 'has_composite_identifier' => $attributes['_api_has_composite_identifier'] ?? false];
360✔
40

41
        if (null === $result['resource_class']) {
360✔
42
            return [];
96✔
43
        }
44

45
        $hasRequestAttributeKey = false;
270✔
46
        if (isset($attributes['_api_operation_name'])) {
270✔
47
            $hasRequestAttributeKey = true;
258✔
48
            $result['operation_name'] = $attributes['_api_operation_name'];
258✔
49
        }
50
        if (isset($attributes['_api_operation'])) {
270✔
51
            $hasRequestAttributeKey = true;
123✔
52
            $result['operation'] = $attributes['_api_operation'];
123✔
53
        }
54

55
        if ($previousObject = $attributes['previous_data'] ?? null) {
270✔
56
            $result['previous_data'] = $previousObject;
36✔
57
        }
58

59
        if (false === $hasRequestAttributeKey) {
270✔
60
            return [];
9✔
61
        }
62

63
        $result += [
261✔
64
            'receive' => (bool) ($attributes['_api_receive'] ?? true),
261✔
65
            'respond' => (bool) ($attributes['_api_respond'] ?? true),
261✔
66
            'persist' => (bool) ($attributes['_api_persist'] ?? true),
261✔
67
        ];
261✔
68

69
        return $result;
261✔
70
    }
71
}
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