public function build()
    {
        $annotationReader = $this->annotationReader;
        if (null === $annotationReader) {
            $annotationReader = new AnnotationReader();
            if (null !== $this->cacheDirectory) {
                $cacheDirectory = sprintf('%s/annotations', $this->cacheDirectory);

                $this->createDirectory($cacheDirectory);
                $annotationReader = new CachedReader($annotationReader, new FilesystemCache($cacheDirectory));
            }
        }

        $metadataDriver  = $this->driverFactory->createDriver($this->metadataDirectories, $annotationReader);

        $metadataFactory = new MetadataFactory($metadataDriver, null, $this->debug);
        $metadataFactory->setIncludeInterfaces($this->includeInterfaceMetadata);

        if (null !== $this->cacheDirectory) {
            $directory = sprintf('%s/metadata', $this->cacheDirectory);

            $this->createDirectory($directory);
            $metadataFactory->setCache(new FileCache($directory));
        }

        return new OpenGraphGenerator($metadataFactory);
    }