ImageMetadata   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 12
eloc 24
c 4
b 1
f 0
dl 0
loc 57
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
C setSpecificAttribute() 0 28 12
1
<?php
2
3
namespace Vaites\ApacheTika\Metadata;
4
5
/**
6
 * Metadata class for images
7
 *
8
 * @author  David Martínez <[email protected]>
9
 */
10
class ImageMetadata extends Metadata
11
{
12
    /**
13
     * Image width in pixels
14
     *
15
     * @var int
16
     */
17
    public $width = 0;
18
19
    /**
20
     * Image height in pixels
21
     *
22
     * @var int
23
     */
24
    public $height = 0;
25
26
    /**
27
     * Lossy/Lossless.
28
     *
29
     * @var bool
30
     */
31
    public $lossless = true;
32
33
    /**
34
     * Sets an attribute
35
     *
36
     * @param mixed $value
37
     * @return \Vaites\ApacheTika\Metadata\MetadataInterface
38
     */
39
    protected function setSpecificAttribute(string $key, $value): MetadataInterface
40
    {
41
        switch(mb_strtolower($key))
42
        {
43
            case 'compression':
44
            case 'compression lossless':
45
                $this->lossless = ($value == 'true' || $value == 'Uncompressed');
46
                break;
47
48
            case 'height':
49
            case 'image height':
50
            case 'tiff:imageheigth':
51
            case 'tiff:imagelength':
52
                $this->height = (int) $value;
53
                break;
54
55
            case 'width':
56
            case 'image width':
57
            case 'tiff:imagewidth':
58
                $this->width = (int) $value;
59
                break;
60
61
            case 'x-tika:content':
62
                $this->content = $value;
63
                break;
64
        }
65
66
        return $this;
67
    }
68
}
69