seeder-migration-issues
This commit is contained in:
51
vendor/zendframework/zend-hydrator/src/NamingStrategy/ArrayMapNamingStrategy.php
vendored
Normal file
51
vendor/zendframework/zend-hydrator/src/NamingStrategy/ArrayMapNamingStrategy.php
vendored
Normal file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Hydrator\NamingStrategy;
|
||||
|
||||
class ArrayMapNamingStrategy implements NamingStrategyInterface
|
||||
{
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $extractionMap = [];
|
||||
|
||||
/**
|
||||
* @var string[]
|
||||
*/
|
||||
private $hydrationMap = [];
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param array $extractionMap A map of string keys and values for symmetric translation of hydrated
|
||||
* and extracted field names
|
||||
*/
|
||||
public function __construct(array $extractionMap)
|
||||
{
|
||||
$this->extractionMap = $extractionMap;
|
||||
$this->hydrationMap = array_flip($extractionMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($name)
|
||||
{
|
||||
return isset($this->hydrationMap[$name]) ? $this->hydrationMap[$name] : $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function extract($name)
|
||||
{
|
||||
return isset($this->extractionMap[$name]) ? $this->extractionMap[$name] : $name;
|
||||
}
|
||||
}
|
||||
64
vendor/zendframework/zend-hydrator/src/NamingStrategy/CompositeNamingStrategy.php
vendored
Normal file
64
vendor/zendframework/zend-hydrator/src/NamingStrategy/CompositeNamingStrategy.php
vendored
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Hydrator\NamingStrategy;
|
||||
|
||||
class CompositeNamingStrategy implements NamingStrategyInterface
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $namingStrategies = [];
|
||||
|
||||
/**
|
||||
* @var NamingStrategyInterface
|
||||
*/
|
||||
private $defaultNamingStrategy;
|
||||
|
||||
/**
|
||||
* @param NamingStrategyInterface[] $strategies indexed by the name they translate
|
||||
* @param NamingStrategyInterface|null $defaultNamingStrategy
|
||||
*/
|
||||
public function __construct(array $strategies, NamingStrategyInterface $defaultNamingStrategy = null)
|
||||
{
|
||||
$this->namingStrategies = array_map(
|
||||
function (NamingStrategyInterface $strategy) {
|
||||
// this callback is here only to ensure type-safety
|
||||
return $strategy;
|
||||
},
|
||||
$strategies
|
||||
);
|
||||
|
||||
$this->defaultNamingStrategy = $defaultNamingStrategy ?: new IdentityNamingStrategy();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function extract($name)
|
||||
{
|
||||
$strategy = isset($this->namingStrategies[$name])
|
||||
? $this->namingStrategies[$name]
|
||||
: $this->defaultNamingStrategy;
|
||||
|
||||
return $strategy->extract($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($name)
|
||||
{
|
||||
$strategy = isset($this->namingStrategies[$name])
|
||||
? $this->namingStrategies[$name]
|
||||
: $this->defaultNamingStrategy;
|
||||
|
||||
return $strategy->hydrate($name);
|
||||
}
|
||||
}
|
||||
29
vendor/zendframework/zend-hydrator/src/NamingStrategy/IdentityNamingStrategy.php
vendored
Normal file
29
vendor/zendframework/zend-hydrator/src/NamingStrategy/IdentityNamingStrategy.php
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Hydrator\NamingStrategy;
|
||||
|
||||
class IdentityNamingStrategy implements NamingStrategyInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function hydrate($name)
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function extract($name)
|
||||
{
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
89
vendor/zendframework/zend-hydrator/src/NamingStrategy/MapNamingStrategy.php
vendored
Normal file
89
vendor/zendframework/zend-hydrator/src/NamingStrategy/MapNamingStrategy.php
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Hydrator\NamingStrategy;
|
||||
|
||||
use Zend\Hydrator\Exception\InvalidArgumentException;
|
||||
|
||||
class MapNamingStrategy implements NamingStrategyInterface
|
||||
{
|
||||
/**
|
||||
* Map for hydrate name conversion.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $mapping = [];
|
||||
|
||||
/**
|
||||
* Reversed map for extract name conversion.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $reverse = [];
|
||||
|
||||
/**
|
||||
* Initialize.
|
||||
*
|
||||
* @param array $mapping Map for name conversion on hydration
|
||||
* @param array $reverse Reverse map for name conversion on extraction
|
||||
*/
|
||||
public function __construct(array $mapping, array $reverse = null)
|
||||
{
|
||||
$this->mapping = $mapping;
|
||||
$this->reverse = $reverse ?: $this->flipMapping($mapping);
|
||||
}
|
||||
|
||||
/**
|
||||
* Safelly flip mapping array.
|
||||
*
|
||||
* @param array $array Array to flip
|
||||
* @return array Flipped array
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
protected function flipMapping(array $array)
|
||||
{
|
||||
array_walk($array, function ($value) {
|
||||
if (!is_string($value) && !is_int($value)) {
|
||||
throw new InvalidArgumentException('Mapping array can\'t be flipped because of invalid value');
|
||||
}
|
||||
});
|
||||
|
||||
return array_flip($array);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given name so that it can be extracted by the hydrator.
|
||||
*
|
||||
* @param string $name The original name
|
||||
* @return mixed The hydrated name
|
||||
*/
|
||||
public function hydrate($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->mapping)) {
|
||||
return $this->mapping[$name];
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the given name so that it can be hydrated by the hydrator.
|
||||
*
|
||||
* @param string $name The original name
|
||||
* @return mixed The extracted name
|
||||
*/
|
||||
public function extract($name)
|
||||
{
|
||||
if (array_key_exists($name, $this->reverse)) {
|
||||
return $this->reverse[$name];
|
||||
}
|
||||
|
||||
return $name;
|
||||
}
|
||||
}
|
||||
34
vendor/zendframework/zend-hydrator/src/NamingStrategy/NamingStrategyInterface.php
vendored
Normal file
34
vendor/zendframework/zend-hydrator/src/NamingStrategy/NamingStrategyInterface.php
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Hydrator\NamingStrategy;
|
||||
|
||||
/**
|
||||
* Allow property extraction / hydration for hydrator
|
||||
*/
|
||||
interface NamingStrategyInterface
|
||||
{
|
||||
/**
|
||||
* Converts the given name so that it can be extracted by the hydrator.
|
||||
*
|
||||
* @param string $name The original name
|
||||
* @param object $object (optional) The original object for context.
|
||||
* @return mixed The hydrated name
|
||||
*/
|
||||
public function hydrate($name);
|
||||
|
||||
/**
|
||||
* Converts the given name so that it can be hydrated by the hydrator.
|
||||
*
|
||||
* @param string $name The original name
|
||||
* @param array $data (optional) The original data for context.
|
||||
* @return mixed The extracted name
|
||||
*/
|
||||
public function extract($name);
|
||||
}
|
||||
80
vendor/zendframework/zend-hydrator/src/NamingStrategy/UnderscoreNamingStrategy.php
vendored
Normal file
80
vendor/zendframework/zend-hydrator/src/NamingStrategy/UnderscoreNamingStrategy.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
/**
|
||||
* Zend Framework (http://framework.zend.com/)
|
||||
*
|
||||
* @link http://github.com/zendframework/zf2 for the canonical source repository
|
||||
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
|
||||
* @license http://framework.zend.com/license/new-bsd New BSD License
|
||||
*/
|
||||
|
||||
namespace Zend\Hydrator\NamingStrategy;
|
||||
|
||||
use Zend\Filter\FilterChain;
|
||||
|
||||
class UnderscoreNamingStrategy implements NamingStrategyInterface
|
||||
{
|
||||
/**
|
||||
* @var FilterChain|null
|
||||
*/
|
||||
protected static $camelCaseToUnderscoreFilter;
|
||||
|
||||
/**
|
||||
* @var FilterChain|null
|
||||
*/
|
||||
protected static $underscoreToStudlyCaseFilter;
|
||||
|
||||
/**
|
||||
* Remove underscores and capitalize letters
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function hydrate($name)
|
||||
{
|
||||
return $this->getUnderscoreToStudlyCaseFilter()->filter($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove capitalized letters and prepend underscores.
|
||||
*
|
||||
* @param string $name
|
||||
* @return string
|
||||
*/
|
||||
public function extract($name)
|
||||
{
|
||||
return $this->getCamelCaseToUnderscoreFilter()->filter($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FilterChain
|
||||
*/
|
||||
protected function getUnderscoreToStudlyCaseFilter()
|
||||
{
|
||||
if (static::$underscoreToStudlyCaseFilter instanceof FilterChain) {
|
||||
return static::$underscoreToStudlyCaseFilter;
|
||||
}
|
||||
|
||||
$filter = new FilterChain();
|
||||
|
||||
$filter->attachByName('WordUnderscoreToStudlyCase');
|
||||
|
||||
return static::$underscoreToStudlyCaseFilter = $filter;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return FilterChain
|
||||
*/
|
||||
protected function getCamelCaseToUnderscoreFilter()
|
||||
{
|
||||
if (static::$camelCaseToUnderscoreFilter instanceof FilterChain) {
|
||||
return static::$camelCaseToUnderscoreFilter;
|
||||
}
|
||||
|
||||
$filter = new FilterChain();
|
||||
|
||||
$filter->attachByName('WordCamelCaseToUnderscore');
|
||||
$filter->attachByName('StringToLower');
|
||||
|
||||
return static::$camelCaseToUnderscoreFilter = $filter;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user