More tidying.
[yaffs-website] / vendor / consolidation / annotated-command / src / Parser / Internal / CommandDocBlockParserFactory.php
1 <?php
2 namespace Consolidation\AnnotatedCommand\Parser\Internal;
3
4 use Consolidation\AnnotatedCommand\Parser\CommandInfo;
5
6 /**
7  * Create an appropriate CommandDocBlockParser.
8  */
9 class CommandDocBlockParserFactory
10 {
11     public static function parse(CommandInfo $commandInfo, \ReflectionMethod $reflection)
12     {
13         return static::create($commandInfo, $reflection)->parse();
14     }
15
16     private static function create(CommandInfo $commandInfo, \ReflectionMethod $reflection)
17     {
18         if (static::hasReflectionDocBlock3()) {
19             return new CommandDocBlockParser3($commandInfo, $reflection);
20         }
21         return new CommandDocBlockParser2($commandInfo, $reflection);
22     }
23
24     private static function hasReflectionDocBlock3()
25     {
26         return class_exists('phpDocumentor\Reflection\DocBlockFactory') && class_exists('phpDocumentor\Reflection\Types\ContextFactory');
27     }
28 }