Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 153 lines (135 sloc) 3.048 kB
fb0ed1a @fxb Initial import
authored
1 <?
2
f3041d3 @fxb Actually this should've been the initial import
authored
3 /** Represents some kind of media and provides common information.
4 *
a8a3d9a @fxb Changed package name
authored
5 * @package php-lastfm-api
f3041d3 @fxb Actually this should've been the initial import
authored
6 * @author Felix Bruns <felixbruns@web.de>
7 * @version 1.0
8 */
fb0ed1a @fxb Initial import
authored
9 class Media {
f3041d3 @fxb Actually this should've been the initial import
authored
10 /** Name of this medium.
11 *
12 * @var string
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
13 * @access private
f3041d3 @fxb Actually this should've been the initial import
authored
14 */
fb0ed1a @fxb Initial import
authored
15 private $name;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
16
f3041d3 @fxb Actually this should've been the initial import
authored
17 /** MusicBrainz ID of this medium.
18 *
19 * @var string
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
20 * @access private
f3041d3 @fxb Actually this should've been the initial import
authored
21 */
fb0ed1a @fxb Initial import
authored
22 private $mbid;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
23
f3041d3 @fxb Actually this should've been the initial import
authored
24 /** Last.fm URL of this medium.
25 *
26 * @var string
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
27 * @access private
f3041d3 @fxb Actually this should've been the initial import
authored
28 */
fb0ed1a @fxb Initial import
authored
29 private $url;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
30
f3041d3 @fxb Actually this should've been the initial import
authored
31 /** An array of images of this medium.
32 *
33 * @var array
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
34 * @access private
f3041d3 @fxb Actually this should've been the initial import
authored
35 */
fb0ed1a @fxb Initial import
authored
36 private $images;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
37
f3041d3 @fxb Actually this should've been the initial import
authored
38 /** Number of listeners of this medium.
39 *
40 * @var integer
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
41 * @access private
f3041d3 @fxb Actually this should've been the initial import
authored
42 */
fb0ed1a @fxb Initial import
authored
43 private $listeners;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
44
f3041d3 @fxb Actually this should've been the initial import
authored
45 /** Play count of this medium.
46 *
47 * @var integer
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
48 * @access private
f3041d3 @fxb Actually this should've been the initial import
authored
49 */
fb0ed1a @fxb Initial import
authored
50 private $playCount;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
51
f3041d3 @fxb Actually this should've been the initial import
authored
52 /** Possible image sizes.
53 *
54 * @var integer
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
55 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
56 */
57 const IMAGE_UNKNOWN = -1;
58 const IMAGE_SMALL = 0;
59 const IMAGE_MEDIUM = 1;
60 const IMAGE_LARGE = 2;
61 const IMAGE_HUGE = 3;
62 const IMAGE_EXTRALARGE = 4;
63 const IMAGE_ORIGINAL = 5;
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
64
f3041d3 @fxb Actually this should've been the initial import
authored
65 /** Create a media object.
66 *
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
67 * @param string $name Name for this medium.
68 * @param string $mbid MusicBrainz ID for this medium.
69 * @param string $url Last.fm URL for this medium.
70 * @param array $images An array of images of different sizes.
71 * @param integer $listeners Number of listeners for this medium.
72 * @param integer $playCount Play count of this medium.
73 *
74 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
75 */
fb0ed1a @fxb Initial import
authored
76 public function __construct($name, $mbid, $url, array $images, $listeners,
77 $playCount){
78 $this->name = $name;
79 $this->mbid = $mbid;
80 $this->url = $url;
81 $this->images = $images;
82 $this->listeners = $listeners;
83 $this->playCount = $playCount;
84 }
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
85
f3041d3 @fxb Actually this should've been the initial import
authored
86 /** Returns the name of this medium.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
87 *
f3041d3 @fxb Actually this should've been the initial import
authored
88 * @return string The mediums name.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
89 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
90 */
fb0ed1a @fxb Initial import
authored
91 public function getName(){
92 return $this->name;
93 }
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
94
f3041d3 @fxb Actually this should've been the initial import
authored
95 /** Returns the MusicBrainz ID of this medium.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
96 *
f3041d3 @fxb Actually this should've been the initial import
authored
97 * @return string MusicBrainz ID.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
98 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
99 */
fb0ed1a @fxb Initial import
authored
100 public function getMbid(){
101 return $this->mbid;
102 }
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
103
104 /** Returns the last.fm URL of this medium.
105 *
f3041d3 @fxb Actually this should've been the initial import
authored
106 * @return string Last.fm URL.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
107 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
108 */
fb0ed1a @fxb Initial import
authored
109 public function getUrl(){
110 return $this->url;
111 }
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
112
f3041d3 @fxb Actually this should've been the initial import
authored
113 /** Returns an image URL of the specified size of this medium.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
114 *
8342b38 @fxb PaginatedResult now implements the Iterator interface and Media::getI…
authored
115 * @param integer $size Image size constant. (Optional)
f3041d3 @fxb Actually this should've been the initial import
authored
116 * @return string An image URL.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
117 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
118 */
8342b38 @fxb PaginatedResult now implements the Iterator interface and Media::getI…
authored
119 public function getImage($size = null){
120 if($size != null){
121 return $this->images[$size];
122 }
123
124 for($size = Media::IMAGE_ORIGINAL; $size > Media::IMAGE_UNKNOWN; $size--){
125 if(array_key_exists($size, $this->images)){
126 return $this->images[$size];
127 }
128 }
129
130 return null;
fb0ed1a @fxb Initial import
authored
131 }
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
132
f3041d3 @fxb Actually this should've been the initial import
authored
133 /** Returns the number of listeners of this medium.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
134 *
f3041d3 @fxb Actually this should've been the initial import
authored
135 * @return integer Number of listeners.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
136 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
137 */
fb0ed1a @fxb Initial import
authored
138 public function getListeners(){
139 return $this->listeners;
140 }
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
141
f3041d3 @fxb Actually this should've been the initial import
authored
142 /** Returns the play count of this medium.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
143 *
f3041d3 @fxb Actually this should've been the initial import
authored
144 * @return integer Play count.
0d36fef @fxb More documentation, exceptions and some small fixes/changes
authored
145 * @access public
f3041d3 @fxb Actually this should've been the initial import
authored
146 */
fb0ed1a @fxb Initial import
authored
147 public function getPlayCount(){
148 return $this->playCount;
149 }
150 }
151
152 ?>
Something went wrong with that request. Please try again.