Address_book_model::get_faculty()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 13
Code Lines 9

Duplication

Lines 13
Ratio 100 %

Importance

Changes 0
Metric Value
cc 3
eloc 9
nc 2
nop 0
dl 13
loc 13
rs 9.4285
c 0
b 0
f 0
1
<?php defined('BASEPATH') OR exit('No direct script access allowed');
2
3
class Address_book_model extends CI_Model {
4
5
    public function __construct() {
6
    }
7
8
    public function change($faculty, $department, $name, $room, $phone, $position) {
9
        
10
        $data = array(
11
            'requested' => date("Y-m-d H:i:s", time()),
12
            'by' => $_SESSION['ldap']['full_name'],
13
            'new_faculty' => $faculty[0]['faculty'],
14
            'new_department' => $department[0]['subfaculty'],
15
            'new_name' => $this->input->post('name'),
16
            'new_room' => $this->input->post('room'),
17
            'new_phone' => $this->input->post('phone'),
18
            'new_position' => $this->input->post('position'),
19
        );
20
        
21
        return $this->db->insert('address_book', $data);
22
        
23
    }
24
    
25 View Code Duplication
    function get_faculty() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
        $this->db->from('faculty');
27
        $this->db->order_by('faculty');
28
        $result = $this->db->get();
29
        $return = array();
30
        if ($result->num_rows() > 0) {
31
            foreach ($result->result_array() as $row) {
32
                $return[$row['cat_id']] = $row['faculty'];
33
            }
34
        }
35
36
        return $return;
37
    }
38
39 View Code Duplication
    function get_department() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
        if (!isset($_GET['cat'])) {
41
            $_GET['cat'] = '1';
42
        }
43
        $result = $this->db->get_where('facultysub', array('cat_id' => $_GET['cat']));
44
        $return = array();
45
        if ($result->num_rows() > 0) {
46
            foreach ($result->result_array() as $row) {
47
                $return[$row['cat_key']] = $row['subfaculty'];
48
            }
49
        }
50
51
        return $return;
52
    }
53
    
54
    function get_faculty_from_number($faculty) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
55
        
56
        $this->db->select('faculty');
57
        $this->db->where('cat_id', $faculty);
58
	$this->db->from('faculty');
59
        return $this->db->get()->result_array();
60
    }
61
    
62
    function get_department_from_number($department) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
63
        
64
        $this->db->select('subfaculty');
65
        $this->db->where('cat_key', $department);
66
	$this->db->from('facultysub');
67
        return $this->db->get()->result_array();
68
    }
69
}
70
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...
71
72
73