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

daycry / class-finder / 16724626674

04 Aug 2025 01:32PM UTC coverage: 82.262% (-12.2%) from 94.493%
16724626674

push

github

web-flow
Update php.yml

320 of 389 relevant lines covered (82.26%)

3.29 hits per line

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

77.27
/src/Libraries/ClassMap/ClassMapFinder.php
1
<?php
2

3
namespace Daycry\ClassFinder\Libraries\ClassMap;
4

5
use Daycry\ClassFinder\ClassFinder;
6
use Daycry\ClassFinder\Interfaces\FinderInterface;
7

8
class ClassMapFinder implements FinderInterface
9
{
10
    private ClassMapFactory $factory;
11

12
    public function __construct()
13
    {
14
        $this->factory = new ClassMapFactory();
3✔
15
    }
16

17
    public function getPriority(): int
18
    {
19
        return 2; // Medium priority for ClassMap
×
20
    }
21

22
    /**
23
     * @return list<string>
24
     */
25
    public function findClasses(string $namespace, int $options): array
26
    {
27
        $classmapEntries = $this->factory->getClassmapEntries();
3✔
28

29
        $matchingEntries = array_filter($classmapEntries, static function (ClassmapEntry $entry) use ($namespace, $options) {
3✔
30
            if (! $entry->matches($namespace, $options)) {
3✔
31
                return false;
3✔
32
            }
33

34
            $potentialClass = $entry->getClassName();
3✔
35
            if (function_exists($potentialClass)) {
3✔
36
                // For some reason calling class_exists() on a namespace'd function raises a Fatal Error (tested PHP 7.0.8)
37
                // Example: DeepCopy\deep_copy
38
                return $options & ClassFinder::ALLOW_FUNCTIONS;
×
39
            }
40
            if (class_exists($potentialClass)) {
3✔
41
                return $options & ClassFinder::ALLOW_CLASSES;
3✔
42
            }
43
            if (interface_exists($potentialClass, false)) {
3✔
44
                return $options & ClassFinder::ALLOW_INTERFACES;
3✔
45
            }
46
            if (trait_exists($potentialClass, false)) {
×
47
                return $options & ClassFinder::ALLOW_TRAITS;
×
48
            }
49
        });
3✔
50

51
        return array_map(static fn (ClassmapEntry $entry) => $entry->getClassName(), $matchingEntries);
3✔
52
    }
53

54
    public function isNamespaceKnown(string $namespace): bool
55
    {
56
        $classmapEntries = $this->factory->getClassmapEntries();
3✔
57

58
        foreach ($classmapEntries as $classmapEntry) {
3✔
59
            if ($classmapEntry->knowsNamespace($namespace)) {
3✔
60
                return true;
3✔
61
            }
62
        }
63

64
        return false;
×
65
    }
66
}
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

© 2025 Coveralls, Inc