Overview

Namespaces

  • LeanMapper
    • Exception
    • Reflection
    • Relationship

Classes

  • LeanMapper\Entity
  • LeanMapper\Reflection\Aliases
  • LeanMapper\Reflection\AliasesBuilder
  • LeanMapper\Reflection\AliasesParser
  • LeanMapper\Reflection\AnnotationsParser
  • LeanMapper\Reflection\EntityReflection
  • LeanMapper\Reflection\Property
  • LeanMapper\Reflection\PropertyFactory
  • LeanMapper\Reflection\PropertyFilters
  • LeanMapper\Reflection\PropertyType
  • LeanMapper\Relationship\BelongsTo
  • LeanMapper\Relationship\BelongsToMany
  • LeanMapper\Relationship\BelongsToOne
  • LeanMapper\Relationship\HasMany
  • LeanMapper\Relationship\HasOne
  • LeanMapper\Repository
  • LeanMapper\Result
  • LeanMapper\Row

Exceptions

  • LeanMapper\Exception\InvalidAnnotationException
  • LeanMapper\Exception\InvalidArgumentException
  • LeanMapper\Exception\InvalidMethodCallException
  • LeanMapper\Exception\InvalidStateException
  • LeanMapper\Exception\InvalidValueException
  • LeanMapper\Exception\MemberAccessException
  • LeanMapper\Exception\RuntimeException
  • LeanMapper\Exception\UtilityClassException
  • Overview
  • Namespace
  • Class
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 
<?php

/**
 * This file is part of the Lean Mapper library (http://www.leanmapper.com)
 *
 * Copyright (c) 2013 Vojtěch Kohout (aka Tharos)
 *
 * For the full copyright and license information, please view the file
 * license-mit.txt that was distributed with this source code.
 */

namespace LeanMapper\Reflection;

use LeanMapper\Relationship\BelongsToMany;
use LeanMapper\Relationship\BelongsToOne;
use LeanMapper\Relationship\HasMany;
use LeanMapper\Relationship\HasOne;

/**
 * Entity property (field) reflection
 *
 * @author Vojtěch Kohout
 */
class Property
{

    /** @var string */
    private $name;

    /** @var PropertyType */
    private $type;

    /** @var bool */
    private $isNullable;

    /** @var bool */
    private $containsCollection;

    /** @var HasOne|HasMany|BelongsToOne|BelongsToMany|null */
    private $relationship;

    /** @var PropertyFilters|null */
    private $filters;


    /**
     * @param string $name
     * @param PropertyType $type
     * @param bool $isNullable
     * @param bool $containsCollection
     * @param HasOne|HasMany|BelongsToOne|BelongsToMany|null $relationship
     * @param PropertyFilters|null $filters
     */
    public function __construct($name, PropertyType $type, $isNullable, $containsCollection, $relationship = null, PropertyFilters $filters = null)
    {
        $this->name = $name;
        $this->type = $type;
        $this->isNullable = $isNullable;
        $this->containsCollection = $containsCollection;
        $this->relationship = $relationship;
        $this->filters = $filters;
    }

    /**
     * Returns property name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Tells whether property is assumed to contain collection
     *
     * @return bool
     */
    public function containsCollection()
    {
        return $this->containsCollection;
    }

    /**
     * Returns property type
     *
     * @return string
     */
    public function getType()
    {
        return $this->type->getType();
    }

    /**
     * Tells whether property type is basic type (boolean|integer|float|string|array)
     *
     * @return bool
     */
    public function isBasicType()
    {
        return $this->type->isBasicType();
    }

    /**
     * Tells whether property can be null
     *
     * @return bool
     */
    public function isNullable()
    {
        return $this->isNullable;
    }

    /**
     * Tells whether property represents relationship
     *
     * @return bool
     */
    public function hasRelationship()
    {
        return $this->relationship !== null;
    }

    /**
     * Returns relationship that property represents
     *
     * @return BelongsToMany|BelongsToOne|HasMany|HasOne|null
     */
    public function getRelationship()
    {
        return $this->relationship;
    }

    /**
     * Returns property filters
     *
     * @return string[]
     */
    public function getFilters()
    {
        return $this->filters !== null ? $this->filters->getFilters() : null;
    }

}
tharos/leanmapper v1.3.0 API documentation API documentation generated by ApiGen