lucid/resource

Resource locator

v0.0.1 2016-04-12 19:51 UTC

This package is not auto-updated.

Last update: 2024-12-17 19:37:50 UTC


README

Author Source Code Software License

Build Status Code Coverage HHVM

Requirements

php >= 5.6

Installation

> composer require lucid/resource

Locating resources

<?php
use Lucid\Resource\Locator;

$locator = new Loacor(['/path/to/dirA', '/path/to/dirB']);

foreach ($locator->locate('config.php') as $resource) {
	$resource->... // do stuff
}

Resources

File Resources

<?php
use Lucid\Resource\FileResource;

$res = new FileResource($file);
$res->getResource(); // returns "/path/file"

$res->isValid($time) // if not mofified since $time

Object Resources

<?php
use Lucid\Resource\ObjectResource;
use Acme\MyObject;

$res = new ObjectResource(new MyObject);
$res->getResource(); // returns "/path/to/Acme/MyObject.php

$res->isValid($time) // if not mofified since $time

Resource Collections

<?php
use Lucid\Resource\Collection;
use Lucid\Resource\FileResource;
use Lucid\Resource\ObjectResource;

$resources = new Collection();

$resources->addResource(new ObjectResource($onject));
$resources->addResource(new FileResource($file));

$resources->addObjectResource($object);
$resources->addFileResource($file);

$resources->all(); // [ObjectResource $resource, FileResource $resource, ... ]

$resources->isValid(time()); // bool