_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q252300 | Path.files | validation | public static function files($path, array $extensions = array())
{
$files = array();
$it = new \RecursiveDirectoryIterator($path);
$filter = false;
if(!empty($extensions) && is_array($extensions)){
$filter = true;
}
foreach(new \RecursiveIteratorItera... | php | {
"resource": ""
} |
q252301 | StringType.value | validation | public function value($encoding = null)
{
if ($this->value !== null) {
if ($encoding === null) {
return mb_convert_encoding($this->value, $this->encoding, 'UTF-8');
} else {
$encoding = $this->getRealEncoding($encoding);
return mb_conve... | php | {
"resource": ""
} |
q252302 | StringType.supportedEncodings | validation | public static function supportedEncodings()
{
if (static::$supported_encodings === null) {
$supported = mb_list_encodings();
foreach ($supported as $key => $value) {
static::$supported_encodings[strtolower($value)] = $value;
foreach (mb_encoding_alia... | php | {
"resource": ""
} |
q252303 | StringType.isEncodingSupported | validation | public static function isEncodingSupported($encoding)
{
$encoding = strtolower($encoding);
if (isset (static::supportedEncodings()[$encoding])) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q252304 | StringType.getRealEncoding | validation | public function getRealEncoding($encoding)
{
if (static::isEncodingSupported($encoding) === false) {
throw new \Exception('Encoding is not supported: "' . $encoding . '"');
}
return static::supportedEncodings()[strtolower($encoding)];
} | php | {
"resource": ""
} |
q252305 | StringType.upperFirst | validation | public function upperFirst()
{
$this->value = mb_strtoupper(mb_substr($this->value, 0, 1, 'UTF-8'), 'UTF-8') . mb_substr($this->value, 1, null, 'UTF-8');
return $this;
} | php | {
"resource": ""
} |
q252306 | LogStyler.icon | validation | public function icon($level, $default = null)
{
if (array_key_exists($level, $this->icons)) {
return $this->icons[$level];
}
return $default;
} | php | {
"resource": ""
} |
q252307 | Query.addMethods | validation | public function addMethods($mixin, array $methods)
{
foreach ($methods as $method)
{
$this->method_map[$method] = $mixin;
}
return $this;
} | php | {
"resource": ""
} |
q252308 | Query.compileMixins | validation | protected function compileMixins()
{
$sql = array();
foreach ($this->mixins as $mixin)
{
$compiled = $this->{$mixin}->compile();
if ($compiled !== "")
{
$sql[] = $compiled;
}
}
return $sql;
} | php | {
"resource": ""
} |
q252309 | CascadeGateway.sendMessage | validation | public function sendMessage(Message $message)
{
$exceptions = [];
/** @var string $gatewayName */
/** @var GatewayInterface $gateway*/
foreach ($this->gateways as $gatewayName => $gateway) {
try {
$gateway->sendMessage($message);
return;
... | php | {
"resource": ""
} |
q252310 | ProductStatusTransformer.getStatusData | validation | protected function getStatusData($identifier)
{
foreach ($this->options['statuses'] as $status) {
if ((int)$status['id'] === (int)$identifier) {
return $status;
}
}
return null;
} | php | {
"resource": ""
} |
q252311 | DataBuilder.setBoolean | validation | public function setBoolean(string $key, $value, bool $ignoredDefaultValue = null)
{
$this->set($key, (bool) $value, $ignoredDefaultValue);
return $this;
} | php | {
"resource": ""
} |
q252312 | DataBuilder.setInteger | validation | public function setInteger(string $key, $value, int $ignoredDefaultValue = null)
{
$this->set($key, (int) $value, $ignoredDefaultValue);
return $this;
} | php | {
"resource": ""
} |
q252313 | DataBuilder.setFloat | validation | public function setFloat(string $key, $value, float $ignoredDefaultValue = null)
{
$this->set($key, (float) $value, $ignoredDefaultValue);
return $this;
} | php | {
"resource": ""
} |
q252314 | DataBuilder.setString | validation | public function setString(string $key, $value, string $ignoredDefaultValue = null)
{
$this->set($key, (string) $value, $ignoredDefaultValue);
return $this;
} | php | {
"resource": ""
} |
q252315 | DataBuilder.setDateTime | validation | public function setDateTime(string $key, $value, string $format, string $ignoredDefaultValue = null)
{
if ($value instanceof DateTime) {
$this->set($key, $value->format($format), $ignoredDefaultValue);
}
return $this;
} | php | {
"resource": ""
} |
q252316 | DataBuilder.setArray | validation | public function setArray(string $key, $value, callable $callback = null, array $ignoredDefaultValue = null)
{
if ($value instanceof Traversable) {
$value = iterator_to_array($value);
}
if (is_array($value)) {
if (is_callable($callback)) {
$value = arra... | php | {
"resource": ""
} |
q252317 | Client.getHttpClient | validation | public function getHttpClient()
{
if (null === $this->httpClient) {
$this->httpClient = new HttpClient();
$this->httpClient->setAdapter($this->getHttpAdapter());
}
return $this->httpClient;
} | php | {
"resource": ""
} |
q252318 | Client.getHttpAdapter | validation | public function getHttpAdapter()
{
if (null === $this->httpAdapter) {
$this->httpAdapter = new Curl();
$this->httpAdapter->setOptions(array(
'sslverifypeer' =>false,
));
}
return $this->httpAdapter;
} | php | {
"resource": ""
} |
q252319 | Tools.formatPhoneNumber | validation | public static function formatPhoneNumber($phoneNumber, $formatType = Tools::PHONE_NUMBER_FORMAT_NUMBER)
{
$formatType = (int)$formatType;
if ($formatType !== self::PHONE_NUMBER_FORMAT_INTERNATIONAL && $formatType !== self::PHONE_NUMBER_FORMAT_INTERNATIONAL_NICE &&
$formatType !== self::... | php | {
"resource": ""
} |
q252320 | Tools.getMonthName | validation | public static function getMonthName($month)
{
if ($month < 1 || $month > 12) {
return '';
}
$monthNames = [
1 => self::poorManTranslate('fts-shared', 'January'),
2 => self::poorManTranslate('fts-shared', 'February'),
3 => self::poorManTranslat... | php | {
"resource": ""
} |
q252321 | Tools.getDayName | validation | public static function getDayName($day)
{
if ($day < self::DOW_MONDAY || $day > self::DOW_SUNDAY) {
return '';
}
$dayNames = [
self::DOW_MONDAY => self::poorManTranslate('fts-shared', 'Monday'),
self::DOW_TUESDAY => self::poorManTranslate('fts-shared', 'T... | php | {
"resource": ""
} |
q252322 | Tools.GUIDv4 | validation | public static function GUIDv4()
{
return sprintf(
'%04x%04x-%04x-%04x-%04x-%04x%04x%04x',
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0xffff),
mt_rand(0, 0x0fff) | 0x4000,
mt_rand(0, 0x3fff) | 0x8000,
mt_rand(0, 0xfff... | php | {
"resource": ""
} |
q252323 | Tools.GUIDv5 | validation | public static function GUIDv5($namespace, $name)
{
if (!Validate::isGuid($namespace)) {
return false;
}
$nHex = str_replace(['-', '{', '}'], '', $namespace);
$nStr = '';
$nHexLen = \strlen($nHex);
for ($i = 0; $i < $nHexLen; $i += 2) {
$nStr ... | php | {
"resource": ""
} |
q252324 | Tools.passwdGen | validation | public static function passwdGen($length = 8, $flag = 'ALPHANUMERIC')
{
switch ($flag) {
case 'NUMERIC':
$str = '0123456789';
break;
case 'ALPHA':
$str = 'abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
break;
... | php | {
"resource": ""
} |
q252325 | Tools.deleteDirectory | validation | public static function deleteDirectory($dirName, $deleteSelf = true)
{
$dirName = rtrim($dirName, '/') . '/';
if (file_exists($dirName) && $files = scandir($dirName, SCANDIR_SORT_NONE)) {
foreach ($files as $file) {
if ($file !== '.' && $file !== '..' && $file !== '.svn')... | php | {
"resource": ""
} |
q252326 | Tools.unformatBytes | validation | public static function unformatBytes($value)
{
if (is_numeric($value)) {
return $value;
}
$value_length = strlen($value);
$qty = (int)substr($value, 0, $value_length - 1);
$unit = strtolower(substr($value, $value_length - 1));
switch ($unit) {
... | php | {
"resource": ""
} |
q252327 | Tools.getOctets | validation | public static function getOctets($option)
{
if (preg_match('/\d+k/i', $option)) {
return 1024 * (int)$option;
}
if (preg_match('/\d+m/i', $option)) {
return 1024 * 1024 * (int)$option;
}
if (preg_match('/\d+g/i', $option)) {
return 1024 *... | php | {
"resource": ""
} |
q252328 | Tools.getUserPlatform | validation | public static function getUserPlatform()
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$user_platform = 'unknown';
if (false !== stripos($user_agent, 'linux')) {
$user_platform = 'Linux';
} elseif (preg_match('/macintosh|mac os x/i', $user_agent)) {
$user_plat... | php | {
"resource": ""
} |
q252329 | Tools.getUserBrowser | validation | public static function getUserBrowser()
{
$user_agent = $_SERVER['HTTP_USER_AGENT'];
$user_browser = 'unknown';
if (false !== stripos($user_agent, 'MSIE') && false === stripos($user_agent, 'Opera')) {
$user_browser = 'Internet Explorer';
} elseif (false !== stripos($user... | php | {
"resource": ""
} |
q252330 | Tools.isCzechHoliday | validation | public static function isCzechHoliday($date)
{
if (!$date instanceof DateTime) {
if (\is_int($date)) {
$date = new DateTime('@' . $date);
} elseif (\is_string($date)) {
$date = new DateTime($date);
} else {
throw new Runtime... | php | {
"resource": ""
} |
q252331 | Tools.getGreeting | validation | public static function getGreeting($time = null)
{
if ($time === null) {
$time = time();
} elseif (\is_string($time)) {
$time = strtotime($time);
}
switch (date('G', $time)) {
case 0:
case 1:
case 2:
case 3:
... | php | {
"resource": ""
} |
q252332 | Tools.gpsDistance | validation | public static function gpsDistance($lat1, $lon1, $lat2, $lon2)
{
$lat1 = deg2rad($lat1);
$lon1 = deg2rad($lon1);
$lat2 = deg2rad($lat2);
$lon2 = deg2rad($lon2);
$lonDelta = $lon2 - $lon1;
$a = ((cos($lat2) * sin($lonDelta)) ** 2) + ((cos($lat1) * sin($lat2) - sin($la... | php | {
"resource": ""
} |
q252333 | Tools.poorManTranslate | validation | public static function poorManTranslate($category, $text, array $params = [])
{
if (class_exists('Yii')) {
return \Yii::t($category, $text, $params);
}
$pos = strrpos($category, '/');
$category = $pos === false ? $category : substr($category, $pos + 1);
$translat... | php | {
"resource": ""
} |
q252334 | Tools.linkRewrite | validation | public static function linkRewrite($str, $allowUnicodeChars = false)
{
if (!\is_string($str)) {
return false;
}
$str = trim($str);
if (\function_exists('mb_strtolower')) {
$str = mb_strtolower($str, 'utf-8');
}
if (!$allowUnicodeChars) {
... | php | {
"resource": ""
} |
q252335 | Tools.getDateFromBirthNumber | validation | public static function getDateFromBirthNumber($no)
{
if (!preg_match('#^\s*(\d\d)(\d\d)(\d\d)[ /]*(\d\d\d)(\d?)\s*$#', $no, $matches)) {
return null;
}
list(, $year, $month, $day, $ext, $c) = $matches;
if ($c === '') {
$year += $year < 54 ? 1900 : 1800;
... | php | {
"resource": ""
} |
q252336 | Tools.generatePin | validation | public static function generatePin($salt, $length = 6, $useMinutes = false)
{
$seed = sha1($salt . (new \DateTime('now', new \DateTimeZone('Europe/Prague')))->format('Ymd' . ($useMinutes ? 'i' : '')), true);
for ($i = 0; $i <= (new \DateTime('now', new \DateTimeZone('Europe/Prague')))->format('G'); ... | php | {
"resource": ""
} |
q252337 | Tools.sendHipChatMessage | validation | public static function sendHipChatMessage($room, $token, $text, $notify = true, $format = 'text')
{
$session = curl_init();
curl_setopt($session, CURLOPT_URL, 'https://api.hipchat.com/v2/room/' . $room . '/notification?auth_token=' . $token);
curl_setopt($session, CURLOPT_POST, 1);
c... | php | {
"resource": ""
} |
q252338 | Tools.secondsBetweenDates | validation | public static function secondsBetweenDates($start, $end, $absolute = true, $timezone = 'Europe/Prague')
{
$timezoneObj = new \DateTimeZone($timezone);
$date = new DateTime($end, $timezoneObj);
$diff = $date->diff(new DateTime($start, $timezoneObj), $absolute);
return ($diff->invert ... | php | {
"resource": ""
} |
q252339 | Tools.secondsBetweenWorkingDays | validation | public static function secondsBetweenWorkingDays($dateFrom, $dateTo, $workDayFrom, $workDayTo, $weekends = false, $holidays = false, $timeZone = 'Europe/Prague')
{
$timeZoneObj = new \DateTimeZone($timeZone);
$dateFromObj = new DateTime($dateFrom, $timeZoneObj);
$dateToObj = new DateTime($da... | php | {
"resource": ""
} |
q252340 | Tools.maxCount | validation | public static function maxCount()
{
$array = \func_get_args();
if (!\is_array($array)) {
return 0;
}
$maxCnt = 0;
foreach ($array as $item) {
if (!\is_array($item)) {
continue;
}
$cnt = \count($item);
... | php | {
"resource": ""
} |
q252341 | Tools.fillToSize | validation | public static function fillToSize(&$array, $size, $fill)
{
$cnt = \count($array);
if ($cnt >= $size) {
return;
}
$array = array_merge($array, array_fill($cnt + 1, $size - $cnt, $fill));
} | php | {
"resource": ""
} |
q252342 | Tools.countryCodeTwoToThree | validation | public static function countryCodeTwoToThree($code)
{
$codes = array_flip(self::$_countryCodes);
if (!array_key_exists($code, $codes)) {
return false;
}
return $codes[$code];
} | php | {
"resource": ""
} |
q252343 | Tools.countryCodeThreeToTwo | validation | public static function countryCodeThreeToTwo($code)
{
if (!array_key_exists($code, self::$_countryCodes)) {
return false;
}
return self::$_countryCodes[$code];
} | php | {
"resource": ""
} |
q252344 | ResultCollection.filter | validation | public function filter(ScopeInterface $scope)
{
$filtered = new self;
foreach ($this as $eachResult) {
/* @var $eachResult ResultInterface */
if ($eachResult->getScope()->isEqualTo($scope)) {
$filtered->add($eachResult);
}
}
retur... | php | {
"resource": ""
} |
q252345 | DateTime.registerClientScript | validation | protected function registerClientScript()
{
$view = $this->getView();
DateTimePickerAssets::register($view);
$id = $this->options['id'];
$options = Json::encode($this->clientOptions);
$view->registerJs("jQuery('#$id').datetimepicker($options);");
} | php | {
"resource": ""
} |
q252346 | Select.join | validation | public function join($table, $type = null)
{
$this->join->addJoin($table, $type);
return $this;
} | php | {
"resource": ""
} |
q252347 | Select.having | validation | public function having($column, $op, $value, $isParam = true)
{
$this->having->andHaving($column, $op, $value, $isParam);
return $this;
} | php | {
"resource": ""
} |
q252348 | CachePoolThrottle.shouldThrottle | validation | public function shouldThrottle(APIRequest $request): bool
{
$item = $this->cacheItemPool->getItem($this->deriveCacheKey($request));
return $item->get() >= $this->limit;
} | php | {
"resource": ""
} |
q252349 | CachePoolThrottle.logRequest | validation | public function logRequest(APIRequest $request): void
{
$item = $this->cacheItemPool->getItem($this->deriveCacheKey($request));
if($requestCount = $item->get()) {
$item->set($requestCount + 1);
} else {
$item->set(1)->expiresAfter($this->perXSeconds);
}
... | php | {
"resource": ""
} |
q252350 | ExtensionServiceProvider.getExtensions | validation | public function getExtensions(Container $app)
{
$directories = $this->findExtensionsDirectories($app);
foreach ($directories as $directory) {
$extensionName = $directory->getRelativePathname();
$this->extensions[$extensionName]['name'] ... | php | {
"resource": ""
} |
q252351 | ExtensionServiceProvider.findExtensionsDirectories | validation | private function findExtensionsDirectories(Container $app)
{
$directories = $app['config.finder']
->ignoreUnreadableDirs()
->directories()
->name('*Extension')
->in($app['app.extensions.dir'])
->depth('< 3')
->sortByName()
;
... | php | {
"resource": ""
} |
q252352 | Migrator.migrate | validation | public function migrate(array $options = []): void
{
// Once we grab all of the migration files for the path, we will compare them
// against the migrations that have already been run for this package then
// run each of the outstanding migrations against a database connection.
$file... | php | {
"resource": ""
} |
q252353 | Migrator.getMigrationFiles | validation | public function getMigrationFiles(string $type): array
{
$array = [];
foreach ($this->filesystem->listContents() as $file) {
if ($type === pathinfo($file['filename'], PATHINFO_EXTENSION)) {
$array[] = $file;
}
}
return $array;
} | php | {
"resource": ""
} |
q252354 | Migrator.runPending | validation | public function runPending(array $migrations, array $options = [])
{
// First we will just make sure that there are any migrations to run. If there
// aren't, we will just make a note of it to the developer so they're aware
// that all of the migrations have been run against this database sy... | php | {
"resource": ""
} |
q252355 | Migrator.rollback | validation | public function rollback(array $options = []): void
{
// We want to pull in the last batch of migrations that ran on the previous
// migration operation. We'll then reverse those migrations and run each
// of them "down" to reverse the last migration "operation" which ran.
$migration... | php | {
"resource": ""
} |
q252356 | Migrator.reset | validation | public function reset(): void
{
// Next, we will reverse the migration list so we can run them back in the
// correct order for resetting this database. This will allow us to get
// the database back into its "empty" state ready for the migrations.
$migrations = array_reverse($this->... | php | {
"resource": ""
} |
q252357 | Migrator.drop | validation | public function drop(): void
{
$dropped = $this->repository->drop();
if (count($dropped) === 0) {
return;
}
$this->notify->note('');
foreach ($dropped as [$type, $value]) {
$type = ucfirst($type);
$this->notify->note("<comment>{$type}</c... | php | {
"resource": ""
} |
q252358 | Migrator.rollbackMigrations | validation | protected function rollbackMigrations(array $migrations): void
{
// A blank line before top output.
$this->notify->note('');
foreach ($this->getMigrationFiles(M::TYPE_DOWN) as $file) {
if (in_array($name = $this->getMigrationName($file), $migrations, true)) {
$th... | php | {
"resource": ""
} |
q252359 | Migrator.runDown | validation | protected function runDown(array $file): void
{
$this->notify->note("<comment>Rolling back:</comment> {$file['basename']}");
$this->runMigration($file);
// Once we have successfully run the migration "down" we will remove it from
// the migration repository so it will be considered... | php | {
"resource": ""
} |
q252360 | Migrator.runUp | validation | protected function runUp(array $file, int $batch): void
{
$this->notify->note("<comment>Migrating:</comment> {$file['basename']}");
$this->runMigration($file);
// Once we have run a migrations class, we will log that it was run in this
// repository so that we don't try to run it n... | php | {
"resource": ""
} |
q252361 | Migrator.runMigration | validation | protected function runMigration(array $file)
{
$this->repository->transaction(function (SqlMigrationRepository $repo) use ($file) {
$contents = (string) $this->filesystem->read($file['path']);
$repo->execute($contents);
});
} | php | {
"resource": ""
} |
q252362 | Migrator.pendingMigrations | validation | protected function pendingMigrations(array $files, array $ran): array
{
$array = [];
foreach ($files as $file) {
if (! in_array($this->getMigrationName($file), $ran, true)) {
$array[] = $file;
}
}
return $array;
} | php | {
"resource": ""
} |
q252363 | Neuron_GameServer_Map_MapObject.getEndLocation | validation | public function getEndLocation ()
{
$lastLocation = $this->getLocation ();
$lastDate = NOW;
foreach ($this->movements as $v)
{
if ($v->getEndTime () > $lastDate)
{
$lastDate = $v->getEndTime ();
$lastLocation = $v->getEndLocation ();
}
}
return $lastLocation;
} | php | {
"resource": ""
} |
q252364 | Neuron_GameServer_Map_MapObject.getUp | validation | public function getUp ($time = NOW)
{
// Go trough the paths to update
foreach ($this->movements as $v)
{
if ($v->isActive ($time))
{
$up = $v->getCurrentUp ($time);
if (isset ($up))
{
return $v->getCurrentUp ($time);
}
}
}
return new Neuron_GameServer_Map_Vector3 (0, 1, 0);
} | php | {
"resource": ""
} |
q252365 | NotifyFactory.create | validation | public static function create($notify)
{
switch (true) {
case $notify === NotifyInterface::STDOUT:
return new NotifyStdout();
case $notify === NotifyInterface::LOGGER:
return new NotifyLogger(PrettyLogger::create());
case $notify === Notify... | php | {
"resource": ""
} |
q252366 | SettingController.index | validation | public function index(Request $request)
{
$this->settingRepository->pushCriteria(new RequestCriteria($request));
$settings = $this->settingRepository->all();
$dateFormats = DateFormatter::dropdownArray();
return view('l5starter::admin.settings.index')->with([
'dateFormat... | php | {
"resource": ""
} |
q252367 | SettingController.update | validation | public function update(Request $request)
{
foreach ($request->all() as $key => $value) {
if (substr($key, 0, 8) == 'setting_') {
$skipSave = false;
$key = substr($key, 8);
if (! $skipSave) {
$this->settingRepository->save($key, ... | php | {
"resource": ""
} |
q252368 | Mailer.renderView | validation | protected function renderView($view, $data)
{
try {
return parent::renderView($view, $data);
} catch (\InvalidArgumentException $e) {
return static::applyDataToView($view, $data);
}
} | php | {
"resource": ""
} |
q252369 | DatabaseBuilder.getClassName | validation | protected function getClassName($fileName)
{
// Get rid of prefix
$namePiece = @explode($this->config['modelsPrefix'], $fileName);
$name = isset($namePiece[1]) ? $namePiece[1] : $fileName;
// Get rid of postfix
$namePiece = @explode($this->config['modelsPostfix'], $n... | php | {
"resource": ""
} |
q252370 | DefaultFormatter.stringize | validation | protected function stringize(array &$arguments)
{
array_walk($arguments, function (&$value) {
if (is_object($value)) {
$value = get_class($value);
} elseif (is_scalar($value)) {
$value = (string) $value;
} else {
$value = js... | php | {
"resource": ""
} |
q252371 | DefaultFormatter.matchTemplate | validation | protected function matchTemplate(
/*# string */ &$template,
array &$arguments
)/*# : string */ {
$count = substr_count($template, '%s');
$size = sizeof($arguments);
if ($count > $size) {
$arguments = $arguments + array_fill($size, $count - $size, '');
} e... | php | {
"resource": ""
} |
q252372 | Framework.getRootBackslash | validation | public static function getRootBackslash($pathname) {
// Remove leading slash if necessary.
if($pathname[0] == '\\') {
$pathname = substr($pathname, 1);
}
// Create array from path
$arr = explode('\\', $pathname);
// If a pathname was given (... | php | {
"resource": ""
} |
q252373 | Db_MySQL.exec | validation | public function exec()
{
// If there's a custom query to execute, do that instead of building one.
if ($this->customQuery) {
return $this->execCustom();
}
// Save copy of relevant data so we can calculate the total rows of this query
// Does not save LIMIT as this is for... | php | {
"resource": ""
} |
q252374 | Db_MySQL.calculate | validation | protected function calculate()
{
// Determine Action
$action = false;
$actions = 0;
if($this->delete) {
$actions += 1;
$action = 'DELETE';
}
if(!empty($this->inserts)) {
$actions += 1;
$action = 'INSERT';
}
if(!empty($this->updates)) {
... | php | {
"resource": ""
} |
q252375 | Db_MySQL.calculateSELECT | validation | protected function calculateSELECT()
{
$this->query .= 'SELECT ';
// If distinct
if ($this->distinct) {
$this->query .= ' DISTINCT ';
}
// If SELECT
$this->queryStringFromArray('selects', '', ', ');
// Determine... | php | {
"resource": ""
} |
q252376 | Db_MySQL.calculateUPDATE | validation | protected function calculateUPDATE()
{
$this->query .= 'UPDATE ';
// Determine Table(s)
$this->queryStringFromArray('tables', '', ', ');
// SETs
$this->queryStringFromArray('updates', ' SET ', ', ');
// Where and IN
$this->conditionS... | php | {
"resource": ""
} |
q252377 | Db_MySQL.calculateINSERT | validation | protected function calculateINSERT()
{
$this->query .= 'INSERT INTO ';
// Determine Table(s)
$this->queryStringFromArray('tables', '', ', ');
// SETs
if (!empty($this->inserts)) {
$this->query .= ' (';
$this->queryStringFromArray('ins... | php | {
"resource": ""
} |
q252378 | Db_MySQL.calculateDELETE | validation | protected function calculateDELETE()
{
$this->query .= 'DELETE FROM ';
// Determine Table(s)
$this->queryStringFromArray('tables', '', ', ');
// Where and IN
$this->conditionStringFromArray('wheres', ' WHERE ', ' AND ');
// OrderBy
$this->qu... | php | {
"resource": ""
} |
q252379 | Db_MySQL.calculateCREATE | validation | protected function calculateCREATE()
{
$this->query .= 'CREATE TABLE IF NOT EXISTS ';
$this->query .= $this->create.' (';
$this->queryStringFromArray('fields', '', ', ', false, true);
$this->primaryKeyStringFromArray('primaryKeys', ', CONSTRAINT ');
$this->foreignKeyStringFro... | php | {
"resource": ""
} |
q252380 | Db_MySQL.getSetItem | validation | protected function getSetItem($dataMember, $offset, $quote = true)
{
$item = $this->{$dataMember}[$offset];
switch ($item[1]) {
case 'varchar':
$type = 'varchar(255)';
break;
default:
$type = $item[1];
}
$this->{... | php | {
"resource": ""
} |
q252381 | Db_MySQL.joinStringFromArray | validation | protected function joinStringFromArray($dataMember, $sep = ' AND ')
{
if (empty($this->$dataMember)) {
return 0;
}
$count = count($this->$dataMember);
//var_dump($this->$dataMember);
for($i=0; $i<$count; $i++) {
$statement = $this->{$dataMember}[$i];
... | php | {
"resource": ""
} |
q252382 | Db_MySQL.getType | validation | public function getType($props)
{
$result = '';
if (isset($props['type'])) {
// If field is a string
if ($props['type'] == 'varchar' || $props['type'] == 'string') {
if (isset($props['size'])) {
$result = 'varchar('.$props['siz... | php | {
"resource": ""
} |
q252383 | Db_MySQL.getAttributes | validation | public function getAttributes($props)
{
$attr = '';
if (isset($props['primaryKey'])) {
$attr .= 'NOT NULL AUTO_INCREMENT ';
}
if (isset($props['defaultValue'])) {
$attr .= "DEFAULT '".$props['defaultValue']."'";
}
ret... | php | {
"resource": ""
} |
q252384 | Parser.run | validation | public function run()
{
$list = $this->getClassList();
$directCollection = new DirectCollection();
foreach ($list as $class) {
$cl = $this->processClass($class);
if ($cl !== false) {
$directCollection->add($cl);
}
}
return... | php | {
"resource": ""
} |
q252385 | Parser.processClass | validation | protected function processClass($class)
{
if (!class_exists('\\' . $class)) {
throw new ExtDirectException(" '{$class}' does not exist!");
}
$annotationReader = new AnnotationReader();
AnnotationRegistry::registerLoader('class_exists');
$reflectionClass = new Re... | php | {
"resource": ""
} |
q252386 | Parser.scanDir | validation | protected function scanDir($dir)
{
$result = array();
$list = $this->scanDirExec($dir);
foreach ($list as $element) {
$elementPath = $dir . DIRECTORY_SEPARATOR . $element;
if (is_file($elementPath)) {
$fileInfo = pathinfo($element);
i... | php | {
"resource": ""
} |
q252387 | Neuron_GameServer_Map_Managers_MapObjectManager.move | validation | public function move
(
Neuron_GameServer_Map_MapObject $object,
Neuron_GameServer_Map_Location $location,
Neuron_GameServer_Map_Date $start,
Neuron_GameServer_Map_Date $end
)
{
throw new Neuron_Exceptions_NotImplemented ("The move method is not implemented in this map.");
} | php | {
"resource": ""
} |
q252388 | Neuron_GameServer_Map_Managers_MapObjectManager.getFromLocation | validation | public function getFromLocation (Neuron_GameServer_Map_Location $location)
{
$area = new Neuron_GameServer_Map_Area ($location, 1);
$objects = $this->getDisplayObjects ($area);
$out = array ();
foreach ($objects as $v)
{
if ($v->getLocation ()->equals ($location))
{
$out[] = $v;
}
}
... | php | {
"resource": ""
} |
q252389 | Neuron_GameServer_Map_Managers_MapObjectManager.getMultipleDisplayObjects | validation | public function getMultipleDisplayObjects ($areas)
{
$out = array ();
foreach ($areas as $v)
{
if (! ($v instanceof Neuron_GameServer_Map_Area))
{
throw new Neuron_Exceptions_InvalidParameter ("Parameters must be an array of area objects.");
}
foreach ($this->getDisplayObjects ($v) as $v)
{... | php | {
"resource": ""
} |
q252390 | ExtDirect.process | validation | protected function process(array $requestParams)
{
$request = new ExtDirectRequest($this->useCache(), $this->getApplicationPath(), $this->getApplicationNameSpace());
$response = new ExtDirectResponse();
$requestParameters = new Parameters();
try {
// parameter validation... | php | {
"resource": ""
} |
q252391 | ExtDirect.setCacheState | validation | protected function setCacheState($useCache)
{
if (is_bool($useCache)) {
$this->useCache = $useCache;
} else {
// every invalid param would activate cache
$this->useCache = true;
}
} | php | {
"resource": ""
} |
q252392 | ExtDirect.getApi | validation | public function getApi()
{
if ($this->api === null) {
$this->api = new ExtDirectApi($this->useCache(), $this->getApplicationPath(), $this->getApplicationNameSpace());
}
return $this->api;
} | php | {
"resource": ""
} |
q252393 | Parameters.setParameters | validation | public function setParameters(array $request)
{
foreach ($this->getRequiredParameters() as $param) {
if (isset($request[$param])) {
// build setter method
$dynamicMethod = "set" . ucfirst($param);
if (method_exists($this, $dynamicMethod)) {
... | php | {
"resource": ""
} |
q252394 | Randomizer.getBoolean | validation | public function getBoolean($probability = 0.5)
{
if ((\is_int($probability) || \is_float($probability)) === false
|| $probability < 0
|| $probability > 1
) {
throw new InvalidArgumentException('Invalid probability');
}
if ($probability == ... | php | {
"resource": ""
} |
q252395 | Randomizer.getArrayKeyByPowers | validation | public function getArrayKeyByPowers(array $powers)
{
if (empty($powers)) {
throw new InvalidArgumentException('Empty powers set');
}
$powersSum = 0;
foreach ($powers as $power) {
if ($power < 0) {
throw new InvalidArgumentException('Negative p... | php | {
"resource": ""
} |
q252396 | Randomizer.getValueByPowers | validation | public function getValueByPowers(array $values, array $powers)
{
if (empty($values)
|| empty($powers)
|| \count($values) !== \count($powers)
) {
throw new InvalidArgumentException('Empty parameter or count not equal');
}
// reindex arrays
... | php | {
"resource": ""
} |
q252397 | Randomizer.getArrayValue | validation | public function getArrayValue(array $values)
{
if (empty($values)) {
throw new InvalidArgumentException('Empty parameter');
}
// reindex array
$values = \array_values($values);
return $values[$this->generator->getInt(0, count($values) - 1)];
} | php | {
"resource": ""
} |
q252398 | Plugin.handleUrl | validation | public function handleUrl($url, Event $event, Queue $queue)
{
$logger = $this->getLogger();
$logger->info('handleUrl', array('url' => $url));
$v = $this->getVideoId($url);
$logger->info('getVideoId', array('url' => $url, 'v' => $v));
if (!$v) {
return;
}
... | php | {
"resource": ""
} |
q252399 | Plugin.getVideoId | validation | protected function getVideoId($url)
{
$logger = $this->getLogger();
$parsed = parse_url($url);
$logger->debug('getVideoId', array('url' => $url, 'parsed' => $parsed));
switch ($parsed['host']) {
case 'youtu.be':
return ltrim($parsed['path'], '/');
... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.