andrey-helldar /
support
| 1 | <?php |
||
| 2 | /****************************************************************************** |
||
| 3 | * This file is part of the "andrey-helldar/support" project. * |
||
| 4 | * * |
||
| 5 | * @author Andrey Helldar <[email protected]> * |
||
| 6 | * * |
||
| 7 | * @copyright 2021 Andrey Helldar * |
||
| 8 | * * |
||
| 9 | * @license MIT * |
||
| 10 | * * |
||
| 11 | * @see https://github.com/andrey-helldar/support * |
||
| 12 | * * |
||
| 13 | * For the full copyright and license information, please view the LICENSE * |
||
| 14 | * file that was distributed with this source code. * |
||
| 15 | ******************************************************************************/ |
||
| 16 | |||
| 17 | namespace Helldar\Support\Helpers; |
||
| 18 | |||
| 19 | use Helldar\Support\Facades\Helpers\Is as IsHelper; |
||
| 20 | use ReflectionClass; |
||
| 21 | |||
| 22 | class Reflection |
||
| 23 | { |
||
| 24 | /** |
||
| 25 | * Creates a ReflectionClass object. |
||
| 26 | * |
||
| 27 | * @param object|ReflectionClass|string $class |
||
| 28 | * |
||
| 29 | * @throws \ReflectionException |
||
| 30 | * |
||
| 31 | * @return \ReflectionClass |
||
| 32 | */ |
||
| 33 | 42 | public function resolve($class): ReflectionClass |
|
| 34 | { |
||
| 35 | 42 | return IsHelper::reflectionClass($class) ? $class : new ReflectionClass($class); |
|
|
0 ignored issues
–
show
Bug
Best Practice
introduced
by
Loading history...
|
|||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Gets class constants. |
||
| 40 | * |
||
| 41 | * @param object|string $class |
||
| 42 | * |
||
| 43 | * @throws \ReflectionException |
||
| 44 | * |
||
| 45 | * @return array |
||
| 46 | */ |
||
| 47 | 2 | public function getConstants($class): array |
|
| 48 | { |
||
| 49 | 2 | return $this->resolve($class)->getConstants(); |
|
| 50 | } |
||
| 51 | } |
||
| 52 |