Exemplo n.º 1
0
 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());
 }
Exemplo n.º 2
0
 /**
  * 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);
 }
Exemplo n.º 3
0
 public function testCanGetBaseClass()
 {
     $this->assertEquals('Baz', String::baseClass('Foo\\Bar\\Baz'));
 }
Exemplo n.º 4
0
 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());
 }
Exemplo n.º 5
0
 /**
  * Get the name of the matching table
  *
  * @return string
  */
 protected function getTableName()
 {
     return String::from(get_called_class())->remove('Seeder')->lower()->obtain();
 }
Exemplo n.º 6
0
<?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());
Exemplo n.º 7
0
 /**
  * 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();
 }