misc_pterodactyl-panel/app/Transformers/Api/Application/BaseTransformer.php

32 lines
1.1 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Transformers\Api\Application;
use Illuminate\Container\Container;
use Pterodactyl\Transformers\Api\Transformer;
use Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException;
abstract class BaseTransformer extends Transformer
{
/**
* Create a new instance of the transformer and pass along the currently
* set API key.
*
* @return \Pterodactyl\Transformers\Api\Application\BaseTransformer
*
* @throws \Illuminate\Contracts\Container\BindingResolutionException
* @throws \Pterodactyl\Exceptions\Transformer\InvalidTransformerLevelException
*/
protected function makeTransformer(string $abstract, array $parameters = [])
{
/** @var \Pterodactyl\Transformers\Api\Application\BaseTransformer $transformer */
$transformer = Container::getInstance()->makeWith($abstract, $parameters);
2021-01-24 01:17:35 +00:00
if (!$transformer instanceof self) {
throw new InvalidTransformerLevelException('Calls to ' . __METHOD__ . ' must return a transformer that is an instance of ' . __CLASS__);
}
return $transformer;
}
}