protected function ensureRepository( $repository ) {
    if ( $repository === null ) {
      return new Repository();
    }

    if ( $repository instanceof RepostoryContract ) {
      return $repository;
    }

    if ( is_array( $repository ) ) {
      return new Repository( $repository );
    }

    throw new \LogicException( 'A repository should either be an array or a Flysystem\Repository object.' );
  }