PHP code example of codexsoft / transmission-ts-converter
1. Go to this page and download the library: Download codexsoft/transmission-ts-converter library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
codexsoft / transmission-ts-converter example snippets
$toTs = (new TransmissionToTypescriptConverter());
$toTs->addKnownConverter(MyElement::class => MyElementTsConverter::class);
// ...preparing Symfony Finder or whatever
$endpointReflections = [];
foreach ($finder->getIterator() as $fileInfo) {
$fqnClassName = (string) 'App'.(new \Stringy\Stringy($fileInfo->getRealPath()))
->removeRight('.php')
->replace('/', "\\");
$reflectionClass = new \ReflectionClass($fqnClassName);
if ($reflectionClass->isAbstract()) {
continue;
}
if (!$reflectionClass->implementsInterface(OpenApi3OperationInterface::class)) {
continue;
}
$endpointReflections[] = $reflectionClass;
$toTs = (new TransmissionToTypescriptConverter());
/**
* Set ref interface name generator
*/
$toTs->setCreateRefClosure(function(string $class) {
$reflection = new \ReflectionClass($class);
return (string) (new \Stringy\Stringy('I'.$reflection->getShortName()))->removeRight('Transformer');
});
}
shell script
php ./vendor/bin/phpunit