Iterator.php 925 Bytes
Newer Older
1
<?php
lsmith's avatar
lsmith committed
2 3
class Doctrine_Record_Iterator extends ArrayIterator
{
4 5 6 7 8 9 10 11 12 13 14 15 16
    /**
     * @var Doctrine_Record $record
     */
    private $record;
    /**
     * @var Doctrine_Null $null
     */
    private static $null;
    /**
     * constructor
     *
     * @param Doctrine_Record $record
     */
lsmith's avatar
lsmith committed
17 18
    public function __construct(Doctrine_Record $record)
    {
19 20 21 22 23 24 25 26
        $this->record = $record;
        parent::__construct($record->getData());
    }
    /**
     * initNullObject
     *
     * @param Doctrine_Null $null
     */
lsmith's avatar
lsmith committed
27 28
    public static function initNullObject(Doctrine_Null $null)
    {
29 30 31 32 33 34 35
        self::$null = $null;
    }
    /**
     * current
     *
     * @return mixed
     */
lsmith's avatar
lsmith committed
36 37
    public function current()
    {
38 39
        $value = parent::current();

lsmith's avatar
lsmith committed
40
        if ($value === self::$null) {
41
            return null;
lsmith's avatar
lsmith committed
42
        } else {
43
            return $value;
lsmith's avatar
lsmith committed
44
        }
45 46
    }
}