scratch – Blame information for rev 87

Subversion Repositories:
Rev:
Rev Author Line No. Line
87 office 1 <?php
2  
3 namespace Fusonic\OpenGraph\Elements;
4  
5 use Fusonic\OpenGraph\Property;
6  
7 /**
8 * An Open Graph image element.
9 */
10 class Image extends ElementBase
11 {
12 /**
13 * The URL of an image resource associated with the object.
14 *
15 * @var string
16 */
17 public $url;
18  
19 /**
20 * An alternate URL to use if an image resource requires HTTPS.
21 *
22 * @var string
23 */
24 public $secureUrl;
25  
26 /**
27 * The MIME type of an image resource.
28 *
29 * @var type
30 */
31 public $type;
32  
33 /**
34 * The width of an image resource in pixels.
35 *
36 * @var int
37 */
38 public $width;
39  
40 /**
41 * The height of an image resource in pixels.
42 *
43 * @var int
44 */
45 public $height;
46  
47 /**
48 * Whether the image is user-generated or not.
49 *
50 * @var bool
51 */
52 public $userGenerated;
53  
54 /**
55 * @param string $url URL to the image file.
56 */
57 public function __construct($url)
58 {
59 parent::__construct();
60  
61 $this->url = $url;
62 }
63  
64 /**
65 * Gets all properties set on this element.
66 *
67 * @return array|Property[]
68 */
69 public function getProperties()
70 {
71 $properties = [];
72  
73 // URL must precede all other properties
74 if ($this->url !== null) {
75 $properties[] = new Property(Property::IMAGE_URL, $this->url);
76 }
77  
78 if ($this->height !== null) {
79 $properties[] = new Property(Property::IMAGE_HEIGHT, $this->height);
80 }
81  
82 if ($this->secureUrl !== null) {
83 $properties[] = new Property(Property::IMAGE_SECURE_URL, $this->secureUrl);
84 }
85  
86 if ($this->type !== null) {
87 $properties[] = new Property(Property::IMAGE_TYPE, $this->type);
88 }
89  
90 if ($this->width !== null) {
91 $properties[] = new Property(Property::IMAGE_WIDTH, $this->width);
92 }
93  
94 if ($this->userGenerated !== null) {
95 $properties[] = new Property(Property::IMAGE_USER_GENERATED, $this->userGenerated);
96 }
97  
98 return $properties;
99 }
100 }