Skip to content

Commit

Permalink
rename Proxy to Lazy; these were never wrappers around the 'real' obj…
Browse files Browse the repository at this point in the history
…ects
  • Loading branch information
Paul M. Jones committed Nov 28, 2012
1 parent 7b8cf1d commit cc40ecf
Show file tree
Hide file tree
Showing 14 changed files with 59 additions and 59 deletions.
8 changes: 4 additions & 4 deletions src.php
Expand Up @@ -6,10 +6,10 @@
require __DIR__ . '/src/Aura/Marshal/Collection/GenericCollection.php';
require __DIR__ . '/src/Aura/Marshal/Exception.php';
require __DIR__ . '/src/Aura/Marshal/Manager.php';
require __DIR__ . '/src/Aura/Marshal/Proxy/BuilderInterface.php';
require __DIR__ . '/src/Aura/Marshal/Proxy/Builder.php';
require __DIR__ . '/src/Aura/Marshal/Proxy/ProxyInterface.php';
require __DIR__ . '/src/Aura/Marshal/Proxy/GenericProxy.php';
require __DIR__ . '/src/Aura/Marshal/Lazy/BuilderInterface.php';
require __DIR__ . '/src/Aura/Marshal/Lazy/Builder.php';
require __DIR__ . '/src/Aura/Marshal/Lazy/LazyInterface.php';
require __DIR__ . '/src/Aura/Marshal/Lazy/GenericLazy.php';
require __DIR__ . '/src/Aura/Marshal/Entity/MagicArrayAccessTrait.php';
require __DIR__ . '/src/Aura/Marshal/Entity/MagicPropertyTrait.php';
require __DIR__ . '/src/Aura/Marshal/Entity/BuilderInterface.php';
Expand Down
2 changes: 1 addition & 1 deletion src/Aura/Marshal/Entity/Builder.php
Expand Up @@ -11,7 +11,7 @@
namespace Aura\Marshal\Entity;

use Aura\Marshal\Type\GenericType;
use Aura\Marshal\Proxy\BuilderInterface as ProxyBuilderInterface;
use Aura\Marshal\Lazy\BuilderInterface as LazyBuilderInterface;

/**
*
Expand Down
10 changes: 5 additions & 5 deletions src/Aura/Marshal/Entity/MagicArrayAccessTrait.php
Expand Up @@ -10,7 +10,7 @@
*/
namespace Aura\Marshal\Entity;

use Aura\Marshal\Proxy\ProxyInterface;
use Aura\Marshal\Lazy\LazyInterface;

/**
*
Expand All @@ -24,7 +24,7 @@ trait MagicArrayAccessTrait
{
/**
*
* Calls ArrayAccess::offsetGet() to get a field value; converts proxy
* Calls ArrayAccess::offsetGet() to get a field value; converts Lazy
* objects for related entites and collections in place.
*
* @param string $field The field name to get.
Expand All @@ -37,9 +37,9 @@ public function __get($field)
// get the field value
$value = $this->offsetGet($field);

// is it a proxy for a related?
if ($value instanceof ProxyInterface) {
// replace the proxy value with the real value
// is it a Lazy placeholder?
if ($value instanceof LazyInterface) {
// replace the Lazy placeholder with the real object
$value = $value->get($this);
$this->offsetSet($field, $value);
}
Expand Down
10 changes: 5 additions & 5 deletions src/Aura/Marshal/Entity/MagicPropertyTrait.php
Expand Up @@ -10,7 +10,7 @@
*/
namespace Aura\Marshal\Entity;

use Aura\Marshal\Proxy\ProxyInterface;
use Aura\Marshal\Lazy\LazyInterface;

/**
*
Expand All @@ -24,7 +24,7 @@ trait MagicPropertyTrait
{
/**
*
* Gets a protected property as a field value; converts proxy objects for
* Gets a protected property as a field value; converts Lazy objects for
* related entites and collections in place.
*
* Note that this will *not* be invoked by in-class uses of the protected
Expand All @@ -40,9 +40,9 @@ public function __get($field)
// get the property value
$value = $this->$field;

// is it a proxy for a related?
if ($value instanceof ProxyInterface) {
// replace the proxy value with the real value
// is it a Lazy placeholder?
if ($value instanceof LazyInterface) {
// replace the Lazy placeholder with the real object
$value = $value->get($this);
$this->$field = $value;
}
Expand Down
Expand Up @@ -8,13 +8,13 @@
* @license http://opensource.org/licenses/bsd-license.php BSD
*
*/
namespace Aura\Marshal\Proxy;
namespace Aura\Marshal\Lazy;

use Aura\Marshal\Relation\RelationInterface;

