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

api-platform / core / 4498909317

pending completion
4498909317

push

github

soyuka
Merge 3.1

364 of 364 new or added lines in 61 files covered. (100.0%)

10781 of 17989 relevant lines covered (59.93%)

11.36 hits per line

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

0.0
/src/Metadata/Util/Reflection.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\Metadata\Util;
15

16
/**
17
 * Reflection utilities.
18
 *
19
 * @internal
20
 *
21
 * @author Kévin Dunglas <dunglas@gmail.com>
22
 */
23
final class Reflection
24
{
25
    public const ACCESSOR_PREFIXES = ['get', 'is', 'has', 'can'];
26
    public const MUTATOR_PREFIXES = ['set', 'add', 'remove'];
27

28
    /**
29
     * Gets the property name associated with an accessor method.
30
     */
31
    public function getProperty(string $methodName): ?string
32
    {
33
        $pattern = implode('|', array_merge(self::ACCESSOR_PREFIXES, self::MUTATOR_PREFIXES));
×
34

35
        if (preg_match('/^('.$pattern.')(.+)$/i', $methodName, $matches)) {
×
36
            return $matches[2];
×
37
        }
38

39
        return null;
×
40
    }
41
}
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