-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add converter for data converting between php and database and vice v…
…ersa
- Loading branch information
Marco Bunge
committed
Jul 20, 2016
1 parent
ecff2ca
commit d7cd512
Showing
2 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
|
||
} |