Converted API from Class to Trait

This commit is contained in:
Sys 2021-06-19 22:16:25 +02:00
parent d406940453
commit 032684b93a
No known key found for this signature in database
GPG Key ID: 3CD2C29F8AB39BFD
2 changed files with 7 additions and 10 deletions

View File

@ -47,7 +47,7 @@ if (is_dir($output)) {
echo '> Extracting JSON scheme.' . PHP_EOL;
$data = $generator->toJson();
} catch (Exception $e) {
echo '> ERROR: Unable to extract scheme:' . $e->getMessage() . PHP_EOL;
echo '> ERROR: Unable to extract scheme: ' . $e->getMessage() . PHP_EOL;
exit(1);
}
} else {
@ -65,7 +65,7 @@ if (is_dir($output)) {
echo '> Extracting JSON scheme.' . PHP_EOL;
$data = $generator->toJson();
} catch (Exception $e) {
echo '> ERROR: Unable to extract scheme:' . $e->getMessage() . PHP_EOL;
echo '> ERROR: Unable to extract scheme: ' . $e->getMessage() . PHP_EOL;
exit(1);
}
echo sprintf('> Outputting PHP stubs to %s.%s', realpath($output), PHP_EOL);

View File

@ -177,23 +177,20 @@ class StubCreator
$file = new PhpFile;
$file->addComment('@noinspection PhpUnused');
$file->addComment('@noinspection PhpUnusedParameterInspection');
$file->addComment('@noinspection PhpIncompatibleReturnTypeInspection');
$file->addComment('@noinspection PhpVoidFunctionResultUsedInspection');
$phpNamespace = $file->addNamespace($this->namespace);
$apiClass = $phpNamespace->addClass('API')
->setType('class');
->setTrait();
$apiClass->addMethod('__construct')
->setPublic()
->addPromotedParameter('client')
->setType('\GuzzleHttp\Client')
->setPrivate();
->setAbstract();
$sendRequest = $apiClass->addMethod('sendRequest')
->setPublic();
->setPublic()
->setAbstract()
->setReturnType(Type::MIXED);
$sendRequest->addParameter('method')
->setType(Type::STRING);
$sendRequest->addParameter('args')
->setType(Type::ARRAY);
$sendRequest->addBody('//TODO: add your logic here');
foreach ($this->scheme['methods'] as $method) {
$function = $apiClass->addMethod($method['name'])
->setPublic()