/**
*
* A builder for Proxy objects.
* A builder for Lazy objects.
*
* @package Aura.Marshal
*
Expand All @@ -28,16 +28,16 @@ class Builder implements BuilderInterface
* @var string
*
*/
protected $class = 'Aura\Marshal\Proxy\GenericProxy';
protected $class = 'Aura\Marshal\Lazy\GenericLazy';

/**
*
* Creates a new Proxy object.
* Creates a new Lazy object.
*
* @param RelationInterface $relation The relationship object between the
* native and foreign types.
*
* @return Proxy
* @return Lazy
*
*/
public function newInstance(RelationInterface $relation)
Expand Down
Expand Up @@ -8,13 +8,13 @@
* @license http://opensource.org/licenses/bsd-license.php BSD
*
*/
namespace Aura\Marshal\Proxy;
namespace Aura\Marshal\Lazy;

use Aura\Marshal\Relation\RelationInterface;

/**
*
* An interface for Proxy builders.
* An interface for Lazy builders.
*
* @package Aura.Marshal
*
Expand All @@ -23,12 +23,12 @@ interface BuilderInterface
{
/**
*
* Creates a new Proxy object.
* Creates a new Lazy object.
*
* @param RelationInterface $relation The relationship object between the
* native and foreign types.
*
* @return Proxy
* @return Lazy
*
*/
public function newInstance(RelationInterface $relation);
Expand Down
Expand Up @@ -8,19 +8,19 @@
* @license http://opensource.org/licenses/bsd-license.php BSD
*
*/
namespace Aura\Marshal\Proxy;
namespace Aura\Marshal\Lazy;

use Aura\Marshal\Relation\RelationInterface;

