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

Cecilapp / Cecil / 5046064611

pending completion
5046064611

push

github

GitHub
perf: native_function_invocation (#1697)

322 of 322 new or added lines in 62 files covered. (100.0%)

2784 of 4121 relevant lines covered (67.56%)

0.68 hits per line

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

0.0
/src/Command/ShowContent/FileExtensionFilter.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of Cecil.
7
 *
8
 * Copyright (c) Arnaud Ligny <arnaud@ligny.fr>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13

14
namespace Cecil\Command\ShowContent;
15

16
use RecursiveFilterIterator;
17

18
/**
19
 * Filters files by extension type.
20
 */
21
class FileExtensionFilter extends RecursiveFilterIterator
22
{
23
    /** @var array */
24
    protected $allowedExt = ['md'];
25

26
    /** @var array */
27
    protected $excludedDir = ['.git', '.cecil', '.cache', '_site'];
28

29
    /**
30
     * @param \RecursiveIterator $iterator
31
     * @param string|array       $extensions
32
     */
33
    public function __construct(\RecursiveIterator $iterator, $extensions = '')
34
    {
35
        parent::__construct($iterator);
×
36
        if (!empty($extensions)) {
×
37
            if (!\is_array($extensions)) {
×
38
                $extensions = [$extensions];
×
39
            }
40
            $this->allowedExt = $extensions;
×
41
        }
42
    }
43

44
    /**
45
     * Valid file.
46
     */
47
    public function accept(): bool
48
    {
49
        /** @var \SplFileInfo $file */
50
        $file = $this->current();
×
51
        if ($file->isFile()) {
×
52
            return \in_array($file->getExtension(), $this->allowedExt);
×
53
        }
54
        if ($file->isDir()) {
×
55
            return !\in_array($file->getBasename(), $this->excludedDir);
×
56
        }
57

58
        return true;
×
59
    }
60
}
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