Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
core_kernel_persistence_smoothsql_SmoothIterator
100.00% covered (success)
100.00%
14 / 14
100.00% covered (success)
100.00%
2 / 2
3
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
 current
100.00% covered (success)
100.00%
10 / 10
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3/**
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; under version 2
7 * of the License (non-upgradable).
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
17 *
18 * Copyright (c) 2002-2008 (original work) 2014 Open Assessment Technologies SA
19 *
20 */
21
22/**
23 * Iterator over all triples
24 *
25 * @author joel bout <joel@taotesting.com>
26 * @package generis
27 */
28class core_kernel_persistence_smoothsql_SmoothIterator extends common_persistence_sql_QueryIterator
29{
30    /**
31     * Constructor of the iterator expecting the model ids
32     *
33     * @param array $modelIds
34     */
35    public function __construct(common_persistence_SqlPersistence $persistence, $modelIds = null)
36    {
37        $query = 'SELECT * FROM statements '
38            . (is_null($modelIds) ? '' : 'WHERE modelid IN (' . implode(',', $modelIds) . ') ')
39            . 'ORDER BY id';
40        parent::__construct($persistence, $query);
41    }
42
43    /**
44     * (non-PHPdoc)
45     * @see Iterator::current()
46     * @return core_kernel_classes_Triple
47     */
48    public function current()
49    {
50        $statement = parent::current();
51
52        $triple = new core_kernel_classes_Triple();
53        $triple->modelid = $statement["modelid"];
54        $triple->subject = $statement["subject"];
55        $triple->predicate = $statement["predicate"];
56        $triple->object = $statement["object"];
57        $triple->id = $statement["id"];
58        $triple->lg = $statement["l_language"];
59        $triple->author = $statement["author"];
60        return $triple;
61    }
62}