Beispiel #1
0
 public function getByShortName(Text $name)
 {
     foreach ($this->collection as $param) {
         if ($name->equals($param->short_name)) {
             return $param;
         }
     }
 }
Beispiel #2
0
 public function getByShortName(Text $name)
 {
     foreach ($this->collection as $opt) {
         if ($name->equals($opt->short_name)) {
             return $opt;
         }
     }
 }
Beispiel #3
0
 /**
  * @param  Text    $name               The name of the person to say hello to
  * @param  Number  $count              The number of times to say hello
  * @opt            $caps   (short: a)  Whether or not to display text in capitol letters
  */
 public function say(Text $name, Number $count = null, Optional $caps)
 {
     if ($count === null) {
         $count = new Number(1);
     }
     for ($i = 0; $i < $count->raw; $i++) {
         if (!$caps->raw) {
             echo "Hello {$name}\n";
         } else {
             echo "HELLO {$name->toUpperCase()}\n";
         }
     }
 }
Beispiel #4
0
 /**
  * Splits a given Text object based on this regular expression
  * 
  * @param   Text  $text  The text to split
  * 
  * @return  array<Text>  An array of new Text objects based on the given Text, split by this regular expression
  */
 public function split(Text $text)
 {
     return $text->fromArray(preg_split($this->raw, (string) $text));
 }
Beispiel #5
0
 public function testSplitByString()
 {
     $text = new Text('Split me up');
     $delim = new Text(' ');
     $parts = $text->split($delim);
     $this->assertEquals([new Text('Split'), new Text('me'), new Text('up')], $parts);
 }
Beispiel #6
0
 private function underscoreToDash(Text $text)
 {
     return $text->replace($this->text_underscore, $this->text_dash);
 }