_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q12200 | CDatabaseBasic.saveHistory | train | public function saveHistory($extra = null)
{
if (!is_null($extra)) {
self::$queries[] = $extra;
self::$params[] = null;
}
self::$queries[] = 'Saved query-history to session.';
self::$params[] = null;
$key = $this->options['session_key'];
$_SE... | php | {
"resource": ""
} |
q12201 | CDatabaseBasic.executeFetchAll | train | public function executeFetchAll(
$query = null,
$params = []
) {
$this->execute($query, $params);
return $this->fetchAll();
} | php | {
"resource": ""
} |
q12202 | CDatabaseBasic.executeFetchOne | train | public function executeFetchOne(
$query = null,
$params = []
) {
$this->execute($query, $params);
return $this->fetchOne();
} | php | {
"resource": ""
} |
q12203 | CDatabaseBasic.fetchInto | train | public function fetchInto($object)
{
$this->stmt->setFetchMode(\PDO::FETCH_INTO, $object);
return $this->stmt->fetch();
} | php | {
"resource": ""
} |
q12204 | Utility.machineName | train | public static function machineName($string, $pattern = '/[^a-zA-Z0-9\-]/')
{
if (!is_string($string)) {
throw new \InvalidArgumentException(
'A non string argument has been given.'
);
}
$string = strtr($string, ' ', '-');
return strtolower(sel... | php | {
"resource": ""
} |
q12205 | CsvManager.hasDuplicates | train | public function hasDuplicates($target)
{
if ($this->exists($target)) {
$duplicates = $this->getDuplicates();
return (int) $duplicates[$target] > 1;
} else {
throw new RuntimeException(sprintf(
'Attempted to read non-existing value %s', $ta... | php | {
"resource": ""
} |
q12206 | CsvManager.append | train | public function append($value)
{
if (strpos($value, self::SEPARATOR) !== false) {
throw new LogicException('A value cannot contain delimiter');
}
array_push($this->collection, $value);
return $this;
} | php | {
"resource": ""
} |
q12207 | CsvManager.exists | train | public function exists()
{
foreach (func_get_args() as $value) {
if (!in_array($value, $this->collection)) {
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q12208 | CsvManager.delete | train | public function delete($target, $keepDuplicates = true)
{
// We need a copy of $this->collection, not itself:
$array = $this->collection;
foreach ($array as $index => $value) {
if ($value == $target) {
unset($array[$index]);
if ($keepDup... | php | {
"resource": ""
} |
q12209 | CsvManager.loadFromString | train | public function loadFromString($string)
{
$target = array();
$array = explode(self::SEPARATOR, $string);
foreach ($array as $index => $value) {
// Additional check
if (!empty($value)) {
// Ensure we have only clean values
if (... | php | {
"resource": ""
} |
q12210 | AbstractMediaElement.createSourceElements | train | final protected function createSourceElements(array $sources)
{
// To be returned
$output = array();
foreach ($sources as $type => $src) {
$output[] = $this->createSourceElement($type, $src);
}
return $output;
} | php | {
"resource": ""
} |
q12211 | AbstractMediaElement.createSourceElement | train | final protected function createSourceElement($type, $src)
{
// Tag attributes
$attrs = array(
'src' => $src,
'type' => $type
);
$node = new NodeElement();
return $node->openTag('source')
->addAttributes($attrs)
... | php | {
"resource": ""
} |
q12212 | Module.getViews | train | public function getViews()
{
$config = $this->config;
$directories = array();
$dir = $this->directory;
if (isset($config['app']['views'])) {
$directoriesTmp = $config['app']['views'];
if (!is_array($directoriesTmp)) {
$directoriesTmp = array($d... | php | {
"resource": ""
} |
q12213 | ObjectEncoder.addIgnoredProperty | train | public function addIgnoredProperty(string $type, $propertyNames): void
{
if (!is_string($propertyNames) && !is_array($propertyNames)) {
throw new InvalidArgumentException('Property name must be a string or array of strings');
}
if (!isset($this->ignoredEncodedPropertyNamesByType... | php | {
"resource": ""
} |
q12214 | ObjectEncoder.decodeArrayOrVariadicConstructorParamValue | train | protected function decodeArrayOrVariadicConstructorParamValue(
ReflectionParameter $constructorParam,
$constructorParamValue,
EncodingContext $context
) {
if (!is_array($constructorParamValue)) {
throw new EncodingException('Value must be an array');
}
if... | php | {
"resource": ""
} |
q12215 | ObjectEncoder.decodeConstructorParamValue | train | private function decodeConstructorParamValue(
ReflectionParameter $constructorParam,
$constructorParamValue,
ReflectionClass $reflectionClass,
string $normalizedHashPropertyName,
EncodingContext $context
) {
if ($constructorParam->hasType() && !$constructorParam->isAr... | php | {
"resource": ""
} |
q12216 | ObjectEncoder.normalizeHashProperties | train | private function normalizeHashProperties(array $objectHash): array
{
$encodedHashProperties = [];
foreach ($objectHash as $propertyName => $propertyValue) {
$encodedHashProperties[$this->normalizePropertyName($propertyName)] = $propertyName;
}
return $encodedHashPropert... | php | {
"resource": ""
} |
q12217 | ObjectEncoder.propertyIsIgnored | train | private function propertyIsIgnored(string $type, string $propertyName): bool
{
return isset($this->ignoredEncodedPropertyNamesByType[$type][$this->normalizePropertyName($propertyName)]);
} | php | {
"resource": ""
} |
q12218 | ObjectEncoder.tryDecodeValueFromGetterType | train | private function tryDecodeValueFromGetterType(
ReflectionClass $reflectionClass,
string $normalizedPropertyName,
$encodedValue,
EncodingContext $context,
&$decodedValue
): bool {
// Check if we can infer the type from any getters or setters
foreach ($reflectio... | php | {
"resource": ""
} |
q12219 | MagicQuotesFilter.filter | train | public function filter($value)
{
return is_array($value) ? array_map(array($this, __FUNCTION__), $value) : stripslashes($value);
} | php | {
"resource": ""
} |
q12220 | LastCategoryKeeper.getLastCategoryId | train | public function getLastCategoryId()
{
$value = $this->getData();
if ($this->flashed === true) {
// Clear data
$this->clearData();
}
return $value;
} | php | {
"resource": ""
} |
q12221 | EnhancementConfigProvider.getDefaultPaymentConfig | train | public function getDefaultPaymentConfig()
{
$configuration = [];
$isActive = $this->enhancementHelper->isActiveDefaultPayment();
$configuration['isActiveDefaultPayment'] = $isActive;
if ($isActive) {
$configuration['defaultMethod'] = $this->enhancementHelper->getDefaultM... | php | {
"resource": ""
} |
q12222 | EnhancementConfigProvider.getGoogleAddressConfig | train | public function getGoogleAddressConfig()
{
$configuration = [];
$isActive = $this->enhancementHelper->isActiveGoogleAddress();
$configuration['isActiveGoogleAddress'] = $isActive;
if ($isActive) {
$configuration['googleAddressCountry'] = $this->enhancementHelper->getGoog... | php | {
"resource": ""
} |
q12223 | PartialBag.getPartialFile | train | public function getPartialFile($name)
{
$file = $this->findPartialFile($name);
if (is_file($file)) {
return $file;
} else if ($this->hasStaticPartial($name)) {
return $this->getStaticFile($name);
} else {
throw new LogicException(sprintf('Could ... | php | {
"resource": ""
} |
q12224 | PartialBag.addStaticPartial | train | public function addStaticPartial($baseDir, $name)
{
$file = $this->createPartialPath($baseDir, $name);
if (!is_file($file)) {
throw new LogicException(sprintf('Invalid base directory or file name provided "%s"', $file));
}
$this->staticPartials[$name] = $file;
r... | php | {
"resource": ""
} |
q12225 | PartialBag.addStaticPartials | train | public function addStaticPartials(array $collection)
{
foreach ($collection as $baseDir => $name) {
$this->addStaticPartial($baseDir, $name);
}
return $this;
} | php | {
"resource": ""
} |
q12226 | PartialBag.findPartialFile | train | private function findPartialFile($name)
{
foreach ($this->partialDirs as $dir) {
$file = $this->createPartialPath($dir, $name);
if (is_file($file)) {
return $file;
}
}
return false;
} | php | {
"resource": ""
} |
q12227 | Aoe_Api2_Model_Acl._setRules | train | protected function _setRules()
{
$resources = $this->getResources();
/** @var Mage_Api2_Model_Resource_Acl_Global_Rule_Collection $rulesCollection */
$rulesCollection = Mage::getResourceModel('api2/acl_global_rule_collection');
foreach ($rulesCollection as $rule) {
/** @... | php | {
"resource": ""
} |
q12228 | HeaderBag.getRequestHeader | train | public function getRequestHeader($header, $default = false)
{
if ($this->hasRequestHeader($header)) {
$headers = $this->getAllRequestHeaders();
return $headers[$header];
} else {
return $default;
}
} | php | {
"resource": ""
} |
q12229 | HeaderBag.setStatusCode | train | public function setStatusCode($code)
{
static $sg = null;
if (is_null($sg)) {
$sg = new StatusGenerator();
}
$status = $sg->generate($code);
if ($status !== false) {
$this->append($status);
}
return $this;
} | php | {
"resource": ""
} |
q12230 | HeaderBag.setMany | train | public function setMany(array $headers)
{
$this->clear();
foreach ($headers as $header) {
$this->append($header);
}
return $this;
} | php | {
"resource": ""
} |
q12231 | HeaderBag.appendPair | train | public function appendPair($key, $value)
{
$header = sprintf('%s: %s', $key, $value);
$this->append($header);
return $this;
} | php | {
"resource": ""
} |
q12232 | HeaderBag.appendPairs | train | public function appendPairs(array $headers)
{
foreach ($headers as $key => $value) {
$this->appendPair($key, $value);
}
return $this;
} | php | {
"resource": ""
} |
q12233 | Response.display | train | public function display()
{
\http_response_code($this->getResponseCode());
if ($this->contentType) {
header('Content-Type: ' . $this->contentType);
}
// header('Content-Length: ' . strlen($this->content));
if ($this->redirection) {
header('Locat... | php | {
"resource": ""
} |
q12234 | HtmlCompressor.compress | train | public function compress($content)
{
// Increment recursion level only before doing a compression
ini_set('pcre.recursion_limit', '16777');
$content = $this->removeSpaces($content);
$content = $this->removeComments($content);
return $content;
} | php | {
"resource": ""
} |
q12235 | DrushCommand.findDrupalDocroot | train | protected function findDrupalDocroot()
{
/** @var EngineType $engine */
$engine = $this->engineInstance();
/** @var DrupalProjectType $project */
$project = $this->projectInstance();
if ($engine instanceof DockerEngineType && !$this->localhost) {
return "/var/ww... | php | {
"resource": ""
} |
q12236 | NewsAdmin.getEditForm | train | public function getEditForm($id = null, $fields = null)
{
$form = parent::getEditForm($id, $fields);
$siteConfig = SiteConfig::current_site_config();
/**
* SortOrder is ignored unless sortable is enabled.
*/
if ($this->modelClass === "Tag" && $siteConfig->AllowTags)... | php | {
"resource": ""
} |
q12237 | NewsAdmin.getList | train | public function getList()
{
/** @var DataList $list */
$list = parent::getList();
if ($this->modelClass === 'News' && class_exists('Subsite') && Subsite::currentSubsiteID() > 0) {
$pages = NewsHolderPage::get()->filter(array('SubsiteID' => (int)Subsite::currentSubsiteID()));
... | php | {
"resource": ""
} |
q12238 | ArrayDigitList.validateDigits | train | private function validateDigits(& $digits)
{
ksort($digits);
if (count($digits) < 2) {
throw new \InvalidArgumentException('Number base must have at least 2 digits');
} elseif (array_keys($digits) !== range(0, count($digits) - 1)) {
throw new \InvalidArgumentExceptio... | php | {
"resource": ""
} |
q12239 | ArrayDigitList.detectDuplicates | train | private function detectDuplicates(array $digits)
{
for ($i = count($digits); $i > 0; $i--) {
if (array_search(array_pop($digits), $digits) !== false) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q12240 | ArrayDigitList.detectConflict | train | private function detectConflict(array $digits, callable $detect)
{
foreach ($digits as $digit) {
if ($this->inDigits($digit, $digits, $detect)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q12241 | ArrayDigitList.inDigits | train | private function inDigits($digit, array $digits, callable $detect)
{
foreach ($digits as $haystack) {
if ($digit !== $haystack && $detect($haystack, $digit) !== false) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q12242 | BaseDataContext.setKernel | train | public function setKernel(KernelInterface $kernel) {
$this->kernel = $kernel;
$this->container = $kernel->getContainer();
} | php | {
"resource": ""
} |
q12243 | BaseDataContext.createClient | train | public function createClient() {
$this->client = $this->getKernel()->getContainer()->get('test.client');
$client = $this->client;
return $client;
} | php | {
"resource": ""
} |
q12244 | BaseDataContext.parseScenarioParameters | train | public function parseScenarioParameters(array &$parameters, $checkExp = false) {
foreach ($parameters as $key => $value) {
if ($this->isScenarioParameter($value, $checkExp)) {
$parameters[$key] = $this->getScenarioParameter($value);
}
}
return $parameters;... | php | {
"resource": ""
} |
q12245 | BaseDataContext.isScenarioParameter | train | public function isScenarioParameter($value, $checkExp = false) {
if ($this->scenarioParameters === null) {
$this->initParameters();
}
$result = isset($this->scenarioParameters[$value]);
if (!$result) {
if (substr($value, 0, 1) === "%" && substr($value, strlen($val... | php | {
"resource": ""
} |
q12246 | BaseDataContext.getScenarioParameter | train | public function getScenarioParameter($key, $checkExp = false) {
$parameters = $this->getScenarioParameters();
// var_dump(array_keys($parameters));
$user = null;
if ($this->currentUser) {
$user = $this->find($this->userClass, $this->currentUser->getId());
}
$v... | php | {
"resource": ""
} |
q12247 | BaseDataContext.iSetConfigurationKeyWithValue | train | public function iSetConfigurationKeyWithValue($wrapperName, $key, $value) {
if ($value === "false") {
$value = false;
} else if ($value === "true") {
$value = true;
}
$configurationManager = $this->container->get($this->container->getParameter("tecnocreaciones_too... | php | {
"resource": ""
} |
q12248 | BaseDataContext.aClearEntityTable | train | public function aClearEntityTable($className, $andWhere = null) {
$doctrine = $this->getDoctrine();
$em = $doctrine->getManager();
if ($em->getFilters()->isEnabled('softdeleteable')) {
$em->getFilters()->disable('softdeleteable');
}
if ($className === \Pandco\Bundle\A... | php | {
"resource": ""
} |
q12249 | BaseDataContext.theQuantityOfElementInEntityIs | train | public function theQuantityOfElementInEntityIs($className, $expresion) {
$doctrine = $this->getDoctrine();
$em = $doctrine->getManager();
$query = $em->createQuery('SELECT COUNT(u.id) FROM ' . $className . ' u');
$count = $query->getSingleScalarResult();
$expAmount = explode(" ",... | php | {
"resource": ""
} |
q12250 | BaseDataContext.findOneElement | train | public function findOneElement($class, UserInterface $user = null) {
$em = $this->getDoctrine()->getManager();
$alias = "o";
$qb = $em->createQueryBuilder()
->select($alias)
->from($class, $alias);
if ($user !== null) {
$qb
... | php | {
"resource": ""
} |
q12251 | BaseDataContext.arrayReplaceRecursiveValue | train | private function arrayReplaceRecursiveValue(&$array, $parameters) {
foreach ($array as $key => $value) {
// create new key in $array, if it is empty or not an array
if (!isset($array[$key]) || (isset($array[$key]) && !is_array($array[$key]))) {
$array[$key] = array();
... | php | {
"resource": ""
} |
q12252 | BaseDataContext.aExecuteCommandTo | train | public function aExecuteCommandTo($command) {
$this->restartKernel();
$kernel = $this->getKernel();
$application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
$application->setAutoExit(false);
$exploded = explode(" ", $command);
$commandsParams = ... | php | {
"resource": ""
} |
q12253 | CreditCardDetector.detect | train | public function detect($number)
{
foreach (self::$cardPatterns as $name => $pattern) {
if (preg_match($pattern, $number)) {
return $name;
}
}
return false;
} | php | {
"resource": ""
} |
q12254 | CacheFile.load | train | public function load()
{
// Check for existence only once and save the result
$exists = is_file($this->file);
if ($this->autoCreate == false && !$exists) {
throw new RuntimeException('File does not exist');
} else if ($this->autoCreate == true && !$exists) {
... | php | {
"resource": ""
} |
q12255 | CacheFile.save | train | public function save(array $data)
{
return (bool) file_put_contents($this->file, $this->serializer->serialize($data));
} | php | {
"resource": ""
} |
q12256 | Scanner.getAccounts | train | public function getAccounts()
{
if ($output = $this->execute('icacls', $this->path)) {
// The first element will always include the path, we'll
// remove it before passing the output to the parser.
$output[0] = str_replace($this->path, '', $output[0]);
// The... | php | {
"resource": ""
} |
q12257 | Scanner.getId | train | public function getId()
{
if ($output = $this->execute('fsutil file queryfileid', $this->path)) {
if ((bool) preg_match('/(\d{1}[x].*)/', $output[0], $matches)) {
return $matches[0];
}
}
} | php | {
"resource": ""
} |
q12258 | Geo.calculateNewCoordinates | train | public static function calculateNewCoordinates(float $initialLatitude, float $initialLongitude, float $distance, int $bearing)
{
$bearing = deg2rad($bearing);
$latitude = deg2rad($initialLatitude);
$longitude = deg2rad($initialLongitude);
$earth = self::EARTH_RADIUS_METERS / 1000;
... | php | {
"resource": ""
} |
q12259 | Geo.calculateDistance | train | public static function calculateDistance(float $sourceLatitude, float $sourceLongitude, float $targetLatitude, float $targetLongitude) : float
{
$radSourceLat = deg2rad($sourceLatitude);
$radSourceLon = deg2rad($sourceLongitude);
$radTargetLat = deg2rad($targetLatitude);
$radTargetLo... | php | {
"resource": ""
} |
q12260 | Checkbox.createHiddenNode | train | private function createHiddenNode(array $attrs)
{
$attrs = array(
'type' => 'hidden',
'name' => $attrs['name'],
'value' => '0'
);
$node = new NodeElement();
$node->openTag('input')
->addAttributes($attrs)
->finalize(true)... | php | {
"resource": ""
} |
q12261 | Checkbox.createCheckboxNode | train | private function createCheckboxNode(array $attrs)
{
$defaults = array(
'type' => 'checkbox',
'value' => '1'
);
$attrs = array_merge($defaults, $attrs);
$node = new NodeElement();
$node->openTag('input')
->addAttributes($attrs);
... | php | {
"resource": ""
} |
q12262 | AbstractArray.has | train | public function has($needle, bool $strict = true): bool
{
foreach ($this->values as $value) {
if ($strict && $value === $needle) {
return true;
}
if ($strict && $value == $needle) {
return true;
}
}
return fals... | php | {
"resource": ""
} |
q12263 | AbstractArray.addValues | train | protected function addValues($values)
{
if (!is_array($values) && !$values instanceof \Traversable) {
//Unable to process values
return;
}
foreach ($values as $value) {
//Passing every value thought the filter
$value = $this->filterValue($valu... | php | {
"resource": ""
} |
q12264 | Assets.generate_script_dependencies | train | public static function generate_script_dependencies( $maybe_dependencies ) {
$dependencies = [];
foreach ( $maybe_dependencies as $dependency ) {
if ( ! wp_script_is( $dependency, 'enqueued' ) && ! wp_script_is( $dependency, 'registered' ) ) {
continue;
}
$dependencies[] = $dependency;
}
return $de... | php | {
"resource": ""
} |
q12265 | Assets.generate_style_dependencies | train | public static function generate_style_dependencies( $maybe_dependencies ) {
$dependencies = [];
foreach ( $maybe_dependencies as $dependency ) {
if ( ! wp_style_is( $dependency, 'enqueued' ) && ! wp_style_is( $dependency, 'registered' ) ) {
continue;
}
$dependencies[] = $dependency;
}
return $depen... | php | {
"resource": ""
} |
q12266 | MapperFactory.createArgs | train | private function createArgs()
{
$args = array($this->db);
if (is_object($this->paginator)) {
array_push($args, $this->paginator);
}
array_push($args, $this->prefix);
return $args;
} | php | {
"resource": ""
} |
q12267 | LabelManager.loadLabels | train | public function loadLabels($locale, $force = false)
{
if (!$this->labelsLoaded || $force) {
if (file_exists(\Nf\Registry::get('applicationPath') . '/labels/' . $locale . '.ini')) {
$this->labels=parse_ini_file(\Nf\Registry::get('applicationPath') . '/labels/' . $locale . '.ini', ... | php | {
"resource": ""
} |
q12268 | YmlCommandLine.fromYamlString | train | public static function fromYamlString($yml, $config_yml = null)
{
$parser = new sfYamlParser();
$yml_tree = $parser->parse($yml);
if ($config_yml) {
$yml_config_tree = $parser->parse($config_yml);
self::mergeDefaultsIntoYml($yml_tree, $yml_config_tree);
}
... | php | {
"resource": ""
} |
q12269 | RouteNotation.toArgs | train | public function toArgs($notation)
{
$target = $this->toClassPath($notation);
return explode(self::ROUTE_SYNTAX_SEPARATOR, $target);
} | php | {
"resource": ""
} |
q12270 | RouteNotation.toCompliant | train | public function toCompliant($notation)
{
$chunks = explode(self::ROUTE_SYNTAX_SEPARATOR, $notation);
// Save the action into a variable
$action = $chunks[1];
// Break what we have according to separators now
$parts = explode(':', $chunks[0]);
// Take a module and sav... | php | {
"resource": ""
} |
q12271 | RouteNotation.toClassPath | train | public function toClassPath($class)
{
$parts = explode(self::ROUTE_SYNTAX_DELIMITER, $class);
$module = $parts[0];
unset($parts[0]);
$path = sprintf('/%s/%s/%s', $module, self::ROUTE_CONTROLLER_DIR, implode('/', $parts));
return $path;
} | php | {
"resource": ""
} |
q12272 | CwsCrypto.hashPassword | train | public function hashPassword($password)
{
if ($this->mode == self::MODE_BCRYPT) {
return $this->hashModeBcrypt($password);
} elseif ($this->mode == self::MODE_PBKDF2) {
return $this->hashModePbkdf2($password);
}
$this->error = 'You have to set the mode...';
... | php | {
"resource": ""
} |
q12273 | CwsCrypto.hashModePbkdf2 | train | private function hashModePbkdf2($password)
{
$this->cwsDebug->titleH2('Create password hash using PBKDF2');
$this->cwsDebug->labelValue('Password', $password);
$salt = $this->random(self::PBKDF2_RANDOM_BYTES);
$this->cwsDebug->labelValue('Salt', $salt);
$algorithm = $this->... | php | {
"resource": ""
} |
q12274 | CwsCrypto.checkPassword | train | public function checkPassword($password, $hash)
{
if ($this->mode == self::MODE_BCRYPT) {
return $this->checkModeBcrypt($password, $hash);
} elseif ($this->mode == self::MODE_PBKDF2) {
return $this->checkModePbkdf2($password, $hash);
}
$this->error = 'You hav... | php | {
"resource": ""
} |
q12275 | CwsCrypto.checkModeBcrypt | train | private function checkModeBcrypt($password, $hash)
{
$this->cwsDebug->titleH2('Check password hash in BCRYPT mode');
$this->cwsDebug->labelValue('Password', $password);
$this->cwsDebug->labelValue('Hash', $hash);
$checkHash = crypt($password, $hash);
$this->cwsDebug->labelVa... | php | {
"resource": ""
} |
q12276 | CwsCrypto.checkModePbkdf2 | train | private function checkModePbkdf2($password, $hash)
{
$this->cwsDebug->titleH2('Check password hash in PBKDF2 mode');
$this->cwsDebug->labelValue('Password', $password);
$this->cwsDebug->dump('Hash', $hash);
$params = explode(self::PBKDF2_SEPARATOR, $hash);
if (count($params)... | php | {
"resource": ""
} |
q12277 | CwsCrypto.encrypt | train | public function encrypt($data)
{
$this->cwsDebug->titleH2('Encrypt data');
if (empty($this->encryptionKey)) {
$this->error = 'You have to set the encryption key...';
$this->cwsDebug->error($this->error);
return;
}
if (empty($data)) {
... | php | {
"resource": ""
} |
q12278 | CwsCrypto.decrypt | train | public function decrypt($data)
{
$this->cwsDebug->titleH2('Decrypt data');
if (empty($this->encryptionKey)) {
$this->error = 'You have to set the encryption key...';
$this->cwsDebug->error($this->error);
return;
}
if (empty($data)) {
... | php | {
"resource": ""
} |
q12279 | CwsCrypto.encode | train | private function encode($data)
{
$rdm = $this->random();
$data = base64_encode($data);
$startIndex = rand(1, strlen($rdm));
$params = base64_encode($startIndex).self::ENC_SEPARATOR;
$params .= base64_encode(strlen($data)).self::ENC_SEPARATOR;
return $params.substr_re... | php | {
"resource": ""
} |
q12280 | CwsCrypto.decode | train | private function decode($encData)
{
$params = explode(self::ENC_SEPARATOR, $encData);
if (count($params) < self::ENC_SECTIONS) {
return false;
}
$startIndex = intval(base64_decode($params[self::ENC_STARTINDEX_INDEX]));
$dataLength = intval(base64_decode($params[s... | php | {
"resource": ""
} |
q12281 | CwsCrypto.validateKey | train | private static function validateKey($key, $size)
{
$length = strlen($key);
if ($length < $size) {
$key = str_pad($key, $size, $key);
} elseif ($length > $size) {
$key = substr($key, 0, $size);
}
return $key;
} | php | {
"resource": ""
} |
q12282 | AuthManager.getData | train | public function getData($key, $default = false)
{
if ($this->sessionBag->has($key)){
return $this->sessionBag->get($key);
} else {
return $default;
}
} | php | {
"resource": ""
} |
q12283 | AuthManager.loggenIn | train | private function loggenIn()
{
if (!$this->has()) {
if (!($this->authService instanceof UserAuthServiceInterface)) {
// Not logged in
return false;
}
// Now try to find only in cookies, if found prepare a bag
if ($this->reAuth->... | php | {
"resource": ""
} |
q12284 | AuthManager.login | train | public function login($login, $passwordHash, $remember = false)
{
if ((bool) $remember == true) {
// Write to client's cookies
$this->reAuth->store($login, $passwordHash);
}
// Store it
$this->sessionBag->set(self::AUTH_NAMESPACE, array(
'login' =... | php | {
"resource": ""
} |
q12285 | AuthManager.logout | train | public function logout()
{
if ($this->has()) {
$this->sessionBag->remove(self::AUTH_NAMESPACE);
}
if ($this->reAuth->isStored()) {
$this->reAuth->clear();
}
} | php | {
"resource": ""
} |
q12286 | ControllersRouteGenerator.generateRoute | train | public function generateRoute($method, array $path) : ?Route {
$pathPartsSize = sizeof($path);
//Obtención del nombre de la clase de controlador
$controllerClassName = $this->namespace;
if ($pathPartsSize > 1) {
for ($i = 0; $i < $pathPartsSize - 1; $i++) {
i... | php | {
"resource": ""
} |
q12287 | Select2Util.convertToDynamicLoader | train | public static function convertToDynamicLoader(ChoiceListFactoryInterface $choiceListFactory, Options $options, $value)
{
if ($value instanceof DynamicChoiceLoaderInterface) {
return $value;
}
if (!\is_array($options['choices'])) {
throw new InvalidConfigurationExcept... | php | {
"resource": ""
} |
q12288 | CommentReport.parameterFields | train | public function parameterFields()
{
$return = FieldList::create(
$title = TextField::create(
'Title', _t('CommentReport.NEWSSEARCHTITLE', 'Search newsitem')
), $count = DropdownField::create(
'Comment', _t('CommentReport.COUNTFILTER', 'Comment count filter... | php | {
"resource": ""
} |
q12289 | Query.get_related_posts_query | train | public static function get_related_posts_query( $post_id ) {
$_post = get_post( $post_id );
if ( ! isset( $_post->ID ) ) {
return;
}
$tax_query = [];
$taxonomies = get_object_taxonomies( get_post_type( $post_id ), 'object' );
foreach ( $taxonomies as $taxonomy ) {
if ( false === $taxonomy->public |... | php | {
"resource": ""
} |
q12290 | CsrfProtector.prepare | train | public function prepare()
{
if (!$this->sessionBag->has(self::CSRF_TKN_NAME)) {
$this->sessionBag->set(self::CSRF_TKN_NAME, $this->generateToken());
$this->sessionBag->set(self::CSRF_TKN_TIME, time());
}
$this->prepared = true;
} | php | {
"resource": ""
} |
q12291 | CsrfProtector.isExpired | train | public function isExpired()
{
$this->validatePrepared();
if (!$this->sessionBag->has(self::CSRF_TKN_TIME)) {
return true;
} else {
$age = time() - $this->sessionBag->get(self::CSRF_TKN_TIME);
return $age >= $this->ttl;
}
} | php | {
"resource": ""
} |
q12292 | CsrfProtector.isValid | train | public function isValid($token)
{
$this->validatePrepared();
return $this->sessionBag->has(self::CSRF_TKN_NAME) &&
$this->sessionBag->has(self::CSRF_TKN_TIME) &&
$this->sessionBag->get(self::CSRF_TKN_NAME) === $token;
} | php | {
"resource": ""
} |
q12293 | Template.getQuery | train | public function getQuery()
{
$properties = array(
'data' => $this,
);
$wrapper = new \stdClass();
$collection = new \StdClass();
foreach ($properties as $name => $value) {
if (is_array( $value )) {
foreach ($value as &$val) {
... | php | {
"resource": ""
} |
q12294 | Template.importItem | train | public function importItem(Item $item)
{
foreach ($this->data as $templateData) {
foreach ($item->getData() as $itemData) {
if ($itemData->getName() === $templateData->getName()) {
$templateData->setName($itemData->getName());
$templateData... | php | {
"resource": ""
} |
q12295 | Math.roundCollection | train | public static function roundCollection(array $data, $precision = 2)
{
$output = array();
foreach ($data as $key => $value){
$output[$key] = round($value, $precision);
}
return $output;
} | php | {
"resource": ""
} |
q12296 | Math.average | train | public static function average($values)
{
$sum = array_sum($values);
$count = count($values);
// Avoid useless calculations
if ($count == 0) {
return 0;
}
return $sum / $count;
} | php | {
"resource": ""
} |
q12297 | Math.percentage | train | public static function percentage($total, $actual, $round = 1)
{
// Avoid useless calculations
if ($total == 0 || $actual == 0) {
return 0;
}
$value = 100 * $actual / $total;
if (is_integer($round)) {
$value = round($value, $round);
}
... | php | {
"resource": ""
} |
q12298 | ConfigProvider.get | train | public function get($key = null, $default = null)
{
if (is_null($key)) {
return Config::get($this->configKey());
}
return Config::get($this->configKey() . '.' . $key, $default);
} | php | {
"resource": ""
} |
q12299 | SickRage.episode | train | public function episode($tvdbId, $season, $episode, $fullPath = 0)
{
$uri = 'episode';
$uriData = [
'tvdbid' => $tvdbId,
'season' => $season,
'episode' => $episode,
'full_path' => $fullPath
];
try {
$response = $... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.