GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — develop ( e263f3...74da5c )
by Tom Van
23s
created

MimeType   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 35
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 3
A fromMimeType() 0 6 1
1
<?php
2
/**
3
 * PHP Exif MimeType ValueObject
4
 *
5
 * @link        http://github.com/PHPExif/php-exif-common for the canonical source repository
6
 * @copyright   Copyright (c) 2016 Tom Van Herreweghe <[email protected]>
7
 * @license     http://github.com/PHPExif/php-exif-common/blob/master/LICENSE MIT License
8
 * @category    PHPExif
9
 * @package     Common
10
 * @codeCoverageIgnore
11
 */
12
13
namespace PHPExif\Common\Data\ValueObject;
14
15
use PHPExif\Common\Data\ValueObject\StringObject;
16
use \InvalidArgumentException;
17
use \RuntimeException;
18
19
/**
20
 * MimeType class
21
 *
22
 * A value object to describe the MimeType data
23
 *
24
 * @category    PHPExif
25
 * @package     Common
26
 */
27
class MimeType extends StringObject
28
{
29
    /**
30
     * @param string $stringData
31
     *
32
     * @throws InvalidArgumentException If given string is not really a string
33
     * @throws RuntimeExcpetion If given string is in incorrect format
34
     */
35
    public function __construct($stringData)
36
    {
37
        if (!is_string($stringData)) {
38
            throw new InvalidArgumentException('Given data is not a string');
39
        }
40
41
        if (!preg_match('#^image/(jpeg|gif|tiff|bmp)$#', $stringData, $matches)) {
42
            throw new RuntimeException('Given MimeType is not in a valid format. Need: "image/<type>"');
43
        }
44
45
        $this->setStringData($stringData);
46
    }
47
48
    /**
49
     * Creates a new instance from given MimeType object
50
     *
51
     * @param MimeType $mimeType
52
     *
53
     * @return MimeType
54
     */
55
    public static function fromMimeType(MimeType $mimeType)
56
    {
57
        return new self(
58
            (string) $mimeType
59
        );
60
    }
61
}
62