1
|
<?php
|
2
|
|
3
|
|
4
|
class ImageMediaItem {
|
5
|
|
6
|
private $size;
|
7
|
private $url;
|
8
|
|
9
|
/**
|
10
|
* ImageMediaItem constructor.
|
11
|
*/
|
12
|
public function __construct($url, MediaSize $size = null) {
|
13
|
$this->size = $size;
|
14
|
$this->url = $url;
|
15
|
}
|
16
|
|
17
|
public static function fromMediaRepresentationPart($mediaRepresentationPart){
|
18
|
$h = @$mediaRepresentationPart->height;
|
19
|
$w = @$mediaRepresentationPart->width;
|
20
|
return new ImageMediaItem($mediaRepresentationPart->uri, new MediaSize($w, $h));
|
21
|
}
|
22
|
|
23
|
/**
|
24
|
* @return \MediaSize
|
25
|
*/
|
26
|
public function getSize() {
|
27
|
return $this->size;
|
28
|
}
|
29
|
|
30
|
/**
|
31
|
* @return mixed
|
32
|
*/
|
33
|
public function getUrl() {
|
34
|
return $this->url;
|
35
|
}
|
36
|
|
37
|
}
|