protected static function eatBag($input) { $length = strlen($input); $collected = ''; for ($i = 0; $i < $length; $i++) { $c = $input[$i]; if ($c === ';') { break; } else { $collected .= $c; } } return [new Bag($collected), substr($input, $i + 1)]; }