You are here

LazyLoadableObjectClassMetadata.php in Zircon Profile 8

File

vendor/doctrine/common/tests/Doctrine/Tests/Common/Proxy/LazyLoadableObjectClassMetadata.php
View source
<?php

/*
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the MIT license. For more information, see
 * <http://www.doctrine-project.org>.
 */
namespace Doctrine\Tests\Common\Proxy;

use ReflectionClass;
use Doctrine\Common\Persistence\Mapping\ClassMetadata;

/**
 * Class metadata test asset for @see LazyLoadableObject
 *
 * @author Marco Pivetta <ocramius@gmail.com>
 * @since  2.4
 */
class LazyLoadableObjectClassMetadata implements ClassMetadata {

  /**
   * @var ReflectionClass
   */
  protected $reflectionClass;

  /**
   * @var array
   */
  protected $identifier = array(
    'publicIdentifierField' => true,
    'protectedIdentifierField' => true,
  );

  /**
   * @var array
   */
  protected $fields = array(
    'publicIdentifierField' => true,
    'protectedIdentifierField' => true,
    'publicPersistentField' => true,
    'protectedPersistentField' => true,
  );

  /**
   * @var array
   */
  protected $associations = array(
    'publicAssociation' => true,
    'protectedAssociation' => true,
  );

  /**
   * {@inheritDoc}
   */
  public function getName() {
    return $this
      ->getReflectionClass()
      ->getName();
  }

  /**
   * {@inheritDoc}
   */
  public function getIdentifier() {
    return array_keys($this->identifier);
  }

  /**
   * {@inheritDoc}
   */
  public function getReflectionClass() {
    if (null === $this->reflectionClass) {
      $this->reflectionClass = new \ReflectionClass(__NAMESPACE__ . '\\LazyLoadableObject');
    }
    return $this->reflectionClass;
  }

  /**
   * {@inheritDoc}
   */
  public function isIdentifier($fieldName) {
    return isset($this->identifier[$fieldName]);
  }

  /**
   * {@inheritDoc}
   */
  public function hasField($fieldName) {
    return isset($this->fields[$fieldName]);
  }

  /**
   * {@inheritDoc}
   */
  public function hasAssociation($fieldName) {
    return isset($this->associations[$fieldName]);
  }

  /**
   * {@inheritDoc}
   */
  public function isSingleValuedAssociation($fieldName) {
    throw new \BadMethodCallException('not implemented');
  }

  /**
   * {@inheritDoc}
   */
  public function isCollectionValuedAssociation($fieldName) {
    throw new \BadMethodCallException('not implemented');
  }

  /**
   * {@inheritDoc}
   */
  public function getFieldNames() {
    return array_keys($this->fields);
  }

  /**
   * {@inheritDoc}
   */
  public function getIdentifierFieldNames() {
    return $this
      ->getIdentifier();
  }

  /**
   * {@inheritDoc}
   */
  public function getAssociationNames() {
    return array_keys($this->associations);
  }

  /**
   * {@inheritDoc}
   */
  public function getTypeOfField($fieldName) {
    return 'string';
  }

  /**
   * {@inheritDoc}
   */
  public function getAssociationTargetClass($assocName) {
    throw new \BadMethodCallException('not implemented');
  }

  /**
   * {@inheritDoc}
   */
  public function isAssociationInverseSide($assocName) {
    throw new \BadMethodCallException('not implemented');
  }

  /**
   * {@inheritDoc}
   */
  public function getAssociationMappedByTargetField($assocName) {
    throw new \BadMethodCallException('not implemented');
  }

  /**
   * {@inheritDoc}
   */
  public function getIdentifierValues($object) {
    throw new \BadMethodCallException('not implemented');
  }

}

Classes

Namesort descending Description
LazyLoadableObjectClassMetadata Class metadata test asset for @author Marco Pivetta <ocramius@gmail.com> @since 2.4