Skip to content

Commit

Permalink
Add converter for data converting between php and database and vice v…
Browse files Browse the repository at this point in the history
…ersa
  • Loading branch information
Marco Bunge committed Jul 20, 2016
1 parent ecff2ca commit d7cd512
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
1 change: 1 addition & 0 deletions ChangeLog-1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes of the Blast orm 1.0 release series are documented in this f

- Add table prefixes when accessing tablename from provider
- Add accessor for definitions in entities
- Add converter for data converting between php and database and vice versa

## 0.6.3

Expand Down
57 changes: 57 additions & 0 deletions src/Entity/Converter/Converter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<?php
/**
*
* (c) Marco Bunge <marco_bunge@web.de>
*
* For the full copyright and license information, please view the LICENSE.txt
* file that was distributed with this source code.
*
* Date: 20.07.2016
* Time: 09:07
*
*/

namespace Blast\Orm\Entity\Converter;
use Doctrine\DBAL\Types\Type;

/**
* Interface Converter
* @package Blast\Orm\Entity\Converter
*
* The converter could be passed to a connection or query object and allows custom converting between
* php and db values and vice versa for a single type.
*/
interface Converter
{

/**
* Converter constructor.
* @param Type $type
*/
public function __construct(Type $type);

/**
* Convert a database value to a PHP value
*
* @param mixed $value
* @param array $options An array of custom options for a specific converter
* @return mixed The converted PHP value
*/
public function toPhpValue($value, array $options = []);

/**
* Convert a PHP value to a database value
*
* @param mixed $value
* @param array $options An array of custom options for a specific converter
* @return mixed The converted database value
*/
public function toDatabaseValue($value, array $options = []);

/**
* The given type for converter
* @return mixed
*/
public function getType();

}

0 comments on commit d7cd512

Please sign in to comment.