https://github.com/alex-oleshkevich/classnames
The missing class name extractor from PHP files.
https://github.com/alex-oleshkevich/classnames
Last synced: about 2 months ago
JSON representation
The missing class name extractor from PHP files.
- Host: GitHub
- URL: https://github.com/alex-oleshkevich/classnames
- Owner: alex-oleshkevich
- License: mit
- Created: 2019-11-05T09:15:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-05T09:20:26.000Z (over 5 years ago)
- Last Synced: 2025-02-25T10:51:47.906Z (2 months ago)
- Language: PHP
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# PHP Class\Interface\Trait names extractor from files.
This library extracts entity names from php files.
Supports plain classes, multiple entity per file, classes within curly namespaces, etc.
[](https://packagist.org/packages/alex-oleshkevich/classnames)
[](https://packagist.org/packages/alex-oleshkevich/classnames)
[](https://packagist.org/packages/alex-oleshkevich/classnames)
[](https://packagist.org/packages/alex-oleshkevich/classnames)
[](https://www.versioneye.com/user/projects/57e3b1ed6dfcd00042a4f686)
### Installation
```bash
composer install alex-oleshkevich/classnames
```### Example
```php
$extractor = new \ClassNames\ClassNames;
$classes = $extractor->getClassNames('/path/to/file.php');
// or
$interfaces = $extractor->getInterfaceNames('/path/to/file.php');
// or
$traits = $extractor->getTraitNames('/path/to/file.php');
```
All functions listed above return a plain array of found entities.
```php
// file "/path/to/file.php"
namespace TestAsset {
class Asset {}
class Asset2 {}
}$extractor = new \ClassNames\ClassNames;
$classes = $extractor->getClassNames('/path/to/file.php');
print_r($classes);
/**
* Array
* (
* [0] => TestAsset\Asset
* [1] => TestAsset\Asset2
* )
*/
```