public function testGateGetter() { $gate = new Gate('chapelle', 'start'); $this->assertEquals('chapelle', $gate->getName()); }
private function calculateRoute() { $referenceStart = array_search($this->route->getStart()->gate, Gate::listGates($this->route->getWay())); $referenceEnd = array_search($this->route->getEnd()->gate, Gate::listGates($this->route->getWay())); $dataCalculated = ['time' => 0, 'timeReference' => 0, 'kms' => 0]; if ($referenceStart >= $referenceEnd) { while ($referenceStart < count(Gate::listGates($this->route->getWay()))) { $section = $this->sectionCollection->getItems($this->route->getWay(), $referenceStart); $this->route->setSection($section); $dataCalculated = $this->incrementValues($dataCalculated, $section->getData()); $referenceStart++; } //and restart $cursor = 0; while ($cursor < $referenceEnd) { $section = $this->sectionCollection->getItems($this->route->getWay(), $cursor); $this->route->setSection($section); foreach ($section->getData() as $field => $number) { $dataCalculated[$field] += (int) $number; } $cursor++; } } else { while ($referenceStart < $referenceEnd) { $section = $this->sectionCollection->getItems($this->route->getWay(), $referenceStart); $this->route->setSection($section); $dataCalculated = $this->incrementValues($dataCalculated, $section->getData()); $referenceStart++; } } foreach ($dataCalculated as $field => $value) { $this->route->{'set' . ucwords($field)}($value); } }