_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q237900 | Auth_Login_Driver.groups | train | public function groups($driver = null)
{
$result = array();
if ($driver === null)
{
foreach (\Auth::group(true) as $group)
{
method_exists($group, 'groups') and $result = \Arr::merge($result, $group->groups());
}
}
else
{
$result = \Auth::group($driver)->groups();
}
return $result;
} | php | {
"resource": ""
} |
q237901 | Auth_Login_Driver.roles | train | public function roles($driver = null)
{
$result = array();
if ($driver === null)
{
foreach (\Auth::acl(true) as $acl)
{
method_exists($acl, 'roles') and $result = \Arr::merge($result, $acl->roles());
}
}
else
{
$result = \Auth::acl($driver)->roles();
}
return $result;
} | php | {
"resource": ""
} |
q237902 | Auth_Login_Driver.remember_me | train | public function remember_me($user_id = null)
{
// if no user-id is given, get the current user's id
if ($user_id === null and isset($this->user['id']))
{
$user_id = $this->user['id'];
}
// if we have a session and an id, set it
if (static::$remember_me and $user_id)
{
static::$remember_me->set('us... | php | {
"resource": ""
} |
q237903 | FluentCurl.doPostRequest | train | public function doPostRequest(
string $url,
array $data,
array $headers = [],
bool $closeConnection = true
) {
$this->setUrl($url)
->setPostMethod()
->setPostFields($data)
->setMustReturnTransfer()
->setHttpHeader($headers)
... | php | {
"resource": ""
} |
q237904 | Router._checkAcl | train | private function _checkAcl()
{
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '#' . $this->_view . '#action#' . $this->_action . '/acl');
if ($aclConfig === NULL) {
$aclConfig = Agl::app()->getConfig('core-layout/modules/' . $this->_module . '#' . $this->_view . '/acl');
}
if... | php | {
"resource": ""
} |
q237905 | Router.route | train | public function route()
{
$content = $this->_controller->{$this->_actionMethod}();
if ($this->_controller->isJson()) {
Request::setHeader(Request::HEADER_JSON);
echo json_encode($content);
} else {
echo $content;
}
} | php | {
"resource": ""
} |
q237906 | Client.sendRequest | train | private function sendRequest($url, $params, $post = 1, $headers = array('Accept: application/json, text/javascript, */*; q=0.01', 'Content-Type=application/x-www-form-urlencoded'))
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
if (null !== $params)
cu... | php | {
"resource": ""
} |
q237907 | Client.queryString | train | private function queryString($params)
{
$querystring = '?';
foreach($params as $k => $v) {
$querystring .= $k.'='.urlencode($v).'&';
}
return substr($querystring, 0, -1);
} | php | {
"resource": ""
} |
q237908 | Client.saveToken | train | private function saveToken()
{
$fd = fopen($this->cacheFolder."/token.txt", 'w');
fwrite($fd, $this->token);
fclose($fd);
} | php | {
"resource": ""
} |
q237909 | Client.loadToken | train | private function loadToken()
{
if (file_exists($this->cacheFolder."/token.txt"))
{
$fd = fopen($this->cacheFolder."/token.txt", 'r');
$this->token = fgets($fd);
fclose($fd);
} else {
$this->connect();
}
} | php | {
"resource": ""
} |
q237910 | Client.connect | train | public function connect()
{
$request = $this->sendRequest($this->baseUrl."/auth", array('username' => $this->login, 'password' => $this->password), 2);
$response = json_decode($request['body'], true);
if (array_key_exists('error', $response))
{
throw new \Exception('Erreur '.$response['code'].' : '.$respo... | php | {
"resource": ""
} |
q237911 | Client.search | train | public function search($query, $params = array())
{
// Set default category to "Série TV"
if (!isset($params['cid']))
$params['cid'] = '433';
if (!isset($params['offset']))
$params['offset'] = '0';
if (!isset($params['limit']))
$params['limit'] = '200';
$request = $this->sendRequest($this->baseUrl.... | php | {
"resource": ""
} |
q237912 | Client.downloadTorrent | train | public function downloadTorrent($id, $path = '')
{
$request = $this->sendRequest($this->baseUrl."/torrents/download/".$id, null, 0);
$response = json_decode($request['body'], true);
if (NULL === $response)
{
preg_match('/filename="(.*?)"/i', $request['header'], $filename);
$file = fopen($path.'/'.$fil... | php | {
"resource": ""
} |
q237913 | ConfigLoad._constructVar | train | private function _constructVar($sContent, $aConfVars, $sVarTemplate)
{
foreach ($aConfVars as $mKey => $mOne) {
if (is_array($mOne)) {
$sContent .= $sVarTemplate.'[\''.$mKey.'\'] = array(); ';
$sContent = $this->_constructVar($sContent, $mOne, $sVarTemplate.'[\''.$mKey.'\']');
}
else {
$sCon... | php | {
"resource": ""
} |
q237914 | XliffTranslationValue.getSourceElement | train | protected function getSourceElement(): ?XmlElement
{
$list = $this->node->getElementsByTagNameNS(XliffFile::XLIFF_NS, 'source');
if ($list->length && $element = $list->item(0)) {
/** @var XmlElement $element */
return $element;
}
return null;
} | php | {
"resource": ""
} |
q237915 | Json.isJson | train | public static function isJson($input): bool
{
$test = json_decode($input);
return ($test instanceof \stdClass || \is_array($test));
} | php | {
"resource": ""
} |
q237916 | BBCode.processText | train | public function processText(string $text): string
{
$text = str_replace("<br>", "", $text);
$text = str_replace("<br/>", "", $text);
$text = str_replace("<br />", "", $text);
$text = str_replace("\n", "<br>", $text);
$text = str_replace("\t", " ", $text);
... | php | {
"resource": ""
} |
q237917 | ClientSocketApi.serverSocketRequest | train | protected function serverSocketRequest()
{
$base = function_exists('lzf_compress') ? self::REQUEST_SOCKET_LZF : self::REQUEST_SOCKET_NON_LZF;
$url = sprintf("%s%s/%d", $this->clientApiConfig->getEndpoint(), $base, $this->clientApiConfig->getProjectId());
$data = array(
'key' => $... | php | {
"resource": ""
} |
q237918 | ClientSocketApi.send | train | protected function send($msg)
{
$msg .= PHP_EOL;
return $this->socket->write($msg, strlen($msg));
} | php | {
"resource": ""
} |
q237919 | Object.copy | train | public static function copy($value){
if(\is_object($value)){
if(\is_callable($value)){
return \Closure::bind($value, null);
}
return clone $value;
}
return $value;
} | php | {
"resource": ""
} |
q237920 | Object.propertiesExist | train | public static function propertiesExist($obj /*, $prop1, $prop2, etc... */){
for($i = 1, $l = \func_num_args() - 1; $i <= $l; ++$i){
if(!\property_exists($obj, \func_get_arg($i))){
return false;
}
}
return true;
} | php | {
"resource": ""
} |
q237921 | HelpCommand.getDescribedCommand | train | protected function getDescribedCommand($args)
{
$this->describedCommand = $command = $this->getParent();
foreach ($args as $arg)
{
$command = $command->getChild($arg);
if (!$command)
{
throw new CommandNotFoundException(sprintf('Command: "%s" not found.', implode(' ', $args)), $this->describedComm... | php | {
"resource": ""
} |
q237922 | BackgroundProcess.doProcess | train | public function doProcess(){
$command = 'nohup '.$this->command.' > /dev/null 2>&1 & echo $!';
exec($command ,$pross);
$this->pid = (int)$pross[0];
} | php | {
"resource": ""
} |
q237923 | HSerializer.getValue | train | private function getValue($value)
{
if ($this->isBoolean($value)) {
return (strtolower($value) === 'true');
} elseif ($this->isInteger($value)) {
return (int)$value;
} elseif ($this->isNumber($value)) {
return (float)$value;
}
return $value... | php | {
"resource": ""
} |
q237924 | MSqlField.clear | train | public function clear(): void
{
$this->value = null;
$this->defaultValue = null;
$this->lenght = -1;
$this->type = MDataType::UNKNOWN;
$this->name = null;
} | php | {
"resource": ""
} |
q237925 | Response.isValidHash | train | public function isValidHash() : Bool
{
$hash = $_POST['HASHPARAMS'];
$hashEx = explode(':', $hash);
$real = NULL;
foreach( $hashEx as $part )
{
if( ! empty($_POST[$part]) )
{
$real .= $_POST[$part];
}
... | php | {
"resource": ""
} |
q237926 | AccountController.homeAction | train | public function homeAction(Request $request)
{
// TODO check if AuthenticationCredentialsNotFoundException is raised without a cookie.
if (!$this->get('security.authorization_checker')->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$request->getSession()->set('_ekyna.login_success.target_p... | php | {
"resource": ""
} |
q237927 | Router.group | train | public static function group($group, \Closure $closure)
{
self::$group = $group;
call_user_func($closure, self::getInstance());
self::$group = null;
} | php | {
"resource": ""
} |
q237928 | Router.api | train | public function api($match, $apiController, $kwargs = [], $methods = null)
{
if (is_string($methods)) {
$methods = array($methods);
}
if (! is_array($kwargs)) { // @codeCoverageIgnore
$kwargs = []; // @codeCoverageIgnore
}
if ($methods === null) {
... | php | {
"resource": ""
} |
q237929 | Router.get | train | public function get($match, $callback, $kwargs = [])
{
$this->addRoute(new Route($match, 'GET', $callback, self::$group, $kwargs));
} | php | {
"resource": ""
} |
q237930 | Router.before | train | public function before($callback, $group = null, $methods = array())
{
$methods = array_map('strtoupper', $methods);
if ($group === null) {
if (self::$group !== null) {
$group = self::$group;
} else {
$group = 'global';
}
}
... | php | {
"resource": ""
} |
q237931 | Message.addFrom | train | public function addFrom(string $address, ?string $name = null): Message
{
$this->from[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | {
"resource": ""
} |
q237932 | Message.addTo | train | public function addTo(string $address, ?string $name = null): Message
{
$this->to[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | {
"resource": ""
} |
q237933 | Message.addReplyTo | train | public function addReplyTo(string $address, ?string $name = null): Message
{
$this->replyTo[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | {
"resource": ""
} |
q237934 | Message.addCc | train | public function addCc(string $address, ?string $name = null): Message
{
$this->cc[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | {
"resource": ""
} |
q237935 | Message.addBcc | train | public function addBcc(string $address, ?string $name = null): Message
{
$this->bcc[] = [
'address' => $address,
'name' => $name
];
return $this;
} | php | {
"resource": ""
} |
q237936 | Message.addContent | train | public function addContent(string $content, string $contentType, ?string $charset = null): Message
{
$charset = $charset ?: $this->getCharset();
$this->content[] = [
'content' => $content,
'content_type' => $contentType,
'charset' => $charset
];... | php | {
"resource": ""
} |
q237937 | Message.setSender | train | public function setSender(string $address, ?string $name = null): Message
{
$this->sender = [
'address' => $address,
'name' => $name
];
return $this;
} | php | {
"resource": ""
} |
q237938 | Message.setMaxLineLength | train | public function setMaxLineLength(int $maxLineLength): Message
{
// Each line of characters MUST be no more than 998 characters,
// and SHOULD be no more than 78 characters, excluding the CRLF.
// https://tools.ietf.org/html/rfc5322#section-2.1.1
$maxLineLength = (int) abs($maxLineLen... | php | {
"resource": ""
} |
q237939 | Method.getPossibleValues | train | public static function getPossibleValues(): array
{
return [
self::POST,
self::PUT,
self::PATCH,
self::DELETE,
self::GET,
];
} | php | {
"resource": ""
} |
q237940 | NumericGuardTrait.guardAgainstString | train | protected function guardAgainstString(
$data,
$dataName = 'Argument',
$exceptionClass = 'Zend\Stdlib\Exception\InvalidArgumentException'
) {
if (!is_numeric($data)) {
$message = sprintf(
"%s must be a numeric, [%s] given",
$dataName,
... | php | {
"resource": ""
} |
q237941 | MixedChecker.cardNumber | train | public function cardNumber($value): bool
{
if (!is_string($value) || strlen($value) < 12) {
return false;
}
$result = 0;
$odd = strlen($value) % 2;
preg_replace('/[^0-9]+/', '', $value);
for ($i = 0; $i < strlen($value); ++$i) {
$result += $o... | php | {
"resource": ""
} |
q237942 | MixedChecker.match | train | public function match($value, string $field, bool $strict = false): bool
{
if ($strict) {
return $value === $this->getValidator()->getValue($field, null);
}
return $value == $this->getValidator()->getValue($field, null);
} | php | {
"resource": ""
} |
q237943 | AbstractController.createErrorResponse | train | protected function createErrorResponse($content = 'Unknown Error', $code = 500)
{
$data = [
'message' => $content
];
$response = $this->createJsonResponse($data, $code);
return $response;
} | php | {
"resource": ""
} |
q237944 | AbstractController.createSimpleResponse | train | protected function createSimpleResponse($code = 500, $content = 'Unknown error')
{
$response = new Response;
$response->setStatusCode($code)
->setContent($content);
return $response;
} | php | {
"resource": ""
} |
q237945 | AbstractController.createConstraintViolationResponse | train | protected function createConstraintViolationResponse(ConstraintViolationListInterface $violationList)
{
$errors = $this->validationErrorFormatter->groupViolationsByField($violationList);
return $this->createJsonResponse(
['errors' => $errors],
422
);
} | php | {
"resource": ""
} |
q237946 | CloverProject.getTotalCodeCoverage | train | public function getTotalCodeCoverage() {
$totalStatements = 0;
$totalCoveredStatements = 0;
foreach ($this->getFiles() as $file) {
$totalStatements += $file->getStatements();
$totalCoveredStatements += $file->getCoveredStatements();
}
foreach ($this->getPackages() as $package) {
foreach ($package->ge... | php | {
"resource": ""
} |
q237947 | CloverProject.getMaximumCRAPIndex | train | public function getMaximumCRAPIndex() {
$maximumCRAP = 0;
foreach ($this->getFiles() as $file) {
foreach ($file->getLines() as $line) {
if ($line->getType() == CloverLine::TYPE_METHOD) {
if ($line->getCrap() > $maximumCRAP) {
$maximumCRAP = $line->getCRAP();
}
}
}
}
foreach ($this-... | php | {
"resource": ""
} |
q237948 | RequestDataSetTrait.existRequestData | train | public function existRequestData ($name) {
return Request::IsPostMethod() ? $this->existFormData($name) : $this->existParameter($name);
} | php | {
"resource": ""
} |
q237949 | AbstractCollection.exchangeArray | train | public function exchangeArray($collection)
{
if (!is_array($collection) && !($collection instanceof Traversable)) {
throw new Exception\InvalidArgumentException(
sprintf(
'Expected argument "array" or "Traversable"; "%s" given',
gettype($co... | php | {
"resource": ""
} |
q237950 | AbstractCollection.get | train | public function get($index)
{
if (null === $index) {
throw new Exception\InvalidArgumentException('The specified key name is null');
}
if (!$this->has($index)) {
throw new Exception\OutOfBoundsException(sprintf('Index "%s" is out of bounds', $index));
}
... | php | {
"resource": ""
} |
q237951 | AbstractCollection.has | train | public function has($key)
{
if (null === $key) {
throw new Exception\InvalidArgumentException('The specified key name is null');
}
if (!is_scalar($key)) {
throw new Exception\InvalidArgumentException('The specified key name must be a scalar');
}
retu... | php | {
"resource": ""
} |
q237952 | AbstractCollection.exists | train | public function exists(Closure $predicate)
{
foreach ($this->collections as $key => $element) {
if ($predicate($key, $element)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q237953 | AbstractCollection.merge | train | public function merge($collection)
{
if (!is_array($collection) && !($collection instanceof Traversable)) {
throw new Exception\InvalidArgumentException(
sprintf(
'Expected argument "array" or "Traversable"; "%s" given',
gettype($collection... | php | {
"resource": ""
} |
q237954 | AbstractCollection.toArray | train | public function toArray($recursive = true)
{
$results = [];
$collections = $this->collections;
if ($recursive) {
foreach ($collections as $key => $value) {
if ($value instanceof CollectionInterface) {
/** @noinspection PhpMethodParametersC... | php | {
"resource": ""
} |
q237955 | Config.update | train | public function update($setting, $value){
if($this->db->update($this->table_config, array('value' => $value), array('setting' => $setting))){
$this->set($setting, $value);
}
return $this;
} | php | {
"resource": ""
} |
q237956 | Render.options | train | public static function options($options, $selected = []): string
{
$html = '';
$selected = array_flip($selected);
foreach ($options as $value => $name) {
$html .= is_array($name)
? self::tag('optgroup', ['label' => $value], self::options($name, $selected))
... | php | {
"resource": ""
} |
q237957 | Tracker.updatePeakMemoryUsage | train | private function updatePeakMemoryUsage ()
{
$memory = memory_get_peak_usage ();
if ($memory > $this->peakMemoryUsage)
{
$this->peakMemoryUsage = $memory;
$this->setParameter ('Memory/PeakMemoryUsage', $memory);
if (extension_loaded ('newrelic'))
{
newrelic_custom_metric ('Custom/PeakMemoryUsage'... | php | {
"resource": ""
} |
q237958 | OptionsRequiredTrait.checkRequired | train | private function checkRequired(array $options, array $keys)
{
$missing = array_keys(array_diff_key(array_flip($keys), $options));
if (!empty($missing)) {
throw CommandException::missingOptions($missing);
}
} | php | {
"resource": ""
} |
q237959 | Select.& | train | public function &createOption($optgroup = ''): Option
{
$option = $this->factory->create('Form\Option');
$this->addOption($option, $optgroup);
return $option;
} | php | {
"resource": ""
} |
q237960 | Select.& | train | public function &newOption($value = null, $inner = null, bool $selected = false, string $optgroup = ''): Option
{
/* @var $option \Core\Html\Form\Option */
$option = $this->factory->create('Form\Option');
if (isset($value)) {
$option->setValue($value);
}
if (iss... | php | {
"resource": ""
} |
q237961 | Select.addOption | train | public function addOption(Option $option, string $optgroup = ''): Select
{
if (empty($optgroup)) {
$this->options[] = $option;
}
else {
$this->options[$optgroup][] = $option;
}
return $this;
} | php | {
"resource": ""
} |
q237962 | Select.buildOption | train | private function buildOption(Option $option): string
{
// Select unselected options when the options value is in selects value array
if (!$option->getSelected() && in_array($option->getValue(), $this->value)) {
$option->isSelected();
}
return $option->build();
} | php | {
"resource": ""
} |
q237963 | PhlexibleElasticaExtension.loadClients | train | private function loadClients(array $clients, ContainerBuilder $container)
{
foreach ($clients as $name => $clientConfig) {
$clientId = sprintf('phlexible_elastica.client.%s', $name);
$clientDef = new DefinitionDecorator('phlexible_elastica.client_prototype');
$clientDef->... | php | {
"resource": ""
} |
q237964 | PhlexibleElasticaExtension.loadIndexes | train | private function loadIndexes(array $indexes, ContainerBuilder $container)
{
foreach ($indexes as $name => $index) {
$indexId = sprintf('phlexible_elastica.index.%s', $name);
$indexName = isset($index['index_name']) ? $index['index_name'] : $name;
$indexDef = new Definitio... | php | {
"resource": ""
} |
q237965 | PhlexibleElasticaExtension.getClient | train | private function getClient($clientName)
{
if (!array_key_exists($clientName, $this->clients)) {
throw new InvalidArgumentException(sprintf('The elastica client with name "%s" is not defined', $clientName));
}
return $this->clients[$clientName]['reference'];
} | php | {
"resource": ""
} |
q237966 | RouteCollector.addRoute | train | public function addRoute($httpMethod, $route, $handler)
{
parent::addRoute($httpMethod, $route, $handler);
// Route ended with slash , redirect non slash to slash
if (substr($route, -1) === '/') {
parent::addRoute($httpMethod, substr($route, 0, -1),
new RouteHand... | php | {
"resource": ""
} |
q237967 | Vector.cosineSimilarity | train | public static function cosineSimilarity(array $vector_a, array $vector_b,
$length_a = null, $length_b = null){
$sum = 0;
$sum_a_sq = ($length_a === null ? 0.0 : (float) $length_a);
$sum_b_sq = ($length_b === null ? 0.0 : (float) $length_b);
foreach($vector_a as $key => $value){
if(isset($vector_b[$key])... | php | {
"resource": ""
} |
q237968 | Model.save | train | public function save()
{
if($this->exists())
{
// update
$query = new Query(static::table());
$query->update($this->getData(), $this->getIdentifyCondition());
return $query->execute();
}
else
{
// insert
$query = new Query(static::table());
$query->insert($this->getD... | php | {
"resource": ""
} |
q237969 | Model.erase | train | public function erase(){
if($this->exists())
{
$query = new Query(static::table());
$query->delete()->where($this->getIdentifyCondition());
if($query->execute())
$this->clear();
return $query->success();
}
return false;
} | php | {
"resource": ""
} |
q237970 | Model.schema | train | public static function schema(){
$classname = get_called_class();
if(!array_key_exists($classname, self::$schemas)){
$schema = new SchemaBuilder(static::table());
static::define($schema);
self::$schemas[$classname] = $schema;
}
return self::$schemas[$c... | php | {
"resource": ""
} |
q237971 | CommandPipeline.pipe | train | public function pipe(CommandMessage $message): void
{
/** @var CommandFilter $filter */
$filter = $this->stack->pop();
$filter->process($message, [$this, 'pipe']);
} | php | {
"resource": ""
} |
q237972 | Module.setRoutePrefixes | train | public function setRoutePrefixes($routeNamePrefix, $routePatternPrefix)
{
$this->setRouteNamePrefix($routeNamePrefix);
$this->setRoutePatternPrefix($routePatternPrefix);
return $this;
} | php | {
"resource": ""
} |
q237973 | Module.setActionOption | train | public function setActionOption($actionName, $optionName, $optionValue)
{
$this->getAction($actionName)->setOption($optionName, $optionValue);
return $this;
} | php | {
"resource": ""
} |
q237974 | Loader.getDatabaseConfig | train | protected function getDatabaseConfig()
{
if ($this->app->config()['use_cache']) {
$key = 'rails.ar.dbconfig';
if ($dbConfig = $this->app->getService('rails.cache')->read($key)) {
return $dbConfig;
}
}
$connections = $this->getDatab... | php | {
"resource": ""
} |
q237975 | Loader.getDatabaseConnections | train | protected function getDatabaseConnections()
{
$configFile = $this->findDatabaseFile();
if (!$configFile) {
return false;
}
switch (substr($configFile, -3)) {
case 'php':
$connections = require $configFile;
brea... | php | {
"resource": ""
} |
q237976 | DateRange.getCurrentMonthDaysRange | train | public static function getCurrentMonthDaysRange($keyFormat = 'Y-m-d', $interval = '1 day')
{
$start = Carbon::now()->subMonth(1)->setTime(0, 0);
$end = Carbon::now()->setTime(23, 59, 59);
$range = new Collection;
/** @var \Carbon\Carbon $period */
foreach (new DatePerio... | php | {
"resource": ""
} |
q237977 | Route.runWithCustomDispatcher | train | protected function runWithCustomDispatcher(Request $request)
{
list($class, $method) = explode('@', $this->action['uses']);
$dispatcher = $this->container->make('illuminate.route.dispatcher');
return $dispatcher->dispatch($this, $request, $class, $method);
} | php | {
"resource": ""
} |
q237978 | EnvironmentsController.actionIndex | train | public function actionIndex($option = null)
{
$option = Question::displayWithQuit('Select operation', ['Update', 'Delete'], $option);
$project = env('project');
if($option == 'u') {
//Question::confirm('Do are you sure update?', 1);
$projectInput = Question::displayWithQuit('Select project', ['common', $pr... | php | {
"resource": ""
} |
q237979 | DeviceDetect.detectDevice | train | protected static function detectDevice()
{
$detect = new MobileDetect();
self::$detectCode = array();
self::$detectCode['tablet'] = $detect->isTablet();
self::$detectCode['mobile'] = $detect->isMobile() && !$detect->isTablet();
self::$detectCode['desktop'] = !self::$detectCode['tablet'] && !... | php | {
"resource": ""
} |
q237980 | Slug.uniqueSlug | train | private function uniqueSlug($bean, $property_name, $slug) {
$other = \R::findOne($bean->getMeta('type'), $property_name . ' = ? ', [ $slug ] );
if ($other) {
if ($other->id == $bean->id) {
return true;
} else {
return false;
}
} else {
return true;
}
} | php | {
"resource": ""
} |
q237981 | Slug.makeSlug | train | private function makeSlug($bean, $property_name, $slug_string) {
$string = $this->neatTrim( $slug_string, 100 ); // Maximum of 100 characters with complete words
$slug = $this->slugify( $string );
if ( $this->uniqueSlug( $bean, $property_name, $slug ) ) {
return $slug;
} else {
// Create slug with uniqid(... | php | {
"resource": ""
} |
q237982 | Memory.realpath | train | public function realpath($path)
{
$path = str_replace('\\', '/', rtrim($path, '/'));
if ($path[0] != '/' && (strlen($path) < 2 || $path[1] != ':')) {
$path = getcwd() . '/' . $path;
}
$parts = explode('/', $path);
$path = [];
foreach ($parts as $part) {
... | php | {
"resource": ""
} |
q237983 | Memory.glob | train | public function glob($pattern)
{
$matched = [];
$pattern = $this->realpath($pattern);
$pattern = '@^' . str_replace(['\*', '\?'], ['[^\\\/]*', '.'], preg_quote($pattern)) .'$@';
foreach (array_keys($this->files) as $path) {
if (preg_match($pattern, $path))
... | php | {
"resource": ""
} |
q237984 | Memory.isFile | train | public function isFile($path)
{
$node = $this->at($path);
return null !== $node && 'file' === $node->type;
} | php | {
"resource": ""
} |
q237985 | Memory.isDir | train | public function isDir($path)
{
$node = $this->at($path);
return null !== $node && 'dir' === $node->type;
} | php | {
"resource": ""
} |
q237986 | Memory.md5File | train | public function md5File($path)
{
if (! $this->isFile($path))
return false;
return md5($this->at($path)->content);
} | php | {
"resource": ""
} |
q237987 | Memory.fileGetContents | train | public function fileGetContents($path)
{
if (! $this->isFile($path))
return false;
return $this->at($path)->content;
} | php | {
"resource": ""
} |
q237988 | Memory.filePutContents | train | public function filePutContents($path, $content, $flags = 0)
{
if (! $this->isFile($path) && !$this->createFile($path))
return false;
if (($flags & FILE_APPEND) == FILE_APPEND)
$this->at($path)->content .= $content;
else
$this->at($path)->content = $conten... | php | {
"resource": ""
} |
q237989 | Memory.isReadable | train | public function isReadable($path)
{
$node = $this->at($path);
return null !== $node && (0x0100 & $node->perms);
} | php | {
"resource": ""
} |
q237990 | Memory.isWritable | train | public function isWritable($path)
{
$node = $this->at($path);
return null !== $node && (0x0080 & $node->perms);
} | php | {
"resource": ""
} |
q237991 | Memory.isExecutable | train | public function isExecutable($path)
{
$node = $this->at($path);
return null !== $node
&& (0x0040 & $node->perms)
&& !(0x0800 & $node->perms);
} | php | {
"resource": ""
} |
q237992 | Memory.rmdir | train | public function rmdir($path)
{
$path = $this->realpath($path) . '/';
$length = strlen($path);
foreach (array_keys($this->files) as $filename) {
if (substr($filename, 0, $length) === $path) {
return false;
}
}
$this->at($path, null);
... | php | {
"resource": ""
} |
q237993 | Memory.rename | train | public function rename($oldPath, $newPath)
{
$old = $this->at($oldPath);
$new = $this->at($newPath);
if (null === $old || (null !== $new && 'dir' === $new->type))
return false;
if ('file' === $old->type) {
$this->at($newPath, $old);
} else {
... | php | {
"resource": ""
} |
q237994 | Memory.fileperms | train | public function fileperms($path)
{
$node = $this->at($path);
if (null === $node) {
return false;
}
return $node->perms;
} | php | {
"resource": ""
} |
q237995 | Memory.chmod | train | public function chmod($path, $value)
{
$node = $this->at($path);
if (null === $node || !is_numeric($value)) {
return false;
}
$node->perms = $value;
return true;
} | php | {
"resource": ""
} |
q237996 | Memory.mkdir | train | public function mkdir($path, $mode = 0777, $recursive = false)
{
if (null !== $this->at($path)) {
trigger_error("mkdir(): File exists");
return false;
}
$parts = explode('/', $this->realpath($path));
$filesCount = 0;
$missing = [];
$item = arr... | php | {
"resource": ""
} |
q237997 | BlackHoleErrorHandler.enable | train | public function enable() {
// suppress all errors
$this->errorHandler->addErrorHandler(function() {return true;});
$this->errorHandler->addExceptionHandler(function(Exception $ex) {return true;});
} | php | {
"resource": ""
} |
q237998 | GoogleConfig.getBodyAttributes | train | public function getBodyAttributes()
{
$attributes = [];
$api = GoogleAPI::singleton();
if ($key = $api->getAPIKey()) {
$attributes['data-google-api-key'] = $key;
}
if ($lang = $api->getAPILanguage()) {
$attributes['data-googl... | php | {
"resource": ""
} |
q237999 | GoogleConfig.getVerificationCode | train | protected function getVerificationCode($code)
{
// Trim Code:
$code = trim($code);
// Detect HTML:
if (stripos($code, '<meta') === 0) {
// Extract Verification Code:
preg_match('/content="(.+)"/', $code, $ma... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.