Completed
Pull Request — develop (#1350)
by Naveen
03:22
created

Video   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 89
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 89
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A from() 0 7 3
A get_data() 0 14 1
1
<?php
2
/**
3
 * @since 3.31.0
4
 * @author Naveen Muthusamy <[email protected]>
5
 */
6
7
namespace Wordlift\Videoobject\Data\Video;
8
9
class Video {
10
	/**
11
	 * @var string The title of the video.
12
	 */
13
	public $name;
14
15
	/**
16
	 * @var string The video description.
17
	 */
18
	public $description;
19
20
	/**
21
	 * @var array Thumbnail urls.
22
	 */
23
	public $thumbnail_urls;
24
25
	/**
26
	 * @var string Published date.
27
	 */
28
	public $upload_date;
29
30
	/**
31
	 * @var string Video url.
32
	 */
33
	public $content_url;
34
35
	/**
36
	 * @var string Video duration in IS08601 format.
37
	 */
38
	public $duration;
39
40
	/**
41
	 * @var string
42
	 */
43
	public $embed_url;
44
45
	/**
46
	 * @var string An unique identifier, usually the video url.
47
	 */
48
	public $id;
49
50
	/**
51
	 * @var int The number of views for the video.
52
	 */
53
	public $views;
54
55
56
	/**
57
	 * All the live video properties.
58
	 */
59
	/**
60
	 * @var bool
61
	 */
62
	public $is_live_video;
63
64
	/**
65
	 * @var string Live video start date
66
	 */
67
	public $live_video_start_date;
68
69
	/**
70
	 * @var string Live video end date
71
	 */
72
	public $live_video_end_date;
73
74
	public function from( $data ) {
75
		$keys = array_keys( get_class_vars( get_class( $this ) ) );
76
		// Loop through the keys and set the value from array
77
		foreach ( $keys as $key ) {
78
			$this->$key = array_key_exists( $key, $data ) ? $data[ $key ] : null;
79
		}
80
	}
81
82
	public function get_data() {
83
84
		return array(
85
			'@type'        => 'VideoObject',
86
			'name'         => $this->name,
87
			'description'  => $this->description,
88
			'contentUrl'   => $this->content_url,
89
			'embedUrl'     => $this->embed_url,
90
			'uploadDate'   => $this->upload_date,
91
			'thumbnailUrl' => $this->thumbnail_urls,
92
			'duration'     => $this->duration
93
		);
94
95
	}
96
97
}