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

Filesize::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
/**
3
 * PHP Exif Filesize 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 \InvalidArgumentException;
16
use \JsonSerializable;
17
use \RuntimeException;
18
19
/**
20
 * Filesize class
21
 *
22
 * A value object to describe the Filesize
23
 *
24
 * @category    PHPExif
25
 * @package     Common
26
 */
27
class Filesize implements JsonSerializable
28
{
29
    /**
30
     * The filesize in bytes
31
     *
32
     * @var int
33
     */
34
    private $bytes;
35
36
    /**
37
     * @param int $bytes
38
     *
39
     * @throws InvalidArgumentException If given bytes are not an integer
40
     */
41
    public function __construct($bytes)
42
    {
43
        if (!is_int($bytes)) {
44
            throw new InvalidArgumentException('Given amount in bytes must be an integer');
45
        }
46
47
        $this->setBytes($bytes);
48
    }
49
50
    /**
51
     * Sets the bytes
52
     *
53
     * @param int $bytes
54
     *
55
     * @return void
56
     */
57
    private function setBytes($bytes)
58
    {
59
        $this->bytes = $bytes;
60
    }
61
62
    /**
63
     * Getter for bytes
64
     *
65
     * @return int
66
     */
67
    public function getBytes()
68
    {
69
        return $this->bytes;
70
    }
71
72
    /**
73
     * Returns the filesize in KiloBytes
74
     *
75
     * @return float
76
     */
77
    public function getKiloBytes()
78
    {
79
        return ($this->getBytes() / 1024);
80
    }
81
82
    /**
83
     * Returns the filesize in MegaBytes
84
     *
85
     * @return float
86
     */
87
    public function getMegaBytes()
88
    {
89
        return ($this->getKiloBytes() / 1024);
90
    }
91
92
    /**
93
     * Returns the filesize in GigaBytes
94
     *
95
     * @return float
96
     */
97
    public function getGigaBytes()
98
    {
99
        return ($this->getMegaBytes() / 1024);
100
    }
101
102
    /**
103
     * Creates a new instance from given Filesize object
104
     *
105
     * @param Filesize $filesize
106
     *
107
     * @return Filesize
108
     */
109
    public static function fromFilesize(Filesize $filesize)
110
    {
111
        return new self(
112
            $filesize->getBytes()
113
        );
114
    }
115
116
    /**
117
     * @inheritDoc
118
     *
119
     * @return int
120
     */
121
    public function jsonSerialize()
122
    {
123
        return $this->getBytes();
124
    }
125
126
    /**
127
     * Returns string representation
128
     *
129
     * @return string
130
     */
131
    public function __toString()
132
    {
133
        return (string) $this->getBytes();
134
    }
135
}
136