for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Moka\Plugin;
use Moka\Exception\NotImplementedException;
class PluginHelper
{
/**
* The base namespace with plugin must be declared
*/
const PLUGIN_NAMESPACE_TEMPLATE = 'Moka\\Plugin\\%s\\%sPlugin';
* @param string $pluginName
* @return string
public static function generatePluginFQCN(string $pluginName): string
return sprintf(
self::PLUGIN_NAMESPACE_TEMPLATE,
ucfirst($pluginName),
ucfirst($pluginName)
);
}
* @throws NotImplementedException
public static function loadPlugin(string $pluginName): string
$pluginFQCN = PluginHelper::generatePluginFQCN($pluginName);
if (!class_exists($pluginFQCN) || !in_array(PluginInterface::class, class_implements($pluginFQCN), true)) {
throw new NotImplementedException(
sprintf(
'Mocking strategy "%s" does not exist',
$pluginName
)
return $pluginFQCN;