repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
antonioribeiro/countries
src/package/Services/Countries.php
Countries.instantiateHydrator
protected function instantiateHydrator(Hydrator $hydrator = null) { if (is_null($this->hydrator) || ! is_null($hydrator)) { $this->hydrator = ! is_null($hydrator) ? $hydrator : new Hydrator($this->config); } return $this->hydrator; }
php
protected function instantiateHydrator(Hydrator $hydrator = null) { if (is_null($this->hydrator) || ! is_null($hydrator)) { $this->hydrator = ! is_null($hydrator) ? $hydrator : new Hydrator($this->config); } return $this->hydrator; }
[ "protected", "function", "instantiateHydrator", "(", "Hydrator", "$", "hydrator", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "hydrator", ")", "||", "!", "is_null", "(", "$", "hydrator", ")", ")", "{", "$", "this", "->", "hydra...
Instantiate hydrator. @param Hydrator|null $hydrator @return Hydrator
[ "Instantiate", "hydrator", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Countries.php#L228-L237
antonioribeiro/countries
src/update/Countries.php
Countries.update
public function update() { $this->helper->progress('--- Countries'); $dataDir = '/countries/default/'; $this->updater->setCountries($this->cache->remember('updateCountries->buildCountriesCoollection', 160, function () use ($dataDir) { $this->helper->eraseDataDir($dataDir); ...
php
public function update() { $this->helper->progress('--- Countries'); $dataDir = '/countries/default/'; $this->updater->setCountries($this->cache->remember('updateCountries->buildCountriesCoollection', 160, function () use ($dataDir) { $this->helper->eraseDataDir($dataDir); ...
[ "public", "function", "update", "(", ")", "{", "$", "this", "->", "helper", "->", "progress", "(", "'--- Countries'", ")", ";", "$", "dataDir", "=", "'/countries/default/'", ";", "$", "this", "->", "updater", "->", "setCountries", "(", "$", "this", "->", ...
Update countries.
[ "Update", "countries", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Countries.php#L69-L89
antonioribeiro/countries
src/update/Countries.php
Countries.buildCountriesCoollection
public function buildCountriesCoollection($dataDir) { $this->helper->message('Processing countries...'); $mledoze = $this->mledoze->loadMledozeCountries(); $shapeFile = $this->helper->loadShapeFile('third-party/natural_earth/ne_10m_admin_0_countries'); $this->helper->message('Gene...
php
public function buildCountriesCoollection($dataDir) { $this->helper->message('Processing countries...'); $mledoze = $this->mledoze->loadMledozeCountries(); $shapeFile = $this->helper->loadShapeFile('third-party/natural_earth/ne_10m_admin_0_countries'); $this->helper->message('Gene...
[ "public", "function", "buildCountriesCoollection", "(", "$", "dataDir", ")", "{", "$", "this", "->", "helper", "->", "message", "(", "'Processing countries...'", ")", ";", "$", "mledoze", "=", "$", "this", "->", "mledoze", "->", "loadMledozeCountries", "(", ")...
Build countries collection. @param $dataDir @return \PragmaRX\Coollection\Package\Coollection
[ "Build", "countries", "collection", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Countries.php#L97-L149
antonioribeiro/countries
src/update/Rinvex.php
Rinvex.fillRinvexFields
public function fillRinvexFields($natural) { $mergeable = [ 'calling_code' => 'dialling', // 'borders' => 'geo', 'area' => 'geo', 'continent' => 'geo', 'landlocked' => 'geo', 'region' => 'geo', 'region...
php
public function fillRinvexFields($natural) { $mergeable = [ 'calling_code' => 'dialling', // 'borders' => 'geo', 'area' => 'geo', 'continent' => 'geo', 'landlocked' => 'geo', 'region' => 'geo', 'region...
[ "public", "function", "fillRinvexFields", "(", "$", "natural", ")", "{", "$", "mergeable", "=", "[", "'calling_code'", "=>", "'dialling'", ",", "// 'borders' => 'geo',", "'area'", "=>", "'geo'", ",", "'continent'", "=>", "'geo'", ",", "'landlocked'",...
Fill array with Rinvex usable data. @param \PragmaRX\Coollection\Package\Coollection $natural @return \PragmaRX\Coollection\Package\Coollection
[ "Fill", "array", "with", "Rinvex", "usable", "data", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Rinvex.php#L48-L72
antonioribeiro/countries
src/update/Rinvex.php
Rinvex.findRinvexState
public function findRinvexState($country, $needle) { $states = $this->findRinvex($country, 'divisions')->map(function ($state, $postal) { $state['postal'] = $postal; $state['name'] = $this->helper->fixUtf8($state['name']); return $state; }); if ($states...
php
public function findRinvexState($country, $needle) { $states = $this->findRinvex($country, 'divisions')->map(function ($state, $postal) { $state['postal'] = $postal; $state['name'] = $this->helper->fixUtf8($state['name']); return $state; }); if ($states...
[ "public", "function", "findRinvexState", "(", "$", "country", ",", "$", "needle", ")", "{", "$", "states", "=", "$", "this", "->", "findRinvex", "(", "$", "country", ",", "'divisions'", ")", "->", "map", "(", "function", "(", "$", "state", ",", "$", ...
Find the Rinvex state. @param $country @param \PragmaRX\Coollection\Package\Coollection $needle @return null|Coollection
[ "Find", "the", "Rinvex", "state", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Rinvex.php#L113-L142
antonioribeiro/countries
src/update/Rinvex.php
Rinvex.mergeWithRinvex
public function mergeWithRinvex($natural, $rinvex, $translation, $suffix = '_rinvex') { $defaultToRinvex = coollect([ 'currency', 'languages', 'dialling', ]); $merge = coollect([ 'geo', 'translations', 'flag', ]...
php
public function mergeWithRinvex($natural, $rinvex, $translation, $suffix = '_rinvex') { $defaultToRinvex = coollect([ 'currency', 'languages', 'dialling', ]); $merge = coollect([ 'geo', 'translations', 'flag', ]...
[ "public", "function", "mergeWithRinvex", "(", "$", "natural", ",", "$", "rinvex", ",", "$", "translation", ",", "$", "suffix", "=", "'_rinvex'", ")", "{", "$", "defaultToRinvex", "=", "coollect", "(", "[", "'currency'", ",", "'languages'", ",", "'dialling'",...
Merge country data with Rinvex data. @param Coollection $natural @param Coollection $rinvex @param $translation @param string $suffix @return mixed|\PragmaRX\Coollection\Package\Coollection
[ "Merge", "country", "data", "with", "Rinvex", "data", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Rinvex.php#L164-L219
antonioribeiro/countries
src/update/Cities.php
Cities.update
public function update() { $this->helper->progress('--- Cities'); $this->helper->eraseDataDir($dataDir = '/cities/default/'); $result = $this->helper->loadShapeFile('third-party/natural_earth/ne_10m_populated_places'); $this->helper->message('Processing cities...'); $norm...
php
public function update() { $this->helper->progress('--- Cities'); $this->helper->eraseDataDir($dataDir = '/cities/default/'); $result = $this->helper->loadShapeFile('third-party/natural_earth/ne_10m_populated_places'); $this->helper->message('Processing cities...'); $norm...
[ "public", "function", "update", "(", ")", "{", "$", "this", "->", "helper", "->", "progress", "(", "'--- Cities'", ")", ";", "$", "this", "->", "helper", "->", "eraseDataDir", "(", "$", "dataDir", "=", "'/cities/default/'", ")", ";", "$", "result", "=", ...
Update cities.
[ "Update", "cities", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Cities.php#L35-L64
antonioribeiro/countries
src/package/Services/Helper.php
Helper.loadJson
public function loadJson($file, $dir = null) { if (empty($file)) { throw new Exception('loadJson Error: File name not set'); } if (! file_exists($file) && ! file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) { return coollect(); } ...
php
public function loadJson($file, $dir = null) { if (empty($file)) { throw new Exception('loadJson Error: File name not set'); } if (! file_exists($file) && ! file_exists($file = $this->dataDir("/$dir/".strtolower($file).'.json'))) { return coollect(); } ...
[ "public", "function", "loadJson", "(", "$", "file", ",", "$", "dir", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "file", ")", ")", "{", "throw", "new", "Exception", "(", "'loadJson Error: File name not set'", ")", ";", "}", "if", "(", "!", "...
Loads a json file. @param $file @param string $dir @return \PragmaRX\Coollection\Package\Coollection @throws Exception
[ "Loads", "a", "json", "file", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Helper.php#L45-L62
antonioribeiro/countries
src/package/Services/Helper.php
Helper.loadJsonFiles
public function loadJsonFiles($dir) { return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) { $key = str_replace('.json', '', str_replace('.json5', '', basename($file))); return [$key => $this->loadJson($file)]; }); }
php
public function loadJsonFiles($dir) { return coollect(glob("$dir/*.json*"))->mapWithKeys(function ($file) { $key = str_replace('.json', '', str_replace('.json5', '', basename($file))); return [$key => $this->loadJson($file)]; }); }
[ "public", "function", "loadJsonFiles", "(", "$", "dir", ")", "{", "return", "coollect", "(", "glob", "(", "\"$dir/*.json*\"", ")", ")", "->", "mapWithKeys", "(", "function", "(", "$", "file", ")", "{", "$", "key", "=", "str_replace", "(", "'.json'", ",",...
Load json files from dir. @param $dir @return \PragmaRX\Coollection\Package\Coollection
[ "Load", "json", "files", "from", "dir", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Helper.php#L70-L77
antonioribeiro/countries
src/package/Services/Helper.php
Helper.moveFilesWildcard
public function moveFilesWildcard($from, $to) { coollect(glob($this->dataDir($from)))->each(function ($from) use ($to) { $this->mkDir($dir = $this->dataDir($to)); rename($from, $dir.'/'.basename($from)); }); }
php
public function moveFilesWildcard($from, $to) { coollect(glob($this->dataDir($from)))->each(function ($from) use ($to) { $this->mkDir($dir = $this->dataDir($to)); rename($from, $dir.'/'.basename($from)); }); }
[ "public", "function", "moveFilesWildcard", "(", "$", "from", ",", "$", "to", ")", "{", "coollect", "(", "glob", "(", "$", "this", "->", "dataDir", "(", "$", "from", ")", ")", ")", "->", "each", "(", "function", "(", "$", "from", ")", "use", "(", ...
Move files using wildcard filter. @param $from @param $to
[ "Move", "files", "using", "wildcard", "filter", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Helper.php#L85-L92
antonioribeiro/countries
src/package/Services/Helper.php
Helper.dataDir
public function dataDir($path = '') { $path = (empty($path) || starts_with($path, DIRECTORY_SEPARATOR)) ? $path : "/{$path}"; return __COUNTRIES_DIR__.$this->toDir("/src/data$path"); }
php
public function dataDir($path = '') { $path = (empty($path) || starts_with($path, DIRECTORY_SEPARATOR)) ? $path : "/{$path}"; return __COUNTRIES_DIR__.$this->toDir("/src/data$path"); }
[ "public", "function", "dataDir", "(", "$", "path", "=", "''", ")", "{", "$", "path", "=", "(", "empty", "(", "$", "path", ")", "||", "starts_with", "(", "$", "path", ",", "DIRECTORY_SEPARATOR", ")", ")", "?", "$", "path", ":", "\"/{$path}\"", ";", ...
Get data directory. @param $path @return string
[ "Get", "data", "directory", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Helper.php#L100-L105
antonioribeiro/countries
src/update/Nationality.php
Nationality.fillMledozeFields
public function fillMledozeFields($fields) { $fields['name_nev'] = $fields['name']; $fields['name'] = [ 'common' => $fields['name'], 'official' => $fields['formal_en'], ]; $fields['cca2'] = $fields['iso_a2'] == '-99' ? $fields['adm0_a3'] : $fields['iso_a2'];...
php
public function fillMledozeFields($fields) { $fields['name_nev'] = $fields['name']; $fields['name'] = [ 'common' => $fields['name'], 'official' => $fields['formal_en'], ]; $fields['cca2'] = $fields['iso_a2'] == '-99' ? $fields['adm0_a3'] : $fields['iso_a2'];...
[ "public", "function", "fillMledozeFields", "(", "$", "fields", ")", "{", "$", "fields", "[", "'name_nev'", "]", "=", "$", "fields", "[", "'name'", "]", ";", "$", "fields", "[", "'name'", "]", "=", "[", "'common'", "=>", "$", "fields", "[", "'name'", ...
Fill mledoze fields with natural earth vector data. @param $fields @return mixed
[ "Fill", "mledoze", "fields", "with", "natural", "earth", "vector", "data", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Nationality.php#L57-L79
antonioribeiro/countries
src/update/Nationality.php
Nationality.findMledozeCountry
public function findMledozeCountry($mledoze, $natural) { list($country, $countryCode) = $this->updater->findCountryByAnyField($mledoze, $natural); if (! $country->isEmpty()) { return [coollect($this->helper->arrayKeysSnakeRecursive($country)), $countryCode]; } return [c...
php
public function findMledozeCountry($mledoze, $natural) { list($country, $countryCode) = $this->updater->findCountryByAnyField($mledoze, $natural); if (! $country->isEmpty()) { return [coollect($this->helper->arrayKeysSnakeRecursive($country)), $countryCode]; } return [c...
[ "public", "function", "findMledozeCountry", "(", "$", "mledoze", ",", "$", "natural", ")", "{", "list", "(", "$", "country", ",", "$", "countryCode", ")", "=", "$", "this", "->", "updater", "->", "findCountryByAnyField", "(", "$", "mledoze", ",", "$", "n...
Find a mledoze country from natural earth vector data. @param Coollection $mledoze @param Coollection $natural @return array
[ "Find", "a", "mledoze", "country", "from", "natural", "earth", "vector", "data", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Nationality.php#L88-L97
antonioribeiro/countries
src/update/Nationality.php
Nationality.mergeWithMledoze
public function mergeWithMledoze($mledoze, $natural, $suffix = '_nev') { if ($mledoze->isEmpty() || $natural->isEmpty()) { return $mledoze->isEmpty() ? $this->fillMledozeFields($natural) : $this->natural->fillNaturalFields($mledoze); } $result = [...
php
public function mergeWithMledoze($mledoze, $natural, $suffix = '_nev') { if ($mledoze->isEmpty() || $natural->isEmpty()) { return $mledoze->isEmpty() ? $this->fillMledozeFields($natural) : $this->natural->fillNaturalFields($mledoze); } $result = [...
[ "public", "function", "mergeWithMledoze", "(", "$", "mledoze", ",", "$", "natural", ",", "$", "suffix", "=", "'_nev'", ")", "{", "if", "(", "$", "mledoze", "->", "isEmpty", "(", ")", "||", "$", "natural", "->", "isEmpty", "(", ")", ")", "{", "return"...
Merge the two countries sources. @param \PragmaRX\Coollection\Package\Coollection $mledoze @param \PragmaRX\Coollection\Package\Coollection $natural @param string $suffix @return mixed
[ "Merge", "the", "two", "countries", "sources", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Nationality.php#L107-L143
antonioribeiro/countries
src/package/Support/Collection.php
Collection.where
public function where($key, $operator, $value = null) { if (func_num_args() == 2) { $value = $operator; $operator = '='; } $countries = method_exists($this, 'where'.ucfirst($key)) ? $this->{'where'.ucfirst($key)}($value) : parent::where($key,...
php
public function where($key, $operator, $value = null) { if (func_num_args() == 2) { $value = $operator; $operator = '='; } $countries = method_exists($this, 'where'.ucfirst($key)) ? $this->{'where'.ucfirst($key)}($value) : parent::where($key,...
[ "public", "function", "where", "(", "$", "key", ",", "$", "operator", ",", "$", "value", "=", "null", ")", "{", "if", "(", "func_num_args", "(", ")", "==", "2", ")", "{", "$", "value", "=", "$", "operator", ";", "$", "operator", "=", "'='", ";", ...
Where on steroids. @param string $key @param mixed $operator @param null $value @return static
[ "Where", "on", "steroids", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Support/Collection.php#L51-L64
antonioribeiro/countries
src/package/Support/Collection.php
Collection.arrayFinder
private function arrayFinder(string $propertyName, $find, Closure $finderClosure) { return $this->filter(function ($data) use ($find, $propertyName, $finderClosure) { try { $attributeValue = $data->{$propertyName}; } catch (\Exception $e) { $attributeV...
php
private function arrayFinder(string $propertyName, $find, Closure $finderClosure) { return $this->filter(function ($data) use ($find, $propertyName, $finderClosure) { try { $attributeValue = $data->{$propertyName}; } catch (\Exception $e) { $attributeV...
[ "private", "function", "arrayFinder", "(", "string", "$", "propertyName", ",", "$", "find", ",", "Closure", "$", "finderClosure", ")", "{", "return", "$", "this", "->", "filter", "(", "function", "(", "$", "data", ")", "use", "(", "$", "find", ",", "$"...
Where for different attributes. @param string $propertyName @param $find @param Closure $finderClosure @return static
[ "Where", "for", "different", "attributes", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Support/Collection.php#L107-L120
antonioribeiro/countries
src/package/Support/Collection.php
Collection._whereKey
private function _whereKey(string $arrayName, $value) { $finderClosure = function ($value, $attributeValue) { return Arr::has($attributeValue, $value); }; return $this->hydrateDefaultElements( $this->arrayFinder($arrayName, $value, $finderClosure) ); }
php
private function _whereKey(string $arrayName, $value) { $finderClosure = function ($value, $attributeValue) { return Arr::has($attributeValue, $value); }; return $this->hydrateDefaultElements( $this->arrayFinder($arrayName, $value, $finderClosure) ); }
[ "private", "function", "_whereKey", "(", "string", "$", "arrayName", ",", "$", "value", ")", "{", "$", "finderClosure", "=", "function", "(", "$", "value", ",", "$", "attributeValue", ")", "{", "return", "Arr", "::", "has", "(", "$", "attributeValue", ",...
Where for keys. @param string $arrayName @param $value @return static
[ "Where", "for", "keys", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Support/Collection.php#L129-L138
antonioribeiro/countries
src/package/Support/Collection.php
Collection._whereAttribute
private function _whereAttribute(string $arrayName, $value) { $finderClosure = function ($value, $attributeValue) { return in_array($value, $attributeValue->toArray()); }; return $this->hydrateDefaultElements( $this->arrayFinder($arrayName, $value, $finderClosure) ...
php
private function _whereAttribute(string $arrayName, $value) { $finderClosure = function ($value, $attributeValue) { return in_array($value, $attributeValue->toArray()); }; return $this->hydrateDefaultElements( $this->arrayFinder($arrayName, $value, $finderClosure) ...
[ "private", "function", "_whereAttribute", "(", "string", "$", "arrayName", ",", "$", "value", ")", "{", "$", "finderClosure", "=", "function", "(", "$", "value", ",", "$", "attributeValue", ")", "{", "return", "in_array", "(", "$", "value", ",", "$", "at...
Where for different attributes. @param string $arrayName @param $value @return static
[ "Where", "for", "different", "attributes", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Support/Collection.php#L147-L156
antonioribeiro/countries
src/package/Services/Cache/Service.php
Service.instantiateManager
public function instantiateManager($config, $manager, $path) { return is_null($manager) ? new NetteManager($config, $path) : $manager; }
php
public function instantiateManager($config, $manager, $path) { return is_null($manager) ? new NetteManager($config, $path) : $manager; }
[ "public", "function", "instantiateManager", "(", "$", "config", ",", "$", "manager", ",", "$", "path", ")", "{", "return", "is_null", "(", "$", "manager", ")", "?", "new", "NetteManager", "(", "$", "config", ",", "$", "path", ")", ":", "$", "manager", ...
Instantiate the cache manager. @param $config @param $manager @param $path @return NetteManager|mixed
[ "Instantiate", "the", "cache", "manager", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Cache/Service.php#L65-L70
antonioribeiro/countries
src/package/Services/Cache/Service.php
Service.set
public function set($key, $value, $ttl = null) { if ($this->enabled()) { return $this->manager->set($key, $value, $ttl); } return $value; }
php
public function set($key, $value, $ttl = null) { if ($this->enabled()) { return $this->manager->set($key, $value, $ttl); } return $value; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ")", "{", "if", "(", "$", "this", "->", "enabled", "(", ")", ")", "{", "return", "$", "this", "->", "manager", "->", "set", "(", "$", "key", ",", "...
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. @param string $key @param mixed $value @param null $ttl @return bool
[ "Persists", "data", "in", "the", "cache", "uniquely", "referenced", "by", "a", "key", "with", "an", "optional", "expiration", "TTL", "time", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Cache/Service.php#L121-L128
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.canHydrate
protected function canHydrate($element, $enabled, $countryCode) { return ($enabled || $this->config->get('hydrate.elements.'.$element)) && ! isset($this->repository->countries[$countryCode]['hydrated'][$element]); }
php
protected function canHydrate($element, $enabled, $countryCode) { return ($enabled || $this->config->get('hydrate.elements.'.$element)) && ! isset($this->repository->countries[$countryCode]['hydrated'][$element]); }
[ "protected", "function", "canHydrate", "(", "$", "element", ",", "$", "enabled", ",", "$", "countryCode", ")", "{", "return", "(", "$", "enabled", "||", "$", "this", "->", "config", "->", "get", "(", "'hydrate.elements.'", ".", "$", "element", ")", ")", ...
Can hydrate? @param $element @param $enabled @param $countryCode @return bool
[ "Can", "hydrate?" ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L64-L68
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateCountries
private function hydrateCountries($countries, $elements = null) { return countriesCollect( $countries->map(function ($country) use ($elements) { return $this->hydrateCountry($country, $elements); }) ); }
php
private function hydrateCountries($countries, $elements = null) { return countriesCollect( $countries->map(function ($country) use ($elements) { return $this->hydrateCountry($country, $elements); }) ); }
[ "private", "function", "hydrateCountries", "(", "$", "countries", ",", "$", "elements", "=", "null", ")", "{", "return", "countriesCollect", "(", "$", "countries", "->", "map", "(", "function", "(", "$", "country", ")", "use", "(", "$", "elements", ")", ...
Hydrate elements of a collection of countries. @param $countries @param $elements @return mixed
[ "Hydrate", "elements", "of", "a", "collection", "of", "countries", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L98-L105
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateCountry
private function hydrateCountry($country, $elements) { $countryCode = $country['cca3']; $this->addCountry($countryCode, $country); foreach ($elements as $element => $enabled) { $this->hydrateCountryElement($countryCode, $element, $enabled); } return $this->getC...
php
private function hydrateCountry($country, $elements) { $countryCode = $country['cca3']; $this->addCountry($countryCode, $country); foreach ($elements as $element => $enabled) { $this->hydrateCountryElement($countryCode, $element, $enabled); } return $this->getC...
[ "private", "function", "hydrateCountry", "(", "$", "country", ",", "$", "elements", ")", "{", "$", "countryCode", "=", "$", "country", "[", "'cca3'", "]", ";", "$", "this", "->", "addCountry", "(", "$", "countryCode", ",", "$", "country", ")", ";", "fo...
Hydrate elements of a country. @param $country @param $elements @return mixed
[ "Hydrate", "elements", "of", "a", "country", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L114-L125
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.loadCities
private function loadCities($country) { return $this->repository->getHelper()->loadJson($country['cca3'], 'cities/default') ->overwrite($this->repository->getHelper()->loadJson($country['cca3'], 'cities/overload')); }
php
private function loadCities($country) { return $this->repository->getHelper()->loadJson($country['cca3'], 'cities/default') ->overwrite($this->repository->getHelper()->loadJson($country['cca3'], 'cities/overload')); }
[ "private", "function", "loadCities", "(", "$", "country", ")", "{", "return", "$", "this", "->", "repository", "->", "getHelper", "(", ")", "->", "loadJson", "(", "$", "country", "[", "'cca3'", "]", ",", "'cities/default'", ")", "->", "overwrite", "(", "...
Load the cities file and merge overloads. @param $country @return mixed
[ "Load", "the", "cities", "file", "and", "merge", "overloads", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L155-L159
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.loadStates
private function loadStates($country) { return $this->repository->getHelper()->loadJson($country['cca3'], 'states/default') ->overwrite($this->repository->getHelper()->loadJson($country['cca3'], 'states/overload')); }
php
private function loadStates($country) { return $this->repository->getHelper()->loadJson($country['cca3'], 'states/default') ->overwrite($this->repository->getHelper()->loadJson($country['cca3'], 'states/overload')); }
[ "private", "function", "loadStates", "(", "$", "country", ")", "{", "return", "$", "this", "->", "repository", "->", "getHelper", "(", ")", "->", "loadJson", "(", "$", "country", "[", "'cca3'", "]", ",", "'states/default'", ")", "->", "overwrite", "(", "...
Load the states file and merge overloads. @param $country @return mixed
[ "Load", "the", "states", "file", "and", "merge", "overloads", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L167-L171
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.loadTaxes
private function loadTaxes($country) { return $this->repository->getHelper()->loadJson($country['cca3'], 'taxes/default') ->overwrite($this->repository->getHelper()->loadJson($country['cca3'], 'taxes/overload')); }
php
private function loadTaxes($country) { return $this->repository->getHelper()->loadJson($country['cca3'], 'taxes/default') ->overwrite($this->repository->getHelper()->loadJson($country['cca3'], 'taxes/overload')); }
[ "private", "function", "loadTaxes", "(", "$", "country", ")", "{", "return", "$", "this", "->", "repository", "->", "getHelper", "(", ")", "->", "loadJson", "(", "$", "country", "[", "'cca3'", "]", ",", "'taxes/default'", ")", "->", "overwrite", "(", "$"...
Load the taxes file and merge overloads. @param $country @return mixed
[ "Load", "the", "taxes", "file", "and", "merge", "overloads", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L179-L183
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.needsHydration
protected function needsHydration($countryCode, $element, $enabled = false) { if (! $this->canHydrate($element, $enabled, $countryCode)) { return false; } return $this->updateHydrated($countryCode, $element); }
php
protected function needsHydration($countryCode, $element, $enabled = false) { if (! $this->canHydrate($element, $enabled, $countryCode)) { return false; } return $this->updateHydrated($countryCode, $element); }
[ "protected", "function", "needsHydration", "(", "$", "countryCode", ",", "$", "element", ",", "$", "enabled", "=", "false", ")", "{", "if", "(", "!", "$", "this", "->", "canHydrate", "(", "$", "element", ",", "$", "enabled", ",", "$", "countryCode", ")...
Check if an element needs hydrated. @param $countryCode @param $element @param bool $enabled @return bool
[ "Check", "if", "an", "element", "needs", "hydrated", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L193-L200
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.getHydrationElements
protected function getHydrationElements($elements) { $elements = ($elements ?: $this->config->get('hydrate.elements')); if (is_string($elements) || is_numeric($elements)) { return [$elements => true]; } return $this->checkHydrationElements($elements); }
php
protected function getHydrationElements($elements) { $elements = ($elements ?: $this->config->get('hydrate.elements')); if (is_string($elements) || is_numeric($elements)) { return [$elements => true]; } return $this->checkHydrationElements($elements); }
[ "protected", "function", "getHydrationElements", "(", "$", "elements", ")", "{", "$", "elements", "=", "(", "$", "elements", "?", ":", "$", "this", "->", "config", "->", "get", "(", "'hydrate.elements'", ")", ")", ";", "if", "(", "is_string", "(", "$", ...
Get hydration elements. @param $elements @return array|string|mixed
[ "Get", "hydration", "elements", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L273-L282
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateFlag
public function hydrateFlag($country) { $country = countriesCollect($country)->overwrite( ['flag' => $this->repository->makeAllFlags($country)] ); return $country; }
php
public function hydrateFlag($country) { $country = countriesCollect($country)->overwrite( ['flag' => $this->repository->makeAllFlags($country)] ); return $country; }
[ "public", "function", "hydrateFlag", "(", "$", "country", ")", "{", "$", "country", "=", "countriesCollect", "(", "$", "country", ")", "->", "overwrite", "(", "[", "'flag'", "=>", "$", "this", "->", "repository", "->", "makeAllFlags", "(", "$", "country", ...
Hydrate flag. @param $country @return mixed
[ "Hydrate", "flag", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L290-L297
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateBorders
public function hydrateBorders($country) { $country['borders'] = isset($country['borders']) ? $country['borders'] = countriesCollect($country['borders'])->map(function ($border) { return $this->repository->call('where', ['cca3', $border])->first(); }) : co...
php
public function hydrateBorders($country) { $country['borders'] = isset($country['borders']) ? $country['borders'] = countriesCollect($country['borders'])->map(function ($border) { return $this->repository->call('where', ['cca3', $border])->first(); }) : co...
[ "public", "function", "hydrateBorders", "(", "$", "country", ")", "{", "$", "country", "[", "'borders'", "]", "=", "isset", "(", "$", "country", "[", "'borders'", "]", ")", "?", "$", "country", "[", "'borders'", "]", "=", "countriesCollect", "(", "$", ...
Hydrate borders. @param $country @return mixed
[ "Hydrate", "borders", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L305-L314
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateTimezonesTimes
public function hydrateTimezonesTimes($country) { $country = $this->hydrateTimezones($country); $country['timezones'] = $country->timezones->map(function ($timezone) { return $timezone->overwrite(['times' => $this->repository->findTimezoneTime($timezone['zone_id'])]); }); ...
php
public function hydrateTimezonesTimes($country) { $country = $this->hydrateTimezones($country); $country['timezones'] = $country->timezones->map(function ($timezone) { return $timezone->overwrite(['times' => $this->repository->findTimezoneTime($timezone['zone_id'])]); }); ...
[ "public", "function", "hydrateTimezonesTimes", "(", "$", "country", ")", "{", "$", "country", "=", "$", "this", "->", "hydrateTimezones", "(", "$", "country", ")", ";", "$", "country", "[", "'timezones'", "]", "=", "$", "country", "->", "timezones", "->", ...
Hydrate all times for a country timezones. @param $country @return mixed
[ "Hydrate", "all", "times", "for", "a", "country", "timezones", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L333-L342
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateCurrencies
public function hydrateCurrencies($country) { $currencies = []; $country = $this->fixCurrencies($country); if (isset($country['currencies'])) { $currencies = countriesCollect($country['currencies'])->mapWithKeys(function ($code) { if ($this->isCurrenciesArray($c...
php
public function hydrateCurrencies($country) { $currencies = []; $country = $this->fixCurrencies($country); if (isset($country['currencies'])) { $currencies = countriesCollect($country['currencies'])->mapWithKeys(function ($code) { if ($this->isCurrenciesArray($c...
[ "public", "function", "hydrateCurrencies", "(", "$", "country", ")", "{", "$", "currencies", "=", "[", "]", ";", "$", "country", "=", "$", "this", "->", "fixCurrencies", "(", "$", "country", ")", ";", "if", "(", "isset", "(", "$", "country", "[", "'c...
Hydrate currencies. @param $country @return mixed
[ "Hydrate", "currencies", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L350-L373
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrate
public function hydrate($target, $elements = null) { $elements = $this->getHydrationElements($elements); if (coollect($elements)->count() === 0) { return $target; } return $this->isCountry($target->toArray()) ? $this->hydrateCountry($target, $elements) ...
php
public function hydrate($target, $elements = null) { $elements = $this->getHydrationElements($elements); if (coollect($elements)->count() === 0) { return $target; } return $this->isCountry($target->toArray()) ? $this->hydrateCountry($target, $elements) ...
[ "public", "function", "hydrate", "(", "$", "target", ",", "$", "elements", "=", "null", ")", "{", "$", "elements", "=", "$", "this", "->", "getHydrationElements", "(", "$", "elements", ")", ";", "if", "(", "coollect", "(", "$", "elements", ")", "->", ...
Hydrate a countries collection with languages. @param \PragmaRX\Coollection\Package\Coollection|array|\stdClass $target @param null $elements @return \PragmaRX\Coollection\Package\Coollection
[ "Hydrate", "a", "countries", "collection", "with", "languages", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L382-L393
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.addCountry
public function addCountry($countryCode, $country) { if (! isset($this->repository->countries[$countryCode])) { $this->repository->countries[$countryCode] = $country; } }
php
public function addCountry($countryCode, $country) { if (! isset($this->repository->countries[$countryCode])) { $this->repository->countries[$countryCode] = $country; } }
[ "public", "function", "addCountry", "(", "$", "countryCode", ",", "$", "country", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "repository", "->", "countries", "[", "$", "countryCode", "]", ")", ")", "{", "$", "this", "->", "repository", ...
Check and create a country in the repository. @param $country @param $countryCode
[ "Check", "and", "create", "a", "country", "in", "the", "repository", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L412-L417
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.hydrateCountryElement
public function hydrateCountryElement($countryCode, $element, $enabled) { if ($this->needsHydration($countryCode, $element, $enabled)) { $this->repository->countries[$countryCode] = $this->{'hydrate'.Str::studly($element)}($this->repository->countries[$countryCode]); } }
php
public function hydrateCountryElement($countryCode, $element, $enabled) { if ($this->needsHydration($countryCode, $element, $enabled)) { $this->repository->countries[$countryCode] = $this->{'hydrate'.Str::studly($element)}($this->repository->countries[$countryCode]); } }
[ "public", "function", "hydrateCountryElement", "(", "$", "countryCode", ",", "$", "element", ",", "$", "enabled", ")", "{", "if", "(", "$", "this", "->", "needsHydration", "(", "$", "countryCode", ",", "$", "element", ",", "$", "enabled", ")", ")", "{", ...
Hydrate a country element. @param $countryCode @param $element @param $enabled
[ "Hydrate", "a", "country", "element", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L426-L431
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.checkHydrationElements
protected function checkHydrationElements($elements) { $elements = countriesCollect($elements)->mapWithKeys(function ($value, $key) { if (is_numeric($key)) { $key = $value; $value = true; } return [$key => $value]; })->filter(funct...
php
protected function checkHydrationElements($elements) { $elements = countriesCollect($elements)->mapWithKeys(function ($value, $key) { if (is_numeric($key)) { $key = $value; $value = true; } return [$key => $value]; })->filter(funct...
[ "protected", "function", "checkHydrationElements", "(", "$", "elements", ")", "{", "$", "elements", "=", "countriesCollect", "(", "$", "elements", ")", "->", "mapWithKeys", "(", "function", "(", "$", "value", ",", "$", "key", ")", "{", "if", "(", "is_numer...
Check hydration elements. @param $elements @return static
[ "Check", "hydration", "elements", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L439-L453
antonioribeiro/countries
src/package/Services/Hydrator.php
Hydrator.updateHydrated
protected function updateHydrated($countryCode, $element) { $hydrated = $this->createHydrated($countryCode); $hydrated[$element] = true; $this->repository->countries[$countryCode]['hydrated'] = $hydrated; return true; }
php
protected function updateHydrated($countryCode, $element) { $hydrated = $this->createHydrated($countryCode); $hydrated[$element] = true; $this->repository->countries[$countryCode]['hydrated'] = $hydrated; return true; }
[ "protected", "function", "updateHydrated", "(", "$", "countryCode", ",", "$", "element", ")", "{", "$", "hydrated", "=", "$", "this", "->", "createHydrated", "(", "$", "countryCode", ")", ";", "$", "hydrated", "[", "$", "element", "]", "=", "true", ";", ...
Update hydrated. @param $countryCode @param $element @return bool
[ "Update", "hydrated", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Hydrator.php#L472-L481
antonioribeiro/countries
src/package/Services/Cache/Managers/Nette.php
Nette.getCacheDir
public function getCacheDir() { if (is_null($this->dir)) { $this->dir = $this->config->cache->directory ?: sys_get_temp_dir().'/__PRAGMARX_COUNTRIES__/cache'; if (! file_exists($this->dir)) { mkdir($this->dir, 0755, true); } } return $thi...
php
public function getCacheDir() { if (is_null($this->dir)) { $this->dir = $this->config->cache->directory ?: sys_get_temp_dir().'/__PRAGMARX_COUNTRIES__/cache'; if (! file_exists($this->dir)) { mkdir($this->dir, 0755, true); } } return $thi...
[ "public", "function", "getCacheDir", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "dir", ")", ")", "{", "$", "this", "->", "dir", "=", "$", "this", "->", "config", "->", "cache", "->", "directory", "?", ":", "sys_get_temp_dir", "(", ...
Get the cache directory. @return mixed|string|static
[ "Get", "the", "cache", "directory", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Cache/Managers/Nette.php#L63-L74
antonioribeiro/countries
src/package/Services/Cache/Managers/Nette.php
Nette.set
public function set($key, $value, $ttl = null) { if ($this->enabled()) { return $this->cache->save($key, $value, [NetteCache::EXPIRE => $this->makeExpiration($ttl)]); } return $value; }
php
public function set($key, $value, $ttl = null) { if ($this->enabled()) { return $this->cache->save($key, $value, [NetteCache::EXPIRE => $this->makeExpiration($ttl)]); } return $value; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "null", ")", "{", "if", "(", "$", "this", "->", "enabled", "(", ")", ")", "{", "return", "$", "this", "->", "cache", "->", "save", "(", "$", "key", ",", "$...
Persists data in the cache, uniquely referenced by a key with an optional expiration TTL time. @param string $key @param mixed $value @param null $ttl @return bool
[ "Persists", "data", "in", "the", "cache", "uniquely", "referenced", "by", "a", "key", "with", "an", "optional", "expiration", "TTL", "time", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Cache/Managers/Nette.php#L124-L131
antonioribeiro/countries
src/package/Services/Cache/Managers/Nette.php
Nette.getMultiple
public function getMultiple($keys, $default = null) { return coollect($keys)->map(function ($key) { return $this->get($key); }); }
php
public function getMultiple($keys, $default = null) { return coollect($keys)->map(function ($key) { return $this->get($key); }); }
[ "public", "function", "getMultiple", "(", "$", "keys", ",", "$", "default", "=", "null", ")", "{", "return", "coollect", "(", "$", "keys", ")", "->", "map", "(", "function", "(", "$", "key", ")", "{", "return", "$", "this", "->", "get", "(", "$", ...
Obtains multiple cache items by their unique keys. @param $keys @param null $default @return array
[ "Obtains", "multiple", "cache", "items", "by", "their", "unique", "keys", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Cache/Managers/Nette.php#L159-L164
antonioribeiro/countries
src/package/Services/Cache/Managers/Nette.php
Nette.setMultiple
public function setMultiple($values, $ttl = null) { return coollect($values)->map(function ($value, $key) use ($ttl) { return $this->set($key, $value, $ttl); }); }
php
public function setMultiple($values, $ttl = null) { return coollect($values)->map(function ($value, $key) use ($ttl) { return $this->set($key, $value, $ttl); }); }
[ "public", "function", "setMultiple", "(", "$", "values", ",", "$", "ttl", "=", "null", ")", "{", "return", "coollect", "(", "$", "values", ")", "->", "map", "(", "function", "(", "$", "value", ",", "$", "key", ")", "use", "(", "$", "ttl", ")", "{...
Persists a set of key => value pairs in the cache, with an optional TTL. @param $values @param null $ttl @return bool
[ "Persists", "a", "set", "of", "key", "=", ">", "value", "pairs", "in", "the", "cache", "with", "an", "optional", "TTL", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Services/Cache/Managers/Nette.php#L173-L178
antonioribeiro/countries
src/update/Updater.php
Updater.update
public function update($command = null) { $this->command = $this->instantiateCommand($command); $this->helper->downloadFiles(); $this->countries->update(); $this->currencies->update(); $this->loadCountries(); $this->states->update(); $this->cities->updat...
php
public function update($command = null) { $this->command = $this->instantiateCommand($command); $this->helper->downloadFiles(); $this->countries->update(); $this->currencies->update(); $this->loadCountries(); $this->states->update(); $this->cities->updat...
[ "public", "function", "update", "(", "$", "command", "=", "null", ")", "{", "$", "this", "->", "command", "=", "$", "this", "->", "instantiateCommand", "(", "$", "command", ")", ";", "$", "this", "->", "helper", "->", "downloadFiles", "(", ")", ";", ...
Update all data. @param $command
[ "Update", "all", "data", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Updater.php#L176-L197
antonioribeiro/countries
src/update/Updater.php
Updater.addDataSource
public function addDataSource($record, $source) { if (arrayable($record)) { $record = $record->toArray(); } if (! isset($record[$field = 'data_sources'])) { $record['data_sources'] = []; } $record['data_sources'][] = $source; return coollect...
php
public function addDataSource($record, $source) { if (arrayable($record)) { $record = $record->toArray(); } if (! isset($record[$field = 'data_sources'])) { $record['data_sources'] = []; } $record['data_sources'][] = $source; return coollect...
[ "public", "function", "addDataSource", "(", "$", "record", ",", "$", "source", ")", "{", "if", "(", "arrayable", "(", "$", "record", ")", ")", "{", "$", "record", "=", "$", "record", "->", "toArray", "(", ")", ";", "}", "if", "(", "!", "isset", "...
Add data sources to collection. @param \PragmaRX\Coollection\Package\Coollection $record @param string $source @return \PragmaRX\Coollection\Package\Coollection
[ "Add", "data", "sources", "to", "collection", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Updater.php#L206-L219
antonioribeiro/countries
src/update/Updater.php
Updater.generateAllJsonFiles
public function generateAllJsonFiles($dir, $makeGroupKeyClosure, $records, $groupKey) { if (! empty($groupKey)) { $records = $records->groupBy($groupKey); } $records->each(function (Coollection $record, $key) use ($dir, $makeGroupKeyClosure) { $this->helper->mkdir(di...
php
public function generateAllJsonFiles($dir, $makeGroupKeyClosure, $records, $groupKey) { if (! empty($groupKey)) { $records = $records->groupBy($groupKey); } $records->each(function (Coollection $record, $key) use ($dir, $makeGroupKeyClosure) { $this->helper->mkdir(di...
[ "public", "function", "generateAllJsonFiles", "(", "$", "dir", ",", "$", "makeGroupKeyClosure", ",", "$", "records", ",", "$", "groupKey", ")", "{", "if", "(", "!", "empty", "(", "$", "groupKey", ")", ")", "{", "$", "records", "=", "$", "records", "->"...
Generate all json files. @param $dir @param Closure|null $makeGroupKeyClosure @param \PragmaRX\Coollection\Package\Coollection $records @param string|null $groupKey
[ "Generate", "all", "json", "files", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Updater.php#L286-L311
antonioribeiro/countries
src/update/Updater.php
Updater.generateJsonFiles
public function generateJsonFiles($data, $dir, $normalizerClosure, $makeGroupKeyClosure, $mergeData, $groupKey = 'cca3') { $this->helper->message('Normalizing data...'); $data = $this->normalizeData($data, $dir, $normalizerClosure); $this->helper->message('Merging data...'); $data...
php
public function generateJsonFiles($data, $dir, $normalizerClosure, $makeGroupKeyClosure, $mergeData, $groupKey = 'cca3') { $this->helper->message('Normalizing data...'); $data = $this->normalizeData($data, $dir, $normalizerClosure); $this->helper->message('Merging data...'); $data...
[ "public", "function", "generateJsonFiles", "(", "$", "data", ",", "$", "dir", ",", "$", "normalizerClosure", ",", "$", "makeGroupKeyClosure", ",", "$", "mergeData", ",", "$", "groupKey", "=", "'cca3'", ")", "{", "$", "this", "->", "helper", "->", "message"...
Generate json files from array. @param $data @param $dir @param Closure $normalizerClosure @param Closure|null $makeGroupKeyClosure @param Closure $mergeData @param string $groupKey @return \PragmaRX\Coollection\Package\Coollection
[ "Generate", "json", "files", "from", "array", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Updater.php#L324-L339
antonioribeiro/countries
src/update/Updater.php
Updater.normalizeStateOrCityData
public function normalizeStateOrCityData($item) { $fields = [ ['cca2', 'iso_a2'], ['name.common', 'admin'], ['name.official', 'admin'], ['adm0_a3', 'adm0_a3'], ]; list(, $countryCode) = $this->findByFields($this->_countries, $item, $fields, 'c...
php
public function normalizeStateOrCityData($item) { $fields = [ ['cca2', 'iso_a2'], ['name.common', 'admin'], ['name.official', 'admin'], ['adm0_a3', 'adm0_a3'], ]; list(, $countryCode) = $this->findByFields($this->_countries, $item, $fields, 'c...
[ "public", "function", "normalizeStateOrCityData", "(", "$", "item", ")", "{", "$", "fields", "=", "[", "[", "'cca2'", ",", "'iso_a2'", "]", ",", "[", "'name.common'", ",", "'admin'", "]", ",", "[", "'name.official'", ",", "'admin'", "]", ",", "[", "'adm0...
Normalize data. @param $item @return mixed
[ "Normalize", "data", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Updater.php#L374-L398
antonioribeiro/countries
src/update/States.php
States.update
public function update() { $this->helper->progress('--- States'); $this->helper->eraseDataDir($dataDir = '/states/default'); $result = $this->helper->loadShapeFile('third-party/natural_earth/ne_10m_admin_1_states_provinces'); $this->helper->message('Processing states...'); ...
php
public function update() { $this->helper->progress('--- States'); $this->helper->eraseDataDir($dataDir = '/states/default'); $result = $this->helper->loadShapeFile('third-party/natural_earth/ne_10m_admin_1_states_provinces'); $this->helper->message('Processing states...'); ...
[ "public", "function", "update", "(", ")", "{", "$", "this", "->", "helper", "->", "progress", "(", "'--- States'", ")", ";", "$", "this", "->", "helper", "->", "eraseDataDir", "(", "$", "dataDir", "=", "'/states/default'", ")", ";", "$", "result", "=", ...
Update states.
[ "Update", "states", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/States.php#L41-L76
antonioribeiro/countries
src/update/States.php
States.makeStatePostalCode
public function makeStatePostalCode($item) { $item = coollect($item); if ($item->iso_3166_2 !== '') { $code = explode('-', $item->iso_3166_2); if (count($code) > 1) { return $code[1]; } } if (! empty(trim($item->postal))) { ...
php
public function makeStatePostalCode($item) { $item = coollect($item); if ($item->iso_3166_2 !== '') { $code = explode('-', $item->iso_3166_2); if (count($code) > 1) { return $code[1]; } } if (! empty(trim($item->postal))) { ...
[ "public", "function", "makeStatePostalCode", "(", "$", "item", ")", "{", "$", "item", "=", "coollect", "(", "$", "item", ")", ";", "if", "(", "$", "item", "->", "iso_3166_2", "!==", "''", ")", "{", "$", "code", "=", "explode", "(", "'-'", ",", "$",...
Get the state postal code. @param $item @return mixed
[ "Get", "the", "state", "postal", "code", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/States.php#L84-L109
antonioribeiro/countries
src/update/Helper.php
Helper.addSuffix
protected function addSuffix($suffix, $string) { if (substr($string, -strlen($suffix)) !== (string) $suffix) { $string .= $suffix; } return $string; }
php
protected function addSuffix($suffix, $string) { if (substr($string, -strlen($suffix)) !== (string) $suffix) { $string .= $suffix; } return $string; }
[ "protected", "function", "addSuffix", "(", "$", "suffix", ",", "$", "string", ")", "{", "if", "(", "substr", "(", "$", "string", ",", "-", "strlen", "(", "$", "suffix", ")", ")", "!==", "(", "string", ")", "$", "suffix", ")", "{", "$", "string", ...
Add suffix to string. @param $suffix @param $string @return mixed
[ "Add", "suffix", "to", "string", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L76-L83
antonioribeiro/countries
src/update/Helper.php
Helper.deleteDirectory
protected function deleteDirectory($dir) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($files as $fileInfo) { $todo = ($fileInfo->i...
php
protected function deleteDirectory($dir) { $files = new RecursiveIteratorIterator( new RecursiveDirectoryIterator($dir, RecursiveDirectoryIterator::SKIP_DOTS), RecursiveIteratorIterator::CHILD_FIRST ); foreach ($files as $fileInfo) { $todo = ($fileInfo->i...
[ "protected", "function", "deleteDirectory", "(", "$", "dir", ")", "{", "$", "files", "=", "new", "RecursiveIteratorIterator", "(", "new", "RecursiveDirectoryIterator", "(", "$", "dir", ",", "RecursiveDirectoryIterator", "::", "SKIP_DOTS", ")", ",", "RecursiveIterato...
Delete a whole directory. @param $dir
[ "Delete", "a", "whole", "directory", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L103-L117
antonioribeiro/countries
src/update/Helper.php
Helper.download
public function download($url, $directory) { coollect((array) $url)->each(function ($url) use ($directory) { $filename = basename($url); $destination = $this->toDir("{$directory}/{$filename}"); $this->message("Downloading to {$destination}"); $this->mkDir($...
php
public function download($url, $directory) { coollect((array) $url)->each(function ($url) use ($directory) { $filename = basename($url); $destination = $this->toDir("{$directory}/{$filename}"); $this->message("Downloading to {$destination}"); $this->mkDir($...
[ "public", "function", "download", "(", "$", "url", ",", "$", "directory", ")", "{", "coollect", "(", "(", "array", ")", "$", "url", ")", "->", "each", "(", "function", "(", "$", "url", ")", "use", "(", "$", "directory", ")", "{", "$", "filename", ...
Download one or more files. @param $url @param $directory
[ "Download", "one", "or", "more", "files", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L159-L172
antonioribeiro/countries
src/update/Helper.php
Helper.delTree
public function delTree($dir) { if (! file_exists($dir)) { return false; } $files = array_diff(scandir($dir), ['.', '..']); $this->deleteAllFiles($dir, $files); return rmdir($dir); }
php
public function delTree($dir) { if (! file_exists($dir)) { return false; } $files = array_diff(scandir($dir), ['.', '..']); $this->deleteAllFiles($dir, $files); return rmdir($dir); }
[ "public", "function", "delTree", "(", "$", "dir", ")", "{", "if", "(", "!", "file_exists", "(", "$", "dir", ")", ")", "{", "return", "false", ";", "}", "$", "files", "=", "array_diff", "(", "scandir", "(", "$", "dir", ")", ",", "[", "'.'", ",", ...
Delete a directory and all its files. @param $dir @return bool
[ "Delete", "a", "directory", "and", "all", "its", "files", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L297-L308
antonioribeiro/countries
src/update/Helper.php
Helper.shapeFile
public function shapeFile($dir) { $shapeRecords = new ShapeFile($dir); $result = []; foreach ($shapeRecords as $record) { if ($record['dbf']['_deleted']) { continue; } $data = $record['dbf']; unset($data['_deleted']); ...
php
public function shapeFile($dir) { $shapeRecords = new ShapeFile($dir); $result = []; foreach ($shapeRecords as $record) { if ($record['dbf']['_deleted']) { continue; } $data = $record['dbf']; unset($data['_deleted']); ...
[ "public", "function", "shapeFile", "(", "$", "dir", ")", "{", "$", "shapeRecords", "=", "new", "ShapeFile", "(", "$", "dir", ")", ";", "$", "result", "=", "[", "]", ";", "foreach", "(", "$", "shapeRecords", "as", "$", "record", ")", "{", "if", "(",...
Load a shapeFile. @param $dir @return \PragmaRX\Coollection\Package\Coollection
[ "Load", "a", "shapeFile", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L316-L343
antonioribeiro/countries
src/update/Helper.php
Helper.arrayKeysSnakeRecursive
public function arrayKeysSnakeRecursive($array) { $result = []; $array = arrayable($array) ? $array->toArray() : $array; array_walk($array, function ($value, $key) use (&$result) { $result[snake_case($key)] = arrayable($value) || is_array($value) ? $this->arrayK...
php
public function arrayKeysSnakeRecursive($array) { $result = []; $array = arrayable($array) ? $array->toArray() : $array; array_walk($array, function ($value, $key) use (&$result) { $result[snake_case($key)] = arrayable($value) || is_array($value) ? $this->arrayK...
[ "public", "function", "arrayKeysSnakeRecursive", "(", "$", "array", ")", "{", "$", "result", "=", "[", "]", ";", "$", "array", "=", "arrayable", "(", "$", "array", ")", "?", "$", "array", "->", "toArray", "(", ")", ":", "$", "array", ";", "array_walk...
Recursively change all array keys case. @param array|\PragmaRX\Coollection\Package\Coollection $array @return \PragmaRX\Coollection\Package\Coollection
[ "Recursively", "change", "all", "array", "keys", "case", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L351-L364
antonioribeiro/countries
src/update/Helper.php
Helper.unzip
public function unzip($file, $path) { if (ends_with($file, '.zip')) { $this->message("Unzipping to {$file}"); $this->unzipFile($file, $path); } }
php
public function unzip($file, $path) { if (ends_with($file, '.zip')) { $this->message("Unzipping to {$file}"); $this->unzipFile($file, $path); } }
[ "public", "function", "unzip", "(", "$", "file", ",", "$", "path", ")", "{", "if", "(", "ends_with", "(", "$", "file", ",", "'.zip'", ")", ")", "{", "$", "this", "->", "message", "(", "\"Unzipping to {$file}\"", ")", ";", "$", "this", "->", "unzipFil...
Unzip a file. @param $file @param $path
[ "Unzip", "a", "file", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L396-L403
antonioribeiro/countries
src/update/Helper.php
Helper.downloadDataFiles
public function downloadDataFiles() { $this->config->get('downloadable')->each(function ($urls, $path) { if (! file_exists($destination = $this->dataDir("third-party/$path"))) { coollect($urls)->each(function ($url) use ($path, $destination) { $this->download(...
php
public function downloadDataFiles() { $this->config->get('downloadable')->each(function ($urls, $path) { if (! file_exists($destination = $this->dataDir("third-party/$path"))) { coollect($urls)->each(function ($url) use ($path, $destination) { $this->download(...
[ "public", "function", "downloadDataFiles", "(", ")", "{", "$", "this", "->", "config", "->", "get", "(", "'downloadable'", ")", "->", "each", "(", "function", "(", "$", "urls", ",", "$", "path", ")", "{", "if", "(", "!", "file_exists", "(", "$", "des...
Download files.
[ "Download", "files", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L419-L432
antonioribeiro/countries
src/update/Helper.php
Helper.loadShapeFile
public function loadShapeFile($file) { $this->progress('Loading shape file...'); if (file_exists($sha = $this->dataDir('tmp/'.sha1($file = $this->dataDir($file))))) { $this->progress('Loaded.'); return $this->loadJson($sha); } $this->progress($file); ...
php
public function loadShapeFile($file) { $this->progress('Loading shape file...'); if (file_exists($sha = $this->dataDir('tmp/'.sha1($file = $this->dataDir($file))))) { $this->progress('Loaded.'); return $this->loadJson($sha); } $this->progress($file); ...
[ "public", "function", "loadShapeFile", "(", "$", "file", ")", "{", "$", "this", "->", "progress", "(", "'Loading shape file...'", ")", ";", "if", "(", "file_exists", "(", "$", "sha", "=", "$", "this", "->", "dataDir", "(", "'tmp/'", ".", "sha1", "(", "...
Load the shape file (DBF) to array. @param string $file @return \PragmaRX\Coollection\Package\Coollection
[ "Load", "the", "shape", "file", "(", "DBF", ")", "to", "array", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L462-L483
antonioribeiro/countries
src/update/Helper.php
Helper.moveDataFile
public function moveDataFile($from, $to) { if (str_contains($from, '*.')) { $this->moveFilesWildcard($from, $to); return; } if (file_exists($from = $this->dataDir($from))) { $this->mkDir(dirname($to = $this->dataDir($to))); rename($from, $to...
php
public function moveDataFile($from, $to) { if (str_contains($from, '*.')) { $this->moveFilesWildcard($from, $to); return; } if (file_exists($from = $this->dataDir($from))) { $this->mkDir(dirname($to = $this->dataDir($to))); rename($from, $to...
[ "public", "function", "moveDataFile", "(", "$", "from", ",", "$", "to", ")", "{", "if", "(", "str_contains", "(", "$", "from", ",", "'*.'", ")", ")", "{", "$", "this", "->", "moveFilesWildcard", "(", "$", "from", ",", "$", "to", ")", ";", "return",...
Move a data file or many using wildcards. @param $from @param $to
[ "Move", "a", "data", "file", "or", "many", "using", "wildcards", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L506-L519
antonioribeiro/countries
src/update/Helper.php
Helper.moveDataFiles
public function moveDataFiles() { $this->config->get('moveable')->each(function ($to, $from) { $this->moveDataFile($from, $to); }); }
php
public function moveDataFiles() { $this->config->get('moveable')->each(function ($to, $from) { $this->moveDataFile($from, $to); }); }
[ "public", "function", "moveDataFiles", "(", ")", "{", "$", "this", "->", "config", "->", "get", "(", "'moveable'", ")", "->", "each", "(", "function", "(", "$", "to", ",", "$", "from", ")", "{", "$", "this", "->", "moveDataFile", "(", "$", "from", ...
Move data files to the proper location.
[ "Move", "data", "files", "to", "the", "proper", "location", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L524-L529
antonioribeiro/countries
src/update/Helper.php
Helper.progress
public function progress($string = '') { if (is_null($this->command)) { dump($string); return; } $this->command->line($string); }
php
public function progress($string = '') { if (is_null($this->command)) { dump($string); return; } $this->command->line($string); }
[ "public", "function", "progress", "(", "$", "string", "=", "''", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "command", ")", ")", "{", "dump", "(", "$", "string", ")", ";", "return", ";", "}", "$", "this", "->", "command", "->", "line...
Show the progress. @param string $string
[ "Show", "the", "progress", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L536-L545
antonioribeiro/countries
src/update/Helper.php
Helper.message
public function message($message, $type = 'line') { if (! is_null($this->command)) { $this->command->{$type}($message); } }
php
public function message($message, $type = 'line') { if (! is_null($this->command)) { $this->command->{$type}($message); } }
[ "public", "function", "message", "(", "$", "message", ",", "$", "type", "=", "'line'", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "command", ")", ")", "{", "$", "this", "->", "command", "->", "{", "$", "type", "}", "(", "$", "...
Display a message in console. @param $message @param string $type
[ "Display", "a", "message", "in", "console", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L553-L558
antonioribeiro/countries
src/update/Helper.php
Helper.loadCsv
public function loadCsv($file, $dir = null) { if (empty($file)) { $this->abort('loadCsv Error: File name not set'); } if (! file_exists($file)) { $file = $this->dataDir($this->addSuffix('.csv', "/$dir/".strtolower($file))); } return coollect($this->c...
php
public function loadCsv($file, $dir = null) { if (empty($file)) { $this->abort('loadCsv Error: File name not set'); } if (! file_exists($file)) { $file = $this->dataDir($this->addSuffix('.csv', "/$dir/".strtolower($file))); } return coollect($this->c...
[ "public", "function", "loadCsv", "(", "$", "file", ",", "$", "dir", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "file", ")", ")", "{", "$", "this", "->", "abort", "(", "'loadCsv Error: File name not set'", ")", ";", "}", "if", "(", "!", "f...
Loads a json file. @param $file @param string $dir @return \PragmaRX\Coollection\Package\Coollection @throws \Exception
[ "Loads", "a", "json", "file", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L579-L590
antonioribeiro/countries
src/update/Helper.php
Helper.makeJsonFileName
public function makeJsonFileName($key, $dir = '') { if (! ends_with($dir, (DIRECTORY_SEPARATOR))) { $dir .= DIRECTORY_SEPARATOR; } return $this->dataDir($this->addSuffix('.json', $this->toDir($dir).strtolower($key))); }
php
public function makeJsonFileName($key, $dir = '') { if (! ends_with($dir, (DIRECTORY_SEPARATOR))) { $dir .= DIRECTORY_SEPARATOR; } return $this->dataDir($this->addSuffix('.json', $this->toDir($dir).strtolower($key))); }
[ "public", "function", "makeJsonFileName", "(", "$", "key", ",", "$", "dir", "=", "''", ")", "{", "if", "(", "!", "ends_with", "(", "$", "dir", ",", "(", "DIRECTORY_SEPARATOR", ")", ")", ")", "{", "$", "dir", ".=", "DIRECTORY_SEPARATOR", ";", "}", "re...
Make state json filename. @param $key @param string $dir @return string
[ "Make", "state", "json", "filename", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L599-L606
antonioribeiro/countries
src/update/Helper.php
Helper.putFile
public function putFile($file, $contents) { $this->mkdir(dirname($file)); file_put_contents($file, $contents); }
php
public function putFile($file, $contents) { $this->mkdir(dirname($file)); file_put_contents($file, $contents); }
[ "public", "function", "putFile", "(", "$", "file", ",", "$", "contents", ")", "{", "$", "this", "->", "mkdir", "(", "dirname", "(", "$", "file", ")", ")", ";", "file_put_contents", "(", "$", "file", ",", "$", "contents", ")", ";", "}" ]
Put contents into a file. @param $file @param $contents
[ "Put", "contents", "into", "a", "file", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L614-L619
antonioribeiro/countries
src/update/Helper.php
Helper.deleteTemporaryFiles
public function deleteTemporaryFiles() { $this->progress('--- Delete temporary files'); $this->config->get('deletable')->each(function ($directory) { if (file_exists($directory = $this->dataDir($directory))) { $this->deleteDirectory($directory); } });...
php
public function deleteTemporaryFiles() { $this->progress('--- Delete temporary files'); $this->config->get('deletable')->each(function ($directory) { if (file_exists($directory = $this->dataDir($directory))) { $this->deleteDirectory($directory); } });...
[ "public", "function", "deleteTemporaryFiles", "(", ")", "{", "$", "this", "->", "progress", "(", "'--- Delete temporary files'", ")", ";", "$", "this", "->", "config", "->", "get", "(", "'deletable'", ")", "->", "each", "(", "function", "(", "$", "directory"...
Delete uneeded data files.
[ "Delete", "uneeded", "data", "files", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/update/Helper.php#L678-L687
antonioribeiro/countries
src/package/Data/Repository.php
Repository.call
public function call($name, $arguments) { if ($value = $this->cache->get($cacheKey = $this->cache->makeKey([$name, $arguments]))) { return $value; } $result = call_user_func_array([$this, $name], $arguments); if ($this->config->get('hydrate.before')) { $resu...
php
public function call($name, $arguments) { if ($value = $this->cache->get($cacheKey = $this->cache->makeKey([$name, $arguments]))) { return $value; } $result = call_user_func_array([$this, $name], $arguments); if ($this->config->get('hydrate.before')) { $resu...
[ "public", "function", "call", "(", "$", "name", ",", "$", "arguments", ")", "{", "if", "(", "$", "value", "=", "$", "this", "->", "cache", "->", "get", "(", "$", "cacheKey", "=", "$", "this", "->", "cache", "->", "makeKey", "(", "[", "$", "name",...
Call a method currencies collection. @param $name @param $arguments @return bool|mixed
[ "Call", "a", "method", "currencies", "collection", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L97-L110
antonioribeiro/countries
src/package/Data/Repository.php
Repository.loadCountries
public function loadCountries() { $this->countriesJson = $this->loadCountriesJson(); $overload = $this->helper->loadJsonFiles($this->helper->dataDir('countries/overload'))->mapWithKeys(function ($country, $code) { return [upper($code) => $country]; }); $this->countriesJ...
php
public function loadCountries() { $this->countriesJson = $this->loadCountriesJson(); $overload = $this->helper->loadJsonFiles($this->helper->dataDir('countries/overload'))->mapWithKeys(function ($country, $code) { return [upper($code) => $country]; }); $this->countriesJ...
[ "public", "function", "loadCountries", "(", ")", "{", "$", "this", "->", "countriesJson", "=", "$", "this", "->", "loadCountriesJson", "(", ")", ";", "$", "overload", "=", "$", "this", "->", "helper", "->", "loadJsonFiles", "(", "$", "this", "->", "helpe...
Load countries. @return \PragmaRX\Coollection\Package\Coollection
[ "Load", "countries", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L146-L157
antonioribeiro/countries
src/package/Data/Repository.php
Repository.loadCountriesJson
public function loadCountriesJson() { $data = $this->helper->loadJson( $fileName = $this->helper->dataDir('countries/default/_all_countries.json') ); if ($data->isEmpty()) { throw new \Exception("Could not load countries from {$fileName}"); } return ...
php
public function loadCountriesJson() { $data = $this->helper->loadJson( $fileName = $this->helper->dataDir('countries/default/_all_countries.json') ); if ($data->isEmpty()) { throw new \Exception("Could not load countries from {$fileName}"); } return ...
[ "public", "function", "loadCountriesJson", "(", ")", "{", "$", "data", "=", "$", "this", "->", "helper", "->", "loadJson", "(", "$", "fileName", "=", "$", "this", "->", "helper", "->", "dataDir", "(", "'countries/default/_all_countries.json'", ")", ")", ";",...
Load countries json file. @return \PragmaRX\Coollection\Package\Coollection @throws \Exception
[ "Load", "countries", "json", "file", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L164-L175
antonioribeiro/countries
src/package/Data/Repository.php
Repository.loadCurrenciesForCountry
public function loadCurrenciesForCountry($code) { $currencies = $this->helper->loadJson( $this->helper->dataDir('currencies/default/'.strtolower($code).'.json') ); return $currencies; }
php
public function loadCurrenciesForCountry($code) { $currencies = $this->helper->loadJson( $this->helper->dataDir('currencies/default/'.strtolower($code).'.json') ); return $currencies; }
[ "public", "function", "loadCurrenciesForCountry", "(", "$", "code", ")", "{", "$", "currencies", "=", "$", "this", "->", "helper", "->", "loadJson", "(", "$", "this", "->", "helper", "->", "dataDir", "(", "'currencies/default/'", ".", "strtolower", "(", "$",...
Load currency json file. @param $code @return string
[ "Load", "currency", "json", "file", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L183-L190
antonioribeiro/countries
src/package/Data/Repository.php
Repository.currencies
public function currencies() { $currencies = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/default'))->mapWithKeys(function ($country, $code) { return [upper($code) => $country]; }); $overload = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/ov...
php
public function currencies() { $currencies = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/default'))->mapWithKeys(function ($country, $code) { return [upper($code) => $country]; }); $overload = $this->helper->loadJsonFiles($this->helper->dataDir('currencies/ov...
[ "public", "function", "currencies", "(", ")", "{", "$", "currencies", "=", "$", "this", "->", "helper", "->", "loadJsonFiles", "(", "$", "this", "->", "helper", "->", "dataDir", "(", "'currencies/default'", ")", ")", "->", "mapWithKeys", "(", "function", "...
Get all currencies. @return \PragmaRX\Coollection\Package\Coollection
[ "Get", "all", "currencies", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L207-L218
antonioribeiro/countries
src/package/Data/Repository.php
Repository.makeAllFlags
public function makeAllFlags($country) { return [ // https://www.flag-sprites.com/ // https://github.com/LeoColomb/flag-sprites 'sprite' => '<span class="flag flag-'.($cca3 = strtolower($country['cca3'])).'"></span>', // https://github.com/lipis/flag-icon-css...
php
public function makeAllFlags($country) { return [ // https://www.flag-sprites.com/ // https://github.com/LeoColomb/flag-sprites 'sprite' => '<span class="flag flag-'.($cca3 = strtolower($country['cca3'])).'"></span>', // https://github.com/lipis/flag-icon-css...
[ "public", "function", "makeAllFlags", "(", "$", "country", ")", "{", "return", "[", "// https://www.flag-sprites.com/", "// https://github.com/LeoColomb/flag-sprites", "'sprite'", "=>", "'<span class=\"flag flag-'", ".", "(", "$", "cca3", "=", "strtolower", "(", "$", "c...
Make flags array for a coutry. @param $country @return array
[ "Make", "flags", "array", "for", "a", "coutry", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L226-L245
antonioribeiro/countries
src/package/Data/Repository.php
Repository.getGeometry
public function getGeometry($country) { return $this->helper->loadFile( $this->helper->dataDir('geo/'.strtolower($country).'.geo.json') ); }
php
public function getGeometry($country) { return $this->helper->loadFile( $this->helper->dataDir('geo/'.strtolower($country).'.geo.json') ); }
[ "public", "function", "getGeometry", "(", "$", "country", ")", "{", "return", "$", "this", "->", "helper", "->", "loadFile", "(", "$", "this", "->", "helper", "->", "dataDir", "(", "'geo/'", ".", "strtolower", "(", "$", "country", ")", ".", "'.geo.json'"...
Get country geometry. @param $country @return string
[ "Get", "country", "geometry", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L277-L282
antonioribeiro/countries
src/package/Data/Repository.php
Repository.getTopology
public function getTopology($country) { return $this->helper->loadFile( $this->helper->dataDir('topo/'.strtolower($country).'.topo.json') ); }
php
public function getTopology($country) { return $this->helper->loadFile( $this->helper->dataDir('topo/'.strtolower($country).'.topo.json') ); }
[ "public", "function", "getTopology", "(", "$", "country", ")", "{", "return", "$", "this", "->", "helper", "->", "loadFile", "(", "$", "this", "->", "helper", "->", "dataDir", "(", "'topo/'", ".", "strtolower", "(", "$", "country", ")", ".", "'.topo.json...
Get country topology. @param $country @return string
[ "Get", "country", "topology", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L290-L295
antonioribeiro/countries
src/package/Data/Repository.php
Repository.findTimezones
public function findTimezones($countryCode) { return $this->helper->loadJson( $this->helper->dataDir('timezones/countries/default/'.strtolower($countryCode).'.json') ); }
php
public function findTimezones($countryCode) { return $this->helper->loadJson( $this->helper->dataDir('timezones/countries/default/'.strtolower($countryCode).'.json') ); }
[ "public", "function", "findTimezones", "(", "$", "countryCode", ")", "{", "return", "$", "this", "->", "helper", "->", "loadJson", "(", "$", "this", "->", "helper", "->", "dataDir", "(", "'timezones/countries/default/'", ".", "strtolower", "(", "$", "countryCo...
Find a country timezone. @param $countryCode @return null
[ "Find", "a", "country", "timezone", "." ]
train
https://github.com/antonioribeiro/countries/blob/45f10dde1b4214f2f4c447ba2f3a2b48c0ff0c4a/src/package/Data/Repository.php#L315-L320
spatie/array-to-xml
src/ArrayToXml.php
ArrayToXml.convertElement
private function convertElement(DOMElement $element, $value) { $sequential = $this->isArrayAllKeySequential($value); if (! is_array($value)) { $value = htmlspecialchars($value); $value = $this->removeControlCharacters($value); $element->nodeValue = $value; ...
php
private function convertElement(DOMElement $element, $value) { $sequential = $this->isArrayAllKeySequential($value); if (! is_array($value)) { $value = htmlspecialchars($value); $value = $this->removeControlCharacters($value); $element->nodeValue = $value; ...
[ "private", "function", "convertElement", "(", "DOMElement", "$", "element", ",", "$", "value", ")", "{", "$", "sequential", "=", "$", "this", "->", "isArrayAllKeySequential", "(", "$", "value", ")", ";", "if", "(", "!", "is_array", "(", "$", "value", ")"...
Parse individual element. @param DOMElement $element @param string|string[] $value
[ "Parse", "individual", "element", "." ]
train
https://github.com/spatie/array-to-xml/blob/e917f0e6208465fbe3810c8abbf8aa7a3dc01365/src/ArrayToXml.php#L96-L131
spatie/array-to-xml
src/ArrayToXml.php
ArrayToXml.addNode
protected function addNode(DOMElement $element, $key, $value) { if ($this->replaceSpacesByUnderScoresInKeyNames) { $key = str_replace(' ', '_', $key); } $child = $this->document->createElement($key); $element->appendChild($child); $this->convertElement($child, $v...
php
protected function addNode(DOMElement $element, $key, $value) { if ($this->replaceSpacesByUnderScoresInKeyNames) { $key = str_replace(' ', '_', $key); } $child = $this->document->createElement($key); $element->appendChild($child); $this->convertElement($child, $v...
[ "protected", "function", "addNode", "(", "DOMElement", "$", "element", ",", "$", "key", ",", "$", "value", ")", "{", "if", "(", "$", "this", "->", "replaceSpacesByUnderScoresInKeyNames", ")", "{", "$", "key", "=", "str_replace", "(", "' '", ",", "'_'", "...
Add node. @param DOMElement $element @param string $key @param string|string[] $value
[ "Add", "node", "." ]
train
https://github.com/spatie/array-to-xml/blob/e917f0e6208465fbe3810c8abbf8aa7a3dc01365/src/ArrayToXml.php#L140-L149
spatie/array-to-xml
src/ArrayToXml.php
ArrayToXml.addCollectionNode
protected function addCollectionNode(DOMElement $element, $value) { if ($element->childNodes->length === 0 && $element->attributes->length === 0) { $this->convertElement($element, $value); return; } $child = $this->document->createElement($element->tagName); ...
php
protected function addCollectionNode(DOMElement $element, $value) { if ($element->childNodes->length === 0 && $element->attributes->length === 0) { $this->convertElement($element, $value); return; } $child = $this->document->createElement($element->tagName); ...
[ "protected", "function", "addCollectionNode", "(", "DOMElement", "$", "element", ",", "$", "value", ")", "{", "if", "(", "$", "element", "->", "childNodes", "->", "length", "===", "0", "&&", "$", "element", "->", "attributes", "->", "length", "===", "0", ...
Add collection node. @param DOMElement $element @param string|string[] $value @internal param string $key
[ "Add", "collection", "node", "." ]
train
https://github.com/spatie/array-to-xml/blob/e917f0e6208465fbe3810c8abbf8aa7a3dc01365/src/ArrayToXml.php#L159-L170
spatie/array-to-xml
src/ArrayToXml.php
ArrayToXml.isArrayAllKeySequential
protected function isArrayAllKeySequential($value) { if (! is_array($value)) { return false; } if (count($value) <= 0) { return true; } return array_unique(array_map('is_int', array_keys($value))) === [true]; }
php
protected function isArrayAllKeySequential($value) { if (! is_array($value)) { return false; } if (count($value) <= 0) { return true; } return array_unique(array_map('is_int', array_keys($value))) === [true]; }
[ "protected", "function", "isArrayAllKeySequential", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "if", "(", "count", "(", "$", "value", ")", "<=", "0", ")", "{", "return", "...
Check if array are all sequential. @param array|string $value @return bool
[ "Check", "if", "array", "are", "all", "sequential", "." ]
train
https://github.com/spatie/array-to-xml/blob/e917f0e6208465fbe3810c8abbf8aa7a3dc01365/src/ArrayToXml.php#L200-L211
spatie/array-to-xml
src/ArrayToXml.php
ArrayToXml.addAttributes
protected function addAttributes($element, $data) { foreach ($data as $attrKey => $attrVal) { $element->setAttribute($attrKey, $attrVal); } }
php
protected function addAttributes($element, $data) { foreach ($data as $attrKey => $attrVal) { $element->setAttribute($attrKey, $attrVal); } }
[ "protected", "function", "addAttributes", "(", "$", "element", ",", "$", "data", ")", "{", "foreach", "(", "$", "data", "as", "$", "attrKey", "=>", "$", "attrVal", ")", "{", "$", "element", "->", "setAttribute", "(", "$", "attrKey", ",", "$", "attrVal"...
Add attributes. @param DOMElement $element @param string[] $data
[ "Add", "attributes", "." ]
train
https://github.com/spatie/array-to-xml/blob/e917f0e6208465fbe3810c8abbf8aa7a3dc01365/src/ArrayToXml.php#L219-L224
spatie/array-to-xml
src/ArrayToXml.php
ArrayToXml.createRootElement
protected function createRootElement($rootElement) { if (is_string($rootElement)) { $rootElementName = $rootElement ?: 'root'; return $this->document->createElement($rootElementName); } $rootElementName = $rootElement['rootElementName'] ?? 'root'; $element ...
php
protected function createRootElement($rootElement) { if (is_string($rootElement)) { $rootElementName = $rootElement ?: 'root'; return $this->document->createElement($rootElementName); } $rootElementName = $rootElement['rootElementName'] ?? 'root'; $element ...
[ "protected", "function", "createRootElement", "(", "$", "rootElement", ")", "{", "if", "(", "is_string", "(", "$", "rootElement", ")", ")", "{", "$", "rootElementName", "=", "$", "rootElement", "?", ":", "'root'", ";", "return", "$", "this", "->", "documen...
Create the root element. @param string|array $rootElement @return DOMElement
[ "Create", "the", "root", "element", "." ]
train
https://github.com/spatie/array-to-xml/blob/e917f0e6208465fbe3810c8abbf8aa7a3dc01365/src/ArrayToXml.php#L232-L253
phpclassic/php-shopify
lib/RecurringApplicationCharge.php
RecurringApplicationCharge.customize
public function customize($dataArray) { $dataArray = $this->wrapData($dataArray); $url = $this->generateUrl($dataArray, 'customize'); return $this->put(array(), $url); }
php
public function customize($dataArray) { $dataArray = $this->wrapData($dataArray); $url = $this->generateUrl($dataArray, 'customize'); return $this->put(array(), $url); }
[ "public", "function", "customize", "(", "$", "dataArray", ")", "{", "$", "dataArray", "=", "$", "this", "->", "wrapData", "(", "$", "dataArray", ")", ";", "$", "url", "=", "$", "this", "->", "generateUrl", "(", "$", "dataArray", ",", "'customize'", ")"...
/* Customize a recurring application charge @param array $data @return array
[ "/", "*", "Customize", "a", "recurring", "application", "charge" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/RecurringApplicationCharge.php#L61-L68
phpclassic/php-shopify
lib/ShopifySDK.php
ShopifySDK.config
public static function config($config) { foreach ($config as $key => $value) { self::$config[$key] = $value; } //Re-set the admin url if shop url is changed if(isset($config['ShopUrl'])) { self::setAdminUrl(); } //If want to keep more wait ti...
php
public static function config($config) { foreach ($config as $key => $value) { self::$config[$key] = $value; } //Re-set the admin url if shop url is changed if(isset($config['ShopUrl'])) { self::setAdminUrl(); } //If want to keep more wait ti...
[ "public", "static", "function", "config", "(", "$", "config", ")", "{", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "self", "::", "$", "config", "[", "$", "key", "]", "=", "$", "value", ";", "}", "//Re-set the adm...
Configure the SDK client @param array $config @return ShopifySDK
[ "Configure", "the", "SDK", "client" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifySDK.php#L286-L303
phpclassic/php-shopify
lib/ShopifySDK.php
ShopifySDK.setAdminUrl
public static function setAdminUrl() { $shopUrl = self::$config['ShopUrl']; //Remove https:// and trailing slash (if provided) $shopUrl = preg_replace('#^https?://|/$#', '', $shopUrl); if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) { $apiKey = se...
php
public static function setAdminUrl() { $shopUrl = self::$config['ShopUrl']; //Remove https:// and trailing slash (if provided) $shopUrl = preg_replace('#^https?://|/$#', '', $shopUrl); if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) { $apiKey = se...
[ "public", "static", "function", "setAdminUrl", "(", ")", "{", "$", "shopUrl", "=", "self", "::", "$", "config", "[", "'ShopUrl'", "]", ";", "//Remove https:// and trailing slash (if provided)", "$", "shopUrl", "=", "preg_replace", "(", "'#^https?://|/$#'", ",", "'...
Set the admin url, based on the configured shop url @return string
[ "Set", "the", "admin", "url", "based", "on", "the", "configured", "shop", "url" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifySDK.php#L310-L328
phpclassic/php-shopify
lib/ShopifySDK.php
ShopifySDK.checkApiCallLimit
public static function checkApiCallLimit($firstCallWait = false) { $timeToWait = 0; if (static::$microtimeOfLastApiCall == null) { if ($firstCallWait) { $timeToWait = static::$timeAllowedForEachApiCall; } } else { $now = microtime(true); ...
php
public static function checkApiCallLimit($firstCallWait = false) { $timeToWait = 0; if (static::$microtimeOfLastApiCall == null) { if ($firstCallWait) { $timeToWait = static::$timeAllowedForEachApiCall; } } else { $now = microtime(true); ...
[ "public", "static", "function", "checkApiCallLimit", "(", "$", "firstCallWait", "=", "false", ")", "{", "$", "timeToWait", "=", "0", ";", "if", "(", "static", "::", "$", "microtimeOfLastApiCall", "==", "null", ")", "{", "if", "(", "$", "firstCallWait", ")"...
Maintain maximum 2 calls per second to the API @see https://help.shopify.com/api/guides/api-call-limit @param bool $firstCallWait Whether to maintain the wait time even if it is the first API call
[ "Maintain", "maximum", "2", "calls", "per", "second", "to", "the", "API" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifySDK.php#L346-L370
phpclassic/php-shopify
lib/CurlRequest.php
CurlRequest.init
protected static function init($url, $httpHeaders = array()) { // Create Curl resource $ch = curl_init(); // Set URL curl_setopt($ch, CURLOPT_URL, $url); //Return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = array(); ...
php
protected static function init($url, $httpHeaders = array()) { // Create Curl resource $ch = curl_init(); // Set URL curl_setopt($ch, CURLOPT_URL, $url); //Return the transfer as a string curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $headers = array(); ...
[ "protected", "static", "function", "init", "(", "$", "url", ",", "$", "httpHeaders", "=", "array", "(", ")", ")", "{", "// Create Curl resource", "$", "ch", "=", "curl_init", "(", ")", ";", "// Set URL", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ...
Initialize the curl resource @param string $url @param array $httpHeaders @return resource
[ "Initialize", "the", "curl", "resource" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/CurlRequest.php#L39-L59
phpclassic/php-shopify
lib/CurlRequest.php
CurlRequest.get
public static function get($url, $httpHeaders = array()) { //Initialize the Curl resource $ch = self::init($url, $httpHeaders); return self::processRequest($ch); }
php
public static function get($url, $httpHeaders = array()) { //Initialize the Curl resource $ch = self::init($url, $httpHeaders); return self::processRequest($ch); }
[ "public", "static", "function", "get", "(", "$", "url", ",", "$", "httpHeaders", "=", "array", "(", ")", ")", "{", "//Initialize the Curl resource", "$", "ch", "=", "self", "::", "init", "(", "$", "url", ",", "$", "httpHeaders", ")", ";", "return", "se...
Implement a GET request and return output @param string $url @param array $httpHeaders @return string
[ "Implement", "a", "GET", "request", "and", "return", "output" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/CurlRequest.php#L69-L75
phpclassic/php-shopify
lib/CurlRequest.php
CurlRequest.put
public static function put($url, $data, $httpHeaders = array()) { $ch = self::init($url, $httpHeaders); //set the request type curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); return self::processRequest($ch); }
php
public static function put($url, $data, $httpHeaders = array()) { $ch = self::init($url, $httpHeaders); //set the request type curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); return self::processRequest($ch); }
[ "public", "static", "function", "put", "(", "$", "url", ",", "$", "data", ",", "$", "httpHeaders", "=", "array", "(", ")", ")", "{", "$", "ch", "=", "self", "::", "init", "(", "$", "url", ",", "$", "httpHeaders", ")", ";", "//set the request type", ...
Implement a PUT request and return output @param string $url @param array $data @param array $httpHeaders @return string
[ "Implement", "a", "PUT", "request", "and", "return", "output" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/CurlRequest.php#L105-L113
phpclassic/php-shopify
lib/CurlRequest.php
CurlRequest.delete
public static function delete($url, $httpHeaders = array()) { $ch = self::init($url, $httpHeaders); //set the request type curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); return self::processRequest($ch); }
php
public static function delete($url, $httpHeaders = array()) { $ch = self::init($url, $httpHeaders); //set the request type curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); return self::processRequest($ch); }
[ "public", "static", "function", "delete", "(", "$", "url", ",", "$", "httpHeaders", "=", "array", "(", ")", ")", "{", "$", "ch", "=", "self", "::", "init", "(", "$", "url", ",", "$", "httpHeaders", ")", ";", "//set the request type", "curl_setopt", "("...
Implement a DELETE request and return output @param string $url @param array $httpHeaders @return string
[ "Implement", "a", "DELETE", "request", "and", "return", "output" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/CurlRequest.php#L123-L130
phpclassic/php-shopify
lib/CurlRequest.php
CurlRequest.processRequest
protected static function processRequest($ch) { # Check for 429 leaky bucket error while(1) { $output = curl_exec($ch); self::$lastHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if(self::$lastHttpCode != 429) { break; } ...
php
protected static function processRequest($ch) { # Check for 429 leaky bucket error while(1) { $output = curl_exec($ch); self::$lastHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); if(self::$lastHttpCode != 429) { break; } ...
[ "protected", "static", "function", "processRequest", "(", "$", "ch", ")", "{", "# Check for 429 leaky bucket error", "while", "(", "1", ")", "{", "$", "output", "=", "curl_exec", "(", "$", "ch", ")", ";", "self", "::", "$", "lastHttpCode", "=", "curl_getinfo...
Execute a request, release the resource and return output @param resource $ch @throws CurlException if curl request is failed with error @return string
[ "Execute", "a", "request", "release", "the", "resource", "and", "return", "output" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/CurlRequest.php#L141-L161
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.generateUrl
public function generateUrl($urlParams = array(), $customAction = null) { return $this->resourceUrl . ($customAction ? "/$customAction" : '') . '.json' . (!empty($urlParams) ? '?' . http_build_query($urlParams) : ''); }
php
public function generateUrl($urlParams = array(), $customAction = null) { return $this->resourceUrl . ($customAction ? "/$customAction" : '') . '.json' . (!empty($urlParams) ? '?' . http_build_query($urlParams) : ''); }
[ "public", "function", "generateUrl", "(", "$", "urlParams", "=", "array", "(", ")", ",", "$", "customAction", "=", "null", ")", "{", "return", "$", "this", "->", "resourceUrl", ".", "(", "$", "customAction", "?", "\"/$customAction\"", ":", "''", ")", "."...
Generate the custom url for api request based on the params and custom action (if any) @param array $urlParams @param string $customAction @return string
[ "Generate", "the", "custom", "url", "for", "api", "request", "based", "on", "the", "params", "and", "custom", "action", "(", "if", "any", ")" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L291-L294
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.get
public function get($urlParams = array(), $url = null, $dataKey = null) { if (!$url) $url = $this->generateUrl($urlParams); $response = HttpRequestJson::get($url, $this->httpHeaders); if (!$dataKey) $dataKey = $this->id ? $this->resourceKey : $this->pluralizeKey(); return $this->...
php
public function get($urlParams = array(), $url = null, $dataKey = null) { if (!$url) $url = $this->generateUrl($urlParams); $response = HttpRequestJson::get($url, $this->httpHeaders); if (!$dataKey) $dataKey = $this->id ? $this->resourceKey : $this->pluralizeKey(); return $this->...
[ "public", "function", "get", "(", "$", "urlParams", "=", "array", "(", ")", ",", "$", "url", "=", "null", ",", "$", "dataKey", "=", "null", ")", "{", "if", "(", "!", "$", "url", ")", "$", "url", "=", "$", "this", "->", "generateUrl", "(", "$", ...
Generate a HTTP GET request and return results as an array @param array $urlParams Check Shopify API reference of the specific resource for the list of URL parameters @param string $url @param string $dataKey Keyname to fetch data from response array @uses HttpRequestJson::get() to send the HTTP request @return arra...
[ "Generate", "a", "HTTP", "GET", "request", "and", "return", "results", "as", "an", "array" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L307-L317
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.count
public function count($urlParams = array()) { if (!$this->countEnabled) { throw new SdkException("Count is not available for " . $this->getResourceName()); } $url = $this->generateUrl($urlParams, 'count'); return $this->get(array(), $url, 'count'); }
php
public function count($urlParams = array()) { if (!$this->countEnabled) { throw new SdkException("Count is not available for " . $this->getResourceName()); } $url = $this->generateUrl($urlParams, 'count'); return $this->get(array(), $url, 'count'); }
[ "public", "function", "count", "(", "$", "urlParams", "=", "array", "(", ")", ")", "{", "if", "(", "!", "$", "this", "->", "countEnabled", ")", "{", "throw", "new", "SdkException", "(", "\"Count is not available for \"", ".", "$", "this", "->", "getResourc...
Get count for the number of resources available @param array $urlParams Check Shopify API reference of the specific resource for the list of URL parameters @return integer
[ "Get", "count", "for", "the", "number", "of", "resources", "available" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L326-L335
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.search
public function search($query) { if (!$this->searchEnabled) { throw new SdkException("Search is not available for " . $this->getResourceName()); } if (!is_array($query)) $query = array('query' => $query); $url = $this->generateUrl($query, 'search'); return $thi...
php
public function search($query) { if (!$this->searchEnabled) { throw new SdkException("Search is not available for " . $this->getResourceName()); } if (!is_array($query)) $query = array('query' => $query); $url = $this->generateUrl($query, 'search'); return $thi...
[ "public", "function", "search", "(", "$", "query", ")", "{", "if", "(", "!", "$", "this", "->", "searchEnabled", ")", "{", "throw", "new", "SdkException", "(", "\"Search is not available for \"", ".", "$", "this", "->", "getResourceName", "(", ")", ")", ";...
Search within the resouce @param mixed $query @throws SdkException if search is not enabled for the resouce @return array
[ "Search", "within", "the", "resouce" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L346-L357
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.post
public function post($dataArray, $url = null, $wrapData = true) { if (!$url) $url = $this->generateUrl(); if ($wrapData && !empty($dataArray)) $dataArray = $this->wrapData($dataArray); $response = HttpRequestJson::post($url, $dataArray, $this->httpHeaders); return $this->processRe...
php
public function post($dataArray, $url = null, $wrapData = true) { if (!$url) $url = $this->generateUrl(); if ($wrapData && !empty($dataArray)) $dataArray = $this->wrapData($dataArray); $response = HttpRequestJson::post($url, $dataArray, $this->httpHeaders); return $this->processRe...
[ "public", "function", "post", "(", "$", "dataArray", ",", "$", "url", "=", "null", ",", "$", "wrapData", "=", "true", ")", "{", "if", "(", "!", "$", "url", ")", "$", "url", "=", "$", "this", "->", "generateUrl", "(", ")", ";", "if", "(", "$", ...
Call POST method to create a new resource @param array $dataArray Check Shopify API reference of the specific resource for the list of required and optional data elements to be provided @param string $url @param bool $wrapData @uses HttpRequestJson::post() to send the HTTP request @return array
[ "Call", "POST", "method", "to", "create", "a", "new", "resource" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L370-L379
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.delete
public function delete($urlParams = array(), $url = null) { if (!$url) $url = $this->generateUrl($urlParams); $response = HttpRequestJson::delete($url, $this->httpHeaders); return $this->processResponse($response); }
php
public function delete($urlParams = array(), $url = null) { if (!$url) $url = $this->generateUrl($urlParams); $response = HttpRequestJson::delete($url, $this->httpHeaders); return $this->processResponse($response); }
[ "public", "function", "delete", "(", "$", "urlParams", "=", "array", "(", ")", ",", "$", "url", "=", "null", ")", "{", "if", "(", "!", "$", "url", ")", "$", "url", "=", "$", "this", "->", "generateUrl", "(", "$", "urlParams", ")", ";", "$", "re...
Call DELETE method to delete an existing resource @param array $urlParams Check Shopify API reference of the specific resource for the list of URL parameters @param string $url @uses HttpRequestJson::delete() to send the HTTP request @return array an empty array will be returned if the request is successfully comple...
[ "Call", "DELETE", "method", "to", "delete", "an", "existing", "resource" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L414-L421
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.wrapData
protected function wrapData($dataArray, $dataKey = null) { if (!$dataKey) $dataKey = $this->getResourcePostKey(); return array($dataKey => $dataArray); }
php
protected function wrapData($dataArray, $dataKey = null) { if (!$dataKey) $dataKey = $this->getResourcePostKey(); return array($dataKey => $dataArray); }
[ "protected", "function", "wrapData", "(", "$", "dataArray", ",", "$", "dataKey", "=", "null", ")", "{", "if", "(", "!", "$", "dataKey", ")", "$", "dataKey", "=", "$", "this", "->", "getResourcePostKey", "(", ")", ";", "return", "array", "(", "$", "da...
Wrap data array with resource key @param array $dataArray @param string $dataKey @return array
[ "Wrap", "data", "array", "with", "resource", "key" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L431-L436
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.castString
protected function castString($array) { if (is_string($array)) return $array; $string = ''; $i = 0; foreach ($array as $key => $val) { //Add values separated by comma //prepend the key string, if it's an associative key //Check if the value itself...
php
protected function castString($array) { if (is_string($array)) return $array; $string = ''; $i = 0; foreach ($array as $key => $val) { //Add values separated by comma //prepend the key string, if it's an associative key //Check if the value itself...
[ "protected", "function", "castString", "(", "$", "array", ")", "{", "if", "(", "is_string", "(", "$", "array", ")", ")", "return", "$", "array", ";", "$", "string", "=", "''", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "array", "as", "$",...
Convert an array to string @param array $array @internal @return string
[ "Convert", "an", "array", "to", "string" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L447-L465
phpclassic/php-shopify
lib/ShopifyResource.php
ShopifyResource.processResponse
public function processResponse($responseArray, $dataKey = null) { if ($responseArray === null) { //Something went wrong, Checking HTTP Codes $httpOK = 200; //Request Successful, OK. $httpCreated = 201; //Create Successful. //should be null if any other libra...
php
public function processResponse($responseArray, $dataKey = null) { if ($responseArray === null) { //Something went wrong, Checking HTTP Codes $httpOK = 200; //Request Successful, OK. $httpCreated = 201; //Create Successful. //should be null if any other libra...
[ "public", "function", "processResponse", "(", "$", "responseArray", ",", "$", "dataKey", "=", "null", ")", "{", "if", "(", "$", "responseArray", "===", "null", ")", "{", "//Something went wrong, Checking HTTP Codes", "$", "httpOK", "=", "200", ";", "//Request Su...
Process the request response @param array $responseArray Request response in array format @param string $dataKey Keyname to fetch data from response array @throws ApiException if the response has an error specified @throws CurlException if response received with unexpected HTTP code. @return array
[ "Process", "the", "request", "response" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/ShopifyResource.php#L478-L504
phpclassic/php-shopify
lib/AuthHelper.php
AuthHelper.getCurrentUrl
public static function getCurrentUrl() { if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https'; } ...
php
public static function getCurrentUrl() { if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { $protocol = 'https'; } ...
[ "public", "static", "function", "getCurrentUrl", "(", ")", "{", "if", "(", "isset", "(", "$", "_SERVER", "[", "'HTTPS'", "]", ")", "&&", "(", "$", "_SERVER", "[", "'HTTPS'", "]", "==", "'on'", "||", "$", "_SERVER", "[", "'HTTPS'", "]", "==", "1", "...
Get the url of the current page @return string
[ "Get", "the", "url", "of", "the", "current", "page" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/AuthHelper.php#L20-L33
phpclassic/php-shopify
lib/AuthHelper.php
AuthHelper.verifyShopifyRequest
public static function verifyShopifyRequest() { $data = $_GET; if(!isset(ShopifySDK::$config['SharedSecret'])) { throw new SdkException("Please provide SharedSecret while configuring the SDK client."); } $sharedSecret = ShopifySDK::$config['SharedSecret']; //Ge...
php
public static function verifyShopifyRequest() { $data = $_GET; if(!isset(ShopifySDK::$config['SharedSecret'])) { throw new SdkException("Please provide SharedSecret while configuring the SDK client."); } $sharedSecret = ShopifySDK::$config['SharedSecret']; //Ge...
[ "public", "static", "function", "verifyShopifyRequest", "(", ")", "{", "$", "data", "=", "$", "_GET", ";", "if", "(", "!", "isset", "(", "ShopifySDK", "::", "$", "config", "[", "'SharedSecret'", "]", ")", ")", "{", "throw", "new", "SdkException", "(", ...
Verify if the request is made from shopify using hmac hash value @throws SdkException if SharedSecret is not provided or hmac is not found in the url parameters @return bool
[ "Verify", "if", "the", "request", "is", "made", "from", "shopify", "using", "hmac", "hash", "value" ]
train
https://github.com/phpclassic/php-shopify/blob/d3c7f3bdfed59dd4fdcd005cef80f7bfb5d4a6c3/lib/AuthHelper.php#L42-L74