@@ -31,31 +31,31 @@ discard block |
||
| 31 | 31 | |
| 32 | 32 | public $requestOptions = array(); |
| 33 | 33 | |
| 34 | - public function __construct($firebaseURI,$firebaseSecret = '',$firebaseDefaultPath = '/') |
|
| 34 | + public function __construct($firebaseURI, $firebaseSecret = '', $firebaseDefaultPath = '/') |
|
| 35 | 35 | { |
| 36 | 36 | $this->firebaseSecret = $firebaseSecret; |
| 37 | 37 | $this->firebaseURI = $firebaseURI; |
| 38 | 38 | $this->firebaseDefaultPath = $firebaseDefaultPath; |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - public function getPathURI($path = ''){ |
|
| 41 | + public function getPathURI($path = '') { |
|
| 42 | 42 | //remove .json or last slash from firebaseURI |
| 43 | 43 | $templates = array( |
| 44 | 44 | '.json', |
| 45 | 45 | '/.json', |
| 46 | 46 | '/' |
| 47 | 47 | ); |
| 48 | - foreach ($templates as $template){ |
|
| 49 | - $this->firebaseURI = rtrim($this->firebaseURI,$template); |
|
| 48 | + foreach ($templates as $template) { |
|
| 49 | + $this->firebaseURI = rtrim($this->firebaseURI, $template); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | //check https |
| 53 | - if(strpos($this->firebaseURI, 'http://') !== false){ |
|
| 53 | + if (strpos($this->firebaseURI, 'http://') !== false) { |
|
| 54 | 54 | throw new \Exception("https is required."); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | //check firebaseURI |
| 58 | - if(strlen($this->firebaseURI) == 0){ |
|
| 58 | + if (strlen($this->firebaseURI) == 0) { |
|
| 59 | 59 | throw new \Exception("firebase URI is required"); |
| 60 | 60 | } |
| 61 | 61 | |
@@ -68,12 +68,12 @@ discard block |
||
| 68 | 68 | * @param array $options |
| 69 | 69 | * @return \Requests_Response |
| 70 | 70 | */ |
| 71 | - public function get($path = '',$options = array()){ |
|
| 72 | - return Requests::get($this->getPathURI($path),$this->requestHeader,$this->mergeRequestOptions($options)); |
|
| 71 | + public function get($path = '', $options = array()) { |
|
| 72 | + return Requests::get($this->getPathURI($path), $this->requestHeader, $this->mergeRequestOptions($options)); |
|
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function getShallow($path = '',$options = array()){ |
|
| 76 | - return Requests::get($this->getPathURI($path). '?' . http_build_query(array(self::OPTION_SHALLOW => 'true')), |
|
| 75 | + public function getShallow($path = '', $options = array()) { |
|
| 76 | + return Requests::get($this->getPathURI($path).'?'.http_build_query(array(self::OPTION_SHALLOW => 'true')), |
|
| 77 | 77 | $this->mergeRequestOptions($options)); |
| 78 | 78 | } |
| 79 | 79 | |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | * @param array $options |
| 83 | 83 | * @return \Requests_Response |
| 84 | 84 | */ |
| 85 | - public function put($path = '',$options = array()){ |
|
| 86 | - return Requests::put($this->getPathURI($path),$this->requestHeader,$this->mergeRequestOptions($options,true)); |
|
| 85 | + public function put($path = '', $options = array()) { |
|
| 86 | + return Requests::put($this->getPathURI($path), $this->requestHeader, $this->mergeRequestOptions($options, true)); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -91,8 +91,8 @@ discard block |
||
| 91 | 91 | * @param array $options |
| 92 | 92 | * @return \Requests_Response |
| 93 | 93 | */ |
| 94 | - public function post($path = '',$options = array()){ |
|
| 95 | - return Requests::post($this->getPathURI($path),$this->requestHeader,$this->mergeRequestOptions($options,true)); |
|
| 94 | + public function post($path = '', $options = array()) { |
|
| 95 | + return Requests::post($this->getPathURI($path), $this->requestHeader, $this->mergeRequestOptions($options, true)); |
|
| 96 | 96 | } |
| 97 | 97 | |
| 98 | 98 | /** |
@@ -100,8 +100,8 @@ discard block |
||
| 100 | 100 | * @param array $options |
| 101 | 101 | * @return \Requests_Response |
| 102 | 102 | */ |
| 103 | - public function patch($path = '',$options = array()){ |
|
| 104 | - return Requests::patch($this->getPathURI($path),$this->requestHeader,$this->mergeRequestOptions($options,true)); |
|
| 103 | + public function patch($path = '', $options = array()) { |
|
| 104 | + return Requests::patch($this->getPathURI($path), $this->requestHeader, $this->mergeRequestOptions($options, true)); |
|
| 105 | 105 | } |
| 106 | 106 | |
| 107 | 107 | /** |
@@ -109,18 +109,18 @@ discard block |
||
| 109 | 109 | * @param array $options |
| 110 | 110 | * @return \Requests_Response |
| 111 | 111 | */ |
| 112 | - public function delete($path = '',$options = array()){ |
|
| 113 | - return Requests::delete($this->getPathURI($path),$this->requestHeader,$this->mergeRequestOptions($options)); |
|
| 112 | + public function delete($path = '', $options = array()) { |
|
| 113 | + return Requests::delete($this->getPathURI($path), $this->requestHeader, $this->mergeRequestOptions($options)); |
|
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - protected function mergeRequestOptions($options = array(),$encode = false){ |
|
| 116 | + protected function mergeRequestOptions($options = array(), $encode = false) { |
|
| 117 | 117 | $requestOptions = array(); |
| 118 | 118 | |
| 119 | - if(isset($options['data'])){ |
|
| 120 | - $requestOptions = array_merge($options['data'],$requestOptions); |
|
| 119 | + if (isset($options['data'])) { |
|
| 120 | + $requestOptions = array_merge($options['data'], $requestOptions); |
|
| 121 | 121 | } |
| 122 | 122 | |
| 123 | - if($encode){ |
|
| 123 | + if ($encode) { |
|
| 124 | 124 | $requestOptions = json_encode($requestOptions); |
| 125 | 125 | } |
| 126 | 126 | |