Pop\Code\Reflection::getClassNamespace PHP Method

getClassNamespace() protected method

Get the namespace and uses, if any
protected getClassNamespace ( ) : void
return void
    protected function getClassNamespace()
    {
        $fileContents = file_exists($this->getFilename()) ? file_get_contents($this->getFilename()) : null;
        // Detect and set namespace
        if ($this->inNamespace()) {
            $this->generator->setNamespace(new Generator\NamespaceGenerator($this->getNamespaceName()));
            if (null !== $fileContents) {
                $matches = array();
                preg_match('/^use(.*)/m', $fileContents, $matches, PREG_OFFSET_CAPTURE);
                if (isset($matches[0][0])) {
                    $uses = substr($fileContents, $matches[0][1] + 4);
                    $uses = substr($uses, 0, strpos($uses, ';'));
                    $usesAry = explode(',', $uses);
                    foreach ($usesAry as $use) {
                        $use = trim($use);
                        $as = null;
                        if (stripos($use, 'as') !== false) {
                            $as = trim(substr($use, strpos($use, 'as') + 2));
                            $use = trim(substr($use, 0, strpos($use, 'as')));
                        }
                        $this->generator->getNamespace()->setUse($use, $as);
                    }
                }
            }
        }
    }