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); }
public static function getInstance($registry) { if (self::$_instance === null) { self::$_instance = new self($registry); } return self::$_instance; }
/** * 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); }
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); }
/** * @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']; } }
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); }
/** * 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'); } }
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); }
public function stop() { parent::stop(); $this->stopListeners(); $this->queries = array(); }
/** * * @param int $code */ public function __construct($code) { parent::__construct('code', $code); }
<?php class Simple { public function hello() { print "Hello world!\n"; } } $simple = new Simple(); $simple->hello();
protected function __construct($registry, $settingsId = 0) { $this->setPage('checkout'); $this->_settingsId = $settingsId; parent::__construct($registry); }
<?php require_once 'config.php'; header('Content-Type: text/plain'); echo Simple::getValue2() . "\n";
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')); }
/** * @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)); }
<?php require_once 'config.php'; header('Content-Type: text/plain'); $obj = new Simple(); echo $obj->getValue() . "\n";
<?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';
public function __construct($options) { parent::__construct($options); $this->setJs(preg_replace('/%msSearchable%/', (int) $this->msSearchable, $this->js)); }
/** * * @param string $message */ public function __construct($message) { parent::__construct('message', $message); }
/** * * @param string $errors */ public function __construct(array $errors = array()) { parent::__construct('errors', $errors); }
/** * * @param string $response */ public function __construct($response = null) { parent::__construct('response', $response); }
} } 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';
/** * 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); }
<?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");