<?php
namespace Moto\Application\Util\UniqueDuplicator; class AbstractUniqueDuplicator { protected $_suffix = ' '; protected $_maxLength = 200; protected $_lastIndex; protected $_startIndex = 2; public function __construct(array $options = array()) { $this->setOptions($options); } public function setOptions($options) { if (!is_array($options) && !$options instanceof \Traversable) { return $this; } foreach ($options as $key => $value) { $setter = 'set' . str_replace(' ', '', ucwords(str_replace('_', ' ', $key))); if (method_exists($this, $setter)) { $this->{$setter}($value); } } return $this; } public function generate($name) { return $name; } public function setSuffix($suffix) { if (is_string($suffix) && strlen($suffix) < 4) { $this->_suffix = $suffix; } return $this; } public function setMaxLength($maxLength) { if (is_numeric($maxLength) && $maxLength > 4) { $this->_maxLength = $maxLength; } return $this; } public function setStartIndex($startIndex) { if (is_numeric($startIndex) && $startIndex > 0) { $this->_startIndex = $startIndex; } return $this; } public function getLastIndex() { return $this->_lastIndex; } } 