File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99namespace Joomla \Github ;
1010
1111use Joomla \Http \Exception \UnexpectedResponseException ;
12+ use Joomla \Http \Http as BaseHttp ;
1213use Joomla \Http \Response ;
1314use Joomla \Uri \Uri ;
1415use Joomla \Registry \Registry ;
@@ -75,14 +76,14 @@ abstract class AbstractGithubObject
7576 * Constructor.
7677 *
7778 * @param Registry $options GitHub options object.
78- * @param Http $client The HTTP client object.
79+ * @param BaseHttp $client The HTTP client object.
7980 *
8081 * @since 1.0
8182 */
82- public function __construct (Registry $ options = null , Http $ client = null )
83+ public function __construct (Registry $ options = null , BaseHttp $ client = null )
8384 {
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 );
8687
8788 $ this ->package = get_class ($ this );
8889 $ this ->package = substr ($ this ->package , strrpos ($ this ->package , '\\' ) + 1 );
Original file line number Diff line number Diff line change 88
99namespace Joomla \Github ;
1010
11+ use Joomla \Http \Http as BaseHttp ;
1112use Joomla \Registry \Registry ;
1213
1314/**
@@ -21,11 +22,11 @@ abstract class AbstractPackage extends AbstractGithubObject
2122 * Constructor.
2223 *
2324 * @param Registry $options GitHub options object.
24- * @param Http $client The HTTP client object.
25+ * @param BaseHttp $client The HTTP client object.
2526 *
2627 * @since 1.0
2728 */
28- public function __construct (Registry $ options = null , Http $ client = null )
29+ public function __construct (Registry $ options = null , BaseHttp $ client = null )
2930 {
3031 parent ::__construct ($ options , $ client );
3132
Original file line number Diff line number Diff line change 88
99namespace Joomla \Github ;
1010
11+ use Joomla \Http \Http as BaseHttp ;
1112use Joomla \Registry \Registry ;
1213
1314/**
@@ -50,20 +51,27 @@ class Github
5051 * Constructor.
5152 *
5253 * @param Registry $options GitHub options object.
53- * @param Http $client The HTTP client object.
54+ * @param BaseHttp $client The HTTP client object.
5455 *
5556 * @since 1.0
5657 */
57- public function __construct (Registry $ options = null , Http $ client = null )
58+ public function __construct (Registry $ options = null , BaseHttp $ client = null )
5859 {
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+ }
6167
6268 // Setup the default API url if not already set.
6369 if (!$ this ->getOption ('api.url ' ))
6470 {
6571 $ this ->setOption ('api.url ' , 'https://api.github.com ' );
6672 }
73+
74+ $ this ->client = $ client ?: new Http ($ this ->options );
6775 }
6876
6977 /**
Original file line number Diff line number Diff line change 1414/**
1515 * HTTP client class for connecting to a GitHub instance.
1616 *
17- * @since 1.0
17+ * @since 1.0
18+ * @deprecated 2.0 Use Joomla\Http\Http instead
1819 */
1920class Http extends BaseHttp
2021{
2122 /**
2223 * @const integer Use no authentication for HTTP connections.
2324 * @since 1.0
25+ * @deprecated 2.0
2426 */
2527 const AUTHENTICATION_NONE = 0 ;
2628
2729 /**
2830 * @const integer Use basic authentication for HTTP connections.
2931 * @since 1.0
32+ * @deprecated 2.0
3033 */
3134 const AUTHENTICATION_BASIC = 1 ;
3235
3336 /**
3437 * @const integer Use OAuth authentication for HTTP connections.
3538 * @since 1.0
39+ * @deprecated 2.0
3640 */
3741 const AUTHENTICATION_OAUTH = 2 ;
3842
@@ -43,6 +47,7 @@ class Http extends BaseHttp
4347 * @param TransportInterface $transport The HTTP transport object.
4448 *
4549 * @since 1.0
50+ * @deprecated 2.0
4651 */
4752 public function __construct ($ options = array (), TransportInterface $ transport = null )
4853 {
You can’t perform that action at this time.
0 commit comments