/** * @param string $word * @return mixed */ private function interpret($word) { switch ($word) { case "getName": if ($this->stack[count($this->stack) - 1] == "list") { if ($this->stack[count($this->stack) - 3] == "sample") { // [...] } } else { switch ($this->stack[count($this->stack) - 2]) { case "sample": if ($this->sample instanceof Sample) { $this->result = $this->sample->get_name(); } else { $this->sample = new Sample($this->stack[count($this->stack) - 1]); $this->result = $this->sample->get_name(); } return $this->result; break; } } break; case "item": $sample_item = new SampleItem($this->sample_id); $this->temp = $sample_item->get_sample_items(); array_push($this->stack, "item"); $item_value_var = new ItemValueVar(); $this->result = $item_value_var->get_content($this->string_array, $this->stack, $this->result, $this->temp); $this->stack = $item_value_var->get_stack(); $this->string_array = $item_value_var->get_string_array(); break; default: break; } if (count($this->string_array) == 0) { return $this->result; } else { return $this->get_content(null, null, null, null); } }
/** * @param string $word * @return mixed */ private function interpret($word) { switch ($word) { case "getName": if ($this->stack[count($this->stack) - 1] == "list") { if ($this->stack[count($this->stack) - 3] == "project") { // [...] } } else { switch ($this->stack[count($this->stack) - 2]) { case "project": if ($this->project instanceof Project) { $this->result = $this->project->get_name(); } else { $this->project = new Project($this->stack[count($this->stack) - 1]); $this->result = $this->project->get_name(); } return $this->result; break; } } break; case "item": if ($this->stack[count($this->stack) - 2] == "status") { $project_item = new ProjectItem($this->project_id); $this->temp = $project_item->get_project_status_items($this->stack[count($this->stack) - 1], true); } else { $project_item = new ProjectItem($this->project_id); $this->temp = $project_item->get_project_items(true); } array_push($this->stack, "item"); $item_value_var = new ItemValueVar(); $this->result = $item_value_var->get_content($this->string_array, $this->stack, $this->result, $this->temp); $this->stack = $item_value_var->get_stack(); $this->string_array = $item_value_var->get_string_array(); break; case "current": array_push($this->stack, "status"); if ($this->project instanceof Project == false) { $this->project = new Project($this->stack[count($this->stack) - 1]); } array_push($this->stack, $this->project->get_current_status_id()); break; case "status": array_push($this->stack, "status"); break; case "required": array_push($this->stack, 0); break; default: if (is_numeric($word)) { if ($this->stack[count($this->stack) - 1] == "status") { array_push($this->stack, $word); } } break; } if (count($this->string_array) == 0) { return $this->result; } else { return $this->get_content(null, null, null, null); } }