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 testCanGetBaseClass()
 {
     $this->assertEquals('Baz', Strings::baseClass('Foo\\Bar\\Baz'));
 }
Example #3
0
function isValidTestName(\string $name)
{
    $name = strtolower($name);
    return Strings::startsWith($name, 'test') || Strings::endsWith($name, 'test');
}
Example #4
0
 /**
  * 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 testMacrosCantConflictBetweenTypes()
 {
     Strings::extend('foobar', function () {
         return 'string';
     });
     Arrays::extend('foobar', function () {
         return 'arrays';
     });
     $this->assertEquals('string', Strings::foobar());
     $this->assertEquals('arrays', Arrays::foobar());
 }
 /**
  * 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();
 }