/**
  * Test: Get handler should return an Lumen compatible Array with controller@method
  */
 public function testGetHandlerWithDeepPath()
 {
     $operationMock = \Mockery::mock(OperationReference::class);
     $operationMock->shouldReceive('getPath')->andReturn('/marco/{id}/name/first');
     $operationMock->shouldReceive('getMethod')->andReturn('POST');
     $operationMock->shouldReceive('getOperationId')->andReturn('operationID');
     $this->assertEquals(['uses' => 'Iadvize\\Test\\Marco\\Name\\FirstController@create', 'as' => 'operationID'], $this->operationParser->getHandler($operationMock));
 }
/**
 * Scan the json file and build routes
 *
 * @param string                   $file            The file path
 * @param OperationParserInterface $operationParser Operation parser
 *
 * @return array
 */
function scan($file, OperationParserInterface $operationParser)
{
    $json = file_get_contents($file);
    if (!$json) {
        throw new \LogicException($file . ' can not be read');
    }
    $swagger = json_decode($json);
    if (json_last_error() !== JSON_ERROR_NONE) {
        throw new \LogicException($file . ' is not a valid json file');
    }
    $document = new Document($swagger);
    /** @var OperationReference[] $operations */
    $operations = $document->getOperationsById();
    $routes = [];
    foreach ($operations as $operation) {
        $routes[] = ['method' => $operation->getMethod(), 'uri' => $operation->getPath(), 'action' => $operationParser->getHandler($operation)];
    }
    return $routes;
}