Linux::setRaspberry PHP Method

setRaspberry() private method

Set Raspberry device name
private setRaspberry ( $revihex, $cpupart ) : CPU
return CPU name
    private function setRaspberry($revihex, $cpupart)
    {
        $list = @parse_ini_file(APP_ROOT . "/data/raspberry.ini", true);
        if (!$list) {
            return '';
        }
        if (strlen($revihex) == 4) {
            if ($this->sys->getMachine() === "") {
                if (isset($list['old']['_' . $revihex])) {
                    $this->sys->setMachine('Raspberry Pi ' . $list['old']['_' . $revihex]);
                } else {
                    $this->sys->setMachine('Raspberry Pi');
                }
            }
            if (isset($list['cpu'][0])) {
                $cpu_buf = preg_split("/:/", $list['cpu'][0], 2);
                if (trim($cpupart) === trim($cpu_buf[0])) {
                    return trim($cpu_buf[1]);
                } else {
                    return '';
                }
            }
        } elseif (($revi = hexdec($revihex)) & 0x800000) {
            if ($this->sys->getMachine() === "") {
                $model = $revi >> 4 & 255;
                if (isset($list['model'][$model])) {
                    $this->sys->setMachine('Raspberry Pi ' . $list['model'][$model] . ' (PCB 1.' . ($revi & 15) . ')');
                } else {
                    $this->sys->setMachine('Raspberry Pi (PCB 1.' . ($revi & 15) . ')');
                }
            }
            $cpu = $revi >> 12 & 15;
            if (isset($list['cpu'][$cpu])) {
                $cpu_buf = preg_split("/:/", $list['cpu'][$cpu], 2);
                if (trim($cpupart) === trim($cpu_buf[0])) {
                    return trim($cpu_buf[1]);
                } else {
                    return '';
                }
            }
        }
        return '';
    }