本文整理汇总了PHP中AbstractAdapter类的典型用法代码示例。如果您正苦于以下问题:PHP AbstractAdapter类的具体用法?PHP AbstractAdapter怎么用?PHP AbstractAdapter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AbstractAdapter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasValidCharacters
/**
* Checks for allowed characters
* @see Zend\Validator\Barcode.AbstractAdapter::checkChars()
*/
public function hasValidCharacters($value)
{
if (strpbrk($value, 'ABCD')) {
$first = $value[0];
if (!strpbrk($first, 'ABCD')) {
// Missing start char
return false;
}
$last = substr($value, -1, 1);
if (!strpbrk($last, 'ABCD')) {
// Missing stop char
return false;
}
$value = substr($value, 1, -1);
} elseif (strpbrk($value, 'TN*E')) {
$first = $value[0];
if (!strpbrk($first, 'TN*E')) {
// Missing start char
return false;
}
$last = substr($value, -1, 1);
if (!strpbrk($last, 'TN*E')) {
// Missing stop char
return false;
}
$value = substr($value, 1, -1);
}
$chars = $this->getCharacters();
$this->setCharacters('0123456789-$:/.+');
$result = parent::hasValidCharacters($value);
$this->setCharacters($chars);
return $result;
}
示例2: checkChars
/**
* Checks for allowed characters
* @see Zend\Validator\Barcode.AbstractAdapter::checkChars()
*/
public function checkChars($value)
{
$first = $value[0];
if (strpbrk($value, 'ABCD') !== false) {
$first = $value[0];
if (strpbrk($first, 'ABCD') === false) {
// Missing start char
return false;
}
$last = substr($value, -1, 1);
if (strpbrk($last, 'ABCD') === false) {
// Missing stop char
return false;
}
$value = substr($value, 1, -1);
}
$chars = $this->_characters;
$this->_characters = '0123456789-$:/.+';
$result = parent::checkChars($value);
$this->_characters = $chars;
return $result;
}
示例3: select
/**
* @param $element
*
* @return Page
*/
public function select($element)
{
$pageClass = $this->getPageClass($element);
$element = $this->item($element);
$this->debug("Clicking element {$element} (" . $element->getId() . ")\n");
$element->click();
return $this->driver->pageFactoryCreate($pageClass);
}
示例4: testAuthenticationFails
public function testAuthenticationFails()
{
$email = 'user@example.com';
$password = 12345678;
$this->auth->expects($this->once())->method('getAdapter')->will($this->returnValue($this->adapter));
$this->auth->expects($this->once())->method('authenticate')->will($this->returnValue($this->getFailureResult()));
$result = $this->authenticator->authenticate($email, $password);
// Ensures identity and credential were actually set on the mock adapter
$this->assertEquals($email, $this->adapter->getIdentity());
$this->assertEquals($password, $this->adapter->getCredential());
$this->assertFalse($result->isValid());
}
示例5: doFetch
/**
* {@inheritdoc}
*/
protected function doFetch(array $ids)
{
$values = array();
$now = time();
foreach ($ids as $id) {
$file = $this->getFile($id);
if (!file_exists($file) || !($h = @fopen($file, 'rb'))) {
continue;
}
if ($now >= (int) ($expiresAt = fgets($h))) {
fclose($h);
if (isset($expiresAt[0])) {
@unlink($file);
}
} else {
$i = rawurldecode(rtrim(fgets($h)));
$value = stream_get_contents($h);
fclose($h);
if ($i === $id) {
$values[$id] = parent::unserialize($value);
}
}
}
return $values;
}
示例6: setDimensions
/**
* Set dimensions
*
* @param array $dimensions
* @param string $unit
*
* @return void
*/
public function setDimensions(array $dimensions, $unit = null)
{
parent::setDimensions($dimensions, $unit);
if (null !== $unit && ($unit == 'IN' || $unit == 'CM')) {
$this->dimensions['UnitOfMeasurement'] = $unit;
}
}
示例7: __construct
/**
* Constructor
*
* Instantiate the cache db object
*
* @param string $db
* @param int $lifetime
* @param string $table
* @param boolean $pdo
* @throws Exception
* @return Sqlite
*/
public function __construct($db, $lifetime = 0, $table = 'pop_cache', $pdo = false)
{
parent::__construct($lifetime);
$this->setDb($db);
$pdoDrivers = class_exists('Pdo', false) ? \PDO::getAvailableDrivers() : [];
if (!class_exists('Sqlite3', false) && !in_array('sqlite', $pdoDrivers)) {
throw new Exception('Error: SQLite is not available.');
} else {
if ($pdo && !in_array('sqlite', $pdoDrivers)) {
$pdo = false;
} else {
if (!$pdo && !class_exists('Sqlite3', false)) {
$pdo = true;
}
}
}
if ($pdo) {
$this->sqlite = new \PDO('sqlite:' . $this->db);
$this->isPdo = true;
} else {
$this->sqlite = new \SQLite3($this->db);
}
if (null !== $table) {
$this->setTable($table);
}
}
示例8: __construct
/**
* Constructor
*
* Instantiate the APC cache object
*
* @param int $lifetime
* @throws Exception
* @return Apc
*/
public function __construct($lifetime = 0)
{
parent::__construct($lifetime);
if (!function_exists('apc_cache_info')) {
throw new Exception('Error: APC is not available.');
}
$this->info = apc_cache_info();
}
示例9: checkLength
/**
* Overrides parent checkLength
*
* @param string $value Value
* @return boolean
*/
public function checkLength($value)
{
if (strlen($value) != 8) {
$this->setCheck(false);
} else {
$this->setCheck(true);
}
return parent::checkLength($value);
}
示例10: hasValidLength
/**
* Overrides parent checkLength
*
* @param string $value Value
* @return bool
*/
public function hasValidLength($value)
{
if (strlen($value) == 7) {
$this->useChecksum(false);
} else {
$this->useChecksum(true);
}
return parent::hasValidLength($value);
}
示例11: hasValidChecksum
/**
* Validates the checksum
*
* @param string $value The barcode to check the checksum for
* @return bool
*/
public function hasValidChecksum($value)
{
if (strlen($value) == 8) {
$this->setChecksum('issn');
} else {
$this->setChecksum('gtin');
}
return parent::hasValidChecksum($value);
}
示例12: checksum
/**
* Validates the checksum
*
* @param string $value The barcode to check the checksum for
* @return boolean
*/
public function checksum($value)
{
if (strlen($value) == 8) {
$this->_checksum = '_issn';
} else {
$this->_checksum = '_gtin';
}
return parent::checksum($value);
}
示例13: setOption
/**
* {@inheritdoc}
*/
public function setOption($key, $value)
{
switch ($key) {
case 'limit':
$value = (int) $value;
$this->limit = $value;
return true;
}
return parent::setOption($key, $value);
}
示例14: __construct
/**
* Constructor
*
* Instantiate the cache session object
*
* @param int $lifetime
* @return Session
*/
public function __construct($lifetime = 0)
{
parent::__construct($lifetime);
if (session_id() == '') {
session_start();
}
if (!isset($_SESSION['_POP_CACHE'])) {
$_SESSION['_POP_CACHE'] = [];
}
}
示例15: init
public static function init(array $params)
{
parent::init($params);
$redis = new \Redis();
if (array_key_exists('socket', $params)) {
$redis->connect($params['socket']);
} else {
$redis->connect($params['host'], $params['port']);
}
$redis->select($params['index']);
self::$redis = $redis;
}