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

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

classy

CI Status codecov Latest Stable Version Total Downloads

Provides a finder for classy elements.

Installation

Run

$ composer require ergebnis/classy

Usage

Collect classy constructs from source code

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

use Localheinz\Classy\Construct;
use Localheinz\Classy\Constructs;

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

namespace Example;

class Foo {}

interface Bar {}

trait Baz {}
PHP;

/** @var Construct[] $constructs */
$constructs = Constructs::fromSource($source);

$names = array_map(function (Construct $construct) {
    return $construct->name();
}, $constructs);

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

Collect classy constructs from a directory

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

use Localheinz\Classy\Construct;
use Localheinz\Classy\Constructs;

/** @var Construct[] $constructs */
$constructs = Constructs::fromDirectory(__DIR__ . '/example');

$names = array_map(function (Construct $construct) {
    return $construct->name();
}, $constructs);

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

Changelog

Please have a look at CHANGELOG.md.

Contributing

Please have a look at CONTRIBUTING.md.

Code of Conduct

Please have a look at CODE_OF_CONDUCT.md.

License

This package is licensed using 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).

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