_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
83
13k
language
stringclasses
1 value
meta_information
dict
q7500
IniParser.castItemValueToProperType
train
public function castItemValueToProperType($value) { $normalized = $value; if (in_array($value, ['true', 'on', 'yes'])) { $normalized = true; } elseif (in_array($value, ['false', 'off', 'no', 'none'])) { $normalized = false; } e...
php
{ "resource": "" }
q7501
Route.createFromReflection
train
public static function createFromReflection(\ReflectionMethod $reflectionMethod, string $basePath = '') { $routes = []; if (is_a($reflectionMethod->class, '\Berlioz\Core\Controller\Controller', true)) { try { if ($reflectionMethod->isPublic()) { if ($...
php
{ "resource": "" }
q7502
Route.filterParameters
train
private function filterParameters(array $params): array { return array_filter( $params, function (&$value) { if (is_array($value)) { $value = $this->filterParameters($value); return count($value)...
php
{ "resource": "" }
q7503
ErrorLogger.as_string
train
private function as_string( $value ) { if ( is_object( $value ) && method_exists( $value, '__toString' ) ) { $value = (string) $value; } if ( is_string( $value ) ) { return $value; } elseif ( is_null( $value ) ) { return 'NULL'; } elseif ( is_bool( $value ) ) { return $value ? '(boolean) TRUE' :...
php
{ "resource": "" }
q7504
NodeFactoryImpl.createNodeInstanceFromNodeParameter
train
public function createNodeInstanceFromNodeParameter($value, $type, $datatype = null, $language = null) { switch ($type) { case 'uri': return $this->createNamedNode($value); case 'bnode': return $this->createBlankNode($value); case 'litera...
php
{ "resource": "" }
q7505
Retriever.methodLoader
train
private function methodLoader($methods) { foreach ($methods as $key => $param) { if (is_array($param)) { $methods[$key] = $this->methodLoader($this->getExportParams($key)); continue; } $method = 'get' . SimpleDataObjectConverter::snakeCaseT...
php
{ "resource": "" }
q7506
Retriever.getExportParams
train
private function getExportParams($key = null) { if ($key && isset($this->exportParams[$key])) { return $this->exportParams[$key]; } return $this->exportParams; }
php
{ "resource": "" }
q7507
SimpleDoctrineMappingLocator.setPaths
train
public function setPaths($paths) { $this->paths = $paths; self::$pathsMap[$this->namespace] = $this->paths; }
php
{ "resource": "" }
q7508
CmsMap._toHtml
train
protected function _toHtml() { if (!$this->getOptions()) { $cmsPages = $this->cmsPageCollection->addStoreFilter($this->getStoreFromContext()); foreach ($cmsPages as $cmsPage) { /** @var \Magento\Cms\Model\Page $cmsPage */ $this->addOption($cmsPage->get...
php
{ "resource": "" }
q7509
CmsMap.getStoreFromContext
train
public function getStoreFromContext() { $params = $this->getRequest()->getParams(); if (isset($params['store'])) { return [$params['store']]; } elseif (isset($params['website'])) { /** @var Website $website */ $website = $this->storeManager->getWebsite($p...
php
{ "resource": "" }
q7510
UserCredentialAbstract._initializeProfile
train
private function _initializeProfile($userProfile) { die(print_r($userProfile)); //validate that user profile has the correct information for password validation if (!is_array($userProfile) || !isset($userProfile['username']) || !isset($userProfile['password']) ...
php
{ "resource": "" }
q7511
UserCredentialAbstract._validateConsecutiveCharacterRepeat
train
final protected function _validateConsecutiveCharacterRepeat() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile...
php
{ "resource": "" }
q7512
UserCredentialAbstract._validatePolicy
train
final protected function _validatePolicy() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ...
php
{ "resource": "" }
q7513
UserCredentialAbstract._validatePolicyAtChange
train
final protected function _validatePolicyAtChange() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']...
php
{ "resource": "" }
q7514
UserCredentialAbstract._canChangePassword
train
final protected function _canChangePassword() { //validate that required indices exist if (!isset($this->_userProfile['username']) || !isset($this->_userProfile['password']) || !isset($this->_userProfile['fullname']) || !isset($this->_userProfile['passhist']) ...
php
{ "resource": "" }
q7515
UserCredentialAbstract._validateTenancy
train
final protected function _validateTenancy() { $userProfile = $this->_userProfile; //Verify if the password was changed today or server has been futuredated $currDateTimeObj = new \DateTime(); //if account has tenancy expiry, deny login if user account tenancy is p...
php
{ "resource": "" }
q7516
AbstractAclManager.doLoadAcl
train
protected function doLoadAcl(ObjectIdentityInterface $objectIdentity) { $acl = null; try { $acl = $this->getAclProvider()->createAcl($objectIdentity); } catch (AclAlreadyExistsException $ex) { $acl = $this->getAclProvider()->findAcl($objectIdentity); } ...
php
{ "resource": "" }
q7517
FTPClient.connect
train
public function connect($timeout = 90) { $host = $this->getAuthenticator()->getHost(); $port = $this->getAuthenticator()->getPort(); $this->setConnection(@ftp_connect($host, $port, $timeout)); if (false === $this->getConnection()) { throw $this->newFTPException("connection fa...
php
{ "resource": "" }
q7518
FTPClient.delete
train
public function delete($path) { if (false === @ftp_delete($this->getConnection(), $path)) { throw $this->newFTPException(sprintf("delete %s failed", $path)); } return $this; }
php
{ "resource": "" }
q7519
FTPClient.pasv
train
public function pasv($pasv) { if (false === @ftp_pasv($this->getConnection(), $pasv)) { throw $this->newFTPException(sprintf("pasv from %d to %d failed", !$pasv, $pasv)); } return $this; }
php
{ "resource": "" }
q7520
FTPClient.put
train
public function put($localFile, $remoteFile, $mode = FTP_IMAGE, $startPos = 0) { if (false === @ftp_put($this->getConnection(), $remoteFile, $localFile, $mode, $startPos)) { throw $this->newFTPException(sprintf("put %s into %s failed", $localFile, $remoteFile)); } return $this; }
php
{ "resource": "" }
q7521
Illuminate.alwaysFrom
train
public function alwaysFrom(string $address, ?string $name = null): void { $this->getMailer()->alwaysFrom($address, $name); }
php
{ "resource": "" }
q7522
Illuminate.alwaysTo
train
public function alwaysTo(string $address, ?string $name = null): void { $this->getMailer()->alwaysTo($address, $name); }
php
{ "resource": "" }
q7523
Illuminate.plain
train
public function plain(string $view, array $data, $callback): Receipt { return $this->send(['text' => $view], $data, $callback); }
php
{ "resource": "" }
q7524
Illuminate.setQueue
train
public function setQueue(QueueContract $queue) { if ($this->mailer instanceof MailerContract) { $this->mailer->setQueue($queue); } $this->queue = $queue; return $this; }
php
{ "resource": "" }
q7525
Illuminate.handleQueuedMessage
train
public function handleQueuedMessage(Job $job, $data) { $this->send($data['view'], $data['data'], $this->getQueuedCallable($data)); $job->delete(); }
php
{ "resource": "" }
q7526
Config.loadUndefinedConfigPaths
train
public function loadUndefinedConfigPaths() { $list = []; $collection = $this->coreConfig->getCollectionByPath(SgCoreInterface::PATH_UNDEFINED . '%'); /** @var \Magento\Framework\App\Config\Value $item */ foreach ($collection as $item) { $path = explode('/', $i...
php
{ "resource": "" }
q7527
Config.getShopNumber
train
public function getShopNumber() { $shopNumber = $this->request->getParam('shop_number'); $item = $this->sgCoreConfig->getShopNumberCollection($shopNumber)->getFirstItem(); return $item->getData('value') ? $shopNumber : ''; }
php
{ "resource": "" }
q7528
NotifierServiceProvider.registerMailer
train
protected function registerMailer(): void { $this->app->singleton('orchestra.mail', function ($app) { $mailer = new Mailer($app, $transport = new TransportManager($app)); if ($app->bound('orchestra.platform.memory')) { $mailer->attach($memory = $app->make('orchestra....
php
{ "resource": "" }
q7529
NotifierServiceProvider.registerIlluminateMailerResolver
train
protected function registerIlluminateMailerResolver(): void { $this->app->afterResolving('mailer', function ($service) { $this->app->make('orchestra.mail')->configureIlluminateMailer($service); }); }
php
{ "resource": "" }
q7530
S3Transporter.delete
train
public function delete($id) { $params = $this->parseUrl($id); try { $this->getClient()->deleteObject(array( 'Bucket' => $params['bucket'], 'Key' => $params['key'] )); } catch (S3Exception $e) { return false; } ...
php
{ "resource": "" }
q7531
S3Transporter.parseUrl
train
public function parseUrl($url) { $region = $this->getConfig('region'); $bucket = $this->getConfig('bucket'); $key = $url; if (strpos($url, 'amazonaws.com') !== false) { // s3<region>.amazonaws.com/<bucket> if (preg_match('/^https?:\/\/s3(.+?)?\.amazonaws\.com\/(...
php
{ "resource": "" }
q7532
Net_SFTP_Stream.register
train
static function register($protocol = 'sftp') { if (in_array($protocol, stream_get_wrappers(), true)) { return false; } $class = function_exists('get_called_class') ? get_called_class() : __CLASS__; return stream_wrapper_register($protocol, $class); }
php
{ "resource": "" }
q7533
UserCredentialGoogleAuthLoginService.checkToken
train
protected function checkToken() { //instantiate MultiOtp Wrapper $multiOtpWrapper = new MultiotpWrapper(); //get the username $currentUserName = $this->getCurrentUsername(); //assert that username is set if (!(\strlen((string) $currentUserName)))...
php
{ "resource": "" }
q7534
Regions.getIsoStateByMagentoRegion
train
public function getIsoStateByMagentoRegion(DataObject $address) { $map = $this->getIsoToMagentoMapping(); $sIsoCode = null; if ($address->getData('country_id') && $address->getData('region_code')) { $sIsoCode = $address->getData('country_id') . "-" . $address->getData('regi...
php
{ "resource": "" }
q7535
SerializerEasyRdf.serializeIteratorToStream
train
public function serializeIteratorToStream(StatementIterator $statements, $outputStream) { /* * check parameter $outputStream */ if (is_resource($outputStream)) { // use it as it is } elseif (is_string($outputStream)) { $outputStream = fopen($outputSt...
php
{ "resource": "" }
q7536
OptionList.set
train
public function set(string $name, $value, int $type = self::TYPE_LOCAL): OptionList { if ($type == self::TYPE_GLOBAL) { self::$globalOptions[$name] = $value; } else { $this->options[$name] = $value; } return $this; }
php
{ "resource": "" }
q7537
OptionList.isset
train
public function isset(string $name, int $type = null): bool { if (is_null($type)) { return array_key_exists($name, $this->options) || array_key_exists($name, self::$globalOptions); } else { if ($type == self::TYPE_GLOBAL) { return array_key_exists($name, self:...
php
{ "resource": "" }
q7538
OptionList.getGlobal
train
public static function getGlobal(string $name) { if (isset(self::$globalOptions[$name])) { return self::$globalOptions[$name]; } else { return null; } }
php
{ "resource": "" }
q7539
OptionList.is_null
train
public function is_null(string $name, int $type = null): bool { if (isset(self::$globalOptions[$name]) && (is_null($type) || $type == self::TYPE_GLOBAL)) { return is_null(self::$globalOptions[$name]); } else { if (isset($this->options[$name]) && (is_null($type) || $type == se...
php
{ "resource": "" }
q7540
LocalFile.getByIdentifier
train
public static function getByIdentifier($id) { $file = config('filer.hash_routes') ? static::whereHash($id)->first() : static::find($id); if (!$file) { throw (new ModelNotFoundException)->setModel(static::class); } return $file; }
php
{ "resource": "" }
q7541
FileHelper.appendTo
train
public static function appendTo($src, $dest, $newline = false) { // Open the destination. $reader = @fopen($src, "r"); if (false === $reader) { throw new FileNotFoundException($src); } // Open the destination. $writer = @fopen($dest, "a"); if (false ...
php
{ "resource": "" }
q7542
FileHelper.formatSize
train
public static function formatSize($size, $unit = null, $decimals = 2) { // Initialize the units. $units = static::getUnits(); // Find the unit. $index = array_search($unit, $units); if (null !== $unit && false === $index) { throw new IllegalArgumentException("The u...
php
{ "resource": "" }
q7543
FileHelper.getFilenames
train
public static function getFilenames($pathname, $extension = null) { // Check if the directory exists. if (false === file_exists($pathname)) { throw new FileNotFoundException($pathname); } // Initialize the filenames. $filenames = []; // Open the directory. ...
php
{ "resource": "" }
q7544
FileHelper.getSize
train
public static function getSize($filename) { if (false === file_exists($filename)) { throw new FileNotFoundException($filename); } clearstatcache(); return filesize($filename); }
php
{ "resource": "" }
q7545
FileHelper.getUnits
train
public static function getUnits() { return [ self::FILE_SIZE_UNIT_B, self::FILE_SIZE_UNIT_KB, self::FILE_SIZE_UNIT_MB, self::FILE_SIZE_UNIT_GB, self::FILE_SIZE_UNIT_TB, self::FILE_SIZE_UNIT_PB, self::FILE_SIZE_UNIT_EB, ...
php
{ "resource": "" }
q7546
FileHelper.zip
train
public static function zip($source, $destination) { // Check if the filename exists. if (false === file_exists($source)) { throw new FileNotFoundException($source); } // Initialize the ZIP archive. $zip = new ZipArchive(); $zip->open($destination, ZipArchive...
php
{ "resource": "" }
q7547
Address.exists
train
public function exists($customerId, array $addressToCheck) { unset($addressToCheck['email']); if (empty($addressToCheck['company'])) { // company would be cast to an empty string, which does not match NULL in the database unset($addressToCheck['company']); } $...
php
{ "resource": "" }
q7548
QuickSort.quickSort
train
private function quickSort($min, $max) { $i = $min; $j = $max; $pivot = $this->values[$min + ($max - $min) / 2]; while ($i <= $j) { while (true === $this->functor->compare($this->values[$i], $pivot)) { ++$i; } while (true === $this...
php
{ "resource": "" }
q7549
QuickSort.swap
train
private function swap($a, $b) { $value = $this->values[$a]; $this->values[$a] = $this->values[$b]; $this->values[$b] = $value; }
php
{ "resource": "" }
q7550
Crypt_RSA._decodeLength
train
function _decodeLength(&$string) { $length = ord($this->_string_shift($string)); if ($length & 0x80) { // definite length, long form $length&= 0x7F; $temp = $this->_string_shift($string, $length); list(, $length) = unpack('N', substr(str_pad($temp, 4, chr(0)...
php
{ "resource": "" }
q7551
Crypt_RSA._rsaes_pkcs1_v1_5_encrypt
train
function _rsaes_pkcs1_v1_5_encrypt($m) { $mLen = strlen($m); // Length checking if ($mLen > $this->k - 11) { user_error('Message too long'); return false; } // EME-PKCS1-v1_5 encoding $psLen = $this->k - $mLen - 3; $ps...
php
{ "resource": "" }
q7552
Crypt_RSA._rsassa_pkcs1_v1_5_verify
train
function _rsassa_pkcs1_v1_5_verify($m, $s) { // Length checking if (strlen($s) != $this->k) { user_error('Invalid signature'); return false; } // RSA verification $s = $this->_os2ip($s); $m2 = $this->_rsavp1($s); if ($m2...
php
{ "resource": "" }
q7553
CallableReflection.getReflector
train
public function getReflector() { if ($this->isFunction() || $this->isClosure()) { return new \ReflectionFunction($this->getCallable()); } if ($this->isMethod()) { return new \ReflectionMethod($this->getClassName(), $this->getMethodName()); } if ($this-...
php
{ "resource": "" }
q7554
AbstractApi.getCloudInstance
train
public static function getCloudInstance($accessKey, $secretKey, $apiHost, $cloudId) { $config = array( 'accounts' => array( 'default' => array( 'access_key' => $accessKey, 'secret_key' => $secretKey, 'api_host' => $apiHo...
php
{ "resource": "" }
q7555
File_X509._mapInAttributes
train
function _mapInAttributes(&$root, $path, $asn1) { $attributes = &$this->_subArray($root, $path); if (is_array($attributes)) { for ($i = 0; $i < count($attributes); $i++) { $id = $attributes[$i]['type']; /* $value contains the DER encoding of an ASN...
php
{ "resource": "" }
q7556
File_X509._mapOutAttributes
train
function _mapOutAttributes(&$root, $path, $asn1) { $attributes = &$this->_subArray($root, $path); if (is_array($attributes)) { $size = count($attributes); for ($i = 0; $i < $size; $i++) { /* [value] contains the DER encoding of an ASN.1 value ...
php
{ "resource": "" }
q7557
File_X509._mapOutDNs
train
function _mapOutDNs(&$root, $path, $asn1) { $dns = &$this->_subArray($root, $path); if (is_array($dns)) { $size = count($dns); for ($i = 0; $i < $size; $i++) { for ($j = 0; $j < count($dns[$i]); $j++) { $type = $dns[$i][$j]['type']...
php
{ "resource": "" }
q7558
File_X509._decodeIP
train
function _decodeIP($ip) { $ip = base64_decode($ip); list(, $ip) = unpack('N', $ip); return long2ip($ip); }
php
{ "resource": "" }
q7559
File_X509.removeDNProp
train
function removeDNProp($propName) { if (empty($this->dn)) { return; } if (($propName = $this->_translateDNProp($propName)) === false) { return; } $dn = &$this->dn['rdnSequence']; $size = count($dn); for ($i = 0; $i < $size;...
php
{ "resource": "" }
q7560
File_X509.getChain
train
function getChain() { $chain = array($this->currentCert); if (!is_array($this->currentCert) || !isset($this->currentCert['tbsCertificate'])) { return false; } if (empty($this->CAs)) { return $chain; } while (true) { $cur...
php
{ "resource": "" }
q7561
File_X509._removeExtension
train
function _removeExtension($id, $path = null) { $extensions = &$this->_extensions($this->currentCert, $path); if (!is_array($extensions)) { return false; } $result = false; foreach ($extensions as $key => $value) { if ($value['extnId'] == $i...
php
{ "resource": "" }
q7562
CustomerParser.parseEntity
train
public function parseEntity(Customer $entity) { $output = [ $this->encodeInteger($entity->getCustomerNumber(), 9), $this->encodeString($entity->getTitle(), 10), $this->encodeString($entity->getSurname(), 25), $this->encodeString($entity->getFirstname(), 25), ...
php
{ "resource": "" }
q7563
LiteralPatternImpl.matches
train
public function matches(Node $toMatch) { if ($toMatch->isConcrete()) { if ($toMatch instanceof Literal) { return $this->getValue() === $toMatch->getValue() && $this->getDatatype() === $toMatch->getDatatype() && $this->getLanguage() === $toM...
php
{ "resource": "" }
q7564
NotifierManager.createOrchestraDriver
train
protected function createOrchestraDriver(): Notification { $mailer = $this->app->make('orchestra.mail'); $notifier = new Handlers\Orchestra($mailer); if ($mailer->attached()) { $notifier->attach($mailer->getMemoryProvider()); } else { $notifier->attach($this-...
php
{ "resource": "" }
q7565
Customer.getCustomFields
train
public function getCustomFields($object) { $customFields = []; foreach ($object->getCustomFields() as $field) { $customFields[$field->getInternalFieldName()] = $field->getValue(); } return $customFields; }
php
{ "resource": "" }
q7566
Forwarder.startup
train
public function startup() { /** @var \Shopgate\Base\Helper\Initializer\Forwarder $forwarderInitializer */ $manager = ObjectManager::getInstance(); $forwarderInitializer = $manager->get('Shopgate\Base\Helper\Initializer\Forwarder'); $this->config = $forwarderIniti...
php
{ "resource": "" }
q7567
AbstractMappingCompilerPass.addEntityMapping
train
protected function addEntityMapping( ContainerBuilder $container, $entityManagerName, $entityNamespace, $entityMappingFilePath, $enable = true ) : self { $entityMapping = $this->resolveEntityMapping( $container, $entityManagerName, ...
php
{ "resource": "" }
q7568
AbstractMappingCompilerPass.resolveEntityMapping
train
private function resolveEntityMapping( ContainerBuilder $container, string $entityManagerName, string $entityNamespace, string $entityMappingFilePath, $enable = true ) : ? EntityMapping { $enableEntityMapping = $this->resolveParameterName( $container, ...
php
{ "resource": "" }
q7569
AbstractMappingCompilerPass.registerLocatorConfigurator
train
private function registerLocatorConfigurator(ContainerBuilder $container) { $locatorConfiguratorId = 'simple_doctrine_mapping.locator_configurator'; if ($container->hasDefinition($locatorConfiguratorId)) { return; } $locatorConfigurator = new Definition('Mmoreram\SimpleD...
php
{ "resource": "" }
q7570
AbstractMappingCompilerPass.registerLocator
train
private function registerLocator( ContainerBuilder $container, EntityMapping $entityMapping ) { /** * Locator. */ $locatorId = 'simple_doctrine_mapping.locator.' . $entityMapping->getUniqueIdentifier(); $locator = new Definition('Mmoreram\SimpleDoctrineMappi...
php
{ "resource": "" }
q7571
AbstractMappingCompilerPass.addDriverInDriverChain
train
private function addDriverInDriverChain( ContainerBuilder $container, EntityMapping $entityMapping ) { $chainDriverDefinition = $container ->getDefinition( 'doctrine.orm.' . $entityMapping->getEntityManagerName() . '_metadata_driver' ); $conta...
php
{ "resource": "" }
q7572
AbstractMappingCompilerPass.addAliases
train
private function addAliases( ContainerBuilder $container, EntityMapping $entityMapping ) { $entityMappingFilePath = $entityMapping->getEntityMappingFilePath(); if (strpos($entityMappingFilePath, '@') === 0) { $bundleName = trim(explode('/', $entityMappingFilePath, 2)[0]);...
php
{ "resource": "" }
q7573
AbstractMappingCompilerPass.resolveEntityManagerName
train
private function resolveEntityManagerName( ContainerBuilder $container, string $entityManagerName ) { if (!$container->has('doctrine.orm.' . $entityManagerName . '_metadata_driver')) { throw new EntityManagerNotFoundException($entityManagerName); } }
php
{ "resource": "" }
q7574
CURLConfiguration.removeHeader
train
public function removeHeader($name) { if (true === array_key_exists($name, $this->headers)) { unset($this->headers[$name]); } }
php
{ "resource": "" }
q7575
File.dimensions
train
public function dimensions() { return $this->_cache(__FUNCTION__, function($file) { /** @type \Transit\File $file */ $dims = null; if (!$file->isImage()) { return $dims; } $data = @getimagesize($file->path()); if ($data ...
php
{ "resource": "" }
q7576
File.exif
train
public function exif(array $fields = array()) { if (!function_exists('exif_read_data')) { return array(); } return $this->_cache(__FUNCTION__, function($file) use ($fields) { /** @type \Transit\File $file */ $exif = array(); $fields = $fields + a...
php
{ "resource": "" }
q7577
File.ext
train
public function ext() { return $this->_cache(__FUNCTION__, function($file) { /** @type \Transit\File $file */ // @version 1.1.1 Removed because of fileinfo bug // return MimeType::getExtFromType($file->type(), true); // @version 1.2.0 Allow support for $_FILES a...
php
{ "resource": "" }
q7578
File.height
train
public function height() { return $this->_cache(__FUNCTION__, function($file) { /** @type \Transit\File $file */ if (!$file->isImage()) { return null; } $height = 0; if ($dims = $file->dimensions()) { $height = $dims[...
php
{ "resource": "" }
q7579
File.move
train
public function move($path, $overwrite = false) { $path = str_replace('\\', '/', $path); if (substr($path, -1) !== '/') { $path .= '/'; } // Don't move to the same folder if (realpath($path) === realpath($this->dir())) { return true; } i...
php
{ "resource": "" }
q7580
File.rename
train
public function rename($name = '', $append = '', $prepend = '', $overwrite = false) { if (is_callable($name)) { $name = call_user_func_array($name, array($this->name(), $this)); } else { $name = $name ?: $this->name(); } // Add boundaries $name = (string)...
php
{ "resource": "" }
q7581
File.reset
train
public function reset($path = '') { clearstatcache(); $this->_cache = array(); if ($path) { $this->_data['name'] = basename($path); $this->_path = $path; } return $this; }
php
{ "resource": "" }
q7582
File.supportsExif
train
public function supportsExif() { return $this->_cache(__FUNCTION__, function($file) { /** @type \Transit\File $file */ if (!$file->isImage()) { return false; } return in_array($file->type(), array('image/jpeg', 'image/tiff')); }); }
php
{ "resource": "" }
q7583
File.width
train
public function width() { return $this->_cache(__FUNCTION__, function($file) { /** @type \Transit\File $file */ if (!$file->isImage()) { return null; } $width = 0; if ($dims = $file->dimensions()) { $width = $dims['wi...
php
{ "resource": "" }
q7584
File.toArray
train
public function toArray() { $data = array( 'basename' => $this->basename(), 'dir' => $this->dir(), 'ext' => $this->ext(), 'name' => $this->name(), 'path' => $this->path(), 'size' => $this->size(), 'type' => $this->type(), ...
php
{ "resource": "" }
q7585
File._cache
train
protected function _cache($key, Closure $callback) { if (isset($this->_cache[$key])) { return $this->_cache[$key]; } // Requires 5.4 // Closure::bind($callback, $this, __CLASS__); $this->_cache[$key] = $callback($this); return $this->_cache[$key]; }
php
{ "resource": "" }
q7586
MimeType.getExtFromType
train
public static function getExtFromType($type, $primary = false) { $exts = array(); foreach (self::$_types as $ext => $mimeType) { $isPrimary = false; if (is_array($mimeType)) { $mimeType = $mimeType[0]; $isPrimary = $mimeType[1]; ...
php
{ "resource": "" }
q7587
MimeType.getTypeFromExt
train
public static function getTypeFromExt($ext) { if (isset(self::$_types[$ext])) { $mime = self::$_types[$ext]; if (is_array($mime)) { $mime = $mime[0]; } return $mime; } throw new InvalidArgumentException(sprintf('Invali...
php
{ "resource": "" }
q7588
MimeType.getApplicationList
train
public static function getApplicationList() { if (self::$_application) { return self::$_application; } self::$_application = self::_getList('application'); return self::$_application; }
php
{ "resource": "" }
q7589
MimeType.getAudioList
train
public static function getAudioList() { if (self::$_audio) { return self::$_audio; } self::$_audio = self::_getList('audio'); return self::$_audio; }
php
{ "resource": "" }
q7590
MimeType.getImageList
train
public static function getImageList() { if (self::$_image) { return self::$_image; } self::$_image = self::_getList('image'); return self::$_image; }
php
{ "resource": "" }
q7591
MimeType.getTextList
train
public static function getTextList() { if (self::$_text) { return self::$_text; } self::$_text = self::_getList('text'); return self::$_text; }
php
{ "resource": "" }
q7592
MimeType.getVideoList
train
public static function getVideoList() { if (self::$_video) { return self::$_video; } self::$_video = self::_getList('video'); return self::$_video; }
php
{ "resource": "" }
q7593
MimeType.getSubTypeList
train
public static function getSubTypeList($type) { if (empty(self::$_subTypes[$type])) { throw new InvalidArgumentException(sprintf('Sub-type %s does not exist', $type)); } $types = array(); foreach (self::$_subTypes[$type] as $ext) { $types[$ext] = self::ge...
php
{ "resource": "" }
q7594
MimeType.isSubType
train
public static function isSubType($subType, $mimeType) { return in_array(self::_findMimeType($mimeType), self::getSubTypeList($subType)); }
php
{ "resource": "" }
q7595
MimeType._getList
train
protected static function _getList($type) { $types = array(); foreach (self::$_types as $ext => $mimeType) { if (is_array($mimeType)) { $mimeType = $mimeType[0]; } if (strpos($mimeType, $type) === 0) { $types[$ext] = $mimeTyp...
php
{ "resource": "" }
q7596
MimeType._findMimeType
train
protected static function _findMimeType($mimeType) { if ($mimeType instanceof File) { $mimeType = $mimeType->type(); } else if (strpos($mimeType, '/') === false) { $mimeType = self::getTypeFromExt($mimeType); } return $mimeType; }
php
{ "resource": "" }
q7597
Quote.setExternalCoupons
train
protected function setExternalCoupons() { $quote = $this->quoteCouponHelper->setCoupon(); $this->quote->loadActive($quote->getEntityId()); }
php
{ "resource": "" }
q7598
Quote.setItems
train
protected function setItems() { foreach ($this->sgBase->getItems() as $item) { if ($item->isSgCoupon()) { continue; } $info = $item->getInternalOrderInfo(); $amountNet = $item->getUnitAmount(); $amountGross = $item->getUni...
php
{ "resource": "" }
q7599
Quote.setCustomer
train
protected function setCustomer() { $this->quoteCustomer->setEntity($this->quote); $this->quoteCustomer->setAddress($this->quote); $this->quoteCustomer->resetGuest($this->quote); }
php
{ "resource": "" }