_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q267200
Container.arrayify
test
protected function arrayify(Container $o) { $a = []; foreach ($o->props as $k => $v) { if ($v instanceof Container) { $a[$k] = $this->arrayify($v); } else { $a[$k] = $v; } } return $a; }
php
{ "resource": "" }
q267201
Container.apply
test
public function apply($modifier) { if (is_callable($modifier)) { foreach ($this->props as $prop => $value) { $this->__set($prop, $modifier($value, $prop)); } } else { foreach ($modifier as $key => $mod) { if (is_callable($mod)) { $this->props->$key = $mod(isset($this->props->$key) ? $this->pro...
php
{ "resource": "" }
q267202
CssResource.fromUrl
test
public static function fromUrl($cssUrl, $baseUrl, $mediaType = 'all') { // Match URL. if (strpos($cssUrl, $baseUrl) === false) { throw new \InvalidArgumentException('The CSS URL does not begin with the base URL'); } // Create. $baseLength = strlen(rtrim($baseUrl,...
php
{ "resource": "" }
q267203
MessagingController.getAddressBook
test
public function getAddressBook() { $acquaintances = Auth::user()->getAcquaintances(); return view('mustard::messages.address-book', [ 'acquaintances' => new Paginator($acquaintances, $acquaintances->count(), config('per_page', 25)), ]); }
php
{ "resource": "" }
q267204
MessagingController.getCompose
test
public function getCompose() { $acquaintances = Auth::user()->getAcquaintances(); if ($acquaintances->isEmpty()) { return redirect()->to('/account/contacts')->withStatus('Your contacts list is empty.'); } return view('mustard::messages.compose', [ 'acquainta...
php
{ "resource": "" }
q267205
MessagingController.getView
test
public function getView($messageId) { $message = Message::find($messageId); $message->read = true; $message->save(); return view('mustard::messages.view', [ 'message' => $message, ]); }
php
{ "resource": "" }
q267206
MessagingController.postManage
test
public function postManage(Request $request) { foreach ($request->input('messages') as $message_id) { $message = Message::find($message_id); if (is_null($message) || !$request->has('action')) { continue; } switch ($request->input('action')) {...
php
{ "resource": "" }
q267207
WindowsExtensionAppenderTrait._appendExtensionsToPaths
test
protected function _appendExtensionsToPaths(array $paths, array $extensions) { $getPathsWithExtensions = function($path) use($extensions) { if ($this->_hasExtension($path)) { return [$path]; } $addExtension = function($extension) use($path) { ...
php
{ "resource": "" }
q267208
Session.destroy
test
public function destroy(): void { // see example here http://goo.gl/nBVl0 $this->logout(); $p = session_get_cookie_params(); setcookie(session_name(), "", time() - 42000, $p["path"], $p["domain"], $p["secure"], $p["httponly"]); session_destroy(); }
php
{ "resource": "" }
q267209
PEAR_Autoloader.addAutoload
test
function addAutoload($method, $classname = null) { if (is_array($method)) { array_walk($method, create_function('$a,&$b', '$b = strtolower($b);')); $this->_autoload_map = array_merge($this->_autoload_map, $method); } else { $this->_autoload_map[strtolower($method)...
php
{ "resource": "" }
q267210
PEAR_Autoloader.removeAutoload
test
function removeAutoload($method) { $method = strtolower($method); $ok = isset($this->_autoload_map[$method]); unset($this->_autoload_map[$method]); return $ok; }
php
{ "resource": "" }
q267211
PEAR_Autoloader.removeAggregateObject
test
function removeAggregateObject($classname) { $ok = false; $classname = strtolower($classname); reset($this->_method_map); while (list($method, $obj) = each($this->_method_map)) { if (is_a($obj, $classname)) { unset($this->_method_map[$method]); ...
php
{ "resource": "" }
q267212
Console_Getopt.getopt2
test
function getopt2($args, $short_options, $long_options = null, $skip_unknown = false) { return Console_Getopt::doGetopt(2, $args, $short_options, $long_options, $skip_unknown); }
php
{ "resource": "" }
q267213
Console_Getopt.doGetopt
test
function doGetopt($version, $args, $short_options, $long_options = null, $skip_unknown = false) { // in case you pass directly readPHPArgv() as the first arg if (PEAR::isError($args)) { return $args; } if (empty($args)) { return array(array(), array()); ...
php
{ "resource": "" }
q267214
Console_Getopt._parseShortOption
test
function _parseShortOption($arg, $short_options, &$opts, &$args, $skip_unknown) { for ($i = 0; $i < strlen($arg); $i++) { $opt = $arg{$i}; $opt_arg = null; /* Try to find the short option in the specifier string. */ if (($spec = strstr($short_options, $op...
php
{ "resource": "" }
q267215
System._parseArgs
test
function _parseArgs($argv, $short_options, $long_options = null) { if (!is_array($argv) && $argv !== null) { // Find all items, quoted or otherwise preg_match_all("/(?:[\"'])(.*?)(?:['\"])|([^\s]+)/", $argv, $av); $argv = $av[1]; foreach ($av[2] as $k => $a) {...
php
{ "resource": "" }
q267216
System._dirToStruct
test
function _dirToStruct($sPath, $maxinst, $aktinst = 0, $silent = false) { $struct = array('dirs' => array(), 'files' => array()); if (($dir = @opendir($sPath)) === false) { if (!$silent) { System::raiseError("Could not open dir $sPath"); } return $s...
php
{ "resource": "" }
q267217
System._multipleToStruct
test
function _multipleToStruct($files) { $struct = array('dirs' => array(), 'files' => array()); settype($files, 'array'); foreach ($files as $file) { if (is_dir($file) && !is_link($file)) { $tmp = System::_dirToStruct($file, 0); $struct = array_mer...
php
{ "resource": "" }
q267218
System.rm
test
function rm($args) { $opts = System::_parseArgs($args, 'rf'); // "f" does nothing but I like it :-) if (PEAR::isError($opts)) { return System::raiseError($opts); } foreach ($opts[0] as $opt) { if ($opt[0] == 'r') { $do_recursive = true; ...
php
{ "resource": "" }
q267219
System.mkDir
test
function mkDir($args) { $opts = System::_parseArgs($args, 'pm:'); if (PEAR::isError($opts)) { return System::raiseError($opts); } $mode = 0777; // default mode foreach ($opts[0] as $opt) { if ($opt[0] == 'p') { $create_parents = true; ...
php
{ "resource": "" }
q267220
System.mktemp
test
function mktemp($args = null) { static $first_time = true; $opts = System::_parseArgs($args, 't:d'); if (PEAR::isError($opts)) { return System::raiseError($opts); } foreach ($opts[0] as $opt) { if ($opt[0] == 'd') { $tmp_is_dir = true;...
php
{ "resource": "" }
q267221
System._removeTmpFiles
test
function _removeTmpFiles() { if (count($GLOBALS['_System_temp_files'])) { $delete = $GLOBALS['_System_temp_files']; array_unshift($delete, '-r'); System::rm($delete); $GLOBALS['_System_temp_files'] = array(); } }
php
{ "resource": "" }
q267222
System.find
test
function find($args) { if (!is_array($args)) { $args = preg_split('/\s+/', $args, -1, PREG_SPLIT_NO_EMPTY); } $dir = realpath(array_shift($args)); if (!$dir) { return array(); } $patterns = array(); $depth = 0; $do_files = $do_d...
php
{ "resource": "" }
q267223
Logger.getLog
test
protected function getLog(string $message, PriorityInterface $priority = null, array $metaData = null): LogInterface { return new Log($message, $priority ?? null, null, $metaData ?? null); }
php
{ "resource": "" }
q267224
BudgetCategoryAbstract.setBudgetId
test
public function setBudgetId($budgetId) { $budgetId = (int) $budgetId; if ($this->budgetId < 0) { throw new \UnderflowException('Value of "budgetId" must be greater than 0'); } if ($this->exists() && $this->budgetId !== $budgetId) { $this->updated['budgetId'...
php
{ "resource": "" }
q267225
BudgetCategoryAbstract.getBudget
test
public function getBudget($isForceReload = false) { if ($isForceReload || null === $this->joinOneCacheBudget) { $mapper = new BudgetMapper($this->dependencyContainer->getDatabase('money')); $this->joinOneCacheBudget = $mapper->findByKeys(array( 'budget_id' => $this->g...
php
{ "resource": "" }
q267226
BudgetCategoryAbstract.getAllTransaction
test
public function getAllTransaction($isForceReload = false) { if ($isForceReload || null === $this->joinManyCacheTransaction) { $mapper = new TransactionMapper($this->dependencyContainer->getDatabase('money')); $mapper->addWhere('category_id', $this->getCategoryId()); $thi...
php
{ "resource": "" }
q267227
Zend_Config_Writer_Ini._prepareValue
test
protected function _prepareValue($value) { if (is_integer($value) || is_float($value)) { return $value; } elseif (is_bool($value)) { return ($value ? 'true' : 'false'); } elseif (strpos($value, '"') === false) { return '"' . $value . '"'; } else {...
php
{ "resource": "" }
q267228
HTTP_Request2.setUrl
test
public function setUrl($url) { if (is_string($url)) { $url = new Net_URL2( $url, array(Net_URL2::OPTION_USE_BRACKETS => $this->config['use_brackets']) ); } if (!$url instanceof Net_URL2) { throw new HTTP_Request2_LogicException( ...
php
{ "resource": "" }
q267229
HTTP_Request2.setMethod
test
public function setMethod($method) { // Method name should be a token: http://tools.ietf.org/html/rfc2616#section-5.1.1 if (preg_match(self::REGEXP_INVALID_TOKEN, $method)) { throw new HTTP_Request2_LogicException( "Invalid request method '{$method}'", ...
php
{ "resource": "" }
q267230
HTTP_Request2.setAuth
test
public function setAuth($user, $password = '', $scheme = self::AUTH_BASIC) { if (empty($user)) { $this->auth = null; } else { $this->auth = array( 'user' => (string)$user, 'password' => (string)$password, 'scheme' ...
php
{ "resource": "" }
q267231
HTTP_Request2.addCookie
test
public function addCookie($name, $value) { if (!empty($this->cookieJar)) { $this->cookieJar->store( array('name' => $name, 'value' => $value), $this->url ); } else { $cookie = $name . '=' . $value; if (preg_match(self::REGEXP_...
php
{ "resource": "" }
q267232
HTTP_Request2.setBody
test
public function setBody($body, $isFilename = false) { if (!$isFilename && !is_resource($body)) { if (!$body instanceof HTTP_Request2_MultipartBody) { $this->body = (string)$body; } else { $this->body = $body; } } else { ...
php
{ "resource": "" }
q267233
HTTP_Request2.getBody
test
public function getBody() { if (self::METHOD_POST == $this->method && (!empty($this->postParams) || !empty($this->uploads)) ) { if (0 === strpos($this->headers['content-type'], 'application/x-www-form-urlencoded')) { $body = http_build_query($this->postP...
php
{ "resource": "" }
q267234
HTTP_Request2.addUpload
test
public function addUpload( $fieldName, $filename, $sendFilename = null, $contentType = null ) { if (!is_array($filename)) { $fileData = $this->fopenWrapper($filename, empty($contentType)); $this->uploads[$fieldName] = array( 'fp' => $fileData['fp'...
php
{ "resource": "" }
q267235
HTTP_Request2.attach
test
public function attach(SplObserver $observer) { foreach ($this->observers as $attached) { if ($attached === $observer) { return; } } $this->observers[] = $observer; }
php
{ "resource": "" }
q267236
HTTP_Request2.detach
test
public function detach(SplObserver $observer) { foreach ($this->observers as $key => $attached) { if ($attached === $observer) { unset($this->observers[$key]); return; } } }
php
{ "resource": "" }
q267237
HTTP_Request2.setLastEvent
test
public function setLastEvent($name, $data = null) { $this->lastEvent = array( 'name' => $name, 'data' => $data ); $this->notify(); }
php
{ "resource": "" }
q267238
HTTP_Request2.setAdapter
test
public function setAdapter($adapter) { if (is_string($adapter)) { if (!class_exists($adapter, false)) { if (false === strpos($adapter, '_')) { $adapter = 'HTTP_Request2_Adapter_' . ucfirst($adapter); } if (!class_exists($...
php
{ "resource": "" }
q267239
HTTP_Request2.setCookieJar
test
public function setCookieJar($jar = true) { if (!class_exists('HTTP_Request2_CookieJar', false)) { require_once 'HTTP/Request2/CookieJar.php'; } if ($jar instanceof HTTP_Request2_CookieJar) { $this->cookieJar = $jar; } elseif (true === $jar) { ...
php
{ "resource": "" }
q267240
HTTP_Request2.send
test
public function send() { // Sanity check for URL if (!$this->url instanceof Net_URL2 || !$this->url->isAbsolute() || !in_array(strtolower($this->url->getScheme()), array('https', 'http')) ) { throw new HTTP_Request2_LogicException( ...
php
{ "resource": "" }
q267241
HTTP_Request2.detectMimeType
test
protected static function detectMimeType($filename) { // finfo extension from PECL available if (function_exists('finfo_open')) { if (!isset(self::$_fileinfoDb)) { self::$_fileinfoDb = @finfo_open(FILEINFO_MIME); } if (self::$_fileinfoDb) { ...
php
{ "resource": "" }
q267242
SettingController.showAction
test
public function showAction(Setting $setting) { $editForm = $this->createForm($this->get('amulen.dashboard.form.setting'), $setting, array( 'action' => $this->generateUrl('admin_amulen_setting_update', array('id' => $setting->getid())), 'method' => 'PUT', )); $deleteFo...
php
{ "resource": "" }
q267243
SettingController.newAction
test
public function newAction() { $setting = new Setting(); $form = $this->createForm($this->get('amulen.dashboard.form.setting'), $setting); return array( 'setting' => $setting, 'form' => $form->createView(), ); }
php
{ "resource": "" }
q267244
SettingController.createAction
test
public function createAction(Request $request) { $setting = new Setting(); $form = $this->createForm($this->get('amulen.dashboard.form.setting'), $setting); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($settin...
php
{ "resource": "" }
q267245
SettingController.updateAction
test
public function updateAction(Setting $setting, Request $request) { $editForm = $this->createForm($this->get('amulen.dashboard.form.setting'), $setting, array( 'action' => $this->generateUrl('admin_amulen_setting_update', array('id' => $setting->getid())), 'method' => 'PUT', )...
php
{ "resource": "" }
q267246
Query.where
test
public function where($expression, $value = null) { // shortcut : id if(is_int($expression) and !$value) { $expression = ['id' => $expression]; } // force array elseif(!is_array($expression)) { $expression = [$expression => $value]; } ...
php
{ "resource": "" }
q267247
Response.withStatus
test
public function withStatus($code, $reason_phrase = '') { if (!in_array($code, array_keys($this->status_codes))) { throw new InvalidArgumentException( 'HTTP Status Code is invalid' ); } $response = clone $this; $response->status_code = (int)$co...
php
{ "resource": "" }
q267248
Remover.remove
test
public function remove($params = array()) { $this->adapter->execute($this->toSql(), array_merge($this->params(), $this->params(true), $params)); return true; }
php
{ "resource": "" }
q267249
Component.hasEventListeners
test
public function hasEventListeners($event) { return !empty($this->listeners[$event]) || !empty($this->onceListeners[$event]); }
php
{ "resource": "" }
q267250
Validation.field
test
protected function field($name, $default = null) { return array_key_exists($name, $this->data) ? $this->data[$name] : $default; }
php
{ "resource": "" }
q267251
Validation.msg
test
protected function msg($msg, array $params = []) { return array_key_exists($msg, $this->messages) ? vsprintf($this->messages[$msg], $params) : null; }
php
{ "resource": "" }
q267252
ResourceController.createAccessDeniedHttpException
test
public function createAccessDeniedHttpException($message = 'Permission Denied!', \Exception $previous = null) { return new \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException($message, $previous); }
php
{ "resource": "" }
q267253
ResourceController.setFlash
test
protected function setFlash($type,$message,$parameters = array(),$domain = 'flashes') { return $this->get('session')->getBag('flashes')->add($type,$this->trans($message, $parameters, $domain)); }
php
{ "resource": "" }
q267254
MySql.commitTransaction
test
function commitTransaction(){ $this->log("COMMIT SAVE_POINT_".$this->transactionCount); $this->transactionCount--; if($this->transactionCount == 0){ parent::commit(); $this->log("COMMIT REAL"); } return $this->transactionCount; }
php
{ "resource": "" }
q267255
MySql.formatDate
test
function formatDate($dateStr=null,$includeTime=null){ if($dateStr === null){ $date = time(); }else if(is_string($dateStr)){ $date = strtotime($dateStr); }else if(is_integer($dateStr)){ $date = $dateStr; }else{ throw new InvalidInputException('1st parameter should be either a string or integer or nul...
php
{ "resource": "" }
q267256
MySql.formatTime
test
function formatTime($hh=0,$mm=0,$ss=0,$ampm="AM"){ $ampm = strtoupper($ampm); $hhUpperBound = 12; if($ampm == "PM"){ $hhUpperBound--; } if(!( (0 <= $hh && $hh <= $hhUpperBound) && (0 <= $mm && $mm <= 60) && (0 <= $ss && $ss <= 60) ) ){ throw new InvalidInputException('invalid par...
php
{ "resource": "" }
q267257
MySql.formatBoolean
test
function formatBoolean($value){ if(is_string($value)){ if(strtoupper($value) == "TRUE"){ $value = '1'; }else if(strtoupper($value) == "FALSE"){ $value = '0'; }else{ throw new InvalidInputException("Not a boolean value"); } }elseif ($value == true){ $value = '1'; }elseif ($value == false...
php
{ "resource": "" }
q267258
MySql.setTimeZone
test
function setTimeZone($timeZone){ if($this->currentTimeZone == $timeZone){ // $timeZone is set already return; } $this->currentTimeZone = $timeZone; //convert php timezone into mysql timezone format $dtz = new \DateTimeZone($timeZone); $timeInTimeZone = new \DateTime('now', $dtz); ...
php
{ "resource": "" }
q267259
Container.get
test
public function get($className, array $parameters = []) { if ($this->injectSelf($className)) { return $this; } $parameterKey = $this->getParameterStoreKey($parameters); $className = $this->resolve($className); if (!isset($this->services[$className][$parameterKe...
php
{ "resource": "" }
q267260
Container.has
test
public function has($className, array $parameters = []) { if ($this->injectSelf($className)) { return true; } $parameterKey = $this->getParameterStoreKey($parameters); $className = $this->resolve($className); return isset($this->services[$className][$parameterK...
php
{ "resource": "" }
q267261
Container.create
test
public function create($className, array $parameters = []) { if ($this->injectSelf($className)) { return $this; } $className = $this->resolve($className); $classMeta = $this->reflectionService->getClassMetaReflection($className); if ($classMeta->isInterface()) ...
php
{ "resource": "" }
q267262
Container.addResolver
test
public function addResolver(ResolverInterface $resolver, $priority = 0) { if (!isset($this->prioritizedResolvers[$priority])) { $this->prioritizedResolvers[$priority] = []; } array_push($this->prioritizedResolvers[$priority], $resolver); krsort($this->prioritizedResolver...
php
{ "resource": "" }
q267263
Container.add
test
public function add($object) { $className = '\\' . get_class($object); if ($this->injectSelf($className)) { throw new InvalidArgumentException('Tried to add a container instance'); } $parameterKey = $this->getParameterStoreKey([]); if (isset($this->services[$cl...
php
{ "resource": "" }
q267264
PgClient.getPool
test
public function getPool() { if (!isset($this->_pool)) { $poolConfig = [ 'loop' => $this->loop, 'clientConfig' => [ ['class' => pgConnection::class], [ $this->connectionParams, ...
php
{ "resource": "" }
q267265
PgClient.query
test
public function query($s) { return Observable::defer(function() use ($s) { $conn = $this->getLeastBusyConnection(); return $conn->query($s); }); }
php
{ "resource": "" }
q267266
PgClient.executeStatement
test
public function executeStatement(string $queryString, array $parameters = []) { return Observable::defer(function() use ($queryString, $parameters) { $conn = $this->getLeastBusyConnection(); return $conn->executeStatement($queryString, $parameters); }); }
php
{ "resource": "" }
q267267
PgClient.createNewConnection
test
private function createNewConnection($addToPool = true, $params = []) { // no idle connections were found - spin up new one $params = ArrayHelper::merge($this->connectionParams, $params); $connection = new pgConnection($params, $this->loop, $this->connector); if (!$addToPool || $this...
php
{ "resource": "" }
q267268
PgClient.getLeastBusyConnectionOld
test
private function getLeastBusyConnectionOld() : pgConnection { if (count($this->connections) === 0) { // try to spin up another connection to return $conn = $this->createNewConnection(); if ($conn === null) { throw new Exception('There are no connections. C...
php
{ "resource": "" }
q267269
ScriptHandler.assetsInstall
test
public static function assetsInstall(Event $event) { $options = self::getOptions($event); $consoleDir = self::getConsoleDir($event, 'install assets'); if (null === $consoleDir) { return; } $webDir = $options['web-dir']; $symlink = ''; if ($optio...
php
{ "resource": "" }
q267270
VersionReader.getReflectionClass
test
public function getReflectionClass($className) { if (isset($this->classReflections[$className])) { return $this->classReflections[$className]; } $class = new \ReflectionClass($className); $this->classReflections[$className] = $class; return $class; ...
php
{ "resource": "" }
q267271
VersionReader.getClassVersion
test
public function getClassVersion($className) { if (isset($this->classVersions[$className])) { return $this->classVersions[$className]; } $class = $this->getReflectionClass($className); $versionAnnotation = $this->reader->getClassAnnotation( $class, ...
php
{ "resource": "" }
q267272
VersionReader.findClassNameByVersion
test
private function findClassNameByVersion($startFromClassName, $version, &$visited = array()) { $versionAnnotation = $this->reader->getClassAnnotation( new \ReflectionClass($startFromClassName), 'Evispa\ObjectMigration\Annotations\Version' ); if ($versionAnnotat...
php
{ "resource": "" }
q267273
VersionReader.getClassMigrationMethods
test
public function getClassMigrationMethods($className) { if (isset($this->classMigrationMethods[$className])) { return $this->classMigrationMethods[$className]; } $migrationAnnotations = $this->getClassMigrationMethodInfo($className); $migrationMethods = new Migra...
php
{ "resource": "" }
q267274
VersionReader.getRequiredClassOptions
test
public function getRequiredClassOptions($className) { $requiredOptions = array(); $scanList = array($className => true); $scannedSourceNames = array(); while (true) { if (0 === count($scanList)) { break; } // find n...
php
{ "resource": "" }
q267275
JobController.showAction
test
public function showAction(Job $job) { $editForm = $this->createForm(new JobType(), $job, array( 'action' => $this->generateUrl('admin_amulen_job_update', array('id' => $job->getid())), 'method' => 'PUT', )); $deleteForm = $this->createDeleteForm($job->getId(), 'admin...
php
{ "resource": "" }
q267276
JobController.newAction
test
public function newAction() { $job = new Job(); $form = $this->createForm(new JobType(), $job); return array( 'job' => $job, 'form' => $form->createView(), ); }
php
{ "resource": "" }
q267277
JobController.createAction
test
public function createAction(Request $request) { $job = new Job(); $form = $this->createForm(new JobType(), $job); if ($form->handleRequest($request)->isValid()) { $em = $this->getDoctrine()->getManager(); $em->persist($job); $em->flush(); ret...
php
{ "resource": "" }
q267278
JobController.updateAction
test
public function updateAction(Job $job, Request $request) { $editForm = $this->createForm(new JobType(), $job, array( 'action' => $this->generateUrl('admin_amulen_job_update', array('id' => $job->getid())), 'method' => 'PUT', )); if ($editForm->handleRequest($request)-...
php
{ "resource": "" }
q267279
File.setClientFilename
test
public function setClientFilename($file_name) { if (is_string($file_name)) { $this->client_file_name = $file_name; $_ext = $this->guessExtension(); if (!empty($_ext) && !strstr($file_name, $_ext)) $this->client_file_name .= '.'.$_ext; } else { ...
php
{ "resource": "" }
q267280
File.guessExtension
test
public function guessExtension() { $_ext = $this->getExtension(); if (empty($_ext) && $this->getRealPath()) { $finfo = new \finfo(); $mime = $finfo->file( $this->getRealPath(), FILEINFO_MIME_TYPE ); $_ext = str_replace('image/', '', $mime); } retur...
php
{ "resource": "" }
q267281
File.getMime
test
public function getMime() { if ($this->getRealPath()) { $finfo = new \finfo(); return $finfo->file( $this->getRealPath(), FILEINFO_MIME_TYPE ); } return null; }
php
{ "resource": "" }
q267282
File.getHumanSize
test
public function getHumanSize( $decimals=2 ) { $sz = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); $factor = floor((strlen($this->getSize()) - 1) / 3); if ($factor >= count($sz)) $factor = count($sz)-1; return sprintf("%.{$decimals}f", $this->getSize() / pow(1024, $factor)) . $sz[$factor]...
php
{ "resource": "" }
q267283
File.getATimeAsDatetime
test
public function getATimeAsDatetime() { $_date = $this->getATime(); if (!empty($_date)) return \DateTime::createFromFormat( 'U', $_date ); return null; }
php
{ "resource": "" }
q267284
File.getCTimeAsDatetime
test
public function getCTimeAsDatetime() { $_date = $this->getCTime(); if (!empty($_date)) return \DateTime::createFromFormat( 'U', $_date ); return null; }
php
{ "resource": "" }
q267285
File.getMTimeAsDatetime
test
public function getMTimeAsDatetime() { $_date = $this->getMTime(); if (!empty($_date)) return \DateTime::createFromFormat( 'U', $_date ); return null; }
php
{ "resource": "" }
q267286
File.createFromContent
test
public static function createFromContent( $file_content, $filename=null, $client_file_name=null ) { $finfo = new \finfo(); $mime = $finfo->buffer( $file_content, FILEINFO_MIME_TYPE ); $extension = end(explode('/', $mime)); if (is_null($filename)) { $_tmp_filename = md5( $...
php
{ "resource": "" }
q267287
ApplicationRepository.findAll
test
public function findAll() { $applications = array(); foreach ($this->getRows() as $row) { $application = $this->createNew(); $application->setId($row['id']); $application->setName($row['name']); $application->setUrl($row['url']); $applica...
php
{ "resource": "" }
q267288
ApplicationRepository.find
test
public function find($id) { foreach ($this->findAll() as $application) { if ($id == $application->getId()) { return $application; } } return null; }
php
{ "resource": "" }
q267289
ApplicationRepository.create
test
public function create(Application $application) { $rows = $this->getRows(); $id = sizeof($rows) + 1; $rows[] = array( 'id' => $id, 'name' => $application->getName(), 'url' => $application->getUrl() ); file_put_contents($this->filename, Y...
php
{ "resource": "" }
q267290
ApplicationRepository.delete
test
public function delete(Application $application) { $rows = array(); foreach ($this->getRows() as $row) { if ($row['id'] == $application->getId()) { continue; } $rows[] = $row; } file_put_contents($this->filename, Yaml::dump($rows)...
php
{ "resource": "" }
q267291
ApplicationRepository.update
test
public function update(Application $application) { $rows = array(); foreach ($this->getRows() as $row) { if ($row['id'] == $application->getId()) { $row = array( 'id' => $application->getId(), 'name' => $application->getName(), ...
php
{ "resource": "" }
q267292
BusinessHours.getClosestDateIntervalBefore
test
private function getClosestDateIntervalBefore(\DateTime $date): DateTimeInterval { $tmpDate = clone $date; $dayOfWeek = (int)$tmpDate->format('N'); $time = TimeBuilder::fromDate($tmpDate); if (null !== $day = $this->getDay($dayOfWeek)) { if (null !== $closestTime = $day-...
php
{ "resource": "" }
q267293
BusinessHours.getClosestDateIntervalAfter
test
private function getClosestDateIntervalAfter(\DateTime $date): DateTimeInterval { $tmpDate = clone $date; $dayOfWeek = (int)$tmpDate->format('N'); $time = TimeBuilder::fromDate($tmpDate); if (null !== $day = $this->getDay($dayOfWeek)) { if (null !== $closestTime = $day->...
php
{ "resource": "" }
q267294
BusinessHours.buildDateTimeInterval
test
private function buildDateTimeInterval(\DateTime $date, TimeIntervalInterface $timeInterval): DateTimeInterval { $intervalStart = clone $date; $intervalEnd = clone $date; $intervalStart->setTime( $timeInterval->getStart()->getHours(), $timeInterval->getStart()->getMi...
php
{ "resource": "" }
q267295
BusinessHours.getDayBefore
test
private function getDayBefore(int $dayNumber) { $tmpDayNumber = $dayNumber; for ($i = 0; $i < 6; $i++) { $tmpDayNumber = (DayInterface::WEEK_DAY_MONDAY === $tmpDayNumber) ? DayInterface::WEEK_DAY_SUNDAY : --$tmpDayNumber; if (null !== $day = $this->getDay($tmpDayNumber)) { ...
php
{ "resource": "" }
q267296
BusinessHours.getDayAfter
test
private function getDayAfter($dayNumber) { $tmpDayNumber = $dayNumber; for ($i = 0; $i < 6; $i++) { $tmpDayNumber = (DayInterface::WEEK_DAY_SUNDAY === $tmpDayNumber) ? DayInterface::WEEK_DAY_MONDAY : ++$tmpDayNumber; if (null !== $day = $this->getDay($tmpDayNumber)) { ...
php
{ "resource": "" }
q267297
PEAR_Installer_Role_Common.getInfo
test
function getInfo($role) { if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) { return PEAR::raiseError('Unknown Role class: "' . $role . '"'); } return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role]; }
php
{ "resource": "" }
q267298
Transaction.commit
test
public function commit() { if (!$this->getIsActive()) { throw new Exception('Failed to commit transaction: transaction was inactive.'); } $connection = $this->getConnection(); $this->_level--; if ($this->_level === 0) { Reaction::debug('Commit transac...
php
{ "resource": "" }
q267299
Transaction.rollBack
test
public function rollBack($final = false) { if (!$this->getIsActive()) { // do nothing if transaction is not active: this could be the transaction is committed // but the event handler to "commitTransaction" throw an exception return Reaction\Promise\reject(new Exception("...
php
{ "resource": "" }