public function testSimpleArraySet()
 {
     $arr['xxxname'] = 'Joe';
     $arr['xxxmale'] = true;
     $s = new Simple();
     $ps = new LoggerReflectionUtils($s);
     $ps->setProperties($arr, "xxx");
     $this->assertEquals($s->getName(), 'Joe');
     $this->assertEquals($s->isMale(), true);
 }
Exemplo n.º 2
0
 public static function getInstance($registry)
 {
     if (self::$_instance === null) {
         self::$_instance = new self($registry);
     }
     return self::$_instance;
 }
Exemplo n.º 3
0
 /**
  * The Content-Length entity-header field indicates the size of the
  * entity-body, in decimal number of OCTETs, sent to the recipient or, in
  * the case of the HEAD method, the size of the entity-body that would
  * have been sent had the request been a GET.
  *
  * Content-Length    = "Content-Length" ":" 1*DIGIT
  *
  * @param  int     $value
  */
 public function __construct($length = null)
 {
     /**
      * @todo: Basic implementation. Add validation?
      */
     parent::__construct('Content-Length', $length);
 }
Exemplo n.º 4
0
 public function testDifferentIvGeneratedOnEachRun()
 {
     $expected = 20;
     $ivs = array();
     for ($i = 1; $i <= $expected; $i++) {
         $ivs[] = $this->_instance->generateIv();
     }
     $duplicatesRemoved = array_values($ivs);
     $this->assertCount($expected, $duplicatesRemoved);
 }
Exemplo n.º 5
0
 /**
  * @param array $state State to restore entity to.
  */
 public function restoreState(array $state)
 {
     parent::restoreState($state);
     if (isset($state['url'])) {
         $this->url = $state['url'];
     }
     if (isset($state['limit'])) {
         $this->limit = $state['limit'];
     }
 }
Exemplo n.º 6
0
 public function __construct($type = 'text/html;', $charset = 'UTF-8')
 {
     /**
      * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
      * @todo: Make it more configurable.
      *
      * This will have to do it for now:
      */
     $content_type = $type . $charset;
     parent::__construct('Content-Type', $type);
 }
Exemplo n.º 7
0
 /**
  * Loads the section $section from the config file $filename for
  * access facilitated by nested object properties.
  *
  * If the section name contains a ":" then the section name to the right
  * is loaded and included into the properties. Note that the keys in
  * this $section will override any keys of the same
  * name in the sections that have been included via ":".
  *
  * If the $section is null, then all sections in the ini file are loaded.
  *
  * If any key includes a ".", then this will act as a separator to
  * create a sub-property.
  *
  * example ini file:
  *      [all]
  *      db.connection = database
  *      hostname = live
  *
  *      [staging : all]
  *      hostname = staging
  *
  * after calling $data = new Yaf_Config_Ini($file, 'staging'); then
  *      $data->hostname === "staging"
  *      $data->db->connection === "database"
  *
  * @param  string        $filename
  * @param  mixed         $section
  * @param  boolean $readonly
  * @throws Yaf_Config_Exception
  * @return void
  */
 public function __construct($filename, $section = null)
 {
     if (empty($filename)) {
         \Yaf\Exception::trigger_error('Unable to find config file ' . $filename, E_USER_ERROR);
         //throw new Yaf_Config_Exception('Filename is not set');
     }
     if (is_array($filename)) {
         $this->_config = $filename;
     } elseif (is_string($filename)) {
         $iniArray = $this->_loadIniFile($filename);
         if (null === $section) {
             // Load entire file
             $dataArray = array();
             foreach ($iniArray as $sectionName => $sectionData) {
                 if (!is_array($sectionData)) {
                     $dataArray = $this->_arrayMergeRecursive($dataArray, $this->_processKey(array(), $sectionName, $sectionData));
                 } else {
                     $dataArray[$sectionName] = $this->_processSection($iniArray, $sectionName);
                 }
             }
             parent::__construct($dataArray, true);
         } else {
             // Load one or more sections
             if (!is_array($section)) {
                 $section = array($section);
             }
             $dataArray = array();
             foreach ($section as $sectionName) {
                 if (!isset($iniArray[$sectionName])) {
                     throw new Exception("There is no section '{$sectionName}' in '{$filename}'");
                 }
                 $dataArray = $this->_arrayMergeRecursive($this->_processSection($iniArray, $sectionName), $dataArray);
             }
             parent::__construct($dataArray, true);
         }
     } else {
         throw new \Yaf\Exception\TypeError('Invalid parameters provided, must be path of ini file');
     }
 }
Exemplo n.º 8
0
 protected function __construct($registry)
 {
     $this->setPage('register');
     parent::__construct($registry);
 }
 /**
  * @param array|\Elastica\Connection[] $connections
  *
  * @throws \Elastica\Exception\ClientException
  *
  * @return \Elastica\Connection
  */
 public function getConnection($connections)
 {
     shuffle($connections);
     return parent::getConnection($connections);
 }
