summaryrefslogtreecommitdiffstats
path: root/library/vendor/Zend/Filter/Word/Separator
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--library/vendor/Zend/Filter/Word/Separator/Abstract.php74
-rw-r--r--library/vendor/Zend/Filter/Word/SeparatorToCamelCase.php63
-rw-r--r--library/vendor/Zend/Filter/Word/SeparatorToDash.php45
-rw-r--r--library/vendor/Zend/Filter/Word/SeparatorToSeparator.php127
4 files changed, 309 insertions, 0 deletions
diff --git a/library/vendor/Zend/Filter/Word/Separator/Abstract.php b/library/vendor/Zend/Filter/Word/Separator/Abstract.php
new file mode 100644
index 0000000..7a95034
--- /dev/null
+++ b/library/vendor/Zend/Filter/Word/Separator/Abstract.php
@@ -0,0 +1,74 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * @see Zend_Filter_PregReplace
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Filter
+ * @uses Zend_Filter_PregReplace
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+abstract class Zend_Filter_Word_Separator_Abstract extends Zend_Filter_PregReplace
+{
+
+ protected $_separator = null;
+
+ /**
+ * Constructor
+ *
+ * @param string $separator Space by default
+ * @return void
+ */
+ public function __construct($separator = ' ')
+ {
+ $this->setSeparator($separator);
+ }
+
+ /**
+ * Sets a new seperator
+ *
+ * @param string $separator Seperator
+ * @return $this
+ */
+ public function setSeparator($separator)
+ {
+ if ($separator == null) {
+ throw new Zend_Filter_Exception('"' . $separator . '" is not a valid separator.');
+ }
+ $this->_separator = $separator;
+ return $this;
+ }
+
+ /**
+ * Returns the actual set seperator
+ *
+ * @return string
+ */
+ public function getSeparator()
+ {
+ return $this->_separator;
+ }
+
+}
diff --git a/library/vendor/Zend/Filter/Word/SeparatorToCamelCase.php b/library/vendor/Zend/Filter/Word/SeparatorToCamelCase.php
new file mode 100644
index 0000000..7f53eb7
--- /dev/null
+++ b/library/vendor/Zend/Filter/Word/SeparatorToCamelCase.php
@@ -0,0 +1,63 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * @see Zend_Filter_PregReplace
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Filter_Word_SeparatorToCamelCase extends Zend_Filter_Word_Separator_Abstract
+{
+
+ public function filter($value)
+ {
+ // a unicode safe way of converting characters to \x00\x00 notation
+ $pregQuotedSeparator = preg_quote($this->_separator, '#');
+
+ if (self::isUnicodeSupportEnabled()) {
+ parent::setMatchPattern(array('#('.$pregQuotedSeparator.')(\p{L}{1})#','#(^\p{Ll}{1})#'));
+ parent::setReplacement(array('Zend_Filter_Word_SeparatorToCamelCase', '_strtoupperArray'));
+ } else {
+ parent::setMatchPattern(array('#('.$pregQuotedSeparator.')([A-Za-z]{1})#','#(^[A-Za-z]{1})#'));
+ parent::setReplacement(array('Zend_Filter_Word_SeparatorToCamelCase', '_strtoupperArray'));
+ }
+
+ return preg_replace_callback($this->_matchPattern, $this->_replacement, $value);
+ }
+
+ /**
+ * @param array $matches
+ * @return string
+ */
+ private static function _strtoupperArray(array $matches)
+ {
+ if (array_key_exists(2, $matches)) {
+ return strtoupper($matches[2]);
+ }
+ return strtoupper($matches[1]);
+ }
+
+}
diff --git a/library/vendor/Zend/Filter/Word/SeparatorToDash.php b/library/vendor/Zend/Filter/Word/SeparatorToDash.php
new file mode 100644
index 0000000..aeab938
--- /dev/null
+++ b/library/vendor/Zend/Filter/Word/SeparatorToDash.php
@@ -0,0 +1,45 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * @see Zend_Filter_SeperatorToSeparator
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Filter_Word_SeparatorToDash extends Zend_Filter_Word_SeparatorToSeparator
+{
+ /**
+ * Constructor
+ *
+ * @param string $searchSeparator Seperator to search for change
+ * @return void
+ */
+ public function __construct($searchSeparator = ' ')
+ {
+ parent::__construct($searchSeparator, '-');
+ }
+
+}
diff --git a/library/vendor/Zend/Filter/Word/SeparatorToSeparator.php b/library/vendor/Zend/Filter/Word/SeparatorToSeparator.php
new file mode 100644
index 0000000..d1ce7e9
--- /dev/null
+++ b/library/vendor/Zend/Filter/Word/SeparatorToSeparator.php
@@ -0,0 +1,127 @@
+<?php
+/**
+ * Zend Framework
+ *
+ * LICENSE
+ *
+ * This source file is subject to the new BSD license that is bundled
+ * with this package in the file LICENSE.txt.
+ * It is also available through the world-wide-web at this URL:
+ * http://framework.zend.com/license/new-bsd
+ * If you did not receive a copy of the license and are unable to
+ * obtain it through the world-wide-web, please send an email
+ * to license@zend.com so we can send you a copy immediately.
+ *
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ * @version $Id$
+ */
+
+/**
+ * @see Zend_Filter_PregReplace
+ */
+
+/**
+ * @category Zend
+ * @package Zend_Filter
+ * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
+ * @license http://framework.zend.com/license/new-bsd New BSD License
+ */
+class Zend_Filter_Word_SeparatorToSeparator extends Zend_Filter_PregReplace
+{
+
+ protected $_searchSeparator = null;
+ protected $_replacementSeparator = null;
+
+ /**
+ * Constructor
+ *
+ * @param string $searchSeparator Seperator to search for
+ * @param string $replacementSeperator Seperator to replace with
+ * @return void
+ */
+ public function __construct($searchSeparator = ' ', $replacementSeparator = '-')
+ {
+ $this->setSearchSeparator($searchSeparator);
+ $this->setReplacementSeparator($replacementSeparator);
+ }
+
+ /**
+ * Sets a new seperator to search for
+ *
+ * @param string $separator Seperator to search for
+ * @return $this
+ */
+ public function setSearchSeparator($separator)
+ {
+ $this->_searchSeparator = $separator;
+ return $this;
+ }
+
+ /**
+ * Returns the actual set seperator to search for
+ *
+ * @return string
+ */
+ public function getSearchSeparator()
+ {
+ return $this->_searchSeparator;
+ }
+
+ /**
+ * Sets a new seperator which replaces the searched one
+ *
+ * @param string $separator Seperator which replaces the searched one
+ * @return $this
+ */
+ public function setReplacementSeparator($separator)
+ {
+ $this->_replacementSeparator = $separator;
+ return $this;
+ }
+
+ /**
+ * Returns the actual set seperator which replaces the searched one
+ *
+ * @return string
+ */
+ public function getReplacementSeparator()
+ {
+ return $this->_replacementSeparator;
+ }
+
+ /**
+ * Defined by Zend_Filter_Interface
+ *
+ * Returns the string $value, replacing the searched seperators with the defined ones
+ *
+ * @param string $value
+ * @return string
+ */
+ public function filter($value)
+ {
+ return $this->_separatorToSeparatorFilter($value);
+ }
+
+ /**
+ * Do the real work, replaces the seperator to search for with the replacement seperator
+ *
+ * Returns the replaced string
+ *
+ * @param string $value
+ * @return string
+ */
+ protected function _separatorToSeparatorFilter($value)
+ {
+ if ($this->_searchSeparator == null) {
+ throw new Zend_Filter_Exception('You must provide a search separator for this filter to work.');
+ }
+
+ $this->setMatchPattern('#' . preg_quote($this->_searchSeparator, '#') . '#');
+ $this->setReplacement($this->_replacementSeparator);
+ return parent::filter($value);
+ }
+
+}