Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
TimerStrategyService
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
2 / 2
4
100.00% covered (success)
100.00%
1 / 1
 getExtraTime
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 getMultipliedTime
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
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) 2019 (original work) Open Assessment Technologies SA ;
19 *
20 */
21
22namespace oat\taoQtiTest\models\runner\time;
23
24use oat\oatbox\service\ConfigurableService;
25use oat\taoTests\models\runner\time\TimerStrategyInterface;
26
27class TimerStrategyService extends ConfigurableService implements TimerStrategyInterface
28{
29    /**
30     * @inheritDoc
31     */
32    public function getExtraTime($time, $multiplier)
33    {
34        if ($multiplier <= 1) {
35            return 0;
36        }
37
38        return $this->getMultipliedTime($time, $multiplier) - $time;
39    }
40
41    /**
42     * @inheritDoc
43     */
44    public function getMultipliedTime($time, $multiplier)
45    {
46        if ($multiplier < 1) {
47            return $time;
48        }
49
50        return $time * $multiplier;
51    }
52}