<commit_before><?php

namespace BsbFlysystem\Adapter\Factory;

use WindowsAzure\Common\ServicesBuilder;
use League\Flysystem\Azure\AzureAdapter as Adapter;
use UnexpectedValueException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class AzureAdapterFactory extends AbstractAdapterFactory implements FactoryInterface
{

    /**
     * @inheritdoc
     */
    public function doCreateService(ServiceLocatorInterface $serviceLocator)
    {
        $endpoint = sprintf(
            'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s',
            $this->options['account-name'],
            $this->options['account-key']
        );
        $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
        $adapter = new Adapter($blobRestProxy, $this->options['container']);

        return $adapter;
    }

    /**
     * @inheritdoc
     */
    protected function validateConfig()
    {
        if (!isset($this->options['account-name'])) {
            throw new UnexpectedValueException("Missing 'account-name' as option");
        }
        if (!isset($this->options['account-key'])) {
            throw new UnexpectedValueException("Missing 'account-key' as option");
        }
        if (!isset($this->options['container'])) {
            throw new UnexpectedValueException("Missing 'container' as option");
        }
    }
}
<commit_msg>Add a check for AzureAdapter existance<commit_after><?php

namespace BsbFlysystem\Adapter\Factory;

use BsbFlysystem\Exception\RequirementsException;
use WindowsAzure\Common\ServicesBuilder;
use League\Flysystem\Azure\AzureAdapter as Adapter;
use UnexpectedValueException;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;

class AzureAdapterFactory extends AbstractAdapterFactory implements FactoryInterface
{

    /**
     * @inheritdoc
     */
    public function doCreateService(ServiceLocatorInterface $serviceLocator)
    {
        if (!class_exists('League\Flysystem\Azure\AzureAdapter')) {
            throw new RequirementsException(
                ['league/flysystem-azure'],
                'Azure'
            );
        }
        $endpoint = sprintf(
            'DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s',
            $this->options['account-name'],
            $this->options['account-key']
        );
        $blobRestProxy = ServicesBuilder::getInstance()->createBlobService($endpoint);
        $adapter = new Adapter($blobRestProxy, $this->options['container']);

        return $adapter;
    }

    /**
     * @inheritdoc
     */
    protected function validateConfig()
    {
        if (!isset($this->options['account-name'])) {
            throw new UnexpectedValueException("Missing 'account-name' as option");
        }
        if (!isset($this->options['account-key'])) {
            throw new UnexpectedValueException("Missing 'account-key' as option");
        }
        if (!isset($this->options['container'])) {
            throw new UnexpectedValueException("Missing 'container' as option");
        }
    }
}

{'fraction_non_alphanumeric': 0.12023084321898045, 'fraction_numerical': 0.0, 'mean_word_length': 3.0677966101694913, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '517478', 'n_tokens_mistral': 798, 'n_tokens_neox': 780, 'n_words': 148}