1 | <?php |
||
2 | |||
3 | /* For licensing terms, see /license.txt */ |
||
4 | |||
5 | namespace Chamilo\PluginBundle\XApi\ToolExperience\Activity; |
||
6 | |||
7 | use Xabbuh\XApi\Model\Activity; |
||
8 | |||
9 | /** |
||
10 | * Class BaseActivity. |
||
11 | * |
||
12 | * @package Chamilo\PluginBundle\XApi\ToolExperience\Activity |
||
13 | */ |
||
14 | abstract class BaseActivity |
||
15 | { |
||
16 | /** |
||
17 | * @var \Chamilo\UserBundle\Entity\User |
||
18 | */ |
||
19 | protected $user; |
||
20 | /** |
||
21 | * @var \Chamilo\CoreBundle\Entity\Course|null |
||
22 | */ |
||
23 | protected $course; |
||
24 | /** |
||
25 | * @var \Chamilo\CoreBundle\Entity\Session|null |
||
26 | */ |
||
27 | protected $session; |
||
28 | |||
29 | abstract public function generate(): Activity; |
||
30 | |||
31 | protected function generateIri(string $path, string $resource, array $params = []): string |
||
32 | { |
||
33 | $cidReq = api_get_cidreq(); |
||
34 | |||
35 | $url = api_get_path($path).$resource; |
||
36 | |||
37 | if ($params) { |
||
0 ignored issues
–
show
|
|||
38 | $url .= '?'.http_build_query($params).'&'; |
||
39 | } elseif (empty($params) && $cidReq) { |
||
40 | $url .= '?'; |
||
41 | } |
||
42 | |||
43 | if ($cidReq) { |
||
44 | $url .= $cidReq; |
||
45 | } |
||
46 | |||
47 | return $url; |
||
48 | } |
||
49 | } |
||
50 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)
or! empty(...)
instead.