Skip to content
This repository has been archived by the owner on Mar 27, 2019. It is now read-only.

Commit

Permalink
Updated to use latest Pathogen.
Browse files Browse the repository at this point in the history
  • Loading branch information
ezzatron committed Nov 3, 2013
1 parent 1022a15 commit 5ea3d62
Show file tree
Hide file tree
Showing 15 changed files with 218 additions and 83 deletions.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,11 @@
],
"require": {
"php": ">=5.3",
"eloquent/pathogen": "~0.5.0",
"eloquent/pathogen": "dev-develop@dev",
"icecave/isolator": "~2"
},
"require-dev": {
"eloquent/liberator": "~1",
"icecave/archer": "~1"
},
"autoload": {
Expand Down
126 changes: 112 additions & 14 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 9 additions & 18 deletions src/Eloquent/Cosmos/ClassName/ClassNameReference.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
namespace Eloquent\Cosmos\ClassName;

use Eloquent\Pathogen\Exception\InvalidPathAtomExceptionInterface;
use Eloquent\Pathogen\Normalizer\PathNormalizerInterface;
use Eloquent\Pathogen\RelativePath;

/**
Expand Down Expand Up @@ -84,30 +83,22 @@ protected function validateAtom($atom)
}

/**
* Create a new class name instance.
* Get the class name factory.
*
* @param mixed<string> $atoms The class name atoms.
* @param boolean $isQualified True if the class name is fully qualified.
* @param boolean|null $hasTrailingSeparator Ignored.
*
* @return ClassNameInterface The newly created class name instance.
* @throws InvalidPathAtomExceptionInterface If any of the supplied atoms are invalid.
* @return Factory\ClassNameFactoryInterface The class name factory.
*/
protected function createPath(
$atoms,
$isQualified,
$hasTrailingSeparator = null
) {
return new ClassNameReference($atoms);
protected static function factory()
{
return Factory\ClassNameFactory::instance();
}

/**
* Create a new default class name normalizer.
* Get the class name normalizer.
*
* @return PathNormalizerInterface The newly created normalizer.
* @return Normalizer\ClassNameNormalizerInterface The class name normalizer.
*/
protected function createDefaultNormalizer()
protected static function normalizer()
{
return new Normalizer\ClassNameNormalizer;
return Normalizer\ClassNameNormalizer::instance();
}
}
16 changes: 16 additions & 0 deletions src/Eloquent/Cosmos/ClassName/Factory/ClassNameFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
*/
class ClassNameFactory implements ClassNameFactoryInterface
{
/**
* Get a static instance of this class name factory.
*
* @return ClassNameFactoryInterface The static class name factory.
*/
public static function instance()
{
if (null === static::$instance) {
static::$instance = new static;
}

return static::$instance;
}

/**
* Creates a new class name instance from its string representation.
*
Expand Down Expand Up @@ -93,4 +107,6 @@ public function createFromAtoms(

return new ClassNameReference($atoms);
}

private static $instance;
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function classNameFactory()
*/
protected function createDefaultClassNameFactory()
{
return new ClassNameFactory;
return ClassNameFactory::instance();
}

private $classNameFactory;
Expand Down
18 changes: 17 additions & 1 deletion src/Eloquent/Cosmos/ClassName/Normalizer/ClassNameNormalizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,20 @@
class ClassNameNormalizer extends PathNormalizer implements
ClassNameNormalizerInterface
{
/**
* Get a static instance of this class name normalizer.
*
* @return ClassNameNormalizerInterface The static class name normalizer.
*/
public static function instance()
{
if (null === static::$instance) {
static::$instance = new static;
}

return static::$instance;
}

/**
* Construct a new class name normalizer.
*
Expand All @@ -29,9 +43,11 @@ class ClassNameNormalizer extends PathNormalizer implements
public function __construct(ClassNameFactoryInterface $factory = null)
{
if (null === $factory) {
$factory = new ClassNameFactory;
$factory = ClassNameFactory::instance();
}

parent::__construct($factory);
}

private static $instance;
}
32 changes: 9 additions & 23 deletions src/Eloquent/Cosmos/ClassName/QualifiedClassName.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
namespace Eloquent\Cosmos\ClassName;

use Eloquent\Pathogen\AbsolutePath;
use Eloquent\Pathogen\Exception\InvalidPathAtomExceptionInterface;
use Eloquent\Pathogen\Normalizer\PathNormalizerInterface;

/**
* Represents a fully qualified class name.
Expand Down Expand Up @@ -79,34 +77,22 @@ protected function validateAtom($atom)
}

/**
* Create a new class name instance.
* Get the class name factory.
*
* @param mixed<string> $atoms The class name atoms.
* @param boolean $isQualified True if the class name is fully qualified.
* @param boolean|null $hasTrailingSeparator Ignored.
*
* @return ClassNameInterface The newly created class name instance.
* @throws InvalidPathAtomExceptionInterface If any of the supplied atoms are invalid.
* @return Factory\ClassNameFactoryInterface The class name factory.
*/
protected function createPath(
$atoms,
$isQualified,
$hasTrailingSeparator = null
) {
if ($isQualified) {
return new QualifiedClassName($atoms);
}

return new ClassNameReference($atoms);
protected static function factory()
{
return Factory\ClassNameFactory::instance();
}

/**
* Create a new default class name normalizer.
* Get the class name normalizer.
*
* @return PathNormalizerInterface The newly created normalizer.
* @return Normalizer\ClassNameNormalizerInterface The class name normalizer.
*/
protected function createDefaultNormalizer()
protected static function normalizer()
{
return new Normalizer\ClassNameNormalizer;
return Normalizer\ClassNameNormalizer::instance();
}
}
2 changes: 1 addition & 1 deletion src/Eloquent/Cosmos/Resolution/ResolutionContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function __construct(
ClassNameFactoryInterface $factory = null
) {
if (null === $factory) {
$factory = new ClassNameFactory;
$factory = ClassNameFactory::instance();
}
if (null === $primaryNamespace) {
$primaryNamespace = $factory->createFromAtoms(array(), true);
Expand Down
4 changes: 2 additions & 2 deletions src/Eloquent/Cosmos/Resolution/UseStatementGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ public function __construct(
$maxReferenceAtoms = 2;
}
if (null === $useStatementFactory) {
$useStatementFactory = new UseStatementFactory;
$useStatementFactory = UseStatementFactory::instance();
}
if (null === $classNameFactory) {
$classNameFactory = new ClassNameFactory;
$classNameFactory = ClassNameFactory::instance();
}

$this->maxReferenceAtoms = $maxReferenceAtoms;
Expand Down
Loading

0 comments on commit 5ea3d62

Please sign in to comment.