for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Vsmoraes\DynamoMapper\Mappings;
use ICanBoogie\Inflector;
use Vsmoraes\DynamoMapper\Exception\InvalidAttributeType;
class Factory
{
const DEFAULT_NAMESPACE = '\Vsmoraes\DynamoMapper\Mappings';
/**
* @param string $type
* @return Mapping
* @throws InvalidAttributeType
*/
public function make(string $type): Mapping
if ($mapClass = $this->isDefaultMapping($type)) {
return new $mapClass;
}
$customMapping = $this->getCustomMapping($type);
if (!is_null($customMapping) && $customMapping instanceof Mapping) {
return $customMapping;
throw new InvalidAttributeType("The attribute type '{$type}' is not supported");
* @return string|null
protected function isDefaultMapping(string $type)
$className = sprintf(
'%s\%sMapping',
static::DEFAULT_NAMESPACE,
Inflector::get()->camelize($type)
);
return class_exists($className) ? $className : null;
* You can extend this class and override this method
* to make your own custom mappings
*
* @see StringMapping for an example
* @return mixed|null
public function getCustomMapping($type)
$type
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.
return null;
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.