spunQ_Member Class Reference

A member of a type. More...

Inheritance diagram for spunQ_Member:

spunQ_DataObject

List of all members.

Public Member Functions

 __construct ()
 Constructor.
 getName ()
 Getter for the name of this member.
 setName ($name)
 Setter for the name of this member.
 getType ()
 Getter for the type of this member.
 setType ($type)
 Setter for the type of this member.
 getDocumentation ()
 Getter for the documentation of this member.
 setDocumentation ($documentation)
 Setter for the documentation of this member.
 getOptions ()
 Getter for the options of this member.
 setOptions (spunQ_Map $options)
 Setter for the options of this member.
 getOwningType ()
 Getter for the owning type of this member.
 setOwningType (spunQ_UserType $owningType)
 Setter for the owning type of this member.
 check ($value, $throwException=true)
 Checks if the assignment of a value to this member would be possible.
 checkKey ($value, $throwException=true)
 Checks if a value would be a legal key to this collection.
 checkValue ($value, $throwException=true)
 Checks if a value would be a legal value of this collection.
 getCanonicalName ()
 Gets concatenated owning type and name.
 __call ($functionName, $arguments)
 Overloaded to provide automatic getters and setters.
 __sleep ()
 Replaces $_type with the type's name.
 _verifyMembers ($omittedMembers=array(), $throwException=true)
 Verifies that all members are valid.
 _getMember ($name)
 Gets the value of a member of this object.
 _setMember ($name, $value)
 Sets the value of a member of this object.
 _getType ($throwException=true)
 Gets the type of this object.

Static Public Member Functions

static valueByProperty ($value, $path)
 Transforms a value using a property path.
static propertyOfValue ($value, $property)
 Gets a single property of a value.

Protected Member Functions

 handleGetUntranslated ($memberName, $arguments, $functionName)
 Needed by __call().
 handleGet ($memberName, $arguments, $functionName)
 Needed by __call().
 initLocalizedMember ($memberName)
 Makes sure a localized member contains a spunQ_Map.
 handleGetFromArray ($memberName, $arguments, $functionName)
 Needed by __call().
 handleSet ($memberName, $arguments, $functionName)
 Needed by __call().
 handleAdd ($memberName, $arguments, $functionName)
 Needed by __call().
 handleRemove ($memberName, $arguments, $functionName)
 Needed by __call().

Protected Attributes

 $owningType
 The type this member belongs to.
 $name
 The name of this member.
 $type
 Type descriptor of this member.
 $documentation
 Documentation of this member as extracted from its doc comments.
 $options
 $_type
 The actual type of this object.


Detailed Description

A member of a type.

Definition at line 7 of file Member.type.php.


Member Function Documentation

spunQ_DataObject::__call ( functionName,
arguments 
) [inherited]

Overloaded to provide automatic getters and setters.

Parameters:
$functionName The function that was called.
$arguments Array containing the arguments that were passed to the function.
Exceptions:
spunQ_BadArgumentCountError 

Definition at line 148 of file DataObject.type.php.

spunQ_DataObject::__sleep (  )  [inherited]

Replaces $_type with the type's name.

Returns:
array<string>

Reimplemented in spunQ_ArrayType, spunQ_MapType, and spunQ_SetType.

Definition at line 178 of file DataObject.type.php.

spunQ_DataObject::_getMember ( name  )  [inherited]

Gets the value of a member of this object.

Will check if the object has a getter for the member and will use that method for getting the value. Otherwise, the value of the object member is returned.

Parameters:
$name The name of the member.
Returns:
any Whatever type the member has.

Definition at line 478 of file DataObject.type.php.

spunQ_DataObject::_getType ( throwException = true  )  [inherited]

Gets the type of this object.

Returns:
spunQ_Type

Definition at line 507 of file DataObject.type.php.

spunQ_DataObject::_setMember ( name,
value 
) [inherited]

Sets the value of a member of this object.

Will check if the object has a setter for the member and will use that method for setting the value. Otherwise, the object member is set directly.

Parameters:
$name The name of the member.
$value The value to set it to.
Returns:
spunQ_DataObject $this

Definition at line 495 of file DataObject.type.php.

spunQ_DataObject::_verifyMembers ( omittedMembers = array(),
throwException = true 
) [inherited]

Verifies that all members are valid.

This function is called from various modules prior to critical actions requiring a complete object - like inserting into a database.

Parameters:
$omittedMembers Do not perform checks on these member names.
$throwException Whether an exception should be thrown if a member does not have a valid value.
Returns:
boolean
Exceptions:
spunQ_IllegalValueException 

Definition at line 458 of file DataObject.type.php.

spunQ_Member::check ( value,
throwException = true 
)

Checks if the assignment of a value to this member would be possible.

