= $this->first && $number <= $this->last); } public static function findBlock($number) { // resolve number from right to left to find fitting block $minLength = 4; $try = $number; while(strlen($try) >= $minLength) { $block = VoicenumberblockModel::getFirst(['prefix' => $try]); if($block) { break; } $try = substr($try, 0, strlen($try)-1); } if(!$block) { return false; } return $block; } public function getProperty($name) { if($this->$name == null) { if($name == "files") { $this->files = VoiceblocknumberFileModel::search(["voicenumberblock_id" => $this->id]); return $this->files; } if($name == "numbers") { $this->numbers = VoicenumberModel::search(["voicenumberblock_id" => $this->id]); return $this->numbers; } if($name == "short_prefix") { $this->short_prefix = substr($this->prefix, strlen($this->countrycode.$this->areacode)); return $this->short_prefix; } if($name == "short_first") { $this->short_first = substr($this->first, strlen($this->countrycode.$this->areacode)); return $this->short_first; } if($name == "short_last") { $this->short_last = substr($this->last, strlen($this->countrycode.$this->areacode)); return $this->short_last; } $classname = ucfirst($name); $idfield = $name."_id"; $this->$name = new $classname($this->$idfield); if($this->$name->id) { return $this->$name; } else { return null; } } return $this->$name; } }