Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -0,0 +1,188 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\DotAccessData\Data;
use Dflydev\PlaceholderResolver\PlaceholderResolverInterface;
use Dflydev\PlaceholderResolver\RegexPlaceholderResolver;
abstract class AbstractConfiguration implements ConfigurationInterface
{
private $placeholderResolver;
private $data;
private $exportIsDirty = true;
private $resolvedExport;
/**
* {@inheritdocs}
*/
public function getRaw($key)
{
return $this->data()->get($key);
}
/**
* {@inheritdocs}
*/
public function get($key)
{
$value = $this->getRaw($key);
if (is_object($value)) {
return $value;
}
$this->resolveValues($value);
return $value;
}
/**
* {@inheritdocs}
*/
public function set($key, $value = null)
{
$this->exportIsDirty = true;
return $this->data()->set($key, $value);
}
/**
* {@inheritdocs}
*/
public function append($key, $value = null)
{
$this->exportIsDirty = true;
return $this->data()->append($key, $value);
}
/**
* {@inheritdocs}
*/
public function exportRaw()
{
return $this->data()->export();
}
/**
* {@inheritdocs}
*/
public function export()
{
if ($this->exportIsDirty) {
$this->resolvedExport = $this->data()->export();
$this->resolveValues($this->resolvedExport);
$this->exportIsDirty = false;
}
return $this->resolvedExport;
}
/**
* {@inheritdocs}
*/
public function exportData()
{
return new Data($this->export());
}
/**
* {@inheritdocs}
*/
public function importRaw($imported = null, $clobber = true)
{
$this->exportIsDirty = true;
if (null !== $imported) {
$this->data()->import($imported, $clobber);
}
}
/**
* {@inheritdocs}
*/
public function import(ConfigurationInterface $imported, $clobber = true)
{
return $this->importRaw($imported->exportRaw(), $clobber);
}
/**
* {@inheritdocs}
*/
public function resolve($value = null)
{
if (null === $value) {
return null;
}
return $this->placeholderResolver()->resolvePlaceholder($value);
}
/**
* {@inheritdocs}
*/
public function setPlaceholderResolver(PlaceholderResolverInterface $placeholderResolver)
{
$this->placeholderResolver = $placeholderResolver;
return $this;
}
/**
* Resolve values
*
* For objects, do nothing. For strings, resolve placeholder.
* For arrays, call resolveValues() on each item.
*
* @param mixed $input
*/
protected function resolveValues(&$input = null)
{
if (is_array($input)) {
foreach ($input as $idx => $value) {
$this->resolveValues($value);
$input[$idx] = $value;
}
} else {
if (!is_object($input)) {
$input = $this->placeholderResolver()->resolvePlaceholder($input);
}
}
}
/**
* Data
*
* @return Data
*/
protected function data()
{
if (null === $this->data) {
$this->data = new Data;
}
return $this->data;
}
/**
* Placeholder Resolver
*
* @return PlaceholderResolverInterface
*/
protected function placeholderResolver()
{
if (null === $this->placeholderResolver) {
$this->placeholderResolver = new RegexPlaceholderResolver(new ConfigurationDataSource($this), '%', '%');
}
return $this->placeholderResolver;
}
}

View file

@ -0,0 +1,94 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
abstract class AbstractConfigurationBuilder implements ConfigurationBuilderInterface
{
private $configurationFactory;
private $placeholderResolverFactory;
/**
* Set Configuration Factory
*
* @param ConfigurationFactoryInterface $configurationFactory
*
* @return AbstractConfigurationBuilder
*/
public function setConfigurationFactory(ConfigurationFactoryInterface $configurationFactory)
{
$this->configurationFactory = $configurationFactory;
return $this;
}
/**
* Configuration Factory
*
* @return ConfigurationFactoryInterface
*/
protected function configurationFactory()
{
if (null === $this->configurationFactory) {
$this->configurationFactory = new ConfigurationFactory;
}
return $this->configurationFactory;
}
/**
* {@inheritdocs}
*/
public function build()
{
$configuration = $this->configurationFactory()->create();
if (null !== $this->placeholderResolverFactory) {
$placeholderResolver = $this->placeholderResolverFactory->create($configuration);
$configuration->setPlaceholderResolver($placeholderResolver);
}
$this->internalBuild($configuration);
return $configuration;
}
/**
* Set Placeholder Resolver Factory
*
* @param PlaceholderResolverFactoryInterface $placeholderResolverFactory
*/
public function setPlaceholderResolverFactory(PlaceholderResolverFactoryInterface $placeholderResolverFactory)
{
$this->placeholderResolverFactory = $placeholderResolverFactory;
}
/**
* Called to reconfigure the specified Configuration Builder to be similar to this instance
*
* @param AbstractConfigurationBuilder $configurationBuilder
*/
public function reconfigure(AbstractConfigurationBuilder $configurationBuilder)
{
if (null !== $this->placeholderResolverFactory) {
$configurationBuilder->setPlaceholderResolverFactory($this->placeholderResolverFactory);
}
$configurationBuilder->setConfigurationFactory($this->configurationFactory());
}
/**
* Internal build
*
* @param ConfigurationInterface $configuration
*/
abstract protected function internalBuild(ConfigurationInterface $configuration);
}

