Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Include the remaining methods in TypeInterface.
A few methods were missed originally, and now that Type implements the
interface we can streamline the API docs as well.
  • Loading branch information
markstory committed Aug 7, 2016
1 parent c54b7d5 commit 5706620
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 34 deletions.
39 changes: 6 additions & 33 deletions src/Database/Type.php
Expand Up @@ -174,34 +174,23 @@ public static function clear()
}

/**
* Returns type identifier name for this object
*
* @return string
* {@inheritDoc}
*/
public function getName()
{
return $this->_name;
}

/**
* Returns the base type name that this class is inheriting.
* This is useful when extending base type for adding extra functionality
* but still want the rest of the framework to use the same assumptions it would
* do about the base type it inherits from.
*
* @return string
* {@inheritDoc}
*/
public function getBaseType()
{
return $this->_name;
}

/**
* Casts given value from a PHP type to one acceptable by database
*
* @param mixed $value value to be converted to database equivalent
* @param \Cake\Database\Driver $driver object from which database preferences and configuration will be extracted
* @return mixed
* {@inheritDoc}
*/
public function toDatabase($value, Driver $driver)
{
Expand Down Expand Up @@ -244,11 +233,7 @@ protected function _basicTypeCast($value)
}

/**
* Casts give value to Statement equivalent
*
* @param mixed $value value to be converted to PHP equivalent
* @param \Cake\Database\Driver $driver object from which database preferences and configuration will be extracted
* @return mixed
* {@inheritDoc}
*/
public function toStatement($value, Driver $driver)
{
Expand Down Expand Up @@ -296,27 +281,15 @@ public static function strval($value)
}

/**
* Generate a new primary key value for a given type.
*
* This method can be used by types to create new primary key values
* when entities are inserted.
*
* @return mixed A new primary key value.
* @see \Cake\Database\Type\UuidType
* {@inheritDoc}
*/
public function newId()
{
return null;
}

/**
* Marshalls flat data into PHP objects.
*
* Most useful for converting request data into PHP objects
* that make sense for the rest of the ORM/Database layers.
*
* @param mixed $value The value to convert.
* @return mixed Converted value.
* {@inheritDoc}
*/
public function marshal($value)
{
Expand Down
20 changes: 19 additions & 1 deletion src/Database/TypeInterface.php
Expand Up @@ -9,7 +9,7 @@
*
* @copyright Copyright (c) Cake Software Foundation, Inc. (http://cakefoundation.org)
* @link http://cakephp.org CakePHP(tm) Project
* @since 3.2.13
* @since 3.2.14
* @license http://www.opensource.org/licenses/mit-license.php MIT License
*/
namespace Cake\Database;
Expand Down Expand Up @@ -68,4 +68,22 @@ public function marshal($value);
* @return string
*/
public function getBaseType();

/**
* Returns type identifier name for this object
*
* @return string
*/
public function getName();

/**
* Generate a new primary key value for a given type.
*
* This method can be used by types to create new primary key values
* when entities are inserted.
*
* @return mixed A new primary key value.
* @see \Cake\Database\Type\UuidType
*/
public function newId();
}

0 comments on commit 5706620

Please sign in to comment.