Demo::fromPath PHP Méthode

fromPath() public static méthode

public static fromPath ( $path )
    public static function fromPath($path)
    {
        $codePath = __DIR__ . '/../demo/' . $path;
        $outputPath = __DIR__ . '/../demo/' . $path . '.expect';
        assert(file_exists($codePath), "code does not exist {$codePath}");
        assert(file_exists($outputPath), "output does not exist {$outputPath}");
        return new Demo($path, file_get_contents($codePath), trim(file_get_contents($outputPath)));
    }

Usage Example

Exemple #1
0
 public static function fromReflectionMethod(\ReflectionMethod $method)
 {
     $methodName = $method->getName();
     $docComment = $method->getDocComment();
     $reactivexId = extract_doc_annotation($docComment, '@reactivex');
     $demoFiles = extract_doc_annotations($docComment, '@demo');
     $description = extract_doc_description($docComment);
     $isObservable = Str::contains($docComment, '@observable');
     $demos = array_map(function ($path) {
         return Demo::fromPath($path);
     }, $demoFiles);
     return new DocumentedMethod($methodName, $reactivexId, $description, $demos, $isObservable);
 }