View file

@ -0,0 +1,35 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
abstract class AbstractPlaceholderResolverFactory implements PlaceholderResolverFactoryInterface
{
/**
* {@inheritdocs}
*/
public function create(ConfigurationInterface $configuration)
{
return $this->createInternal($configuration, new ConfigurationDataSource($configuration));
}
/**
* Internal create
*
* @param ConfigurationInterface $configuration
* @param DataSourceInterface $dataSource
*
* @return PlaceholderResolverInterface
*/
abstract protected function createInternal(ConfigurationInterface $configuration, DataSourceInterface $dataSource);
}

View file

@ -0,0 +1,25 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class Configuration extends AbstractConfiguration
{
/**
* Constructor
*
* @param array|null $config
*/
public function __construct(array $config = null)
{
$this->importRaw($config);
}
}

View file

@ -0,0 +1,22 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
interface ConfigurationBuilderInterface
{
/**
* Build a Configuration
*
* @return ConfigurationInterface
*/
public function build();
}

View file

@ -0,0 +1,67 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
class ConfigurationDataSource implements DataSourceInterface
{
private $configuration;
/**
* Constructor
*
* @param ConfigurationInterface $configuration
*/
public function __construct(ConfigurationInterface $configuration)
{
$this->setConfiguration($configuration);
}
/**
* {@inheritdoc}
*/
public function exists($key, $system = false)
{
if ($system) {
return false;
}
return null !== $this->configuration->getRaw($key);
}
/**
* {@inheritdoc}
*/
public function get($key, $system = false)
{
if ($system) {
return null;
}
return $this->configuration->getRaw($key);
}
/**
* Set Configuration
*
* @param ConfigurationInterface $configuration
*
* @return ConfigurationDataSource
*/
public function setConfiguration(ConfigurationInterface $configuration)
{
$this->configuration = $configuration;
return $this;
}
}

View file

@ -0,0 +1,23 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
class ConfigurationFactory implements ConfigurationFactoryInterface
{
/**
* {@inheritdocs}
*/
public function create()
{
return new Configuration;
}
}

View file

@ -0,0 +1,22 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
interface ConfigurationFactoryInterface
{
/**
* Create a Configuration
*
* @return ConfigurationInterface
*/
public function create();
}

View file

@ -0,0 +1,111 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\DotAccessData\Data;
use Dflydev\PlaceholderResolver\PlaceholderResolverInterface;
interface ConfigurationInterface
{
/**
* Get a value (with placeholders unresolved)
*
* @param string $key
*
* @return mixed
*/
public function getRaw($key);
/**
* Get a value (with placeholders resolved)
*
* @param string $key
*
* @return mixed
*/
public function get($key);
/**
* Set a value
*
* @param string $key
* @param mixed $value
*/
public function set($key, $value = null);
/**
* Append a value
*
* Will force key to be an array if it is only a string
*
* @param string $key
* @param mixed $value
*/
public function append($key, $value = null);
/**
* Export configuration data as an associtaive array (with placeholders unresolved)
*
* @return array
*/
public function exportRaw();
/**
* Export configuration data as an associtaive array (with placeholders resolved)
*
* @return array
*/
public function export();
/**
* Underlying Data representation
*
* Will have all placeholders resolved.
*
* @return Data
*/
public function exportData();
/**
* Import another Configuration
*
* @param array $imported
* @param bool $clobber
*/
public function importRaw($imported, $clobber = true);
/**
* Import another Configuration
*
* @param ConfigurationInterface $imported
* @param bool $clobber
*/
public function import(ConfigurationInterface $imported, $clobber = true);
/**
* Resolve placeholders in value from configuration
*
* @param string|null $value
*
* @return string
*/
public function resolve($value = null);
/**
* Set Placeholder Resolver
*
* @param PlaceholderResolver $placeholderResolver
*
* @return ConfigurationInterface
*/
public function setPlaceholderResolver(PlaceholderResolverInterface $placeholderResolver);
}