Parameters:
$value The value to check
$throwException Whether an exception should be thrown if the type of the value differs.
Returns:
boolean Whether $value is of the type described by this object.
Exceptions:
spunQ_IllegalValueException 

Definition at line 152 of file Member.type.php.

spunQ_Member::checkKey ( value,
throwException = true 
)

Checks if a value would be a legal key to this collection.

Assumes that $type is a spunQ_CollectionType, of course.

Parameters:
$value The value to check
$throwException Whether an exception should be thrown if the type of the value differs.
Returns:
boolean Whether $value is of the type described by this object.
Exceptions:
spunQ_IllegalValueException 

Definition at line 165 of file Member.type.php.

spunQ_Member::checkValue ( value,
throwException = true 
)

Checks if a value would be a legal value of this collection.

Assumes that $type is a spunQ_CollectionType, of course.

Parameters:
$value The value to check
$throwException Whether an exception should be thrown if the type of the value differs.
Returns:
boolean Whether $value is of the type described by this object.
Exceptions:
spunQ_IllegalValueException 

Definition at line 179 of file Member.type.php.

spunQ_Member::getCanonicalName (  ) 

Gets concatenated owning type and name.

Can be used for translations.

Returns:
string

Definition at line 190 of file Member.type.php.

spunQ_Member::getDocumentation (  ) 

Getter for the documentation of this member.

Returns:
string

Definition at line 91 of file Member.type.php.

spunQ_Member::getName (  ) 

Getter for the name of this member.

Returns:
string

Definition at line 56 of file Member.type.php.

spunQ_Member::getOptions (  ) 

Getter for the options of this member.

Returns:
map<string,array<string>>

Definition at line 110 of file Member.type.php.

spunQ_Member::getOwningType (  ) 

Getter for the owning type of this member.

Returns:
spunQ.UserType

Definition at line 129 of file Member.type.php.

spunQ_Member::getType (  ) 

Getter for the type of this member.

Returns:
spunQ.Type

Definition at line 73 of file Member.type.php.

spunQ_DataObject::handleAdd ( memberName,
arguments,
functionName 
) [protected, inherited]

Needed by __call().

Will take care of function calls starting with 'add'.

Parameters:
$memberName The name of the member that is possibly being appended to. Merely the name of the function without the leading 'add', with a lower-case first letter.
$arguments Array containing the arguments that were passed to the function.
$functionName The function that was called.
Returns:
spunQ_DataObject $this
Exceptions:
spunQ_BadArgumentCountError 
spunQ_InvalidArgumentError 

Reimplemented in spunQ_StorableObject.

Definition at line 327 of file DataObject.type.php.

spunQ_DataObject::handleGet ( memberName,
arguments,
functionName 
) [protected, inherited]

Needed by __call().

Will take care of function calls starting with 'get'.

Todo:
spunQ_CollectionType instead of spunQ_ArrayType(?)
Parameters:
$memberName The name of the member that was possibly requested. Merely the name of the function without the leading 'get', with a lower-case first letter.
$arguments Array containing the arguments that were passed to the function.
$functionName The name of the function that was called.
Returns:
any Whatever type the member has.

Reimplemented in spunQ_StorableObject.

Definition at line 217 of file DataObject.type.php.

spunQ_DataObject::handleGetFromArray ( memberName,
arguments,
functionName 
) [protected, inherited]

Needed by __call().

Will take care of getter functions, where the member has an array type.

See also:
handleGet()
Parameters:
$memberName The name of the member that was possibly requested. Merely the name of the function without the leading 'set', with a lower-case first letter.
$arguments Array containing the arguments that were passed to the function.
$functionName The function that was called.
Returns:
array

Reimplemented in spunQ_StorableObject.

Definition at line 264 of file DataObject.type.php.

spunQ_DataObject::handleGetUntranslated ( memberName,
arguments,
functionName 
) [protected, inherited]

Needed by __call().

Will take care of functions requesting all translations available for a member.

Parameters:
$memberName The name of the member that was possibly requested.
$arguments Array containing the arguments that were passed to the function.
$functionName The name of the function that was called.
Returns:
map<spunQ_Locale,any> Mapping locales to whatever type the member has. Note that not every locale needs to be present in this map.

Reimplemented in spunQ_StorableObject.

Definition at line 198 of file DataObject.type.php.

spunQ_DataObject::handleRemove ( memberName,
arguments,
functionName 
) [protected, inherited]

Needed by __call().

Will take care of function calls starting with 'remove'.

Parameters:
$memberName The name of the member that is possibly being removed from. Merely the name of the function without the leading 'remove', with a lower-case first letter.
$arguments Array containing the arguments that were passed to the function.
$functionName The function that was called.
Returns:
spunQ_DataObject $this
Exceptions:
spunQ_BadArgumentCountError 
spunQ_InvalidArgumentError 

