_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q20100
Server.getSupportedHashAlgorithms
train
protected function getSupportedHashAlgorithms() : string { $supportedAlgorithms = hash_algos(); $algorithms = []; foreach ($supportedAlgorithms as $hashAlgo) { if (false !== strpos($hashAlgo, ',')) {
php
{ "resource": "" }
q20101
Server.getClientChecksum
train
protected function getClientChecksum() { $checksumHeader = $this->getRequest()->header('Upload-Checksum'); if (empty($checksumHeader)) { return ''; } list($checksumAlgorithm, $checksum) = explode(' ', $checksumHeader); $checksum = base64_decode($checksum);
php
{ "resource": "" }
q20102
Server.isExpired
train
protected function isExpired($contents) : bool { $isExpired = empty($contents['expires_at']) || Carbon::parse($contents['expires_at'])->lt(Carbon::now());
php
{ "resource": "" }
q20103
Server.getPathForPartialUpload
train
protected function getPathForPartialUpload(string $key) : string { list($actualKey, /* $partialUploadKey */) = explode(self::PARTIAL_UPLOAD_NAME_SEPARATOR, $key); $path = $this->uploadDir . DIRECTORY_SEPARATOR . $actualKey .
php
{ "resource": "" }
q20104
Server.getPartialsMeta
train
protected function getPartialsMeta(array $partials) : array { $files = []; foreach ($partials as
php
{ "resource": "" }
q20105
Server.handleExpiration
train
public function handleExpiration() : array { $deleted = []; $cacheKeys = $this->cache->keys(); foreach ($cacheKeys as $key) { $fileMeta = $this->cache->get($key, true); if ( ! $this->isExpired($fileMeta)) { continue; } if (...
php
{ "resource": "" }
q20106
Server.verifyUploadSize
train
protected function verifyUploadSize() : bool { $maxUploadSize = $this->getMaxUploadSize(); if ($maxUploadSize > 0
php
{ "resource": "" }
q20107
Server.verifyChecksum
train
protected function verifyChecksum(string $checksum, string $filePath) : bool { // Skip if checksum is empty.
php
{ "resource": "" }
q20108
Config.set
train
public static function set($config = null, bool $force = false) { if ( ! $force && ! empty(self::$config)) { return; } if (is_array($config)) { self::$config
php
{ "resource": "" }
q20109
Config.get
train
public static function get(string $key = null) { self::set(); if (empty($key)) { return self::$config; } $keys = explode('.', $key); $value = self::$config; foreach ($keys as $key) {
php
{ "resource": "" }
q20110
JS.stripComments
train
protected function stripComments() { // PHP only supports $this inside anonymous functions since 5.4 $minifier = $this; $callback = function ($match) use ($minifier) { $count = count($minifier->extracted); $placeholder = '/*'.$count.'*/'; $minifier->extrac...
php
{ "resource": "" }
q20111
Minify.canImportFile
train
protected function canImportFile($path) { $parsed = parse_url($path); if ( // file is elsewhere isset($parsed['host']) || // file responds to queries (may change, or need to bypass cache) isset($parsed['query'])
php
{ "resource": "" }
q20112
MakeEloquentFilter.makeClassName
train
public function makeClassName() { $parts = array_map('studly_case', explode('\\', $this->argument('name'))); $className = array_pop($parts); $ns = count($parts) > 0 ? implode('\\', $parts).'\\' : ''; $fqClass = config('eloquentfilter.namespace', 'App\\ModelFilters\\').$ns.$className...
php
{ "resource": "" }
q20113
ModelFilter.removeEmptyInput
train
public function removeEmptyInput($input) { $filterableInput = []; foreach ($input as $key => $val) { if ($val !== '' && $val !== null) {
php
{ "resource": "" }
q20114
ModelFilter.handle
train
public function handle() { // Filter global methods if (method_exists($this, 'setup')) { $this->setup(); } // Run input filters $this->filterInput();
php
{ "resource": "" }
q20115
ModelFilter.related
train
public function related($relation, $column, $operator = null, $value = null, $boolean = 'and') { if ($column instanceof \Closure) { return $this->addRelated($relation, $column); } // If there is no value it is a where = ? query and we set the appropriate params if ($valu...
php
{ "resource": "" }
q20116
ModelFilter.filterInput
train
public function filterInput() { foreach ($this->input as $key => $val) { // Call all local methods on filter
php
{ "resource": "" }
q20117
ModelFilter.getAllRelations
train
public function getAllRelations() { if (count($this->allRelations) === 0) { $allRelations = array_merge(array_keys($this->relations), array_keys($this->localRelatedFilters)); foreach ($allRelations as $related) { $this->allRelations[$related] =
php
{ "resource": "" }
q20118
ModelFilter.filterJoinedRelation
train
public function filterJoinedRelation($related) { // Apply any relation based scope to avoid method duplication $this->callRelatedLocalSetup($related, $this->query); foreach ($this->getLocalRelation($related) as $closure) { // If a relation is defined locally in a method AND is j...
php
{ "resource": "" }
q20119
ModelFilter.getJoinedTables
train
public function getJoinedTables() { $joins = []; if (is_array($queryJoins = $this->query->getQuery()->joins)) {
php
{ "resource": "" }
q20120
ModelFilter.relationIsJoined
train
public function relationIsJoined($relation) { if ($this->_joinedTables === null) { $this->_joinedTables = $this->getJoinedTables(); }
php
{ "resource": "" }
q20121
ModelFilter.filterUnjoinedRelation
train
public function filterUnjoinedRelation($related) { $this->query->whereHas($related, function ($q) use ($related) { $this->callRelatedLocalSetup($related, $q); // If we defined it locally then we're running the closure on the related model here right. foreach ($this->getL...
php
{ "resource": "" }
q20122
ModelFilter.getRelatedFilterInput
train
public function getRelatedFilterInput($related) { return array_key_exists($related, $this->relations) ?
php
{ "resource": "" }
q20123
ModelFilter.input
train
public function input($key = null, $default = null) { if ($key === null) {
php
{ "resource": "" }
q20124
ModelFilter.dropIdSuffix
train
public function dropIdSuffix($bool = null) { if ($bool === null) { return $this->drop_id;
php
{ "resource": "" }
q20125
ModelFilter.convertToCamelCasedMethods
train
public function convertToCamelCasedMethods($bool = null) { if ($bool === null) { return $this->camel_cased_methods;
php
{ "resource": "" }
q20126
ModelFilter.whitelistMethod
train
public function whitelistMethod($method) { $this->blacklist = array_filter($this->blacklist, function
php
{ "resource": "" }
q20127
ModelFilter.methodIsCallable
train
public function methodIsCallable($method) { return ! $this->methodIsBlacklisted($method) &&
php
{ "resource": "" }
q20128
ModelFilter.registerMacros
train
private function registerMacros() { if ( method_exists(Relation::class, 'hasMacro') && method_exists(Relation::class, 'macro') && ! Relation::hasMacro('paginateFilter') && ! Relation::hasMacro('simplePaginateFilter') ) { Relation::macro('pa...
php
{ "resource": "" }
q20129
Filterable.scopeFilter
train
public function scopeFilter($query, array $input = [], $filter = null) { // Resolve the current Model's filter if ($filter === null) { $filter = $this->getModelFilterClass(); } // Create the model filter instance $modelFilter = new $filter($query, $input);
php
{ "resource": "" }
q20130
Filterable.provideFilter
train
public function provideFilter($filter = null) { if ($filter === null) { $filter = config('eloquentfilter.namespace',
php
{ "resource": "" }
q20131
ProjectStatistics.total
train
public function total() : array { $stats = $this->generate(); return [ 'Total', $stats->sum('number_of_classes'), $stats->sum('methods'), round($stats->avg('methods_per_class'), 2),
php
{ "resource": "" }
q20132
ProjectStatistics.generate
train
private function generate() : Collection { if (! $this->cache) { $this->cache = $this->components ->map(function ($classes, $name) { return (new ComponentStatistics($name, $classes))->toArray(); })
php
{ "resource": "" }
q20133
ComponentStatistics.getLines
train
public function getLines() : int { return $this->classes ->map(function ($class) { return $class->getFileName(); }) ->pipe(function ($classes) {
php
{ "resource": "" }
q20134
ComponentStatistics.getLinesOfCode
train
public function getLinesOfCode() : float { return $this->classes ->map(function ($class) { return $class->getFileName(); }) ->pipe(function ($classes) {
php
{ "resource": "" }
q20135
ComponentStatistics.toArray
train
public function toArray() : array { return [ 'component' => $this->name, 'number_of_classes' => $this->getNumberOfClasses(), 'methods' => $this->getNumberOfMethods(), 'methods_per_class' => $this->getNumberOfMethodsPerClass(), 'li...
php
{ "resource": "" }
q20136
ComponentFinder.get
train
public function get() { return $this->findAndLoadClasses() ->map(function ($class) { return new ReflectionClass($class); }) ->reject(function ($class) { return $this->rejectionStrategy->shouldClassBeRejected($class); }) ...
php
{ "resource": "" }
q20137
ComponentFinder.findFilesInProjectPath
train
protected function findFilesInProjectPath() : Collection { $excludes = collect(config('stats.exclude', [])); $files = (new Finder)->files() ->in(config('stats.paths', [])) ->name('*.php'); return
php
{ "resource": "" }
q20138
ComponentFinder.isExcluded
train
protected function isExcluded(SplFileInfo $file, Collection $excludes) { return $excludes->contains(function ($exclude)
php
{ "resource": "" }
q20139
Classifier.classify
train
public function classify(ReflectionClass $class) { $mergedClassifiers = array_merge( self::DEFAULT_CLASSIFIER, config('stats.custom_component_classifier', []) ); foreach ($mergedClassifiers as $classifier) { $c = new $classifier(); if (! $thi...
php
{ "resource": "" }
q20140
ReflectionClass.getDefinedMethods
train
public function getDefinedMethods() : Collection { return collect($this->getMethods())
php
{ "resource": "" }
q20141
Vouchers.generate
train
public function generate(int $amount = 1): array { $codes = []; for ($i = 1; $i <= $amount; $i++) {
php
{ "resource": "" }
q20142
AsYouTypeFormatter.getMetadataForRegion
train
private function getMetadataForRegion($regionCode) { $countryCallingCode = $this->phoneUtil->getCountryCodeForRegion($regionCode); $mainCountry = $this->phoneUtil->getRegionCodeForCountryCode($countryCallingCode); $metadata = $this->phoneUtil->getMetadataForRegion($mainCountry); if (...
php
{ "resource": "" }
q20143
AsYouTypeFormatter.maybeCreateNewTemplate
train
private function maybeCreateNewTemplate() { // When there are multiple available formats, the formatter uses the first format where a // formatting template could be created. foreach ($this->possibleFormats as $key => $numberFormat) { $pattern = $numberFormat->getPattern(); ...
php
{ "resource": "" }
q20144
AsYouTypeFormatter.getFormattingTemplate
train
private function getFormattingTemplate($numberPattern, $numberFormat) { // Creates a phone number consisting only of the digit 9 that matches the // numberPattern by applying the pattern to the longestPhoneNumber string. $longestPhoneNumber = '999999999999999'; $m = new Matcher($numb...
php
{ "resource": "" }
q20145
AsYouTypeFormatter.clear
train
public function clear() { $this->currentOutput = ''; $this->accruedInput = ''; $this->accruedInputWithoutFormatting = ''; $this->formattingTemplate = ''; $this->lastMatchPosition = 0; $this->currentFormattingPattern = ''; $this->prefixBeforeNationalNumber = ''...
php
{ "resource": "" }
q20146
AsYouTypeFormatter.inputDigit
train
public function inputDigit($nextChar) { $this->currentOutput
php
{ "resource": "" }
q20147
AsYouTypeFormatter.ableToExtractLongerNdd
train
private function ableToExtractLongerNdd() { if (mb_strlen($this->extractedNationalPrefix) > 0) { // Put the extracted NDD back to the national number before attempting to extract a new NDD. $this->nationalNumber = $this->extractedNationalPrefix . $this->nationalNumber; //...
php
{ "resource": "" }
q20148
AsYouTypeFormatter.attemptToFormatAccruedDigits
train
public function attemptToFormatAccruedDigits() { foreach ($this->possibleFormats as $numberFormat) { $m = new Matcher($numberFormat->getPattern(), $this->nationalNumber); if ($m->matches()) { $nationalPrefixSeparatorsMatcher = new Matcher(self::$nationalPrefixSeparato...
php
{ "resource": "" }
q20149
AsYouTypeFormatter.attemptToChooseFormattingPattern
train
private function attemptToChooseFormattingPattern() { // We start to attempt to format only when at least MIN_LEADING_DIGITS_LENGTH digits of national // number (excluding national prefix) have been entered. if (mb_strlen($this->nationalNumber) >= self::$minLeadingDigitsLength) { ...
php
{ "resource": "" }
q20150
AsYouTypeFormatter.inputAccruedNationalNumber
train
private function inputAccruedNationalNumber() { $lengthOfNationalNumber = mb_strlen($this->nationalNumber); if ($lengthOfNationalNumber > 0) { $tempNationalNumber = ''; for ($i = 0; $i < $lengthOfNationalNumber; $i++) { $tempNationalNumber = $this->inputDigitH...
php
{ "resource": "" }
q20151
AsYouTypeFormatter.isNanpaNumberWithNationalPrefix
train
private function isNanpaNumberWithNationalPrefix() { // For NANPA numbers beginning with 1[2-9], treat the 1 as the national prefix. The reason is // that national significant numbers in NANPA always start with [2-9] after the national prefix. // Numbers beginning with 1[01] can only be shor...
php
{ "resource": "" }
q20152
AsYouTypeFormatter.removeNationalPrefixFromNationalNumber
train
private function removeNationalPrefixFromNationalNumber() { $startOfNationalNumber = 0; if ($this->isNanpaNumberWithNationalPrefix()) { $startOfNationalNumber = 1; $this->prefixBeforeNationalNumber .= '1' . self::$seperatorBeforeNationalNumber; $this->isCompleteNu...
php
{ "resource": "" }
q20153
PhoneNumberUtil.normalizeHelper
train
protected static function normalizeHelper($number, array $normalizationReplacements, $removeNonMatches) { $normalizedNumber = ''; $strLength = mb_strlen($number, 'UTF-8'); for ($i = 0; $i < $strLength; $i++) { $character = mb_substr($number, $i, 1, 'UTF-8'); if (isset...
php
{ "resource": "" }
q20154
PhoneNumberUtil.formattingRuleHasFirstGroupOnly
train
public static function formattingRuleHasFirstGroupOnly($nationalPrefixFormattingRule) { $firstGroupOnlyPrefixPatternMatcher = new Matcher(static::FIRST_GROUP_ONLY_PREFIX_PATTERN, $nationalPrefixFormattingRule);
php
{ "resource": "" }
q20155
PhoneNumberUtil.getSupportedTypesForMetadata
train
private function getSupportedTypesForMetadata(PhoneMetadata $metadata) { $types = array(); foreach (array_keys(PhoneNumberType::values()) as $type) { if ($type === PhoneNumberType::FIXED_LINE_OR_MOBILE || $type === PhoneNumberType::UNKNOWN) {
php
{ "resource": "" }
q20156
PhoneNumberUtil.getNationalSignificantNumber
train
public function getNationalSignificantNumber(PhoneNumber $number) { // If leading zero(s) have been set, we prefix this now. Note this is not a national prefix. $nationalNumber = ''; if ($number->isItalianLeadingZero() && $number->getNumberOfLeadingZeros() > 0) {
php
{ "resource": "" }
q20157
PhoneNumberUtil.getNumberType
train
public function getNumberType(PhoneNumber $number) { $regionCode = $this->getRegionCodeForNumber($number); $metadata = $this->getMetadataForRegionOrCallingCode($number->getCountryCode(), $regionCode); if ($metadata === null) { return PhoneNumberType::UNKNOWN;
php
{ "resource": "" }
q20158
PhoneNumberUtil.format
train
public function format(PhoneNumber $number, $numberFormat) { if ($number->getNationalNumber() == 0 && $number->hasRawInput()) { // Unparseable numbers that kept their raw input just use that. // This is the only case where a number can be formatted as E164 without a // le...
php
{ "resource": "" }
q20159
PhoneNumberUtil.prefixNumberWithCountryCallingCode
train
protected function prefixNumberWithCountryCallingCode($countryCallingCode, $numberFormat, &$formattedNumber) { switch ($numberFormat) { case PhoneNumberFormat::E164: $formattedNumber = static::PLUS_SIGN . $countryCallingCode . $formattedNumber; return; ...
php
{ "resource": "" }
q20160
PhoneNumberUtil.formatNsnUsingPattern
train
public function formatNsnUsingPattern( $nationalNumber, NumberFormat $formattingPattern, $numberFormat, $carrierCode = null ) { $numberFormatRule = $formattingPattern->getFormat(); $m = new Matcher($formattingPattern->getPattern(), $nationalNumber); if ($numbe...
php
{ "resource": "" }
q20161
PhoneNumberUtil.maybeAppendFormattedExtension
train
protected function maybeAppendFormattedExtension(PhoneNumber $number, $metadata, $numberFormat, &$formattedNumber) { if ($number->hasExtension() && mb_strlen($number->getExtension()) > 0) { if ($numberFormat === PhoneNumberFormat::RFC3966) { $formattedNumber .= static::RFC3966_EX...
php
{ "resource": "" }
q20162
PhoneNumberUtil.getCountryMobileToken
train
public static function getCountryMobileToken($countryCallingCode) { if (count(static::$MOBILE_TOKEN_MAPPINGS) === 0) { static::initMobileTokenMappings(); }
php
{ "resource": "" }
q20163
PhoneNumberUtil.isViablePhoneNumber
train
public static function isViablePhoneNumber($number) { if (static::$VALID_PHONE_NUMBER_PATTERN === null) { static::initValidPhoneNumberPatterns(); } if (mb_strlen($number) < static::MIN_LENGTH_FOR_NSN) { return false;
php
{ "resource": "" }
q20164
PhoneNumberUtil.setItalianLeadingZerosForPhoneNumber
train
public static function setItalianLeadingZerosForPhoneNumber($nationalNumber, PhoneNumber $phoneNumber) { if (strlen($nationalNumber) > 1 && substr($nationalNumber, 0, 1) == '0') { $phoneNumber->setItalianLeadingZero(true); $numberOfLeadingZeros = 1; // Note that if the na...
php
{ "resource": "" }
q20165
PhoneNumberUtil.buildNationalNumberForParsing
train
protected function buildNationalNumberForParsing($numberToParse, &$nationalNumber) { $indexOfPhoneContext = strpos($numberToParse, static::RFC3966_PHONE_CONTEXT); if ($indexOfPhoneContext !== false) { $phoneContextStart = $indexOfPhoneContext + mb_strlen(static::RFC3966_PHONE_CONTEXT); ...
php
{ "resource": "" }
q20166
PhoneNumberUtil.checkRegionForParsing
train
protected function checkRegionForParsing($numberToParse, $defaultRegion) { if (!$this->isValidRegionCode($defaultRegion)) { // If the number is null or empty, we can't infer the region.
php
{ "resource": "" }
q20167
PhoneNumberUtil.parsePrefixAsIdd
train
protected function parsePrefixAsIdd($iddPattern, &$number) { $m = new Matcher($iddPattern, $number); if ($m->lookingAt()) { $matchEnd = $m->end(); // Only strip this if the first digit after the match is not a 0, since country calling codes // cannot begin with 0....
php
{ "resource": "" }
q20168
PhoneNumberUtil.extractCountryCode
train
public function extractCountryCode($fullNumber, &$nationalNumber) { if ((mb_strlen($fullNumber) == 0) || ($fullNumber[0] == '0')) { // Country codes do not begin with a '0'. return 0; } $numberLength = mb_strlen($fullNumber); for ($i = 1; $i <= static::MAX_LEN...
php
{ "resource": "" }
q20169
PhoneNumberUtil.getRegionCodesForCountryCode
train
public function getRegionCodesForCountryCode($countryCallingCode) { $regionCodes = isset($this->countryCallingCodeToRegionCodeMap[$countryCallingCode])
php
{ "resource": "" }
q20170
PhoneNumberUtil.getCountryCodeForValidRegion
train
protected function getCountryCodeForValidRegion($regionCode) { $metadata = $this->getMetadataForRegion($regionCode); if ($metadata === null) {
php
{ "resource": "" }
q20171
PhoneNumberUtil.formatOutOfCountryKeepingAlphaChars
train
public function formatOutOfCountryKeepingAlphaChars(PhoneNumber $number, $regionCallingFrom) { $rawInput = $number->getRawInput(); // If there is no raw input, then we can't keep alpha characters because there aren't any. // In this case, we return formatOutOfCountryCallingNumber. if...
php
{ "resource": "" }
q20172
PhoneNumberUtil.formatOutOfCountryCallingNumber
train
public function formatOutOfCountryCallingNumber(PhoneNumber $number, $regionCallingFrom) { if (!$this->isValidRegionCode($regionCallingFrom)) { return $this->format($number, PhoneNumberFormat::INTERNATIONAL); } $countryCallingCode = $number->getCountryCode(); $nationalSig...
php
{ "resource": "" }
q20173
PhoneNumberUtil.rawInputContainsNationalPrefix
train
protected function rawInputContainsNationalPrefix($rawInput, $nationalPrefix, $regionCode) { $normalizedNationalNumber = static::normalizeDigitsOnly($rawInput); if (strpos($normalizedNationalNumber, $nationalPrefix) === 0) { try { // Some Japanese numbers (e.g. 00777123) ...
php
{ "resource": "" }
q20174
PhoneNumberUtil.formatByPattern
train
public function formatByPattern(PhoneNumber $number, $numberFormat, array $userDefinedFormats) { $countryCallingCode = $number->getCountryCode(); $nationalSignificantNumber = $this->getNationalSignificantNumber($number); if (!$this->hasValidCountryCallingCode($countryCallingCode)) { ...
php
{ "resource": "" }
q20175
PhoneNumberUtil.getExampleNumberForType
train
public function getExampleNumberForType($regionCodeOrType, $type = null) { if ($regionCodeOrType !== null && $type === null) { /* * Gets a valid number for the specified number type (it may belong to any country). */ foreach ($this->getSupportedRegions() as ...
php
{ "resource": "" }
q20176
PhoneNumberUtil.getExampleNumberForNonGeoEntity
train
public function getExampleNumberForNonGeoEntity($countryCallingCode) { $metadata = $this->getMetadataForNonGeographicalRegion($countryCallingCode); if ($metadata !== null) { // For geographical entities, fixed-line data is always present. However, for non-geographical // enti...
php
{ "resource": "" }
q20177
PhoneNumberUtil.isNationalNumberSuffixOfTheOther
train
protected function isNationalNumberSuffixOfTheOther(PhoneNumber $firstNumber, PhoneNumber $secondNumber) { $firstNumberNationalNumber = trim((string)$firstNumber->getNationalNumber()); $secondNumberNationalNumber = trim((string)$secondNumber->getNationalNumber());
php
{ "resource": "" }
q20178
PhoneNumberUtil.isMobileNumberPortableRegion
train
public function isMobileNumberPortableRegion($regionCode) { $metadata = $this->getMetadataForRegion($regionCode); if ($metadata === null) {
php
{ "resource": "" }
q20179
PhoneNumberUtil.truncateTooLongNumber
train
public function truncateTooLongNumber(PhoneNumber $number) { if ($this->isValidNumber($number)) { return true; } $numberCopy = new PhoneNumber(); $numberCopy->mergeFrom($number); $nationalNumber = $number->getNationalNumber(); do { $nationalNum...
php
{ "resource": "" }
q20180
PhoneNumberToTimeZonesMapper.getTimeZonesForGeocodableNumber
train
protected function getTimeZonesForGeocodableNumber(PhoneNumber $number) { $timezones = $this->prefixTimeZonesMap->lookupTimeZonesForNumber($number);
php
{ "resource": "" }
q20181
PrefixFileReader.getDescriptionForNumber
train
public function getDescriptionForNumber(PhoneNumber $number, $language, $script, $region) { $phonePrefix = $number->getCountryCode() . PhoneNumberUtil::getInstance()->getNationalSignificantNumber($number); $phonePrefixDescriptions = $this->getPhonePrefixDescriptions($phonePrefix, $language, $script...
php
{ "resource": "" }
q20182
BuildMetadataFromXml.getMetadataFilter
train
public static function getMetadataFilter($liteBuild, $specialBuild) { if ($specialBuild) { if ($liteBuild) { throw new \RuntimeException('liteBuild and specialBuild may not both be set'); } return MetadataFilter::forSpecialBuild();
php
{ "resource": "" }
q20183
BuildMetadataFromXml.getNationalPrefix
train
public static function getNationalPrefix(\DOMElement $element) { return $element->hasAttribute(self::NATIONAL_PREFIX) ?
php
{ "resource": "" }
q20184
BuildMetadataFromXml.loadNationalFormat
train
public static function loadNationalFormat( PhoneMetadata $metadata, \DOMElement $numberFormatElement, NumberFormat $format ) { self::setLeadingDigitsPatterns($numberFormatElement, $format); $format->setPattern(self::validateRE($numberFormatElement->getAttribute(self::PATTERN)...
php
{ "resource": "" }
q20185
BuildMetadataFromXml.loadInternationalFormat
train
public static function loadInternationalFormat( PhoneMetadata $metadata, \DOMElement $numberFormatElement, NumberFormat $nationalFormat ) { $intlFormat = new NumberFormat(); $intlFormatPattern = $numberFormatElement->getElementsByTagName(self::INTL_FORMAT); $hasExplic...
php
{ "resource": "" }
q20186
BuildMetadataFromXml.parsePossibleLengthStringToSet
train
private static function parsePossibleLengthStringToSet($possibleLengthString) { if (strlen($possibleLengthString) === 0) { throw new \RuntimeException('Empty possibleLength string found.'); } $lengths = explode(',', $possibleLengthString); $lengthSet = array(); ...
php
{ "resource": "" }
q20187
BuildMetadataFromXml.setPossibleLengthsGeneralDesc
train
public static function setPossibleLengthsGeneralDesc(PhoneNumberDesc $generalDesc, $metadataId, \DOMElement $data, $isShortNumberMetadata) { $lengths = array(); $localOnlyLengths = array(); // The general description node should *always* be present if metadata for other types is // p...
php
{ "resource": "" }
q20188
BuildMetadataFromXml.setPossibleLengths
train
private static function setPossibleLengths($lengths, $localOnlyLengths, PhoneNumberDesc $parentDesc = null, PhoneNumberDesc $desc) { // We clear these fields since the metadata tends to inherit from the parent element for other // fields (via a mergeFrom). $desc->clearPossibleLength(); ...
php
{ "resource": "" }
q20189
GeneratePhonePrefixData.parseTextFile
train
private function parseTextFile($filePath, \Closure $handler) { if (!file_exists($filePath) || !is_readable($filePath)) { throw new \InvalidArgumentException("File '{$filePath}' does not exist"); } $data = file($filePath); $countryData = array(); foreach ($data ...
php
{ "resource": "" }
q20190
GeneratePhonePrefixData.makeDataFallbackToEnglish
train
private function makeDataFallbackToEnglish($textFile, &$mappings) { $englishPath = $this->getEnglishDataPath($textFile); if ($textFile == $englishPath || !file_exists($this->getFilePath($englishPath))) { return; } $countryCode = substr($textFile, 3, 2); if (!ar...
php
{ "resource": "" }
q20191
GeneratePhonePrefixData.getPhonePrefixLanguagePairFromFilename
train
private function getPhonePrefixLanguagePairFromFilename($outputFile) { $parts = explode(DIRECTORY_SEPARATOR, $outputFile);
php
{ "resource": "" }
q20192
PhoneNumberToCarrierMapper.getNameForValidNumber
train
public function getNameForValidNumber(PhoneNumber $number, $languageCode) { $languageStr = Locale::getPrimaryLanguage($languageCode);
php
{ "resource": "" }
q20193
PhoneNumberToCarrierMapper.isMobile
train
protected function isMobile($numberType) { return ($numberType === PhoneNumberType::MOBILE ||
php
{ "resource": "" }
q20194
ShortNumberInfo.getRegionCodesForCountryCode
train
protected function getRegionCodesForCountryCode($countryCallingCode) { if (!array_key_exists($countryCallingCode, $this->countryCallingCodeToRegionCodeMap)) { $regionCodes = null; } else {
php
{ "resource": "" }
q20195
ShortNumberInfo.regionDialingFromMatchesNumber
train
protected function regionDialingFromMatchesNumber(PhoneNumber $number, $regionDialingFrom) {
php
{ "resource": "" }
q20196
ShortNumberInfo.getExampleShortNumber
train
public function getExampleShortNumber($regionCode) { $phoneMetadata = $this->getMetadataForRegion($regionCode); if ($phoneMetadata === null) { return ''; } /** @var PhoneNumberDesc $desc */
php
{ "resource": "" }
q20197
ShortNumberInfo.getExampleShortNumberForCost
train
public function getExampleShortNumberForCost($regionCode, $cost) { $phoneMetadata = $this->getMetadataForRegion($regionCode); if ($phoneMetadata === null) { return ''; } /** @var PhoneNumberDesc $desc */ $desc = null; switch ($cost) { case Sho...
php
{ "resource": "" }
q20198
ShortNumberInfo.getRegionCodeForShortNumberFromRegionList
train
protected function getRegionCodeForShortNumberFromRegionList(PhoneNumber $number, $regionCodes) { if (count($regionCodes) == 0) { return null; } if (count($regionCodes) == 1) { return $regionCodes[0]; } $nationalNumber = $this->getNationalSignificant...
php
{ "resource": "" }
q20199
ShortNumberInfo.isValidShortNumberForRegion
train
public function isValidShortNumberForRegion(PhoneNumber $number, $regionDialingFrom) { if (!$this->regionDialingFromMatchesNumber($number, $regionDialingFrom)) { return false; } $phoneMetadata = $this->getMetadataForRegion($regionDialingFrom); if ($phoneMetadata === null...
php
{ "resource": "" }