/** * @param int $bytes * @return string */ public function generate($bytes) { $bytes = parent::validateBytes($bytes); $bin = openssl_random_pseudo_bytes($bytes, $cstrong); $hex = bin2hex($bin); return $hex; }
public function save() { if (!$this->cssgenerator instanceof CSSGenerator) { throw new \Exception('CSSGenerator not set'); } return parent::save(); }
public function _construct() { parent::_construct(); if (!$this->hasInitialObject()) { $this->setInitialObject([]); } }
public function __construct($min = 0, $max = 1, $step = 1) { parent::__construct($min, $max); if (!is_int($step)) { $this->setType(NumberGeneratorInterface::TYPE_FLOAT); } $this->step = $step; }
function __construct($toMock) { parent::__construct($toMock); //ensure the given mock is an interface if (!$this->getToMock()->isInterface()) { throw new GeneratorException(sprintf("The interface to mock %s is not a interface", $toMock)); } }
/** * {@inheritDoc} */ public function generate($input, $output, array $options = array(), $overwrite = false) { $options = $this->handleOptions($options); parent::generate($input, $output, $options, $overwrite); // to delete header or footer generated files if (array_key_exists('header-html', $options) && !filter_var($options['header-html'], FILTER_VALIDATE_URL)) { $this->unlink($options['header-html']); } if (array_key_exists('footer-html', $options) && !filter_var($options['footer-html'], FILTER_VALIDATE_URL)) { $this->unlink($options['footer-html']); } }
/** * {@inheritDoc} */ public function generate($input, $output, array $options = array(), $overwrite = false) { $options = $this->handleOptions($options); parent::generate($input, $output, $options, $overwrite); // to delete header or footer generated files if ($this->hasHtmlHeader) { $this->unlink($options['header-html']); } if ($this->hasHtmlFooter) { $this->unlink($options['footer-html']); } }
/** * Constructor. * * @param string $inClassName * @param string $inSourceFile * @param string $outClassName * @param string $outSourceFile * @throws \RuntimeException */ public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') { if (empty($inSourceFile)) { $inSourceFile = $inClassName . '.php'; } if (!is_file($inSourceFile)) { throw new \RuntimeException(sprintf('"%s" could not be opened.', $inSourceFile)); } if (empty($outClassName)) { $outClassName = substr($inClassName, 0, strlen($inClassName) - 4); } if (empty($outSourceFile)) { $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php'; } parent::__construct($inClassName, $inSourceFile, $outClassName, $outSourceFile); }
/** * Creates instance of geneartor * * @param string $toMock The type of object that needs to be extended * @throws GeneratorException * @internal param string $name Then name of the of the generated class */ function __construct($toMock) { parent::__construct($toMock); //ensure the class is not final if ($this->getToMock()->isFinal()) { throw new GeneratorException(sprintf('Unable to create proxy for %s because its final', $toMock)); } //ensure toMock can be extended if ($this->getToMock()->isInterface()) { throw new GeneratorException(sprintf('Unable to create proxy for %s because its not instantiable or abstract', $toMock)); } $constructor = $this->getToMock()->getConstructor(); if ($constructor != null && $constructor->getNumberOfRequiredParameters() > 0) { throw new GeneratorException(sprintf("Unable to create proxy for %s becuase the constructor has required parameters", $toMock)); } }
/** * Constructor. * * @param string $inClassName * @param string $inSourceFile * @param string $outClassName * @param string $outSourceFile * @throws \RuntimeException */ public function __construct($inClassName, $inSourceFile = '', $outClassName = '', $outSourceFile = '') { if (class_exists($inClassName)) { $reflector = new \ReflectionClass($inClassName); $inSourceFile = $reflector->getFileName(); if ($inSourceFile === false) { $inSourceFile = '<internal>'; } unset($reflector); } else { if (empty($inSourceFile)) { $possibleFilenames = array($inClassName . '.php', str_replace(array('_', '\\'), DIRECTORY_SEPARATOR, $inClassName) . '.php'); foreach ($possibleFilenames as $possibleFilename) { if (is_file($possibleFilename)) { $inSourceFile = $possibleFilename; } } } if (empty($inSourceFile)) { throw new \RuntimeException(sprintf('Neither "%s" nor "%s" could be opened.', $possibleFilenames[0], $possibleFilenames[1])); } if (!is_file($inSourceFile)) { throw new \RuntimeException(sprintf('"%s" could not be opened.', $inSourceFile)); } $inSourceFile = realpath($inSourceFile); include_once $inSourceFile; if (!class_exists($inClassName)) { throw new \RuntimeException(sprintf('Could not find class "%s" in "%s".', $inClassName, $inSourceFile)); } } if (empty($outClassName)) { $outClassName = $inClassName . 'Test'; } if (empty($outSourceFile)) { $outSourceFile = dirname($inSourceFile) . DIRECTORY_SEPARATOR . $outClassName . '.php'; } parent::__construct($inClassName, $inSourceFile, $outClassName, $outSourceFile); }
/** * {@inheritDoc} */ public function __construct($binary = null, array $options = array(), array $env = null) { $this->setDefaultExtension('jpg'); parent::__construct($binary, $options, $env); }
/** * PropertyGenerator constructor. * * @param string $name Property name * @param mixed $value Property value * @param AbstractGenerator|null $parent Parent generator */ public function __construct(string $name, $value = null, AbstractGenerator $parent = null) { $this->name = $name; $this->value = $this->parseValue($value); parent::__construct($parent); }
/** * {@inheritDoc} */ public function generate($input, $output, array $options = array(), $overwrite = false) { $options = $this->handleOptions($this->mergeOptions($options)); parent::generate($input, $output, $options, $overwrite); }
/** * ClassGenerator constructor. * * @param string $className * @param string $testCaseClassName * @param string $testDirectoryName * @param string $sourceFile * @param string $targetClassName * @param string $targetSourceFile */ public function __construct($className, $testCaseClassName, $testDirectoryName, $sourceFile = '', $targetClassName = '', $targetSourceFile = '') { $this->testCaseClassName = $testCaseClassName; parent::__construct($className, $testDirectoryName, $sourceFile, $targetClassName, $targetSourceFile); }
/** * FunctionGenerator constructor. * * @param string $name Function name * @param AbstractGenerator $parent Parent Generator */ public function __construct(string $name, AbstractGenerator $parent = null) { $this->name = $name; parent::__construct($parent); }
public function generate() { parent::generate(); return $this->getTwigPath(); }
/** * ClassGenerator constructor. * * @param string $className Class name * @param GenericGenerator $parent Parent generator */ public function __construct(string $className, GenericGenerator $parent = null) { $this->className = $className; parent::__construct($parent); }
/** * {@inheritDoc} */ public function getOutputFromHtml($html, array $options = array()) { $options = $this->handleOptions($options); return parent::getOutputFromHtml($html, $options); }
/** * @param string path to coverage.dat file * @param string path to source file/directory * @param string */ public function __construct($file, $source = NULL, $title = NULL) { parent::__construct($file, $source); $this->title = $title; }
/** * {@inheritDoc} */ public function __construct(array $options = array()) { $this->setDefaultExtension('jpg'); parent::__construct($options); }
/** * Set a new maximum value for the generator. * * @see \DrupalReleaseDate\NumberGenerator\AbstractGenerator::setMax() */ public function setMax($max) { parent::setMax($max); $this->evaluateWeights(); }
/** * {@inheritDoc} */ public function __construct($binary = null, array $options = array()) { $this->setDefaultExtension('pdf'); parent::__construct($binary, $options); }
/** * {@inheritDoc} */ public function __construct(array $global_options = [], array $object_options = []) { $this->setDefaultExtension('pdf'); parent::__construct($global_options, $object_options); }