Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
10 / 10 |
|
100.00% |
7 / 7 |
CRAP | |
100.00% |
1 / 1 |
| Mimepart | |
100.00% |
10 / 10 |
|
100.00% |
7 / 7 |
12 | |
100.00% |
1 / 1 |
| getDefaults | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| isBase64Encoded | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| isHtml | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| isText | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| isIcs | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| getContent | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| getExtension | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace BO\Zmsentities; |
| 4 | |
| 5 | class Mimepart extends Schema\Entity |
| 6 | { |
| 7 | public const PRIMARY = 'id'; |
| 8 | |
| 9 | public static $schema = "mimepart.json"; |
| 10 | |
| 11 | #[\Override] |
| 12 | public function getDefaults() |
| 13 | { |
| 14 | return [ |
| 15 | 'mime' => '', |
| 16 | 'content' => '', |
| 17 | ]; |
| 18 | } |
| 19 | |
| 20 | public function isBase64Encoded() |
| 21 | { |
| 22 | return ($this->base64) ? true : false; |
| 23 | } |
| 24 | |
| 25 | public function isHtml() |
| 26 | { |
| 27 | return ($this->mime == 'text/html') ? true : false; |
| 28 | } |
| 29 | |
| 30 | public function isText() |
| 31 | { |
| 32 | return ($this->mime == 'text/plain') ? true : false; |
| 33 | } |
| 34 | |
| 35 | public function isIcs() |
| 36 | { |
| 37 | return ($this->mime == 'text/calendar') ? true : false; |
| 38 | } |
| 39 | |
| 40 | public function getContent() |
| 41 | { |
| 42 | return ($this->isBase64Encoded()) ? \base64_decode($this->content) : $this->content; |
| 43 | } |
| 44 | |
| 45 | public function getExtension() |
| 46 | { |
| 47 | return preg_replace('#^.*/#', '', $this->mime); |
| 48 | } |
| 49 | } |