Completed
Push — master ( bc7d7f...7a9596 )
by Théo
02:46
created

FileExtensionCompactor::supports()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 9
c 0
b 0
f 0
rs 9.6666
cc 1
eloc 6
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\Compactor;
16
17
/**
18
 * An abstract compactor class that handles matching supported file by their types.
19
 */
20
abstract class FileExtensionCompactor implements Compactor
21
{
22
    private $extensions;
23
24
    /**
25
     * @param string[] $extensions the list of supported file extensions
26
     */
27
    public function __construct(array $extensions)
28
    {
29
        $this->extensions = $extensions;
30
    }
31
32
    /**
33
     * {@inheritdoc}
34
     */
35
    public function supports(string $file): bool
36
    {
37
        return in_array(
38
            pathinfo(
39
                $file,
40
                PATHINFO_EXTENSION
41
            ),
42
            $this->extensions,
43
            true
44
        );
45
    }
46
}
47