1 | <?php |
||
11 | class Google |
||
12 | { |
||
13 | const V1 = 'v1'; |
||
14 | |||
15 | protected $token; |
||
16 | protected $host; |
||
17 | protected $version; |
||
18 | protected $client; |
||
19 | |||
20 | /** |
||
21 | * Creates a Calendly instance that can register and unregister webhooks with the API |
||
22 | * @param string $token The API token to use |
||
23 | * @param string $version The API version to use |
||
24 | * @param string $host The Host URL |
||
25 | * @param string $client The Client instance that will handle the http request |
||
26 | */ |
||
27 | 24 | public function __construct($token, $version = self::V1, $host = "www.googleapis.com", Client $client = null){ |
|
33 | |||
34 | 12 | public function shorten($url, $encode = true) |
|
46 | |||
47 | /** |
||
48 | * Returns the response data or throws an Exception if it was unsuccessful |
||
49 | * @param string $raw The data from the response |
||
50 | * @return array |
||
51 | */ |
||
52 | 9 | protected function handleResponse($raw){ |
|
72 | |||
73 | /** |
||
74 | * Returns a corrected URL |
||
75 | * @param string $url The URL to modify |
||
76 | * @param boolean $encode Whether or not to encode the URL |
||
77 | * @return string The corrected URL |
||
78 | */ |
||
79 | 15 | protected function fixUrl($url, $encode){ |
|
90 | |||
91 | /** |
||
92 | * Builds the request URL to the Google API for a specified action |
||
93 | * @param string $action The long URL |
||
94 | * @param string $action The API action |
||
95 | * @return string The URL |
||
96 | */ |
||
97 | 12 | protected function buildRequestUrl($action = "url"){ |
|
100 | |||
101 | /** |
||
102 | * Returns the Client instance |
||
103 | * @return Client |
||
104 | */ |
||
105 | 9 | protected function getRequest(){ |
|
112 | |||
113 | /** |
||
114 | * Executes a CURL request to the Google API |
||
115 | * @param string $url The URL to shorten |
||
116 | * @return mixed The response data |
||
117 | */ |
||
118 | 9 | protected function exec($url) |
|
132 | } |
||
133 |
This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.
Unreachable code is most often the result of
return
,die
orexit
statements that have been added for debug purposes.In the above example, the last
return false
will never be executed, because a return statement has already been met in every possible execution path.