Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
62.50% covered (warning)
62.50%
5 / 8
50.00% covered (danger)
50.00%
1 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
MetadataOption
62.50% covered (warning)
62.50%
5 / 8
50.00% covered (danger)
50.00%
1 / 2
7.90
0.00% covered (danger)
0.00%
0 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 check
57.14% covered (warning)
57.14%
4 / 7
0.00% covered (danger)
0.00%
0 / 1
6.97
1<?php
2
3namespace WebPConvert\Options;
4
5use WebPConvert\Options\StringOption;
6use WebPConvert\Options\Exceptions\InvalidOptionValueException;
7
8/**
9 * Metadata option. A Comma-separated list ('all', 'none', 'exif', 'icc', 'xmp')
10 *
11 * @package    WebPConvert
12 * @author     Bjørn Rosell <it@rosell.dk>
13 * @since      Class available since Release 2.0.0
14 */
15class MetadataOption extends StringOption
16{
17
18    protected $typeId = 'metadata';
19    protected $schemaType = ['string'];
20
21    public function __construct($id, $defaultValue)
22    {
23        parent::__construct($id, $defaultValue);
24    }
25
26    public function check()
27    {
28        parent::check();
29
30        $value = $this->getValue();
31
32        if (($value == 'all') || ($value == 'none')) {
33            return;
34        }
35
36        foreach (explode(',', $value) as $item) {
37            if (!in_array($value, ['exif', 'icc', 'xmp'])) {
38                throw new InvalidOptionValueException(
39                    '"metadata" option must be "all", "none" or a comma-separated list of "exif", "icc" or "xmp". ' .
40                    'It was however set to: "' . $value . '"'
41                );
42            }
43        }
44
45        //$this->checkType('string');
46    }
47}