public function testHasAccessToOriginalPhpFunctions() { $array = Arrays::from($this->array); $array = $array->intersect(array('foo' => 'bar', 'kal' => 'mon')); $this->assertEquals(array('foo' => 'bar'), $array->obtain()); $string = String::repeat('foo', 2); $this->assertEquals('foofoo', $string); $string = String::from(' foo ')->trim(); $this->assertEquals('foo', $string->obtain()); }
/** * Precreate object, page and model */ public function __construct() { // Define page if (!$this->page) { $class = get_called_class(); $core = preg_replace('/([a-z])\\\\?([A-Z])/', '$1.$2', $class); // Compute controller $page = String::from($core)->remove('.Controller')->lower()->obtain(); $this->controller = get_called_class(); $this->page = $page; } // Define model $this->model = String::from($core)->explode('.')->removeLast()->last()->singular()->title()->obtain(); $this->item = String::lower($this->model); $this->object = new $this->model(); // Define fallback page $this->here = Redirect::action($this->controller . '@getIndex'); // Share current page with view View::share('page', $this->page); }
public function testCanRepeatString() { $string = String::from('foo')->repeat(3)->obtain(); $this->assertEquals('foofoofoo', $string); }
public function testCanSwitchTypesMidCourse() { $stringToArray = String::from('FOO.BAR')->lower()->explode('.')->last()->title(); $this->assertEquals('Bar', $stringToArray->obtain()); }
/** * Get the name of the matching table * * @return string */ protected function getTableName() { return String::from(get_called_class())->remove('Seeder')->lower()->obtain(); }
/** * Generates a random suite of words * * @param integer $words The number of words * @param integer $length The length of each word * * @return string */ public static function randomStrings($words, $length = 10) { return String::from('0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')->shuffle()->split($length)->slice(0, $words)->implode(' ')->obtain(); }