Exemplo n.º 1
0
 /**
  * This method returns the first "n" items in the string.
  *
  * @access public
  * @static
  * @param IString\Type $xs                                  the left operand
  * @param IInt32\Type $n                                    the number of items to take
  * @return IString\Type                                     the string
  */
 public static function take(IString\Type $xs, IInt32\Type $n) : IString\Type
 {
     $buffer = '';
     $length = IInt32\Module::min($n, $xs->length());
     for ($i = IInt32\Type::zero(); IInt32\Module::lt($i, $length)->unbox(); $i = IInt32\Module::increment($i)) {
         $buffer .= $xs->__item($i);
     }
     return IString\Type::box($buffer);
 }