Photo   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
eloc 20
c 1
b 0
f 1
dl 0
loc 78
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getPhotosFromResult() 0 10 1
A getHtmlAttributions() 0 3 1
A getWidth() 0 3 1
A __construct() 0 6 1
A getPhotoReference() 0 3 1
A getHeight() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Geocoder package.
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 *
10
 * @license    MIT License
11
 */
12
13
namespace Geocoder\Provider\GoogleMapsPlaces\Model;
14
15
/**
16
 * @author atymic <[email protected]>
17
 */
18
class Photo
19
{
20
    /**
21
     * @var string
22
     */
23
    private $photoReference;
24
25
    /**
26
     * @var int
27
     */
28
    private $height;
29
30
    /**
31
     * @var int
32
     */
33
    private $width;
34
35
    /**
36
     * @var array
37
     */
38
    private $htmlAttributions = [];
39
40
    /**
41
     * @param string $photoReference
42
     * @param int    $height
43
     * @param int    $width
44
     * @param array  $htmlAttributions
45
     */
46
    public function __construct(string $photoReference, int $height, int $width, array $htmlAttributions)
47
    {
48
        $this->photoReference = $photoReference;
49
        $this->height = $height;
50
        $this->width = $width;
51
        $this->htmlAttributions = $htmlAttributions;
52
    }
53
54
    /**
55
     * @return string
56
     */
57
    public function getPhotoReference(): string
58
    {
59
        return $this->photoReference;
60
    }
61
62
    /**
63
     * @return int
64
     */
65
    public function getHeight(): int
66
    {
67
        return $this->height;
68
    }
69
70
    /**
71
     * @return int
72
     */
73
    public function getWidth(): int
74
    {
75
        return $this->width;
76
    }
77
78
    /**
79
     * @return array
80
     */
81
    public function getHtmlAttributions(): array
82
    {
83
        return $this->htmlAttributions;
84
    }
85
86
    public static function getPhotosFromResult(array $photos): array
87
    {
88
        return array_map(function ($photo) {
89
            return new self(
90
                $photo->photo_reference,
91
                $photo->height,
92
                $photo->width,
93
                $photo->html_attributions
94
            );
95
        }, $photos);
96
    }
97
}
98