Skip to content

πŸ” Provides a composer package with a finder for classy constructs (classes, enums, interfaces, and traits).

License

Notifications You must be signed in to change notification settings

ergebnis/classy

Repository files navigation

classy

Integrate Merge Release Renew

Code Coverage Type Coverage

Latest Stable Version Total Downloads Monthly Downloads

This project provides a composer package with a finder for classy constructs (classes, enums, interfaces, and traits).

Installation

Run

composer require ergebnis/classy

Usage

Collect classy constructs from source code

Use Classy\Constructs::fromSource() to collect classy constructs in source code:

<?php

declare(strict_types=1);

use Ergebnis\Classy;

$source = <<<'PHP'
<?php

namespace Example;

class Foo {}

enum Bar {}

interface Baz {}

trait Qux {}
PHP;

$constructs = Classy\Constructs::fromSource($source);

$names = array_map(static function (Classy\Construct $construct): string {
    return $construct->name();
}, $constructs);

var_dump($names); // ['Example\Bar', 'Example\Baz', 'Example\Foo', 'Example\Qux']

Collect classy constructs from a directory

Use Classy\Constructs::fromDirectory() to collect classy constructs in a directory:

<?php

declare(strict_types=1);

use Ergebnis\Classy;

$constructs = Classy\Constructs::fromDirectory(__DIR__ . '/example');

$names = array_map(static function (Classy\Construct $construct): string {
    return $construct->name();
}, $constructs);

var_dump($names); // ['Example\Bar', 'Example\Bar\Baz', 'Example\Foo\Bar\Baz']

Changelog

The maintainers of this project record notable changes to this project in a changelog.

Contributing

The maintainers of this project suggest following the contribution guide.

Code of Conduct

The maintainers of this project ask contributors to follow the code of conduct.

General Support Policy

The maintainers of this project provide limited support.

You can support the maintenance of this project by sponsoring @localheinz or requesting an invoice for services related to this project.

PHP Version Support Policy

This project supports PHP versions with active and security support.

The maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.

Security Policy

This project has a security policy.

License

This project uses the MIT license.

Credits

The algorithm for finding classes in PHP files in Constructs has been adopted from Zend\File\ClassFileLocator (originally licensed under BSD-3-Clause).

Social

Follow @localheinz and @ergebnis on Twitter.

About

πŸ” Provides a composer package with a finder for classy constructs (classes, enums, interfaces, and traits).

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Sponsor this project

  •  
  •  

Packages

No packages published