View file

@ -0,0 +1,26 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\PlaceholderResolver\DataSource\DataSourceInterface;
use Dflydev\PlaceholderResolver\RegexPlaceholderResolver;
class PlaceholderResolverFactory extends AbstractPlaceholderResolverFactory
{
/**
* {@inheritdocs}
*/
protected function createInternal(ConfigurationInterface $configuration, DataSourceInterface $dataSource)
{
return new RegexPlaceholderResolver($dataSource, '%', '%');
}
}

View file

@ -0,0 +1,26 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\PlaceholderResolver\PlaceholderResolverInterface;
interface PlaceholderResolverFactoryInterface
{
/**
* Configuration
*
* @param ConfigurationInterface $configuration
*
* @return PlaceholderResolverInterface
*/
public function create(ConfigurationInterface $configuration);
}

View file

@ -0,0 +1,54 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Psr\Log\InvalidArgumentException;
use Symfony\Component\Yaml\Yaml;
class YamlConfigurationBuilder extends AbstractConfigurationBuilder
{
/**
* YAML input string
*
* @var string
*/
protected $input;
/**
* Constructor
*
* @param string|null $input
*/
public function __construct($input = null)
{
$this->input = $input;
}
/**
* {@inheritdocs}
*/
public function internalBuild(ConfigurationInterface $configuration)
{
if (null !== $this->input) {
try{
$yml = Yaml::parse($this->input, Yaml::PARSE_EXCEPTION_ON_INVALID_TYPE);
} catch (\Exception $e) {
throw new InvalidArgumentException($e->getMessage(), 0, $e);
}
if (is_string($yml))
{
throw(new \InvalidArgumentException('Yaml could not be parsed, parser detected a string.'));
}
$configuration->importRaw($yml);
}
}
}

View file

@ -0,0 +1,85 @@
<?php
/*
* This file is a part of dflydev/dot-access-configuration.
*
* (c) Dragonfly Development Inc.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Dflydev\DotAccessConfiguration;
use Dflydev\DotAccessData\Util as DotAccessDataUtil;
use Symfony\Component\Yaml\Yaml;
class YamlFileConfigurationBuilder extends AbstractConfigurationBuilder
{
/**
* YAML Configuration Filenames
*
* @var array
*/
private $yamlConfigurationFilenames;
/**
* Constructor
*
* @param array $yamlConfigurationFilenames
*/
public function __construct(array $yamlConfigurationFilenames)
{
$this->yamlConfigurationFilenames = $yamlConfigurationFilenames;
}
/**
* {@inheritdocs}
*/
public function internalBuild(ConfigurationInterface $configuration)
{
$config = array();
$imports = array();
foreach ($this->yamlConfigurationFilenames as $yamlConfigurationFilename) {
if (file_exists($yamlConfigurationFilename)) {
$config = DotAccessDataUtil::mergeAssocArray($config, Yaml::parse(file_get_contents($yamlConfigurationFilename)));
if (isset($config['imports'])) {
foreach ((array) $config['imports'] as $file) {
if (0 === strpos($file, '/')) {
// Absolute path
$imports[] = $file;
} else {
if ($realpath = realpath(dirname($yamlConfigurationFilename).'/'.$file)) {
$imports[] = $realpath;
}
}
}
}
}
}
if ($imports) {
$importsBuilder = new static($imports);
// We want to reconfigure the imports builder to have the
// same basic configuration as this instance.
$this->reconfigure($importsBuilder);
$configuration->import($importsBuilder->build());
$internalImports = $configuration->get('imports');
} else {
$internalImports = null;
}
$configuration->importRaw($config);
if ($internalImports) {
foreach ((array) $internalImports as $import) {
$configuration->append('imports', $import);
}
}
return $configuration;
}
}