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()); }
/** * Automatic routing */ public function __call($method, $parameters) { // Get view name $view = preg_replace("/([a-z]+)([A-Z][a-z]+)/", '$2', $method); $view = $this->page . '.' . String::lower($view); // Return view if found try { $exists = View::getFinder()->find($view); } catch (InvalidArgumentException $e) { $exists = false; } if ($exists) { return View::make($view); } // Else throw a 404 return parent::__call($method, $parameters); }
public function testCanGetBaseClass() { $this->assertEquals('Baz', String::baseClass('Foo\\Bar\\Baz')); }
public function testMacrosCantConflictBetweenTypes() { String::extend('foobar', function () { return 'string'; }); Arrays::extend('foobar', function () { return 'arrays'; }); $this->assertEquals('string', String::foobar()); $this->assertEquals('arrays', Arrays::foobar()); }
/** * Get the name of the matching table * * @return string */ protected function getTableName() { return String::from(get_called_class())->remove('Seeder')->lower()->obtain(); }
<?php use Flickering\Facades\Flickering; use Underscore\Types\String; require '../vendor/autoload.php'; // Authentificate with the API ------------------------------------- / Flickering::handshake(); // Create a basic router to handle Opauth authentification --------- / // Get current request URI $currentRequest = String::remove($_SERVER['REQUEST_URI'], '/flickering/example/'); // If we're on the login page, or just came back from it, let Opauth handle it if ($currentRequest == '/flickr/' || String::startsWith($currentRequest, '/flickr/oauth_callback')) { return Flickering::getOpauth(); } // If Opauth just took us to the callback adress, launch callback method // to store user access token if ($currentRequest == '/flickr/callback') { Flickering::getOpauthCallback(); } // Display login link if not authentified if (!Flickering::isAuthentified()) { echo '<a href="flickr/">Login to Flickr</a>'; exit; } // Go crazy -------------------------------------------------------- / $userUid = Flickering::getUser()->getUid(); $photos = Flickering::peopleGetPhotos($userUid)->getResults('photo'); var_dump($photos->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(); }