public function relation(string $resource, int $version = null) : ResourceDefinition
    {
        $version = $version ?? $this->version;

        $found = $this->relations->filter(function (ResourceDefinition $definition) use ($resource, $version) {
            return $definition->version === $version && $definition->resource === $resource;
        });

        if ($found->isEmpty()) {
            throw ResourceNotDefinedException::resource($resource, 'version ' . $version);
        }

        return $found->first();
    }