|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Part of the Joomla Framework Github Package |
|
4
|
|
|
* |
|
5
|
|
|
* @copyright Copyright (C) 2005 - 2015 Open Source Matters, Inc. All rights reserved. |
|
6
|
|
|
* @license GNU General Public License version 2 or later; see LICENSE |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace Joomla\Github; |
|
10
|
|
|
|
|
11
|
|
|
use Joomla\Registry\Registry; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* GitHub API package class for the Joomla Framework. |
|
15
|
|
|
* |
|
16
|
|
|
* @since 1.0 |
|
17
|
|
|
*/ |
|
18
|
|
|
abstract class AbstractPackage extends AbstractGithubObject |
|
19
|
|
|
{ |
|
20
|
|
|
/** |
|
21
|
|
|
* Constructor. |
|
22
|
|
|
* |
|
23
|
|
|
* @param Registry $options GitHub options object. |
|
24
|
|
|
* @param Http $client The HTTP client object. |
|
25
|
|
|
* |
|
26
|
|
|
* @since 1.0 |
|
27
|
|
|
*/ |
|
28
|
|
|
public function __construct(Registry $options = null, Http $client = null) |
|
29
|
|
|
{ |
|
30
|
|
|
parent::__construct($options, $client); |
|
31
|
|
|
|
|
32
|
|
|
$this->package = get_class($this); |
|
33
|
|
|
$this->package = substr($this->package, strrpos($this->package, '\\') + 1); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* Magic method to lazily create API objects |
|
38
|
|
|
* |
|
39
|
|
|
* @param string $name Name of property to retrieve |
|
40
|
|
|
* |
|
41
|
|
|
* @since 1.0 |
|
42
|
|
|
* @throws \InvalidArgumentException |
|
43
|
|
|
* |
|
44
|
|
|
* @return AbstractPackage GitHub API package object. |
|
45
|
|
|
*/ |
|
46
|
|
|
public function __get($name) |
|
47
|
|
|
{ |
|
48
|
|
|
$class = '\\Joomla\\Github\\Package\\' . $this->package . '\\' . ucfirst($name); |
|
49
|
|
|
|
|
50
|
|
|
if (false == class_exists($class)) |
|
|
|
|
|
|
51
|
|
|
{ |
|
52
|
|
|
throw new \InvalidArgumentException( |
|
53
|
|
|
sprintf( |
|
54
|
|
|
'Argument %1$s produced an invalid class name: %2$s in package %3$s', |
|
55
|
|
|
$name, $class, $this->package |
|
56
|
|
|
) |
|
57
|
|
|
); |
|
58
|
|
|
} |
|
59
|
|
|
|
|
60
|
|
View Code Duplication |
if (false == isset($this->$name)) |
|
|
|
|
|
|
61
|
|
|
{ |
|
62
|
|
|
$this->$name = new $class($this->options, $this->client); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
return $this->$name; |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
When comparing two booleans, it is generally considered safer to use the strict comparison operator.