Where to put arrays with constant value that will be accessed many times?

后端 未结 6 1582
醉酒成梦
醉酒成梦 2021-01-03 18:06

I have some arrays storing the possible parameters for some 3D printer commands. I use this to check if the command is legal. I am confused about where I should put these ar

6条回答
  •  半阙折子戏
    2021-01-03 18:59

    private static $Ms = array(82, 83, 84, 104, 106, 107, 109, 140, 190);
    private static $Gs = array(0, 1, 20, 21, 28, 90, 91, 92);
    private static $Ts = array(0, 1);
    
    
    public function checkFileGcodeFormat(){
    
        if (! ($this->hasM() && $this->hasNoXYZ() && in_array($this->M, self::$Ms)) || ($this->hasG() && in_array($this->G, self::$Gs)) || ($this->hasT() && $this->hasNoXYZ() && in_array($this->T, self::$Ts)) )
            return false;
        else
            return true;
    }
    

提交回复
热议问题