Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace libs;
- class Base
- {
- const BASE_URL = 'https://api.something.loc/';
- function __construct($keyId, $vCode)
- {
- $this->keyId = $keyId;
- $this->vCode = $vCode;
- }
- /**
- * Return API URI
- * @param [string] $api api name
- * @return [string] API URI
- */
- public function get($api, array $params = [])
- {
- if (method_exists($this, $api)) {
- $data['url'] = $this->$api($params);
- } else {
- return false;
- }
- $uri = self::BASE_URL.$data['url'].'?';
- if ($params) {
- foreach ($params as $p_name => $p_value) {
- $uri .= '&'.$p_name.'='.$p_value;
- }
- }
- $uri .= '&keyID='.$this->keyId.'&vCode='.$this->vCode;
- return $uri;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement