Exemplo n.º 1
0
 /**
  * Checks to see if a flag or serial flag (eg. -y or --pass) is set
  * @param string $flag The flag name/character (can be single or a serial character)
  * @return boolean
  */
 public function isFlagSet($flag)
 {
     if (in_array($flag, $this->flags->all()->toArray())) {
         return true;
     }
     return false;
 }
Exemplo n.º 2
0
 public function testPrependCollection()
 {
     $collection = new Collection(['two', 'three', 'four']);
     $collection->prepend('one');
     $this->assertEquals(['one', 'two', 'three', 'four'], $collection->all()->toArray());
 }
Exemplo n.º 3
0
 /**
  * Writes the environmental variables to the Nginx configuration file.
  * @param Collection $envars
  * @return boolean
  */
 private function writeToVhostConf(Collection $envars)
 {
     $vhost_conf = NginxHandler::VHOST_AVAILABLE_DIR . DIRECTORY_SEPARATOR . $this->identifier . '.conf';
     $configuration = '';
     foreach ($envars->all()->toArray() as $key => $value) {
         $configuration .= '    fastcgi_param               ' . $key . ' ' . $value . ';' . PHP_EOL;
     }
     if (!@file_put_contents($vhost_conf, replace_between(file_get_contents($vhost_conf), '# [[ENVARS]]', '# [[!ENVARS]]', PHP_EOL . $configuration))) {
         return false;
     }
     return true;
 }
Exemplo n.º 4
0
<?php

require_once '../lib/collection.inc.php';
use Ballen\Collection\Collection;
$cars = new Collection();
// Add some cars...
$cars->push('Ford Focus');
$cars->push('BMW 580i');
$cars->push('Toyota Avensis');
$cars->push('Marcos Martina Spyder');
// Lets output the cars as a JSON object
echo $cars->all()->toJson();
// How many cars do we have?
echo '<p>Total cars:' . $cars->count() . '</p>';
// Add some more cars...
$cars->push(['Ferrari Modena', 'Seat Leon', 'Peugeot 307', 'Toyota Auris']);
// How many do we have now?
echo '<p>Total cars after adding four:' . $cars->count() . '</p>';
// Lets get the first car in our collection...
echo '<p>First car added was: ' . $cars->first() . '</p>';
// Get the last car from our collection...
echo '<p>Last car added was: ' . $cars->last() . '</p>';
$mini_cooper = 'Nope!';
if ($cars->has('Mini Cooper')) {
    $mini_cooper = 'Yes!';
}
echo '<p>Do we have a Mini Cooper in our collection? ' . $mini_cooper . '</p>';
// Lets shuffle (randomise) our collection...
$cars->shuffle();
echo '<p>Randomised our order now looks like: ' . $cars->all()->toJson() . '</p>';
// We now have zero items in our collection...