apiVersion() public static method

Returns the API version for Solar.
public static apiVersion ( ) : string
return string A PHP-standard version number.
Example #1
0
    public function testEncode_dequote()
    {
        $json = $this->_newJson();
        $before = array('parameters' => "Form.serialize('foo')", 'asynchronous' => true, 'onSuccess' => 'function(t) { new Effect.Highlight(el, {"duration":1});}', 'on404' => 'function(t) { alert(\'Error 404: location not found\'); }', 'onFailure' => 'function(t) { alert(\'Ack!\'); }', 'requestHeaders' => array('X-Solar-Version', Solar::apiVersion(), 'X-Foo', 'Bar'));
        $after = $json->encode($before, array('onSuccess', 'on404', 'onFailure', 'parameters'));
        $expect = <<<ENDEXPECT
{"parameters":Form.serialize('foo'),"asynchronous":true,"onSuccess":function(t) { new Effect.Highlight(el, {"duration":1});},"on404":function(t) { alert('Error 404: location not found'); },"onFailure":function(t) { alert('Ack!'); },"requestHeaders":["X-Solar-Version","1.0.0","X-Foo","Bar"]}
ENDEXPECT;
        $this->assertSame($after, trim($expect));
    }
Example #2
0
 /**
  * 
  * Public interface to execute the command.
  * 
  * This method...
  * 
  * - populates and validates the option values
  * - calls _preExec()
  * - calls _exec() with the numeric parameters from the options
  * - calls _postExec()
  * 
  * @param array $argv The command-line arguments from the user.
  * 
  * @return void
  * 
  * @todo Accept a Getopt object in addition to $argv array?
  * 
  */
 public function exec($argv = null)
 {
     // get the command-line arguments
     if ($argv === null) {
         // use the $_SERVER values
         $argv = $this->_request->server['argv'];
         // remove the argument pointing to this command
         array_shift($argv);
     } else {
         $argv = (array) $argv;
     }
     // set options, populate values, and validate parameters
     $this->_getopt->populate($argv);
     if (!$this->_getopt->validate()) {
         // need a better way to throw exceptions with specific error
         // messages
         throw $this->_exception('ERR_INVALID_OPTIONS', array('invalid' => $this->_getopt->getInvalid(), 'options' => $this->_getopt->options));
     }
     // retain the option values, minus the numeric params
     $this->_options = $this->_getopt->values();
     $params = array();
     foreach ($this->_options as $key => $val) {
         if (is_int($key)) {
             $params[] = $val;
             unset($this->_options[$key]);
         }
     }
     // special behavior for -V/--version
     if ($this->_options['version']) {
         $vendor = Solar_Class::vendor($this);
         $this->_out("{$vendor} command-line tool, Solar version ");
         $this->_outln(Solar::apiVersion() . '.');
         return;
     }
     // call pre-exec
     $skip_exec = $this->_preExec();
     // should we skip the main execution?
     if ($skip_exec !== true) {
         // call _exec() with the numeric params from getopt
         call_user_func_array(array($this, '_exec'), $params);
     }
     // call post-exec
     $this->_postExec();
     // done, return terminal to normal colors
     $this->_out("%n");
 }