Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
CRAP
100.00% covered (success)
100.00%
1 / 1
AbstractQueuedAction
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
3 / 3
4
100.00% covered (success)
100.00%
1 / 1
 getNumberOfActiveActions
n/a
0 / 0
n/a
0 / 0
0
 getId
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getResult
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
2
 setResult
100.00% covered (success)
100.00%
2 / 2
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) 2017 (original work) Open Assessment Technologies SA;
19 *
20 *
21 */
22
23namespace oat\tao\model\actionQueue;
24
25use oat\oatbox\extension\AbstractAction;
26use oat\oatbox\log\LoggerAwareTrait;
27
28/**
29 * class Action
30 * @author Aleh Hutnikau, <hutnikau@1pt.com>
31 * @package oat\tao\model\actionQueue
32 */
33abstract class AbstractQueuedAction extends AbstractAction implements QueuedAction
34{
35    use LoggerAwareTrait;
36
37    /**
38     * Action execution result
39     * @var mixed
40     */
41    protected $result;
42
43    /**
44     * Whether result has been set or not
45     * @var boolean
46     */
47    protected $resultWasSet = false;
48
49    /**
50     * @inheritdoc
51     */
52    abstract public function getNumberOfActiveActions();
53
54    /**
55     * Get action identifier
56     * @return string
57     */
58    final public function getId()
59    {
60        return static::class;
61    }
62
63    /**
64     * Return result of action execution
65     * @return mixed
66     * @throws ActionQueueException
67     */
68    public function getResult()
69    {
70        if (!$this->resultWasSet) {
71            throw new ActionQueueException(__('Action was not executed yet'));
72        }
73        return $this->result;
74    }
75
76    /**
77     * Set result of action
78     * @param mixed $result
79     */
80    public function setResult($result)
81    {
82        $this->resultWasSet = true;
83        $this->result = $result;
84    }
85}