Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class exampleExternalAPI
- {
- public function echoString($string){
- echo $string;
- }
- }
- class api {
- public $APIs;
- public function __construct($setAPI = null){
- if (isset($setAPI)){
- return $this->setAPI($setAPI);
- }
- }
- public function setAPIs($setAPIs)
- {
- $this->APIs = new stdClass; // clears a previous call to this method
- if (!is_array($setAPIs)) { // if not an array
- $setAPIs = array($setAPIs); // make array
- }
- foreach ($setAPIs as $setAPIType) {
- if (class_exists($setAPIType)) {
- $this->APIs->$setAPIType = new $setAPIType;
- }
- }
- return $this->APIs;
- }
- public function getListOfAPIs($update = false){
- if ($update){
- $this->updateListOfAPIs();
- }
- return $this->listOfAPIs;
- }
- }
- $api = new api();
- $api->setAPIs('exampleExternalAPI');
- $api->APIs->exampleExternalAPI->echoString('string');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement