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