Spamworldpro Mini Shell
Spamworldpro


Server : Apache
System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64
User : corals ( 1002)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
Directory :  /home/corals/old/dev/tests/static/framework/Magento/TestFramework/Utility/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/corals/old/dev/tests/static/framework/Magento/TestFramework/Utility/ClassNameExtractor.php
<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
namespace Magento\TestFramework\Utility;

class ClassNameExtractor
{
    /**
     * Get class name with namespace
     *
     * @param string $fileContent
     * @return bool|string
     */
    public function getNameWithNamespace($fileContent)
    {
        $namespace = $this->getNamespace($fileContent);
        $name = $this->getName($fileContent);
        if ($name) {
            return $namespace ? $namespace . '\\' . $name : $name;
        }
        return false;
    }

    /**
     * Get class name
     *
     * @param string $fileContent
     * @return string|bool
     */
    public function getName($fileContent)
    {
        $namespace = $this->getNamespace($fileContent);
        if (isset($namespace)) {
            preg_match_all(
                '/^\s*(class|abstract\sclass|interface)\s+([a-z0-9]+)(\s+(extends|implements)|\s*$)/im',
                $fileContent,
                $classMatches
            );
            if (isset($classMatches[2][0])) {
                return $classMatches[2][0];
            }
        }
        return false;
    }

    /**
     * Get class namespace
     *
     * @param string $fileContent
     * @return string|bool
     */
    public function getNamespace($fileContent)
    {
        preg_match_all(
            '/namespace\s([a-z0-9\\\\]+);/im',
            $fileContent,
            $namespaceMatches
        );
        if (isset($namespaceMatches[1][0])) {
            return $namespaceMatches[1][0];
        }
        return false;
    }
}

Spamworldpro Mini