set() public static method

public static set ( string $key, mixed $object )
$key string
$object mixed
コード例 #1
0
ファイル: SshCommand.php プロジェクト: AOEpeople/AwsInspector
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     Registry::set('output', $output);
     $instance = $input->getArgument('instance');
     $repository = new Repository();
     $instance = $repository->findEc2Instance($instance);
     if (!$instance instanceof Instance) {
         throw new \Exception('Could not find instance');
     }
     $output->writeln('[Found instance: ' . $instance->getDefaultUsername() . '@' . $instance->getConnectionIp() . ']');
     $connection = $instance->getSshConnection();
     if ($command = $input->getOption('command')) {
         $commandObj = new \AwsInspector\Ssh\Command($connection, $command);
         if ($input->getOption('print')) {
             $output->writeln($commandObj->__toString());
             return 0;
         }
         $res = $commandObj->exec();
         $output->writeln($res['output']);
         return $res['returnVar'];
     }
     if ($input->getOption('print')) {
         $output->writeln($connection->__toString());
         return 0;
     }
     $connection->connect();
     return 0;
 }
コード例 #2
0
 /**
  * @test
  */
 public function getReturnsExpectedObject()
 {
     $object = new \stdClass();
     $object->value = 'My String';
     \AwsInspector\Registry::set('key_phpunit_getReturnsExpectedObject', $object);
     $value = \AwsInspector\Registry::get('key_phpunit_getReturnsExpectedObject');
     $this->assertTrue($value instanceof \stdClass);
     $this->assertSame($object->value, $value->value);
 }