Test Setup Failed
Push — master ( ec638a...cb9435 )
by Julito
51:10
created

aiccObjective::__construct()   D

Complexity

Conditions 10
Paths 12

Size

Total Lines 29
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 10
eloc 19
nc 12
nop 2
dl 0
loc 29
rs 4.8196
c 0
b 0
f 0

How to fix   Complexity   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
require_once 'learnpathItem.class.php';
5
6
/**
7
 * Class aiccObjective
8
 * Class defining the Block elements in an AICC Course Structure file.
9
 * Container for the aiccResource class that deals with elemens from AICC Objectives file
10
 * @package chamilo.learnpath
11
 * @author  Yannick Warnier <[email protected]>
12
 * @license GNU/GPL
13
 */
14
class aiccObjective extends learnpathItem
15
{
16
    public $identifier = '';
17
    public $members = array();
18
19
    /**
20
     * Class constructor. Depending of the type of construction called ('db' or 'manifest'), will create a scormResource
21
     * object from database records or from the array given as second param
22
     * @param    string    Type of construction needed ('db' or 'config', default = 'config')
23
     * @param    mixed    Depending on the type given, DB id for the lp_item or parameters array
24
     */
25
    public function __construct($type = 'config', $params)
26
    {
27
        if (isset($params)) {
28
            switch ($type) {
29
                case 'db':
30
                    // TODO: Implement this way of object creation.
31
                    break;
32
                case 'config': // Do the same as the default.
33
                default:
34
                    foreach ($params as $a => $value) {
35
                        switch ($a) {
36
                            case 'system_id':
37
                                $this->identifier = strtolower($value);
38
                                break;
39
                            case 'member':
40
                                if (strstr($value, ',') !== false) {
41
                                    $temp = explode(',', $value);
42
                                    foreach ($temp as $val) {
43
                                        if (!empty($val)) {
44
                                            $this->members[] = $val;
45
                                        }
46
                                    }
47
                                }
48
                                break;
49
                        }
50
                    }
51
            }
52
        }
53
    }
54
}
55