Code Duplication    Length = 18-18 lines in 3 locations

phpsysinfo/includes/mb/class.ipmi.inc.php 3 locations

@@ 62-79 (lines=18) @@
59
     *
60
     * @return void
61
     */
62
    private function _temperature()
63
    {
64
        foreach ($this->_lines as $line) {
65
            $buffer = preg_split("/\s*\|\s*/", $line);
66
            if ($buffer[2] == "degrees C" && $buffer[3] != "na") {
67
                $dev = new SensorDevice();
68
                $dev->setName($buffer[0]);
69
                $dev->setValue($buffer[1]);
70
                if ($buffer[8] != "na") $dev->setMax($buffer[8]);
71
                switch ($buffer[3]) {
72
                    case "nr": $dev->setEvent("Non-Recoverable"); break;
73
                    case "cr": $dev->setEvent("Critical"); break;
74
                    case "nc": $dev->setEvent("Non-Critical"); break;
75
                }
76
                $this->mbinfo->setMbTemp($dev);
77
            }
78
        }
79
    }
80
81
    /**
82
     * get voltage information
@@ 139-156 (lines=18) @@
136
     *
137
     * @return void
138
     */
139
    private function _power()
140
    {
141
        foreach ($this->_lines as $line) {
142
            $buffer = preg_split("/\s*\|\s*/", $line);
143
            if ($buffer[2] == "Watts" && $buffer[3] != "na") {
144
                $dev = new SensorDevice();
145
                $dev->setName($buffer[0]);
146
                $dev->setValue($buffer[1]);
147
                if ($buffer[8] != "na") $dev->setMax($buffer[8]);
148
                switch ($buffer[3]) {
149
                    case "nr": $dev->setEvent("Non-Recoverable"); break;
150
                    case "cr": $dev->setEvent("Critical"); break;
151
                    case "nc": $dev->setEvent("Non-Critical"); break;
152
                }
153
                $this->mbinfo->setMbPower($dev);
154
            }
155
        }
156
    }
157
158
    /**
159
     * get current information
@@ 163-180 (lines=18) @@
160
     *
161
     * @return void
162
     */
163
    private function _current()
164
    {
165
        foreach ($this->_lines as $line) {
166
            $buffer = preg_split("/\s*\|\s*/", $line);
167
            if ($buffer[2] == "Amps" && $buffer[3] != "na") {
168
                $dev = new SensorDevice();
169
                $dev->setName($buffer[0]);
170
                $dev->setValue($buffer[1]);
171
                if ($buffer[8] != "na") $dev->setMax($buffer[8]);
172
                switch ($buffer[3]) {
173
                    case "nr": $dev->setEvent("Non-Recoverable"); break;
174
                    case "cr": $dev->setEvent("Critical"); break;
175
                    case "nc": $dev->setEvent("Non-Critical"); break;
176
                }
177
                $this->mbinfo->setMbCurrent($dev);
178
            }
179
        }
180
    }
181
182
    /**
183
     * get the information