Jamm\Memory\Tests\TestMethodsGenerator::getTestMethodsForClass PHP Method

getTestMethodsForClass() public method

public getTestMethodsForClass ( string | object $Interface, string | object $ExistingMethodsInterface = '' ) : string
$Interface string | object
$ExistingMethodsInterface string | object
return string
    public function getTestMethodsForClass($Interface, $ExistingMethodsInterface = '')
    {
        $Reflection = new \ReflectionClass($Interface);
        $Methods = $Reflection->getMethods();
        $existing = [];
        if (!empty($ExistingMethodsInterface)) {
            $ExistingClass = new \ReflectionClass($ExistingMethodsInterface);
            $ExistingMethods = $ExistingClass->getMethods();
            if (!empty($ExistingMethods)) {
                foreach ($ExistingMethods as $ExistingMethod) {
                    $name = strtolower($ExistingMethod->name);
                    $name = str_replace('test_', '', $name);
                    $name = str_replace('test', '', $name);
                    $existing[$name] = 1;
                }
            }
        }
        $code = '';
        foreach ($Methods as $Method) {
            if ($Method->isPublic()) {
                $name = strtolower($Method->name);
                if (isset($existing[$name])) {
                    continue;
                }
                $code .= $this->getCodeForMethod($Method) . PHP_EOL;
            }
        }
        return $code;
    }