Exemplo n.º 10
0
 public function stop()
 {
     parent::stop();
     $this->stopListeners();
     $this->queries = array();
 }
Exemplo n.º 11
0
 /**
  *
  * @param  int     $code
  */
 public function __construct($code)
 {
     parent::__construct('code', $code);
 }
Exemplo n.º 12
0
<?php

class Simple
{
    public function hello()
    {
        print "Hello world!\n";
    }
}
$simple = new Simple();
$simple->hello();
Exemplo n.º 13
0
 protected function __construct($registry, $settingsId = 0)
 {
     $this->setPage('checkout');
     $this->_settingsId = $settingsId;
     parent::__construct($registry);
 }
Exemplo n.º 14
0
<?php

require_once 'config.php';
header('Content-Type: text/plain');
echo Simple::getValue2() . "\n";
Exemplo n.º 15
0
 public function testUpcountName()
 {
     $resolver = new Simple(__DIR__ . '/../../fixtures');
     $this->assertEquals('real-image (1).jpg', $resolver->upcountName('real-image.jpg'));
     $this->assertEquals('real-image (2).jpg', $resolver->upcountName('real-image (1).jpg'));
 }
Exemplo n.º 16
0
 /**
  * @dataProvider getPatternDirsDataProvider
  */
 public function testGetPatternDirs($pattern, $optionalParameter = null, $expectedResult = null)
 {
     $params = ['optional_parameter' => $optionalParameter, 'required_parameter' => 'required_parameter'];
     $model = new Simple($pattern, ['optional_parameter']);
     $this->assertEquals($expectedResult, $model->getPatternDirs($params));
 }
Exemplo n.º 17
0
<?php

require_once 'config.php';
header('Content-Type: text/plain');
$obj = new Simple();
echo $obj->getValue() . "\n";
Exemplo n.º 18
0
<?php

class Simple
{
    var $x = 10;
    var $y = 10;
    function test()
    {
        return 20;
    }
    static function staticTest()
    {
        return 30;
    }
}
$simple = new Simple();
return $simple->test() + Simple::staticTest() + $simple->staticTest() + $simple->x + $simple->y === 100 ? 'success' : 'fail';
Exemplo n.º 19
0
 public function __construct($options)
 {
     parent::__construct($options);
     $this->setJs(preg_replace('/%msSearchable%/', (int) $this->msSearchable, $this->js));
 }
Exemplo n.º 20
0
 /**
  *
  * @param  string     $message
  */
 public function __construct($message)
 {
     parent::__construct('message', $message);
 }
Exemplo n.º 21
0
 /**
  *
  * @param  string     $errors
  */
 public function __construct(array $errors = array())
 {
     parent::__construct('errors', $errors);
 }
Exemplo n.º 22
0
 /**
  *
  * @param  string     $response
  */
 public function __construct($response = null)
 {
     parent::__construct('response', $response);
 }
Exemplo n.º 23
0
    }
}
class Simple
{
    function test()
    {
        static $i;
        $i++;
        return $i;
    }
}
test();
test();
Foo::test();
Foo::test();
Bar::test();
Bar::test();
$simple = new Simple();
$simple->test();
$simple->test();
static $one = 20, $two, $three = 40;
if ($one !== 20) {
    return 'fail_1';
}
if ($two !== null) {
    return 'fail_2';
}
if ($three !== 40) {
    return 'fail_3';
}
return test() + Foo::test() + Bar::test() + $simple->test() === 12 ? 'success' : 'fail';
Exemplo n.º 24
0
 /**
  * The Transfer-Encoding general-header field indicates what (if any) type
  * of transformation has been applied to the message body in order to
  * safely transfer it between the sender and the recipient. This differs
  * from the content-coding in that the transfer-coding is a property of
  * the message, not of the entity.
  *
  * If multiple encodings have been applied to an entity,
  * the transfer- codings MUST be listed in the order in which they were
  * applied. Additional information about the encoding parameters MAY be
  * provided by other entity-header fields not defined by this
  * specification.
  *
  * @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
  *
  * @param  string     $transfer_encoding
  */
 public function __construct($transfer_encoding = 'chunked')
 {
     parent::__construct('Transfer-Encoding', $transfer_encoding);
 }
Exemplo n.º 25
0
<?php

require '../vendor/autoload.php';
class Simple extends Simplevent\EventEmitter
{
    public $name = "Simple Class";
}
$simple = new Simple();
$nameID = $simple->on("name", function () {
    var_dump($this->name);
});
$clauseID = $simple->once("name", function () {
    var_dump("I just said my name");
});
var_dump($simple->listeners("name"));
$simple->emit("name");
$simple->emit("name");
// $simple->removeListener( "name", $nameID );
$simple->emit("name");