1 | <?php |
||
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) |
||
49 | |||
50 | /** |
||
51 | * Sets the bytes |
||
52 | * |
||
53 | * @param int $bytes |
||
54 | * |
||
55 | * @return void |
||
56 | */ |
||
57 | private function setBytes($bytes) |
||
61 | |||
62 | /** |
||
63 | * Getter for bytes |
||
64 | * |
||
65 | * @return int |
||
66 | */ |
||
67 | public function getBytes() |
||
71 | |||
72 | /** |
||
73 | * Returns the filesize in KiloBytes |
||
74 | * |
||
75 | * @return float |
||
76 | */ |
||
77 | public function getKiloBytes() |
||
81 | |||
82 | /** |
||
83 | * Returns the filesize in MegaBytes |
||
84 | * |
||
85 | * @return float |
||
86 | */ |
||
87 | public function getMegaBytes() |
||
91 | |||
92 | /** |
||
93 | * Returns the filesize in GigaBytes |
||
94 | * |
||
95 | * @return float |
||
96 | */ |
||
97 | public function getGigaBytes() |
||
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) |
||
115 | |||
116 | /** |
||
117 | * @inheritDoc |
||
118 | * |
||
119 | * @return int |
||
120 | */ |
||
121 | public function jsonSerialize() |
||
125 | |||
126 | /** |
||
127 | * Returns string representation |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | public function __toString() |
||
135 | } |
||
136 |