Reimplemented in spunQ_StorableObject.

Definition at line 399 of file DataObject.type.php.

spunQ_DataObject::handleSet ( memberName,
arguments,
functionName 
) [protected, inherited]

Needed by __call().

Will take care of function calls starting with 'set'.

Parameters:
$memberName The name of the member that is possibly being set. Merely the name of the function without the leading 'set', with a lower-case first letter.
$arguments Array containing the arguments that were passed to the function.
$functionName The function that was called.
Returns:
spunQ_DataObject $this

Reimplemented in spunQ_StorableObject.

Definition at line 292 of file DataObject.type.php.

spunQ_DataObject::initLocalizedMember ( memberName  )  [protected, inherited]

Makes sure a localized member contains a spunQ_Map.

Parameters:
$memberName The name of the member. This member must have the option 'localized'.
Returns:
void

Definition at line 245 of file DataObject.type.php.

static spunQ_DataObject::propertyOfValue ( value,
property 
) [static, inherited]

Gets a single property of a value.

See also:
valueByProperty()
Parameters:
$value The value to fetch property for.
$property The property to fetch.
Returns:
any

Definition at line 74 of file DataObject.type.php.

spunQ_Member::setDocumentation ( documentation  ) 

Setter for the documentation of this member.

Parameters:
$documentation The documentation of this member.
Returns:
spunQ.Member $this

Definition at line 100 of file Member.type.php.

spunQ_Member::setName ( name  ) 

Setter for the name of this member.

Returns:
spunQ.Member $this

Definition at line 64 of file Member.type.php.

spunQ_Member::setOptions ( spunQ_Map options  ) 

Setter for the options of this member.

Parameters:
$options The options for this member.
Returns:
spunQ.Member $this

Definition at line 119 of file Member.type.php.

spunQ_Member::setOwningType ( spunQ_UserType owningType  ) 

Setter for the owning type of this member.

Parameters:
$owningType The owning type for this member.
Returns:
spunQ.Member $this

Definition at line 138 of file Member.type.php.

spunQ_Member::setType ( type  ) 

Setter for the type of this member.

Returns:
spunQ.Member $this

Definition at line 81 of file Member.type.php.

static spunQ_DataObject::valueByProperty ( value,
path 
) [static, inherited]

Transforms a value using a property path.

Some types are considered to have properties within spunQ. These properties can be referred to using property path definitions. The most simple case for properties is the user type, for which every member is considered a property. Concatenations of these paths with dots as separators are called property path. The list of all users in the primary group of a given user can be described using this method in a string: 'primaryGroup.users'.
Different types have different properties:

  • UserType: As already mentioned, every member of a user type is a property of an object of that type.
  • Map:
    • _keys: An array of the keys of the map.
    • _values: An array of the values of the map. Note that _keys and _values are guaranteed to return arrays where the index of a key matches the index of its value in the according result.
    • _key: The first entry of the _keys property. This is handy for referencing the key of single key/value pairs.
    • _value: The first entry of the _values property.
    • _count: The amount of items in the map.
  • Array:
    • _keys: The array of keys of the array. Note that the difference between arrays and maps in spunQ is that arrays are always numerically indexed! So this will always return an array containing a range of integers.
    • _values: Array of values in this array. This essentially returns the array as-is and is a NOOP.
    • _key: The first entry of the _keys property.
    • _value: The first entry of the _values property.
    • _count: The amount of items in the array.
  • String:
    • _length: The length of the string.
Parameters:
$value The value to transform
$path The property path to use for the transformation. This can either be a string as described, or an array, each entry holding a property name.
Returns:
any The described value.
Todo:
refactor

Definition at line 54 of file DataObject.type.php.


Member Data Documentation

spunQ_DataObject::$_type [protected, inherited]

The actual type of this object.

Type:
spunQ.Type

Definition at line 129 of file DataObject.type.php.

spunQ_Member::$documentation [protected]

Documentation of this member as extracted from its doc comments.

Type:
string

Definition at line 31 of file Member.type.php.

spunQ_Member::$name [protected]

The name of this member.

Type:
string

Definition at line 19 of file Member.type.php.

spunQ_Member::$options [protected]

See also:
spunQ_Type::$options
Type:
map<string,array<string>>

Definition at line 37 of file Member.type.php.

spunQ_Member::$owningType [protected]

The type this member belongs to.

Type:
spunQ.UserType

Definition at line 13 of file Member.type.php.

spunQ_Member::$type [protected]

Type descriptor of this member.

Type:
spunQ.Type

Definition at line 25 of file Member.type.php.


The documentation for this class was generated from the following file:

Generated on Fri Jul 1 11:12:43 2011 for spunQ3 by  doxygen 1.5.9