Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
10 / 10
CRAP
100.00% covered (success)
100.00%
1 / 1
Reflection
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
10 / 10
10
100.00% covered (success)
100.00%
1 / 1
 createClass
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createTrait
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createInterface
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createEnum
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createNamespace
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createDocblock
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createFunction
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createMethod
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createProperty
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createConstant
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2declare(strict_types=1);
3/**
4 * Pop PHP Framework (https://www.popphp.org/)
5 *
6 * @link       https://github.com/popphp/popphp-framework
7 * @author     Nick Sagona, III <dev@noladev.com>
8 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
9 * @license    https://www.popphp.org/license     New BSD License
10 */
11
12/**
13 * @namespace
14 */
15namespace Pop\Code;
16
17use Pop\Code\Reflection\Exception;
18use ReflectionException;
19
20/**
21 * Reflection code class
22 *
23 * @category   Pop
24 * @package    Pop\Code
25 * @author     Nick Sagona, III <dev@noladev.com>
26 * @copyright  Copyright (c) 2009-2027 NOLA Interactive, LLC.
27 * @license    https://www.popphp.org/license     New BSD License
28 * @version    6.0.0
29 */
30class Reflection
31{
32
33    /**
34     * Create class
35     *
36     * @param  mixed   $class
37     * @param  ?string $name
38     * @throws Exception
39     * @return Generator\ClassGenerator
40     */
41    public static function createClass(mixed $class, ?string $name = null): Generator\ClassGenerator
42    {
43        return Reflection\ClassReflection::parse($class, $name);
44    }
45
46    /**
47     * Create trait
48     *
49     * @param  mixed   $trait
50     * @param  ?string $name
51     * @throws Exception
52     * @return Generator\TraitGenerator
53     */
54    public static function createTrait(mixed $trait, ?string $name = null): Generator\TraitGenerator
55    {
56        return Reflection\TraitReflection::parse($trait, $name);
57    }
58
59    /**
60     * Create interface
61     *
62     * @param  mixed   $interface
63     * @param  ?string $name
64     * @throws Exception
65     * @return Generator\InterfaceGenerator
66     */
67    public static function createInterface(mixed $interface, ?string $name = null): Generator\InterfaceGenerator
68    {
69        return Reflection\InterfaceReflection::parse($interface, $name);
70    }
71
72    /**
73     * Create enum
74     *
75     * @param  mixed   $enum
76     * @param  ?string $name
77     * @throws Exception
78     * @return Generator\EnumGenerator
79     */
80    public static function createEnum(mixed $enum, ?string $name = null): Generator\EnumGenerator
81    {
82        return Reflection\EnumReflection::parse($enum, $name);
83    }
84
85    /**
86     * Create namespace
87     *
88     * @param  mixed  $namespace
89     * @param  ?string $name
90     * @throws Exception
91     * @return Generator\NamespaceGenerator
92     */
93    public static function createNamespace(mixed $namespace, ?string $name = null): Generator\NamespaceGenerator
94    {
95        return Reflection\NamespaceReflection::parse($namespace, $name);
96    }
97
98    /**
99     * Create docblock
100     *
101     * @param  mixed $docblock
102     * @param  ?int  $forceIndent
103     * @throws Exception
104     * @return Generator\DocblockGenerator
105     */
106    public static function createDocblock(mixed $docblock, ?int $forceIndent = null): Generator\DocblockGenerator
107    {
108        return Reflection\DocblockReflection::parse($docblock, $forceIndent);
109    }
110
111    /**
112     * Create function
113     *
114     * @param  mixed   $function
115     * @param  ?string $name
116     * @throws ReflectionException
117     * @return Generator\FunctionGenerator
118     */
119    public static function createFunction(mixed $function, ?string $name = null): Generator\FunctionGenerator
120    {
121        return Reflection\FunctionReflection::parse($function, $name);
122    }
123
124    /**
125     * Create method
126     *
127     * @param  mixed   $method
128     * @param  ?string $name
129     * @return Generator\MethodGenerator
130     */
131    public static function createMethod(mixed $method, ?string $name = null): Generator\MethodGenerator
132    {
133        return Reflection\MethodReflection::parse($method, $name);
134    }
135
136    /**
137     * Create property
138     *
139     * @param  mixed   $property
140     * @param  ?string $name
141     * @param  mixed   $value
142     * @return Generator\PropertyGenerator
143     */
144    public static function createProperty(mixed $property, ?string $name = null, mixed $value = null): Generator\PropertyGenerator
145    {
146        return Reflection\PropertyReflection::parse($property, $name, $value);
147    }
148
149    /**
150     * Create constant
151     *
152     * @param  mixed   $constant
153     * @param  ?string $name
154     * @return Generator\ConstantGenerator
155     */
156    public static function createConstant(mixed $constant, ?string $name = null): Generator\ConstantGenerator
157    {
158        return Reflection\ConstantReflection::parse($constant, $name);
159    }
160
161}