This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
interface FactoryInterface { | |
public static function factory($classname, $options = null); | |
public static function validate($classname); | |
public static function getClassMap(); | |
} | |
abstract class AbstractFactory { | |
public static function factory($name, $options = null) | |
{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
define('PASSWORD_SHA256', '$5$'); | |
define('PASSWORD_SHA512', '$6$'); | |
define('PASSWORD_BCRYPT', '$2y$'); | |
define('PASSWORD_SCRYPT', '$7$'); // made up here | |
function password_hash($password, $algo = PASSWORD_BCRYPT, array $options = array()) { | |
$salt = ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static function randBytes($length, $strong = false) | |
{ | |
if ($length <= 0) { | |
return false; | |
} | |
if (extension_loaded('openssl')) { | |
$rand = openssl_random_pseudo_bytes($length, $secure); | |
if ($secure === true) { | |
return $rand; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Set data to use when validating and filtering | |
* | |
* @param array|Traversable $data | |
* @return InputFilterInterface | |
*/ | |
public function setData($data) | |
{ | |
if (!is_array($data) && !$data instanceof Traversable) { | |
throw new Exception\InvalidArgumentException(sprintf( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Zend\InputFilter\InputFilter, | |
Zend\InputFilter\Input; | |
$input = new Input('foo'); | |
$input->getFilterChain() | |
->attachByName('stringtrim') | |
->attachByName('alpha'); | |
$inputFilter = new InputFilter(); | |
$inputFilter->add($input) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// The table queue is empty, I got this Fatal error: Uncaught exception 'Zend\Db\Adapter\Exception\InvalidQueryException' with message 'No database selected' in /.../library/Zend/Db/Adapter/Driver/Pdo/Statement.php on line 219 | |
use Zend\Db\TableGateway\TableGateway, | |
Zend\Db\Adapter\Adapter as DbAdapter; | |
$options = array( | |
'driver' => 'pdo_mysql', | |
'username' => 'queue', | |
'password' => 'xxx', | |
'dbname' => 'queue', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function prepareInsert($adapter, $table, array $fields) | |
{ | |
$sql = 'INSERT INTO ' . $adapter->platform->quoteIdentifier($table) . ' (' . | |
implode(",",array_map(array($adapter->platform, 'quoteIdentifier'), $fields)) . ') VALUES (' . | |
implode(",",array_map(array($adapter->driver, 'formatParameterName'), $fields)) . ')'; | |
return $sql; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Zend\Log; | |
use Zend\Log\Logger; | |
interface LoggerAware | |
{ | |
public function setLogger(Logger $logger); | |
public function getLogger(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the router adapters installed | |
*/ | |
public function getRouterAdapters() | |
{ | |
$adapters = []; | |
if (class_exists('Aura\Router\Router')) { | |
$adapters[] = [ 'Zend\Expressive\Router\Aura' ]; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Ecommerce\V1\Rest\Catalog; | |
class CatalogEntity | |
{ | |
public $id; | |
public $name; | |
public $description; | |
public $picture; | |
public $price; | |
public $quantity; |