Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- INTERFACE StringArray_Interface EXTENDS String_Interface
- {
- public function update(Integer $index, String $value);
- public function get(Integer $index);
- }
- class StringArray extends ObjectArray implements StringArray_Interface
- {
- public function push(String $value) { return parent::_push($value);}
- public function get(Integer $index) { return parent::_get($index);}
- public function update(Integer $index, String $value) { return parent::_update($index, $value);}
- public function toUpper() { foreach($this as $key => $value) $value->toUpper(); return $this;}
- public function toLower() { foreach($this as $key => $value) $value->toLower(); return $this;}
- public function trim(String $replace = NULL) { foreach($this as $key => $value) $value->trim($replace); return $this;}
- public function trimStart(String $replace = NULL) { foreach($this as $key => $value) $value->trimStart(); return $this;}
- public function trimEnd(String $replace = NULL) { foreach($this as $key => $value) $value->trimEnd(); return $this;}
- public function leftJoin(String $string, String $separator = NULL) { foreach($this as $key => $value) $value->leftJoin($string, $separator); return $this;}
- public function rightJoin(String $string, String $separator = NULL) { foreach($this as $key => $value) $value->rightJoin($string, $separator); return $this;}
- public function insert(Integer $start, String $string) { foreach($this as $key => $value) $value->insert($start, $string); return $this;}
- public function padLeft(Integer $chars, String $string = NULL) { foreach($this as $key => $value) $value->padLeft($chars, $string); return $this;}
- public function padRight(Integer $chars, String $string = NULL) { foreach($this as $key => $value) $value->padRight($chars, $string); return $this;}
- public function length() { return new Integer($this->size());}
- public function maxLength() { $l = array(); foreach($this as $key => $value) $l[] = $value->length()->get(); return new Integer(max($l));}
- public function minLength() { $l = array(); foreach($this as $key => $value) $l[] = $value->length()->get(); return new Integer(min($l));}
- public function startsWith(String $string, Boolean $casesensitive = NULL) { foreach($this as $key => $value) $value->startsWith($string, $casesensitive); return $this;}
- public function endsWith(String $string, Boolean $casesensitive = NULL) { foreach($this as $key => $value) $value->endsWith($string, $casesensitive); return $this;}
- public function contains(String $string, Boolean $casesensitive = NULL) { foreach($this as $key => $value) $value->contains($string, $casesensitive); return $this;}
- public function indexOf(String $string, Boolean $casesensitive = NULL) { foreach($this as $key => $value) $value->indexOf($string, $casesensitive); return $this;}
- public function lastIndexOf(String $string, Boolean $casesensitive = NULL) { foreach($this as $key => $value) $value->lastIndexOf($string, $casesensitive); return $this;}
- public function replace(String $search, String $replace = NULL) { foreach($this as $key => $value) $value->replace($search, $replace); return $this;}
- public function remove(Integer $start, Integer $length = NULL) { foreach($this as $key => $value) $value->remove($search, $replace); return $this;}
- public function split(String $string = NULL) { throw new ImplementationException(ImplementationException::ERROR_METHOD_NOT_IMPLEMENTED); }
- public function totalLength(Boolean $asArray = NULL)
- {
- if($asArray === NULL || $asArray->get() === FALSE)
- {
- $counter = 0; foreach($this as $key => $value) $counter += $value->length()->get();
- return new Integer($counter);
- }
- $counter = array();
- foreach($this as $key => $value)
- $counter[] = $value->length()->get();
- return new IntegerArray($counter);
- }
- public function compareTo(String $string, Boolean $casesensitive = NULL) { throw new ImplementationException(ImplementationException::ERROR_METHOD_NOT_IMPLEMENTED); }
- public function __construct(array $array)
- {
- parent::__construct();
- foreach($array as $string)
- try{$this->push(($string instanceOf String) ? $string : new String($string));}
- catch(ArgumentException $e){throw new ObjectArrayException(ObjectArrayException::ERR_NO_REGISTER, $e);}
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement