public function testHasAccessToOriginalPhpFunctions() { $array = Arrays::from($this->array); $array = $array->intersect(['foo' => 'bar', 'kal' => 'mon']); $this->assertEquals(['foo' => 'bar'], $array->obtain()); $string = Strings::repeat('foo', 2); $this->assertEquals('foofoo', $string); $string = Strings::from(' foo ')->trim(); $this->assertEquals('foo', $string->obtain()); }
public function testCanRepeatString() { $string = Strings::from('foo')->repeat(3)->obtain(); $this->assertEquals('foofoofoo', $string); }
/** * Create a new PHP Underscore string instance. * * @param string $string * @return static */ public static function from($string = null) { return \Underscore\Types\Strings::from($string); }
public function testCanSwitchTypesMidCourse() { $stringToArray = Strings::from('FOO.BAR')->lower()->explode('.')->last()->title(); $this->assertEquals('Bar', $stringToArray->obtain()); }
/** * Generates a random suite of words. * * @param int $words The number of words * @param int $length The length of each word * * @return string */ public static function randomStrings($words, $length = 10) { return Strings::from('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')->shuffle()->split($length)->slice(0, $words)->implode(' ')->obtain(); }