-
Notifications
You must be signed in to change notification settings - Fork 9
/
Package.php
84 lines (68 loc) · 1.71 KB
/
Package.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
<?php
/*
* This file is part of the Onion package.
*
* (c) Yo-An Lin <cornelius.howl@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
*/
namespace Onion\Pear;
use Onion\Package\PackageInterface;
use Exception;
/**
* pear channel package
* */
class Package
implements PackageInterface
{
public $name;
public $desc;
public $summary;
public $channel;
public $license;
/* last version */
public $latest;
/* last stable version */
public $stable;
/* last alpha version */
public $alpha;
/* last beta version */
public $beta;
/* all releases */
public $releases = array();
/**
* dependencies
*/
public $deps = array();
public function getId()
{
return $this->name;
}
public function __sleep()
{
return array('name','summary','channel','desc','license','latest','stable','alpha','beta','releases','deps');
}
public function __wakeup()
{
}
public function getLastDistUrl()
{
return $this->getDistUrlByVersion( $this->latest );
}
public function getDistUrlByVersion($version, $extension = 'tgz' )
{
// xxx: save for https or http base url from channel discover object
return sprintf( 'http://%s/get/%s-%s.%s' , $this->channel, $this->name , $version , $extension );
}
public function toArray()
{
return (array) $this;
$a = array('name','summary','channel','desc','license','latest','stable','alpha','beta','releases','deps');
foreach( array() as $k ) {
$a[ $k ] = $this->{ $k };
}
return $a;
}
}