Completed
Push — master ( cdaaec...103078 )
by Rafał
14:12
created

FileExtensionChecker   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 27
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A isAudio() 0 4 1
A isVideo() 0 4 1
A isImage() 0 4 1
A isAttachment() 0 4 1
A startsWith() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Content Bundle.
7
 *
8
 * Copyright 2018 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2018 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\ContentBundle\File;
18
19
final class FileExtensionChecker implements FileExtensionCheckerInterface
20
{
21
    public function isAudio(string $mimeType): bool
22
    {
23
        return $this->startsWith($mimeType, 'audio');
24
    }
25
26
    public function isVideo(string $mimeType): bool
27
    {
28
        return $this->startsWith($mimeType, 'video');
29
    }
30
31
    public function isImage(string $mimeType): bool
32
    {
33
        return $this->startsWith($mimeType, 'image');
34
    }
35
36
    public function isAttachment(string $mimeType): bool
37
    {
38
        return $this->startsWith($mimeType, 'application');
39
    }
40
41
    private function startsWith(string $mimeType, string $string): bool
42
    {
43
        return 0 === strpos($mimeType, $string);
44
    }
45
}
46