Skip to content

bearsunday/BEAR.AppMeta

Repository files navigation

BEAR.AppMeta

Scrutinizer Code Quality Code Coverage Build Status

Application meta data value object

  • AppMeta object keep the application path such as $tmpDir, $logDir and $appDir in public property by given app name and context.

  • getGenerator() return \Generator to get resource meta data.

use BEAR\AppMeta\Meta;

$appMeta = new Meta('MyVendor\HelloWorld');

// provids directory path

// $appMeta->name;    // MyVendor\HelloWorld
// $appMeta->appDir;  // MyVendor\HelloWorld/src
// $appMeta->logDir;  // MyVendor\HelloWorld/var/log
// $appMeta->tmpDir;  // MyVendor\HelloWorld/var/tmp

// resource meta generator

foreach ($appMeta->getGenerator('*') as $resourceMeta) {
    var_dump($resourceMeta->uriPath); // app://self/one
    var_dump($resourceMeta->class);   // FakeVendor\HelloWorld\Resource\App\One
    var_dump($resourceMeta->file);    // /path/to/src/Resource/App/One.php
}

foreach ($appMeta->getGenerator('app') as $resourceMeta) {
    var_dump($resourceMeta->uriPath); // /one
    var_dump($resourceMeta->class);   // FakeVendor\HelloWorld\Resource\App\One
    var_dump($resourceMeta->file);    // /path/to/src/Resource/App/One.php
}