У меня есть два класса в php.класс A и класс B. В классе A у меня есть несколько функций, и я хочу вызвать функции класса A в классе B и получить значения в классе B. Вот классы:
Класс A:
<?php
require_once './vendor/autoload.php';
use GuzzleHttp\Client;
class A {
/**
* Undocumented variable
*
* @var Client
*/
protected $client;
public function __construct()
{
$apikey = '000000000000000';
$this->client = new Client([
'base_uri'=>'https://api.omnivore.io/',
'headers' => [
'Api-Key'=>$apikey,
'Content-Type' => 'application/json',
]
]);
}
public function getMerchant(){
$response = $this->client->request('GET','locations');
$output = $response->getBody()->getContents();
$merchants = json_decode($output, true);
}
public function getMenu(){
$response = $this->client->request('GET','locations/iE7EBzbT/menu');
$output = $response->getBody()->getContents();
$menu = json_decode($output, true);
}
}
Класс B:
<?php
class B
{
protected $client;
public function index() {
$apiClient = new A();
$app = $apiClient->getMerchant();
print_r($app) ;
}
}
?>
Итак, вопрос в том, как я могу получить значения продавца в классе B в индексной функции.Любая помощь будет очень ценной.