_id stringlengths 2 7 | title stringlengths 3 151 | partition stringclasses 3
values | text stringlengths 83 13k | language stringclasses 1
value | meta_information dict |
|---|---|---|---|---|---|
q29900 | PlatformCommandController.pullCommand | train | public function pullCommand(string $directory = null, bool $publish = false, bool $database = false, bool $migrate = false, bool $flush = false, bool $dryRun = false, string $configuration = '.platform.app.yaml', string $environment = 'master', bool $yes = false)
{
$this->askForUserAgreement($yes, '<info>Ar... | php | {
"resource": ""
} |
q29901 | PlatformCommandController.buildCommand | train | public function buildCommand($debug = false)
{
$this->outputLine('<b>Run build hook commands</b>');
$this->commandService->executeHooks($this->buildHooks, function (...$args) { $this->outputLine(...$args); } );
$this->sendAndExit(0);
} | php | {
"resource": ""
} |
q29902 | PlatformCommandController.deployCommand | train | public function deployCommand($debug = false)
{
$this->outputLine('<b>Run deploy hook commands</b>');
$this->commandService->executeHooks($this->deployHooks, function (...$args) { $this->outputLine(...$args); } );
} | php | {
"resource": ""
} |
q29903 | Activity.user | train | public function user()
{
$relation = $this->belongsTo($this->getUserModelName());
if (in_array('Illuminate\Database\Eloquent\SoftDeletes', class_uses($this->getUserModelName())))
{
$relation->withTrashed();
}
return $relation;
} | php | {
"resource": ""
} |
q29904 | Activity.scopeOlderThan | train | public function scopeOlderThan($query, $time)
{
if ( ! $time instanceof Carbon)
{
$time = Carbon::createFromTimestamp($time);
}
return $query->where('created_at', '<=', $time->toDateTimeString())->latest();
} | php | {
"resource": ""
} |
q29905 | BeanCollection.next | train | public function next()
{
$row = $this->cursor->getNextItem();
if ($row) {
$beans = $this->repository->convertToBeans($this->type, array( $row ));
$bean = array_shift($beans);
return Model::wrap($bean);
}
return null;
} | php | {
"resource": ""
} |
q29906 | AttachmentLibrary.getRecords | train | public static function getRecords($routesConfigFile, $resource, $objectId, $lang, $copyAttachment = false)
{
$response['attachments'] = Attachment::getRecords([
'lang_id_016' => $lang,
'resource_id_016' => $resource,
'object_id_016' => $objectId,
'... | php | {
"resource": ""
} |
q29907 | AttachmentLibrary.deleteAttachment | train | public static function deleteAttachment($routesConfigFile, $resource, $objectId, $lang = null)
{
Attachment::deleteAttachment([
'lang_id_016' => $lang,
'resource_id_016' => $resource,
'object_id_016' => $objectId
]);
if(isset($lang))
{... | php | {
"resource": ""
} |
q29908 | CSmartyModel.addLocation | train | public function addLocation($path)
{
$retval = false;
if (!($retval = array_search($path, $this->model_location_array, $path))) {
if (($retval = is_dir($path))) {
$this->model_location_array[] = $path;
}
}
return $retval;
} | php | {
"resource": ""
} |
q29909 | Container.bindInjector | train | public function bindInjector(string $class, $injector): Container
{
if (!is_string($injector)) {
throw new \InvalidArgumentException('Injector can only be set as string binding');
}
$this->injectors[$class] = $injector;
return $this;
} | php | {
"resource": ""
} |
q29910 | Container.autowire | train | final protected function autowire(string $class, array $parameters, string $context = null)
{
if (!class_exists($class)) {
throw new NotFoundException("Undefined class or binding '{$class}'");
}
//Automatically create instance
$instance = $this->createInstance($class, $p... | php | {
"resource": ""
} |
q29911 | Configuration.getEntityPaths | train | public static function getEntityPaths(): array
{
if (self::$paths === null) {
self::$paths = [realpath(__DIR__ . DIRECTORY_SEPARATOR . 'Entity')];
}
return self::$paths;
} | php | {
"resource": ""
} |
q29912 | Upstart.startCore | train | private function startCore(bool $isConsole)
{
$this->bootEnv();
$this->initialize();
$this->logger();
$this->errorHandling($isConsole);
$this->bootRemember();
/**
* Create class aliases
*/
$aliases = config('app.aliases');
foreach($aliases as $alias => $class) {
class... | php | {
"resource": ""
} |
q29913 | Armada.paginator | train | public function paginator($nItemsTotal, $nItemsPerPage, $nCurrentPage)
{
$this->pgFactory->setPaginationProperties($nItemsTotal, $nItemsPerPage, $nCurrentPage);
return $this->pgFactory;
} | php | {
"resource": ""
} |
q29914 | Armada.instance | train | public function instance($name)
{
// If the class name starts with a dot, then find the class in the same class path as the caller
if(substr($name, 0, 1) == '.')
{
$name = $this->getJaxonClassPath() . $name;
}
// The class namespace is prepended to the class name
... | php | {
"resource": ""
} |
q29915 | SwiftMailerTransport.addBodies | train | protected function addBodies(\Swift_Message $message, MailRenderedInterface $mailRendered): void
{
$textPlain = $mailRendered->getBody();
$html = $mailRendered->getHtmlBody();
if (null === $html) {
$message->setBody($textPlain, 'text/plain');
return;
}
... | php | {
"resource": ""
} |
q29916 | Common.getCorrectActionName | train | public static function getCorrectActionName($action)
{
$action = strtolower($action);
$action = str_replace(array('-','.'),' ',$action);
$action = str_replace(' ','',ucwords($action));
//$action = (string)(strtolower(substr($action,0,1)).substr($action,1));
return lcfirst($action);
} | php | {
"resource": ""
} |
q29917 | Common.getCorrectControllerName | train | public static function getCorrectControllerName($controller)
{
$controller = strtolower($controller);
$controller = str_replace(array('-','.'),' ',$controller);
$controller = ucwords($controller);
$controller = str_replace(' ','',$controller);
return $controller;
} | php | {
"resource": ""
} |
q29918 | Common.isPost | train | public function isPost($id=false,$filter=null,$filterOptions=array())
{
if(!$id)
{
return (isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == 'POST') ? true : false;
}
else
{
if(isset($_POST[$id]))
{
return $filter ? filter_var($_POST[$id],$filter,$filterOpt... | php | {
"resource": ""
} |
q29919 | Common.isQuery | train | public function isQuery($id=false,$filter=null,$filterOptions=array())
{
if(!$id)
{
return (isset($_SERVER['REQUEST_METHOD']) && strtoupper($_SERVER['REQUEST_METHOD']) == 'GET') ? true : false;
}
else
{
if(isset($_GET[$id]))
{
return $filter ? filter_var($_GET[$id],$filter,$filterOptio... | php | {
"resource": ""
} |
q29920 | Common.isRequest | train | public function isRequest($id=false,$filter=null,$filterOptions=array())
{
if(!$id)
{
return (isset($_SERVER['REQUEST_METHOD']) && (strtoupper($_SERVER['REQUEST_METHOD']) == 'GET' OR strtoupper($_SERVER['REQUEST_METHOD']) == 'POST')) ? true : false;
}
else
{
if(isset($_REQUEST[$id]))
{
... | php | {
"resource": ""
} |
q29921 | Common.getQuery | train | public function getQuery($id=null,$sanitizeFilter=FILTER_SANITIZE_STRING,$sanitizeFilterOptions=array('flags'=>FILTER_FLAG_STRIP_HIGH))
{
if($id==null) return $_GET;
if(isset($_GET[$id]))
{
if(is_array($_GET[$id]))
{
$RETURN = array();
foreach($_GET[$id] as $index => $value)
{
$... | php | {
"resource": ""
} |
q29922 | Common.getPost | train | public function getPost($id=null,$sanitizeFilter=FILTER_SANITIZE_STRING,$sanitizeFilterOptions=array('flags'=>FILTER_FLAG_STRIP_HIGH))
{
if($id==null) return $_POST;
if(isset($_POST[$id]))
{
if(is_array($_POST[$id]))
{
$RETURN = array();
foreach($_POST[$id] as $index => $value)
{
... | php | {
"resource": ""
} |
q29923 | Common.getRequest | train | public function getRequest($id=null,$sanitizeFilter=FILTER_SANITIZE_STRING,$sanitizeFilterOptions=array('flags'=>FILTER_FLAG_STRIP_HIGH))
{
if($id==null) return $_REQUEST;
if(isset($_REQUEST[$id]))
{
if(is_array($_REQUEST[$id]))
{
$RETURN = array();
foreach($_REQUEST[$id] as $index => $... | php | {
"resource": ""
} |
q29924 | Common.getParamByIndex | train | public function getParamByIndex($index='')
{
if(!$index) return $this->_params['number'];
return isset($this->_params['number'][$index]) ? (string) $this->_params['number'][$index] : null;
} | php | {
"resource": ""
} |
q29925 | Area.buildRegExp | train | protected function buildRegExp($pattern)
{
$pattern = '/' . trim($pattern, '/');
$pattern = str_replace('/', '\/', $pattern);
preg_match_all('#((\\\/)?[^\\\/]+)#im', $pattern, $patternMatches);
foreach ($patternMatches[1] as &$match) {
if (strpos($match, '*') !== false) ... | php | {
"resource": ""
} |
q29926 | Area.authorize | train | public function authorize(UserInterface $user, $ip = null)
{
return $this->authRoles($user) && $this->authIps($ip);
} | php | {
"resource": ""
} |
q29927 | Area.authRoles | train | protected function authRoles(UserInterface $user)
{
if (empty($this->roles)) {
return true;
}
foreach ($this->roles as $role) {
if ($user->hasRole($role)) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q29928 | Area.authIps | train | protected function authIps($userIp)
{
if (empty($this->ips)) {
return true;
}
foreach ($this->ips as $ip) {
if ($userIp === $ip) {
return true;
}
}
return false;
} | php | {
"resource": ""
} |
q29929 | Nginx.getItemConfig | train | public function getItemConfig($name = null, array $config = [])
{
return array_merge([
'domain' => $name,
'nginx' => $this,
'class' => $this->defaultClass,
], $config);
} | php | {
"resource": ""
} |
q29930 | AddPageBlocksListener.onBeforeAddPageCommit | train | public function onBeforeAddPageCommit(BeforeAddPageCommitEvent $event)
{
if ($event->isAborted()) {
return;
}
$pageManager = $event->getContentManager();
$templateManager = $pageManager->getTemplateManager();
$pageRepository = $pageManager->getPageRepository();
... | php | {
"resource": ""
} |
q29931 | JwtGuard.execute | train | public function execute( Request $request )
{
$controllerClass = $request->attributes->get('_controller');
if( !($this->isJwtRequired($controllerClass))) {
return null;
}
if( !$this->authoriser->isAuthorised( $request ) ) {
return new JsonResponse( ['error' =... | php | {
"resource": ""
} |
q29932 | StreamWrapperFS.mkdir | train | public function mkdir($uri, $mode, $options) {
return ($this->cxt('swiftfs_fake_isdir_true', FALSE) || !($this->testDirectoryExists($uri)));
} | php | {
"resource": ""
} |
q29933 | StreamWrapperFS.fakeStat | train | protected function fakeStat($dir = FALSE) {
$request_time = time();
// Set inode type to directory or file.
$type = $dir ? 040000 : 0100000;
// Fake world-readible
$mode = $type + $this->cxt('swiftfs_fake_stat_mode', 0777);
$values = array(
'dev' => 0,
'ino' => 0,
'mode' => ... | php | {
"resource": ""
} |
q29934 | Util.getMaxKeyLength | train | public static function getMaxKeyLength(array $array)
{
$maxKeyLength = '0';
foreach ($array as $key => $value) {
$currentLength = static::getVisibleStringLength($key);
if ($currentLength > $maxKeyLength) {
$maxKeyLength = $currentLength;
}
... | php | {
"resource": ""
} |
q29935 | Util.getMaxValueLength | train | public static function getMaxValueLength(array $array)
{
$maxValueLength = '0';
foreach ($array as $value) {
$currentLength = static::getVisibleStringLength($value);
if ($currentLength > $maxValueLength) {
$maxValueLength = $currentLength;
}
... | php | {
"resource": ""
} |
q29936 | Util.getVisibleStringLength | train | public static function getVisibleStringLength($string)
{
// remove escape characters
$pattern = '#' . static::ESCAPE_CHARACTER_REGEX . '#';
$cleanString = preg_replace($pattern, '', $string);
return strlen($cleanString);
} | php | {
"resource": ""
} |
q29937 | BaseBlocks.adjustPosition | train | protected function adjustPosition($op, array $managers)
{
if (count($managers) == 0) {
return null;
}
$this->checkValidOperation($op);
try {
$result = null;
$this->blockRepository->startTransaction();
foreach ($managers as $blockManag... | php | {
"resource": ""
} |
q29938 | DispatcherFactory.build | train | public function build(array $config, ContainerInterface $container = null)
{
$dispatcher = new Dispatcher($container);
foreach ((array) $config as $name => $listeners) {
foreach ($listeners as $listener) {
if (is_callable($listener)) {
$dispatcher->reg... | php | {
"resource": ""
} |
q29939 | DispatcherFactory.applyDefaults | train | public function applyDefaults($definition)
{
if (!is_array($definition)) {
return $definition;
}
if (!isset($definition['component'])) {
throw new AppException('Missing required "component" key in listener definition');
}
return array_merge($this->de... | php | {
"resource": ""
} |
q29940 | DispatcherFactory.buildDefinition | train | public function buildDefinition($definition)
{
if (is_callable($definition)) {
return $definition;
}
if (is_array($definition) && isset($definition['component'])) {
return new Listener(
$definition['component'],
$definition['method'] ?... | php | {
"resource": ""
} |
q29941 | ApiController.getPath | train | private function getPath($folderId)
{
$folder = $this->repository->find($folderId);
$path = [];
while ($folder) {
$path[] = $folder;
$folder = $folder->folder;
}
$firstItem = new stdClass();
$firstItem->name = __('Files');
$firstItem->... | php | {
"resource": ""
} |
q29942 | Callback.invokeArguments | train | public function invokeArguments(array $arguments)
{
$parsedArguments = $this->argumentParser->parse($arguments, $this->getParameters());
return call_user_func_array($this->callable, $parsedArguments);
} | php | {
"resource": ""
} |
q29943 | Api.init | train | public function init ()
{
if (!empty($this->belongs_to)) {
try {
$model = $this->belongs_to['model'];
$this->parent_model = $model::find($this->params[$this->belongs_to['param']]);
} catch (\PDOException $e) {
return $this->http_status(404);
}
}
return parent::init();
} | php | {
"resource": ""
} |
q29944 | CreateRobotsCommand.execute | train | public function execute(Arguments $args, ConsoleIo $io)
{
$this->createFile($io, Folder::slashTerm(WWW_ROOT) . 'robots.txt', 'User-agent: *' . PHP_EOL .
'Disallow: /admin/' . PHP_EOL . 'Disallow: /ckeditor/' . PHP_EOL .
'Disallow: /css/' . PHP_EOL . 'Disallow: /js/' . PHP_EOL .
... | php | {
"resource": ""
} |
q29945 | RouterRule.match | train | public function match($sender, ProtocolInterface $protocol)
{
$callback = $this->matcher;
return $callback($sender, $protocol);
} | php | {
"resource": ""
} |
q29946 | RouterRule.handle | train | public function handle($sender, ProtocolInterface $protocol, $flags, callable $success = null, callable $failure = null, callable $cancel = null, $timeout = 0.0)
{
$callback = $this->handler;
$callback($sender, $protocol, $flags, $success, $failure, $cancel, $timeout);
if ($this->limit > 0)... | php | {
"resource": ""
} |
q29947 | RouterRule.cancel | train | public function cancel()
{
if (isset($this->pointer) && isset($this->router) && !$this->cancelled)
{
$this->router->removeHandler($this->pointer[0], $this->pointer[1]);
$this->cancelled = true;
}
} | php | {
"resource": ""
} |
q29948 | User.saved | train | public function saved($username = NULL, $sid=NULL) {
$current = $this->current($sid);
if ($username) {
$user = $this->get($username, 'username');
if ($current['id'] != $user['id']) throw new \Exception('This users saved images are not publicly shared');
} else {
$user = $current;
}
$query = new \Peyo... | php | {
"resource": ""
} |
q29949 | User.requestPwReset | train | public function requestPwReset($username) {
$setting = new Setting;
$site_name = $setting->get('site_name');
$user = $this->get($username, 'username');
$uid = $this->getSecureID();
// This has to manually add the resource as Resource/add doesn't have a way to specifiy a userID, it has to be derived from a SID... | php | {
"resource": ""
} |
q29950 | Signature.equals | train | public function equals($signature) : bool
{
if ($signature instanceof Signature) {
$signature = $signature->signature;
}
if ($this === $signature || $this->signature == $signature) {
return true;
}
return false;
} | php | {
"resource": ""
} |
q29951 | ArrayHelper.mutate | train | public static function mutate(array &$array, string $writeKey, $value)
{
$ref = &$array;
$keys = explode('.', $writeKey);
while (($key = array_shift($keys)) !== null) {
$hasMoreKeys = \count($keys) > 0;
if ($hasMoreKeys) {
if (!\array_key_exists($key, ... | php | {
"resource": ""
} |
q29952 | SimpleCURL.setHeaders | train | public function setHeaders($key, $value = null)
{
if (is_array($key)) {
foreach ($key as $a_key => $value) {
$this->headers[strtolower($a_key)] = "$a_key: $value";
}
} elseif (empty($value)) {
$this->headers[] = $key;
} else {
$... | php | {
"resource": ""
} |
q29953 | SimpleCURL.removeHeaders | train | public function removeHeaders($keys)
{
$key_array = (array) $keys;
foreach ($key_array as $key) {
unset($this->headers[$key]);
}
} | php | {
"resource": ""
} |
q29954 | SimpleCURL.setOption | train | public function setOption($option, $value = null)
{
if (is_array($option)) {
$this->options += $option;
} else {
$this->options[$option] = $value;
}
return $this;
} | php | {
"resource": ""
} |
q29955 | SimpleCURL.updateURLWithParameters | train | public function updateURLWithParameters($url, array $params)
{
if (empty($params)) {
return $url;
}
$parts = parse_url($url);
$scheme = isset($parts['scheme']) ? $parts['scheme'] : null;
if ($scheme) {
$scheme .= ':';
}
$host = isset... | php | {
"resource": ""
} |
q29956 | SimpleCURL.post | train | public static function post($url, $data = null, $accepts_cookie = true, $compression = 'gzip', $proxy = '')
{
$self = new static($accepts_cookie, $compression, $proxy);
return $self->sendPOST($url, $data);
} | php | {
"resource": ""
} |
q29957 | SimpleCURL.get | train | public static function get($url, $data = [], $accepts_cookie = true, $compression = 'gzip', $proxy = '')
{
$self = new static($accepts_cookie, $compression, $proxy);
return $self->sendGET($url, $data);
} | php | {
"resource": ""
} |
q29958 | AbstractTransformer.getIncludeMap | train | public function getIncludeMap(): array
{
if ($this->cachedIncludeMap === null) {
$this->cachedIncludeMap = $this->getRawIncludeMap();
}
return $this->cachedIncludeMap;
} | php | {
"resource": ""
} |
q29959 | AbstractTransformer.item | train | public function item($data, $transformer = null, $resourceKey = null): Item
{
return new Item($data, $transformer, $resourceKey);
} | php | {
"resource": ""
} |
q29960 | AbstractTransformer.collection | train | public function collection($data, $transformer = null, $resourceKey = null): Collection
{
return new Collection($data, $transformer, $resourceKey);
} | php | {
"resource": ""
} |
q29961 | Navbar.start_el | train | public function start_el( &$output, $item, $depth = 0, $args = [], $item_id = 0 ) {
parent::start_el( $output, $item, $depth, $args, $item_id );
$output = preg_replace(
'/menu-item-has-children([^>\"]*?)">/ms',
'menu-item-has-children$1" aria-haspopup="true">',
$output
);
} | php | {
"resource": ""
} |
q29962 | Navbar._nav_menu_css_class | train | public function _nav_menu_css_class( $classes, $item, $args, $depth ) {
if ( ! is_object( $args->walker ) ) {
return $classes;
}
if ( ! $args->walker instanceof \Inc2734\WP_Basis\App\Walker\Navbar ) {
return $classes;
}
if ( $depth > 0 ) {
$classes[] = 'c-navbar__subitem';
} else {
$classes[] ... | php | {
"resource": ""
} |
q29963 | ResponseRedirect.address | train | public function address($address = null)
{
if ($address !== null) {
$this->address = str_replace('&', '&', $address);
}
$this->setRedirectHeaders();
return $this->address;
} | php | {
"resource": ""
} |
q29964 | ResponseRedirect.delay | train | public function delay($delay = null)
{
if ($delay !== null) {
$this->delay = (int) $delay;
}
$this->setRedirectHeaders();
return $this->delay;
} | php | {
"resource": ""
} |
q29965 | LoginProvider.generateSettings | train | protected function generateSettings()
{
$settings = new LoginProviderSettings();
$settings->identityColumnName = $this->usernameColumnName;
$settings->lockoutAccountAfterFailedLoginAttempts = true;
$settings->numberOfFailedLoginAttemptsBeforeLockout = 3;
$settings->numberOfPr... | php | {
"resource": ""
} |
q29966 | LoginProvider.login | train | public function login($identity, $password)
{
try {
$loginStatus = $this->attemptLogin($identity, $password);
if ($loginStatus) {
$this->createSuccessfulUserLoginAttempt($identity);
}
return $loginStatus;
} catch (LoginDisabledExcepti... | php | {
"resource": ""
} |
q29967 | LoginProvider.checkUserIsPermitted | train | protected function checkUserIsPermitted($user)
{
if (!isset($user)) {
Log::debug("Login failed for ".$user[$this->usernameColumnName]." - the user is disabled.", "LOGIN");
throw new LoginDisabledException();
}
if ($this->hasPasswordExpired($user)){
Log::d... | php | {
"resource": ""
} |
q29968 | CssParserCombinatorUserDefined.filter | train | public function filter($node, $tagname)
{
$userDefFunction = $this->_userDefFunction;
$nodes = $userDefFunction($node, $tagname);
if (!is_array($nodes)) {
throw new CssParserException(
"The user defined combinator is not an array"
);
}
... | php | {
"resource": ""
} |
q29969 | FixedBlock.delete | train | public function delete()
{
/*
* Bug fix
* @link https://bugs.php.net/bug.php?id=71921
*/
shmop_write($this->shmid, str_pad('', shmop_size($this->shmid), ' '), 0);
return shmop_delete($this->shmid);
} | php | {
"resource": ""
} |
q29970 | Upload.generateFilename | train | private function generateFilename()
{
$filename = str_random(100) . "." . $this->extension;
if(Storage::exists($this->folder . '/' . $filename))
{
$this->generateFilename();
}
return $filename;
} | php | {
"resource": ""
} |
q29971 | Polly.read | train | public function read($text)
{
$initializeOptions = $this->getOptions()->getInitializeOptions();
$pollyClient = new PollyClient([
'version' => $initializeOptions->getVersion(),
'region' => $initializeOptions->getRegion(),
'credentials' => [
'key' =>... | php | {
"resource": ""
} |
q29972 | ExceptionListener.onKernelException | train | public function onKernelException(GetResponseForExceptionEvent $event)
{
$exception = $event->getException();
if (! $exception instanceof RedKiteCmsExceptionInterface) {
return;
}
$message = $exception->getMessage();
$jsonMessage = json_decode($message, true);
... | php | {
"resource": ""
} |
q29973 | Cron.checkReportTaskDelivery | train | public static function checkReportTaskDelivery()
{
// get report tasks
$reportTasks = ReportTask::builder()
->whereNotNull('next_run_023')
->where('next_run_023', '<', date('U'))
->get();
foreach ($reportTasks as $reportTask)
self::executeRepo... | php | {
"resource": ""
} |
q29974 | Rut.make | train | public static function make(...$ruts)
{
// Reset the array index to a sequential one.
$ruts = array_values($ruts);
// First check if the dev passed one single array instead multiple $ruts.
// If that's the case, we will unwrap the array and use that. Otherwise,
// we will us... | php | {
"resource": ""
} |
q29975 | Rut.makeValid | train | public static function makeValid(...$ruts)
{
$ruts = self::make(...$ruts);
$ruts = is_array($ruts) ? $ruts : [$ruts];
foreach ($ruts as $rut) {
if (!$rut->isValid()) {
throw new InvalidRutException($rut);
}
}
return count($ruts) === ... | php | {
"resource": ""
} |
q29976 | Rut.addRut | train | public function addRut(string $rut)
{
// Before adding a RUT to this instance, we need to separate the number
// and the verification digit.
[$this->attributes['num'], $this->attributes['vd']] = $this->separateRut($rut);
return $this;
} | php | {
"resource": ""
} |
q29977 | Rut.toFormattedString | train | public function toFormattedString()
{
switch (self::$format) {
case 'full':
return number_format($this->num, 0, ',', '.') . '-' . $this->vd;
case 'basic':
return $this->num.'-'.$this->vd;
case 'raw':
default:
ret... | php | {
"resource": ""
} |
q29978 | Rut.setStringFormat | train | public static function setStringFormat(string $format)
{
switch ($format) {
case 'raw':
self::$format = 'raw';
break;
case 'basic':
self::$format = 'basic';
break;
case 'full':
default:
... | php | {
"resource": ""
} |
q29979 | Response.setContent | train | public function setContent($content, $code = 200)
{
$this->content = $content ? $content : '';
$this->statusCode = $code;
if (!is_scalar($content)) {
$this->toJson();
}
return $this;
} | php | {
"resource": ""
} |
q29980 | Response.appendContent | train | public function appendContent($content, $code = 200)
{
if (!empty($content)) {
$oldContent = $this->getContent();
if (!empty($oldContent)) {
if (!is_scalar($content)) {
$content = json_encode($content);
}
$this->to... | php | {
"resource": ""
} |
q29981 | Response.json | train | public function json($content)
{
$this->header('Content-Type', 'application/json');
$this->json = true;
$this->content = $content;
return $this;
} | php | {
"resource": ""
} |
q29982 | Response.download | train | public function download($path, $name = null)
{
$fResponse = new FileResponse($path);
return $fResponse->forceDownload($name);
} | php | {
"resource": ""
} |
q29983 | Response.getContent | train | public function getContent()
{
//Convert non scalar responses
if ($this->content && !is_scalar($this->content) && !$this->json) {
$this->toJson();
}
if (($this->json || $this->request->wantsJson()) && !is_scalar($this->content)) {
if ($this->content instanceo... | php | {
"resource": ""
} |
q29984 | Response.getStatusText | train | protected function getStatusText()
{
$code = $this->statusCode;
if (empty($code)) {
$code = 200;
}
return "HTTP/1.1 $code " . $this->getHttpResponseMessage($code);
} | php | {
"resource": ""
} |
q29985 | PaymentExtension.onCaptured | train | public function onCaptured($response)
{
$order = $this->owner->Invoice();
if ($order->exists()) {
$payment_amount = MathsHelper::round($this->owner->getAmount(), 2);
$order_amount = MathsHelper::round($order->Total, 2);
// If our payment is the value of the orde... | php | {
"resource": ""
} |
q29986 | PaymentExtension.onRefunded | train | public function onRefunded($response)
{
$order = $this->owner->Invoice();
if ($order->exists()) {
$order->markRefunded();
$order->write();
}
} | php | {
"resource": ""
} |
q29987 | View.addNamespace | train | public function addNamespace($sNamespace, $sDirectory, $sExtension = '')
{
// This method is provided by the Template trait
if(($sDirectory))
{
jaxon()->addViewNamespace($sNamespace, $sDirectory, $sExtension);
}
} | php | {
"resource": ""
} |
q29988 | CssParserModelSelector.filter | train | public function filter($node)
{
$ret = array();
$items = array($node);
foreach ($this->_factors as $factor) {
$ret = $this->_getNodesByFactor($items, $factor);
$items = $ret;
}
return $ret;
} | php | {
"resource": ""
} |
q29989 | CssParserModelSelector._getNodesByFactor | train | private function _getNodesByFactor($nodes, $factor)
{
$ret = array();
foreach ($nodes as $node) {
$items = $factor->filter($node);
$ret = Dom::mergeNodes($ret, $items);
}
return $ret;
} | php | {
"resource": ""
} |
q29990 | Config.mode | train | public function mode($mode = null)
{
if ($mode !== null) {
$this->mode = (string) $mode;
}
return $this->mode;
} | php | {
"resource": ""
} |
q29991 | Config.import | train | public function import(array $arr, $prefix = null)
{
$imports = [];
foreach ($arr as $key => $node) {
if (strpos($key, 'import') === 0) {
$mode = substr($key, 7);
if ($mode == '' || $mode == $this->mode) {
$imports = array_merge($import... | php | {
"resource": ""
} |
q29992 | Config.merge | train | private function merge(array $merged, array $array)
{
foreach ($array as $key => $value) {
if (is_array($value) && isset ($merged[$key]) && is_array($merged[$key])) {
$merged[$key] = $this->merge($merged[$key], $value);
} else {
$merged[$key] = $value;... | php | {
"resource": ""
} |
q29993 | Config.applyPrefix | train | private function applyPrefix(array $array, $prefix = null)
{
if ($prefix === null) {
return $array;
}
$result = [];
foreach ($array as $key => $value) {
$result[$prefix . self::PREFIX_GLUE . $key] = $value;
}
return $result;
} | php | {
"resource": ""
} |
q29994 | Prototype.bindMany | train | public function bindMany(string $class, array $methods)
{
/**
* Map through the functions
*
* @param Closure $closure
*/
array_map(function ($closure) use ($class) {
$info = new ReflectionFunction($closure);
$doc = explode(PHP_EOL, $info->getDocComment());
/**
... | php | {
"resource": ""
} |
q29995 | Prototype.hasManyProps | train | public function hasManyProps(string $class, array $props)
{
/**
* Map through the functions
*
* @param Closure $closure
*/
array_map(function ($closure) use ($class) {
$info = new ReflectionFunction($closure);
$doc = explode(PHP_EOL, $info->getDocComment());
/**
... | php | {
"resource": ""
} |
q29996 | ReflectionAutowire.assertType | train | protected function assertType(string $class, string $param, ?\ReflectionType $reflType): void
{
if ($reflType === null || !$reflType instanceof \ReflectionNamedType) {
throw new AutowireException("Unable to autowire {$class}: Unknown type for parameter '{$param}'.");
}
if ($refl... | php | {
"resource": ""
} |
q29997 | ReflectionAutowire.extractParamAnnotations | train | protected function extractParamAnnotations(string $docComment): array
{
$pattern = '/@param(?:\s+([^$"]\S+))?(?:\s+\$(\w+))?(?:\s+"([^"]++)")?/';
if (!(bool)preg_match_all($pattern, $docComment, $matches, PREG_SET_ORDER)) {
return [];
}
$annotations = [];
forea... | php | {
"resource": ""
} |
q29998 | ReflectionAutowire.getParamType | train | protected function getParamType(\ReflectionClass $class, \ReflectionParameter $param): string
{
$this->assertType($class->getName(), $param->getName(), $param->getType());
return $param->getType()->getName();
} | php | {
"resource": ""
} |
q29999 | ReflectionAutowire.determineDependencies | train | protected function determineDependencies(\ReflectionClass $class, int $skip): array
{
if (!$class->hasMethod('__construct')) {
return [];
}
$constructor = $class->getMethod('__construct');
$docComment = $constructor->getDocComment();
$annotations = is_string($doc... | php | {
"resource": ""
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.