/**
*
* A generic Proxy object, useful in cases when special functionality is not
* A generic Lazy object, useful in cases when special functionality is not
* needed.
*
* @package Aura.Marshal
*
*/
class GenericProxy implements ProxyInterface
class GenericLazy implements LazyInterface
{
/**
*
Expand Down
Expand Up @@ -8,16 +8,16 @@
* @license http://opensource.org/licenses/bsd-license.php BSD
*
*/
namespace Aura\Marshal\Proxy;
namespace Aura\Marshal\Lazy;

/**
*
* An interface for Proxy objects.
* An interface for Lazy objects.
*
* @package Aura.Marshal
*
*/
interface ProxyInterface
interface LazyInterface
{
/**
*
Expand Down
10 changes: 5 additions & 5 deletions src/Aura/Marshal/Type/Builder.php
Expand Up @@ -13,7 +13,7 @@
use Aura\Marshal\Collection\Builder as CollectionBuilder;
use Aura\Marshal\Exception;
use Aura\Marshal\Entity\Builder as EntityBuilder;
use Aura\Marshal\Proxy\Builder as ProxyBuilder;
use Aura\Marshal\Lazy\Builder as LazyBuilder;

/**
*
Expand Down Expand Up @@ -53,7 +53,7 @@ public function newInstance($info)
'index_fields' => [],
'entity_builder' => null,
'collection_builder' => null,
'proxy_builder' => null,
'lazy_builder' => null,
];

$info = array_merge($base, $info);
Expand All @@ -70,16 +70,16 @@ public function newInstance($info)
$info['collection_builder'] = new CollectionBuilder;
}

if (! $info['proxy_builder']) {
$info['proxy_builder'] = new ProxyBuilder;
if (! $info['lazy_builder']) {
$info['lazy_builder'] = new LazyBuilder;
}

$type = new GenericType;
$type->setIdentityField($info['identity_field']);
$type->setIndexFields($info['index_fields']);
$type->setEntityBuilder($info['entity_builder']);
$type->setCollectionBuilder($info['collection_builder']);
$type->setProxyBuilder($info['proxy_builder']);
$type->setLazyBuilder($info['lazy_builder']);

return $type;
}
Expand Down
26 changes: 13 additions & 13 deletions src/Aura/Marshal/Type/GenericType.php
Expand Up @@ -13,7 +13,7 @@
use Aura\Marshal\Collection\BuilderInterface as CollectionBuilderInterface;
use Aura\Marshal\Data;
use Aura\Marshal\Exception;
use Aura\Marshal\Proxy\BuilderInterface as ProxyBuilderInterface;
use Aura\Marshal\Lazy\BuilderInterface as LazyBuilderInterface;
use Aura\Marshal\Entity\BuilderInterface as EntityBuilderInterface;
use Aura\Marshal\Relation\RelationInterface;
use SplObjectStorage;
Expand Down Expand Up @@ -108,12 +108,12 @@ class GenericType extends Data

/**
*
* A builder to create proxy objects.
* A builder to create Lazy objects.
*
* @var ProxyBuilderInterface
* @var LazyBuilderInterface
*
*/
protected $proxy_builder;
protected $lazy_builder;

/**
*
Expand Down Expand Up @@ -250,28 +250,28 @@ public function getCollectionBuilder()

/**
*
* Sets the proxy builder to create proxy objects.
* Sets the lazy builder to create lazy objects.
*
* @param ProxyBuilderInterface $builder The proxy builder.
* @param LazyBuilderInterface $builder The lazy builder.
*
* @return void
*
*/
public function setProxyBuilder(ProxyBuilderInterface $proxy_builder)
public function setLazyBuilder(LazyBuilderInterface $lazy_builder)
{
$this->proxy_builder = $proxy_builder;
$this->lazy_builder = $lazy_builder;
}

/**
*
* Returns the proxy builder that creates proxy objects.
* Returns the lazy builder that creates lazy objects.
*
* @return ProxyBuilderInterface
* @return LazyBuilderInterface
*
*/
public function getProxyBuilder()
public function getLazyBuilder()
{
return $this->proxy_builder;
return $this->lazy_builder;
}

/**
Expand Down Expand Up @@ -438,7 +438,7 @@ protected function loadData(

// set related fields
foreach ($this->getRelations() as $field => $relation) {
$entity->$field = $this->proxy_builder->newInstance($relation);
$entity->$field = $this->lazy_builder->newInstance($relation);
}

// done! return the new offset number.
Expand Down
2 changes: 1 addition & 1 deletion tests/Aura/Marshal/CollectionTest.php
Expand Up @@ -4,7 +4,7 @@
use Aura\Marshal\Type\GenericType;
use Aura\Marshal\Entity\Builder as EntityBuilder;
use Aura\Marshal\Collection\Builder as CollectionBuilder;
use Aura\Marshal\Proxy\Builder as ProxyBuilder;
use Aura\Marshal\Lazy\Builder as LazyBuilder;

/**
* Test class for Collection.
Expand Down
6 changes: 3 additions & 3 deletions tests/Aura/Marshal/EntityTest.php
Expand Up @@ -5,8 +5,8 @@
use Aura\Marshal\MockEntity;
use Aura\Marshal\Entity\Builder;
use Aura\Marshal\MockEntityBuilder;
use Aura\Marshal\Proxy\Builder as ProxyBuilder;
use Aura\Marshal\Proxy\GenericProxy;
use Aura\Marshal\Lazy\Builder as LazyBuilder;
use Aura\Marshal\Lazy\GenericLazy;

/**
* Test class for Entity.
Expand All @@ -20,7 +20,7 @@ protected function getData()
'foo' => 'bar',
'baz' => 'dim',
'zim' => 'gir',
'related' => new GenericProxy(new MockRelation),
'related' => new GenericLazy(new MockRelation),
];
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Aura/Marshal/RelationTest.php
Expand Up @@ -2,7 +2,7 @@
namespace Aura\Marshal;
use Aura\Marshal\Relation\Builder as RelationBuilder;
use Aura\Marshal\Type\Builder as TypeBuilder;
use Aura\Marshal\Proxy\Builder as ProxyBuilder;
use Aura\Marshal\Lazy\Builder as LazyBuilder;

/**
* Test class for Manager.
Expand Down
12 changes: 6 additions & 6 deletions tests/Aura/Marshal/TypeTest.php
Expand Up @@ -8,7 +8,7 @@
use Aura\Marshal\Relation\Builder as RelationBuilder;
use Aura\Marshal\Type\Builder as TypeBuilder;
use Aura\Marshal\Type\GenericType;
use Aura\Marshal\Proxy\Builder as ProxyBuilder;
use Aura\Marshal\Lazy\Builder as LazyBuilder;

/**
* Test class for Type.
Expand All @@ -35,7 +35,7 @@ protected function setUp()
$this->type = new GenericType;
$this->type->setIdentityField($info['identity_field']);
$this->type->setIndexFields($info['index_fields']);
$this->type->setEntityBuilder(new EntityBuilder(new ProxyBuilder));
$this->type->setEntityBuilder(new EntityBuilder(new LazyBuilder));
$this->type->setCollectionBuilder(new CollectionBuilder);
}

Expand Down Expand Up @@ -87,11 +87,11 @@ public function testSetAndGetCollectionBuilder()
$this->assertSame($builder, $actual);
}

public function testSetAndGetProxyBuilder()
public function testSetAndGetLazyBuilder()
{
$builder = new ProxyBuilder;
$this->type->setProxyBuilder($builder);
$actual = $this->type->getProxyBuilder();
$builder = new LazyBuilder;
$this->type->setLazyBuilder($builder);
$actual = $this->type->getLazyBuilder();
$this->assertSame($builder, $actual);
}

Expand Down

0 comments on commit cc40ecf

Please sign in to comment.