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

adriansuter / php-autoload-override / 12951325128

24 Jan 2025 02:10PM UTC coverage: 93.235% (-5.3%) from 98.529%
12951325128

push

github

adriansuter
Update phpunit.

317 of 340 relevant lines covered (93.24%)

3.95 hits per line

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

25.0
/src/AutoloadCollection.php
1
<?php
2

3
/**
4
 * PHP Autoload Override (https://github.com/adriansuter/php-autoload-override)
5
 *
6
 * @license https://github.com/adriansuter/php-autoload-override/blob/master/LICENSE.md (MIT License)
7
 */
8

9
declare(strict_types=1);
10

11
namespace AdrianSuter\Autoload\Override;
12

13
use function array_keys;
14
use function file_exists;
15
use function glob;
16
use function is_dir;
17
use function realpath;
18

19
/**
20
 * @package AdrianSuter\Autoload\Override
21
 */
22
class AutoloadCollection
23
{
24
    /**
25
     * @var bool[] The keys of this associative array are the file paths.
26
     */
27
    private $filePaths = [];
28

29
    /**
30
     * Add a file to the autoload collection.
31
     *
32
     * This method would ignore the file if it could not be found.
33
     *
34
     * @param string $path The path to the file.
35
     */
36
    public function addFile(string $path): void
37
    {
38
        $realpath = realpath($path);
×
39
        if ($realpath !== false) {
×
40
            $this->filePaths[$realpath] = true;
×
41
        }
42
    }
43

44
    /**
45
     * Add a directory, i.e. the php files inside a directory.
46
     *
47
     * This method would ignore the directory if it could not be found.
48
     *
49
     * @param string $directory The directory.
50
     */
51
    public function addDirectory(string $directory): void
52
    {
53
        if (
54
            !file_exists($directory) ||
1✔
55
            !is_dir($directory) ||
×
56
            false === ($directory = realpath($directory))
1✔
57
        ) {
58
            return;
1✔
59
        }
60

61
        $files = glob($directory . '/*.php');
×
62
        if (is_array($files)) {
×
63
            foreach ($files as $file) {
×
64
                $this->addFile($file);
×
65
            }
66
        }
67
    }
68

69
    /**
70
     * Get the file paths.
71
     *
72
     * @return string[] The file paths.
73
     */
74
    public function getFilePaths(): array
75
    {
76
        return array_keys($this->filePaths);
×
77
    }
78
}
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