public function testCanBeCreatedFromLocation() { $location = Location::fromCoordinates(Latitude::fromFloat(10.0), Longitude::fromFloat(10.0)); $jsonLocation = JsonLocation::fromLocation($location); $this->assertInstanceOf(JsonLocation::class, $jsonLocation); return $jsonLocation; }
/** * @param HttpRequest $request */ public function handle(HttpRequest $request) { if ($request->isPost() && $request->getUrl()->getFirstComponent() == 'containers') { return $this->writer->registerContainer(); } if ($request->isGet() && $request->getUrl()->getFirstComponent() == 'containers') { $location = $this->reader->locateContainer(ContainerTrackingNumber::fromString($request->getUrl()->getSecondComponent())); $jsonLocation = JsonLocation::fromLocation($location); return $jsonLocation->json(); } }