BeanContext/Inspector.php

Show: inherited
Table of Contents

\Conjoon_BeanContext_Inspector

Package: Conjoon\BeanContext

Static class with utility methods for working on classes implementing the Conjoon_BeanContext-interface and overall introspection of classes/object-instances.

Author
Thorsten-Suckow-Homberg  
Category
Conjoon  

Constants

Constant  GETTER = 'get'

Const
string  
Constant  SETTER = 'set'

Const
string  

Properties

Propertyprivate  $cache= 'array()'
static

Default valuearray()Details
Type
n/a
Array
 

Methods

methodpubliccreate( string $className, array $properties, boolean $ignoreMissingSetter = false ) : Object
static

Tries to instantiate a class based on the passed arguments.

Parameters
Name Type Description
$className string

The class that should be created. Must implement the interface Conjoon_BeanContext

$properties array

An associative array with key/value-pairs, representing the object properties to set. The Constructor will search for appropriate getter/setter methods and call them, passing the values as arguments.

$ignoreMissingSetter boolean

true to not throw an error if a property occures for which no setter is available

Returns
Type Description
Object
Throws
Exception Description
\Conjoon_BeanContext_Exception if any error during object instantiating or class loading occured
methodprivategetAccessorForProperty( Object $object, string $propertyName, string $accessorType = self::GETTER ) : mixed
static

Helper for getting a getter-method based on the property passed as the argument.

Parameters
Name Type Description
$object Object

The object in which the accessor should be looked up

$propertyName string

The name of the property which accessor has to be looked up

$accessorType string

Which accessor-method to look up, either 'set' or 'get'

Returns
Type Description
mixed <tt>null</tt>, if no appropriate getter method exists for the property, otherwise the method name.
methodpublicgetProperties( Object $object ) : Array
static

Will return the properties as an associative array (key/value pairs) of the specified object based on the setter-methods it implements along with the properties it defines. A property will only be returned if it matches the definition for an Conjoon_BeanContext-property, though it must not neccessarily implement Conjoon_BeanContext.

Parameters
Name Type Description
$object Object

An object instance of any type.

Returns
Type Description
Array
Throws
Exception Description
\Conjoon_BeanContext_Exception A call to any of the getters of the passed object can throw an excepiton, which's message gets wrapped up in an exception of the type Conjoon_BeanContext_Exception
Details
See
\Conjoon_BeanContext  
methodprivategetReflectionClass(  $object ) : \ReflectionClass
static

Returns the reflection class for the object out of the cache.

Parameters
Name Type Description
$object

Object

Returns
Type Description
\ReflectionClass
methodprivategetReflectionMethods(  $object ) : Array | \ReflectionMethod
static

Returns reflection methods for the class the object represents out of the cache.

Parameters
Name Type Description
$object

Object

Returns
Type Description
Array | \ReflectionMethod
methodprivategetReflectionProperties(  $object ) : Array | \ReflectionProperty
static

Returns reflection properties for the class the object represents out of the cache.

Parameters
Name Type Description
$object

Object

Returns
Type Description
Array | \ReflectionProperty
methodprivateisTransient( string $propertyName, Object $object ) : boolean
static

Checks wether a property is transient. A property is transient, if an underscore is part of the property-name. This method will also check if a property with the same name is available that starts with an underscore.

Parameters
Name Type Description
$propertyName string
$object Object
Returns
Type Description
boolean true, if the property is transient, otherwise false
methodpublicloadClass(  $className ) : void
static

Helper for loading a class.

Parameters
Name Type Description
$className
methodprivatesetProperty( Object $object, string $property, mixed $value, boolean $ignoreMissing = false ) : void
static

Helper for setting the properties of an Conjoon_BeanContext-object.

Will throw an exception if the method associated with the property was not found, or any exception that was thrown by the accessor-method of $object. The method assumes that property is already a valid property name according to Conjoon_BeanContext-conventions.

Parameters
Name Type Description
$object Object

The instance to set the property for. Must be of type Conjoon_BeanContext

$property string

The property name that is about to be set.

$value mixed

The value to pass as the argument to the setter-method of $property

$ignoreMissing boolean

when set to true, the method will not throw an error if the

Throws
Exception Description
\Exception
Details
See
\Conjoon_BeanContext  
Documentation was generated by DocBlox 0.18.1.