File tree Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Expand file tree Collapse file tree 4 files changed +26
-11
lines changed Original file line number Diff line number Diff line change 9
9
namespace Joomla \Github ;
10
10
11
11
use Joomla \Http \Exception \UnexpectedResponseException ;
12
+ use Joomla \Http \Http as BaseHttp ;
12
13
use Joomla \Http \Response ;
13
14
use Joomla \Uri \Uri ;
14
15
use Joomla \Registry \Registry ;
@@ -75,14 +76,14 @@ abstract class AbstractGithubObject
75
76
* Constructor.
76
77
*
77
78
* @param Registry $options GitHub options object.
78
- * @param Http $client The HTTP client object.
79
+ * @param BaseHttp $client The HTTP client object.
79
80
*
80
81
* @since 1.0
81
82
*/
82
- public function __construct (Registry $ options = null , Http $ client = null )
83
+ public function __construct (Registry $ options = null , BaseHttp $ client = null )
83
84
{
84
- $ this ->options = isset ( $ options) ? $ options : new Registry ;
85
- $ this ->client = isset ( $ client) ? $ client : new Http ($ this ->options );
85
+ $ this ->options = $ options ? : new Registry ;
86
+ $ this ->client = $ client ? : new Http ($ this ->options );
86
87
87
88
$ this ->package = get_class ($ this );
88
89
$ this ->package = substr ($ this ->package , strrpos ($ this ->package , '\\' ) + 1 );
Original file line number Diff line number Diff line change 8
8
9
9
namespace Joomla \Github ;
10
10
11
+ use Joomla \Http \Http as BaseHttp ;
11
12
use Joomla \Registry \Registry ;
12
13
13
14
/**
@@ -21,11 +22,11 @@ abstract class AbstractPackage extends AbstractGithubObject
21
22
* Constructor.
22
23
*
23
24
* @param Registry $options GitHub options object.
24
- * @param Http $client The HTTP client object.
25
+ * @param BaseHttp $client The HTTP client object.
25
26
*
26
27
* @since 1.0
27
28
*/
28
- public function __construct (Registry $ options = null , Http $ client = null )
29
+ public function __construct (Registry $ options = null , BaseHttp $ client = null )
29
30
{
30
31
parent ::__construct ($ options , $ client );
31
32
Original file line number Diff line number Diff line change 8
8
9
9
namespace Joomla \Github ;
10
10
11
+ use Joomla \Http \Http as BaseHttp ;
11
12
use Joomla \Registry \Registry ;
12
13
13
14
/**
@@ -50,20 +51,27 @@ class Github
50
51
* Constructor.
51
52
*
52
53
* @param Registry $options GitHub options object.
53
- * @param Http $client The HTTP client object.
54
+ * @param BaseHttp $client The HTTP client object.
54
55
*
55
56
* @since 1.0
56
57
*/
57
- public function __construct (Registry $ options = null , Http $ client = null )
58
+ public function __construct (Registry $ options = null , BaseHttp $ client = null )
58
59
{
59
- $ this ->options = isset ($ options ) ? $ options : new Registry ;
60
- $ this ->client = isset ($ client ) ? $ client : new Http ($ this ->options );
60
+ $ this ->options = $ options ?: new Registry ;
61
+
62
+ // Setup the default user agent if not already set.
63
+ if (!$ this ->getOption ('userAgent ' ))
64
+ {
65
+ $ this ->setOption ('userAgent ' , 'JGitHub/2.0 ' );
66
+ }
61
67
62
68
// Setup the default API url if not already set.
63
69
if (!$ this ->getOption ('api.url ' ))
64
70
{
65
71
$ this ->setOption ('api.url ' , 'https://api.github.com ' );
66
72
}
73
+
74
+ $ this ->client = $ client ?: new Http ($ this ->options );
67
75
}
68
76
69
77
/**
Original file line number Diff line number Diff line change 14
14
/**
15
15
* HTTP client class for connecting to a GitHub instance.
16
16
*
17
- * @since 1.0
17
+ * @since 1.0
18
+ * @deprecated 2.0 Use Joomla\Http\Http instead
18
19
*/
19
20
class Http extends BaseHttp
20
21
{
21
22
/**
22
23
* @const integer Use no authentication for HTTP connections.
23
24
* @since 1.0
25
+ * @deprecated 2.0
24
26
*/
25
27
const AUTHENTICATION_NONE = 0 ;
26
28
27
29
/**
28
30
* @const integer Use basic authentication for HTTP connections.
29
31
* @since 1.0
32
+ * @deprecated 2.0
30
33
*/
31
34
const AUTHENTICATION_BASIC = 1 ;
32
35
33
36
/**
34
37
* @const integer Use OAuth authentication for HTTP connections.
35
38
* @since 1.0
39
+ * @deprecated 2.0
36
40
*/
37
41
const AUTHENTICATION_OAUTH = 2 ;
38
42
@@ -43,6 +47,7 @@ class Http extends BaseHttp
43
47
* @param TransportInterface $transport The HTTP transport object.
44
48
*
45
49
* @since 1.0
50
+ * @deprecated 2.0
46
51
*/
47
52
public function __construct ($ options = array (), TransportInterface $ transport = null )
48
53
{
You can’t perform that action at this time.
0 commit comments