id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
232,700
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getNewVsReturningSessions
public function getNewVsReturningSessions($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:userType', ]); return $this->execute($parameters, $parseResult); }
php
public function getNewVsReturningSessions($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:userType', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getNewVsReturningSessions", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions'", ",", "'dimensions'", "=>", "'ga:userType'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
New vs Returning Sessions. This query returns the number of new sessions vs returning sessions. @param array $parameters Parameters you may want to overwrite. @return array
[ "New", "vs", "Returning", "Sessions", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L95-L103
232,701
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getSessionsByCountry
public function getSessionsByCountry($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:country', 'sort' => '-ga:sessions', ]); return $this->execute($parameters, $parseResult); }
php
public function getSessionsByCountry($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:country', 'sort' => '-ga:sessions', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getSessionsByCountry", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions'", ",", "'dimensions'", "=>", "'ga:country'", ",", "'sort'", "=>", "'-ga:sessions'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Sessions by Country. This query returns a breakdown of your sessions by country, sorted by number of sessions. @param array $parameters Parameters you may want to overwrite. @return array
[ "Sessions", "by", "Country", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L114-L123
232,702
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getBrowserAndOperatingSystem
public function getBrowserAndOperatingSystem($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion', ]); return $this->execute($parameters, $parseResult); }
php
public function getBrowserAndOperatingSystem($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getBrowserAndOperatingSystem", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions'", ",", "'dimensions'", "=>", "'ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Browser and Operating System. This query returns a breakdown of sessions by the Operating System, web browser, and browser version used. @param array $parameters Parameters you may want to overwrite. @return array
[ "Browser", "and", "Operating", "System", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L134-L142
232,703
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getTimeOnSite
public function getTimeOnSite($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion', ]); return $this->execute($parameters, $parseResult); }
php
public function getTimeOnSite($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions', 'dimensions' => 'ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getTimeOnSite", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions'", ",", "'dimensions'", "=>", "'ga:operatingSystem,ga:operatingSystemVersion,ga:browser,ga:browserVersion'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Time on Site. This query returns the number of sessions and total time on site, which can be used to calculate average time on site. @param array $parameters Parameters you may want to overwrite. @return array
[ "Time", "on", "Site", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L153-L161
232,704
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getAllTrafficSources_Usage
public function getAllTrafficSources_Usage($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions,ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source,ga:medium', 'sort' => '-ga:sessions', ]); return $this->execute($parameters, $parseResult); }
php
public function getAllTrafficSources_Usage($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions,ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source,ga:medium', 'sort' => '-ga:sessions', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getAllTrafficSources_Usage", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions,ga:pageviews,ga:sessionDuration,ga:exits'", ",", "'dimensions'", "=>", "'ga:source,ga:medium'", ",", "'sort'", "=>", "'-ga:sessions'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
All Traffic Sources - Usage. This query returns the site usage data broken down by source and medium, sorted by sessions in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "All", "Traffic", "Sources", "-", "Usage", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L178-L187
232,705
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getAllTrafficSources_Goals
public function getAllTrafficSources_Goals($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions,ga:goal1Starts,ga:goal1Completions,ga:goal1Value,ga:goalStartsAll,ga:goalCompletionsAll,ga:goalValueAll', 'dimensions' => 'ga:source,ga:medium', 'sort' => '-ga:goalCompletionsAll', ]); return $this->execute($parameters, $parseResult); }
php
public function getAllTrafficSources_Goals($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions,ga:goal1Starts,ga:goal1Completions,ga:goal1Value,ga:goalStartsAll,ga:goalCompletionsAll,ga:goalValueAll', 'dimensions' => 'ga:source,ga:medium', 'sort' => '-ga:goalCompletionsAll', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getAllTrafficSources_Goals", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions,ga:goal1Starts,ga:goal1Completions,ga:goal1Value,ga:goalStartsAll,ga:goalCompletionsAll,ga:goalValueAll'", ",", "'dimensions'", "=>", "'ga:source,ga:medium'", ",", "'sort'", "=>", "'-ga:goalCompletionsAll'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
All Traffic Sources - Goals. This query returns data for the first and all goals defined, sorted by total goal completions in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "All", "Traffic", "Sources", "-", "Goals", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L198-L207
232,706
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getAllTrafficSources_ECommerce
public function getAllTrafficSources_ECommerce($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions,ga:transactionRevenue,ga:transactions,ga:uniquePurchases', 'dimensions' => 'ga:source,ga:medium', 'sort' => '-ga:sessions', ]); return $this->execute($parameters, $parseResult); }
php
public function getAllTrafficSources_ECommerce($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:sessions,ga:transactionRevenue,ga:transactions,ga:uniquePurchases', 'dimensions' => 'ga:source,ga:medium', 'sort' => '-ga:sessions', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getAllTrafficSources_ECommerce", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:sessions,ga:transactionRevenue,ga:transactions,ga:uniquePurchases'", ",", "'dimensions'", "=>", "'ga:source,ga:medium'", ",", "'sort'", "=>", "'-ga:sessions'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
All Traffic Sources - E-Commerce. This query returns information on revenue generated through the site for the given time span, sorted by sessions in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "All", "Traffic", "Sources", "-", "E", "-", "Commerce", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L218-L227
232,707
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getReferringSites
public function getReferringSites($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==referral', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
php
public function getReferringSites($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==referral', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getReferringSites", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:pageviews,ga:sessionDuration,ga:exits'", ",", "'dimensions'", "=>", "'ga:source'", ",", "'filters'", "=>", "'ga:medium==referral'", ",", "'sort'", "=>", "'-ga:pageviews'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Referring Sites. This query returns a list of domains and how many sessions each referred to your site, sorted by pageviews in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Referring", "Sites", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L238-L248
232,708
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getSearchEngines
public function getSearchEngines($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
php
public function getSearchEngines($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getSearchEngines", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:pageviews,ga:sessionDuration,ga:exits'", ",", "'dimensions'", "=>", "'ga:source'", ",", "'filters'", "=>", "'ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==organic,ga:medium==ppc'", ",", "'sort'", "=>", "'-ga:pageviews'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Search Engines. This query returns site usage data for all traffic by search engine, sorted by pageviews in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Search", "Engines", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L259-L269
232,709
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getSearchEngines_OrganicSearch
public function getSearchEngines_OrganicSearch($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==organic', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
php
public function getSearchEngines_OrganicSearch($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==organic', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getSearchEngines_OrganicSearch", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:pageviews,ga:sessionDuration,ga:exits'", ",", "'dimensions'", "=>", "'ga:source'", ",", "'filters'", "=>", "'ga:medium==organic'", ",", "'sort'", "=>", "'-ga:pageviews'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Search Engines - Organic Search. This query returns site usage data for organic traffic by search engine, sorted by pageviews in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Search", "Engines", "-", "Organic", "Search", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L280-L290
232,710
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getSearchEngines_PaidSearch
public function getSearchEngines_PaidSearch($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
php
public function getSearchEngines_PaidSearch($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:sessionDuration,ga:exits', 'dimensions' => 'ga:source', 'filters' => 'ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getSearchEngines_PaidSearch", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:pageviews,ga:sessionDuration,ga:exits'", ",", "'dimensions'", "=>", "'ga:source'", ",", "'filters'", "=>", "'ga:medium==cpa,ga:medium==cpc,ga:medium==cpm,ga:medium==cpp,ga:medium==cpv,ga:medium==ppc'", ",", "'sort'", "=>", "'-ga:pageviews'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Search Engines - Paid Search. This query returns site usage data for paid traffic by search engine, sorted by pageviews in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Search", "Engines", "-", "Paid", "Search", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L301-L311
232,711
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getTopContent
public function getTopContent($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:uniquePageviews,ga:timeOnPage,ga:bounces,ga:entrances,ga:exits', 'dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
php
public function getTopContent($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:pageviews,ga:uniquePageviews,ga:timeOnPage,ga:bounces,ga:entrances,ga:exits', 'dimensions' => 'ga:pagePath', 'sort' => '-ga:pageviews', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getTopContent", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:pageviews,ga:uniquePageviews,ga:timeOnPage,ga:bounces,ga:entrances,ga:exits'", ",", "'dimensions'", "=>", "'ga:pagePath'", ",", "'sort'", "=>", "'-ga:pageviews'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Top Content. This query returns your most popular content, sorted by most pageviews. @param array $parameters Parameters you may want to overwrite. @return array
[ "Top", "Content", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L348-L357
232,712
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getTopLandingPages
public function getTopLandingPages($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:entrances,ga:bounces', 'dimensions' => 'ga:landingPagePath', 'sort' => '-ga:entrances', ]); return $this->execute($parameters, $parseResult); }
php
public function getTopLandingPages($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:entrances,ga:bounces', 'dimensions' => 'ga:landingPagePath', 'sort' => '-ga:entrances', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getTopLandingPages", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:entrances,ga:bounces'", ",", "'dimensions'", "=>", "'ga:landingPagePath'", ",", "'sort'", "=>", "'-ga:entrances'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Top Landing Pages. This query returns your most popular landing pages, sorted by entrances in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Top", "Landing", "Pages", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L368-L377
232,713
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getTopExitPages
public function getTopExitPages($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:exits,ga:pageviews', 'dimensions' => 'ga:exitPagePath', 'sort' => '-ga:exits', ]); return $this->execute($parameters, $parseResult); }
php
public function getTopExitPages($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:exits,ga:pageviews', 'dimensions' => 'ga:exitPagePath', 'sort' => '-ga:exits', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getTopExitPages", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:exits,ga:pageviews'", ",", "'dimensions'", "=>", "'ga:exitPagePath'", ",", "'sort'", "=>", "'-ga:exits'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Top Exit Pages. This query returns your most common exit pages, sorted by exits in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Top", "Exit", "Pages", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L388-L397
232,714
OzanKurt/google-analytics
src/Traits/Filters/GoogleCommonFilters.php
GoogleCommonFilters.getSiteSearch_SearchTerms
public function getSiteSearch_SearchTerms($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:searchUniques', 'dimensions' => 'ga:searchKeyword', 'sort' => '-ga:searchUniques', ]); return $this->execute($parameters, $parseResult); }
php
public function getSiteSearch_SearchTerms($parameters = [], $parseResult = true) { $this->setParams([ 'metrics' => 'ga:searchUniques', 'dimensions' => 'ga:searchKeyword', 'sort' => '-ga:searchUniques', ]); return $this->execute($parameters, $parseResult); }
[ "public", "function", "getSiteSearch_SearchTerms", "(", "$", "parameters", "=", "[", "]", ",", "$", "parseResult", "=", "true", ")", "{", "$", "this", "->", "setParams", "(", "[", "'metrics'", "=>", "'ga:searchUniques'", ",", "'dimensions'", "=>", "'ga:searchKeyword'", ",", "'sort'", "=>", "'-ga:searchUniques'", ",", "]", ")", ";", "return", "$", "this", "->", "execute", "(", "$", "parameters", ",", "$", "parseResult", ")", ";", "}" ]
Site Search - Search Terms. This query returns the number of sessions broken down by internal site search, sorted by number of unique searches for a keyword in descending order. @param array $parameters Parameters you may want to overwrite. @return array
[ "Site", "Search", "-", "Search", "Terms", "." ]
da5fecb6d9267f2fc5015a918c3aebda2c2f70a5
https://github.com/OzanKurt/google-analytics/blob/da5fecb6d9267f2fc5015a918c3aebda2c2f70a5/src/Traits/Filters/GoogleCommonFilters.php#L408-L417
232,715
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.renderSection
protected function renderSection($title, $contentArray) { //title echo Html::tag($this->sectionTitleTag, $title); //table echo Html::beginTag('table', $this->sectionTableOptions); echo Html::beginTag('tbody'); foreach ($contentArray as $key=>$value) { $value = $value instanceof \Closure ? call_user_func($value) : $value; echo Html::beginTag('tr'); echo Html::tag('th', $key); echo Html::tag('td', $value); echo Html::endTag('tr'); } echo Html::endTag('tbody'); echo Html::endTag('table'); }
php
protected function renderSection($title, $contentArray) { //title echo Html::tag($this->sectionTitleTag, $title); //table echo Html::beginTag('table', $this->sectionTableOptions); echo Html::beginTag('tbody'); foreach ($contentArray as $key=>$value) { $value = $value instanceof \Closure ? call_user_func($value) : $value; echo Html::beginTag('tr'); echo Html::tag('th', $key); echo Html::tag('td', $value); echo Html::endTag('tr'); } echo Html::endTag('tbody'); echo Html::endTag('table'); }
[ "protected", "function", "renderSection", "(", "$", "title", ",", "$", "contentArray", ")", "{", "//title", "echo", "Html", "::", "tag", "(", "$", "this", "->", "sectionTitleTag", ",", "$", "title", ")", ";", "//table", "echo", "Html", "::", "beginTag", "(", "'table'", ",", "$", "this", "->", "sectionTableOptions", ")", ";", "echo", "Html", "::", "beginTag", "(", "'tbody'", ")", ";", "foreach", "(", "$", "contentArray", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "value", "=", "$", "value", "instanceof", "\\", "Closure", "?", "call_user_func", "(", "$", "value", ")", ":", "$", "value", ";", "echo", "Html", "::", "beginTag", "(", "'tr'", ")", ";", "echo", "Html", "::", "tag", "(", "'th'", ",", "$", "key", ")", ";", "echo", "Html", "::", "tag", "(", "'td'", ",", "$", "value", ")", ";", "echo", "Html", "::", "endTag", "(", "'tr'", ")", ";", "}", "echo", "Html", "::", "endTag", "(", "'tbody'", ")", ";", "echo", "Html", "::", "endTag", "(", "'table'", ")", ";", "}" ]
Renders an actual section @param string $title the title of the section @param array $contentArray key/value pairs representing titles and values of entries @return string the rendered html code
[ "Renders", "an", "actual", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L176-L194
232,716
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionServer
protected function sectionServer() { $extCheck = [ 'Zend OPcache','memcache','apc','xcache','redis','wincache','Zend Data Cache','curl', 'odbc','intl','gd','imagick','openssl','xdebug', ]; $extensions = []; foreach ($extCheck as $ext) { $hasExt = extension_loaded($ext); $extensions[] = Html::tag('span', $ext, ['class'=>'label label-' . ($hasExt ? 'success' : 'danger')]); } $ret = [ 'Host'=>AsiUrl::getHost(), 'Localhost detected'=>$this->valueBool(AsiUrl::isLocalhost()), 'PHP version'=>phpversion(), 'PHP info'=>$this->valueModal('PHP info', $this->phpInfo), 'Relevant extensions'=>implode(' ', $extensions), ]; if (ServerConfig::extOpCacheLoaded()) { $ret['OpCache enabled'] = $this->valueBool(ServerConfig::opCacheEnabled()); } return $ret; }
php
protected function sectionServer() { $extCheck = [ 'Zend OPcache','memcache','apc','xcache','redis','wincache','Zend Data Cache','curl', 'odbc','intl','gd','imagick','openssl','xdebug', ]; $extensions = []; foreach ($extCheck as $ext) { $hasExt = extension_loaded($ext); $extensions[] = Html::tag('span', $ext, ['class'=>'label label-' . ($hasExt ? 'success' : 'danger')]); } $ret = [ 'Host'=>AsiUrl::getHost(), 'Localhost detected'=>$this->valueBool(AsiUrl::isLocalhost()), 'PHP version'=>phpversion(), 'PHP info'=>$this->valueModal('PHP info', $this->phpInfo), 'Relevant extensions'=>implode(' ', $extensions), ]; if (ServerConfig::extOpCacheLoaded()) { $ret['OpCache enabled'] = $this->valueBool(ServerConfig::opCacheEnabled()); } return $ret; }
[ "protected", "function", "sectionServer", "(", ")", "{", "$", "extCheck", "=", "[", "'Zend OPcache'", ",", "'memcache'", ",", "'apc'", ",", "'xcache'", ",", "'redis'", ",", "'wincache'", ",", "'Zend Data Cache'", ",", "'curl'", ",", "'odbc'", ",", "'intl'", ",", "'gd'", ",", "'imagick'", ",", "'openssl'", ",", "'xdebug'", ",", "]", ";", "$", "extensions", "=", "[", "]", ";", "foreach", "(", "$", "extCheck", "as", "$", "ext", ")", "{", "$", "hasExt", "=", "extension_loaded", "(", "$", "ext", ")", ";", "$", "extensions", "[", "]", "=", "Html", "::", "tag", "(", "'span'", ",", "$", "ext", ",", "[", "'class'", "=>", "'label label-'", ".", "(", "$", "hasExt", "?", "'success'", ":", "'danger'", ")", "]", ")", ";", "}", "$", "ret", "=", "[", "'Host'", "=>", "AsiUrl", "::", "getHost", "(", ")", ",", "'Localhost detected'", "=>", "$", "this", "->", "valueBool", "(", "AsiUrl", "::", "isLocalhost", "(", ")", ")", ",", "'PHP version'", "=>", "phpversion", "(", ")", ",", "'PHP info'", "=>", "$", "this", "->", "valueModal", "(", "'PHP info'", ",", "$", "this", "->", "phpInfo", ")", ",", "'Relevant extensions'", "=>", "implode", "(", "' '", ",", "$", "extensions", ")", ",", "]", ";", "if", "(", "ServerConfig", "::", "extOpCacheLoaded", "(", ")", ")", "{", "$", "ret", "[", "'OpCache enabled'", "]", "=", "$", "this", "->", "valueBool", "(", "ServerConfig", "::", "opCacheEnabled", "(", ")", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Prepares the server section @return array the configuration of the section
[ "Prepares", "the", "server", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L201-L225
232,717
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionYii
protected function sectionYii() { return [ 'Version'=>Yii::getVersion(), 'YII_DEBUG'=>$this->valueBool(YII_DEBUG), 'YII_ENV'=>Html::tag('code', YII_ENV), 'YII_ENV_DEV'=>$this->valueBool(YII_ENV_DEV), 'YII_ENV_PROD'=>$this->valueBool(YII_ENV_PROD), ]; }
php
protected function sectionYii() { return [ 'Version'=>Yii::getVersion(), 'YII_DEBUG'=>$this->valueBool(YII_DEBUG), 'YII_ENV'=>Html::tag('code', YII_ENV), 'YII_ENV_DEV'=>$this->valueBool(YII_ENV_DEV), 'YII_ENV_PROD'=>$this->valueBool(YII_ENV_PROD), ]; }
[ "protected", "function", "sectionYii", "(", ")", "{", "return", "[", "'Version'", "=>", "Yii", "::", "getVersion", "(", ")", ",", "'YII_DEBUG'", "=>", "$", "this", "->", "valueBool", "(", "YII_DEBUG", ")", ",", "'YII_ENV'", "=>", "Html", "::", "tag", "(", "'code'", ",", "YII_ENV", ")", ",", "'YII_ENV_DEV'", "=>", "$", "this", "->", "valueBool", "(", "YII_ENV_DEV", ")", ",", "'YII_ENV_PROD'", "=>", "$", "this", "->", "valueBool", "(", "YII_ENV_PROD", ")", ",", "]", ";", "}" ]
Prepares the yii section @return array the configuration of the section
[ "Prepares", "the", "yii", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L232-L241
232,718
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionDb
protected function sectionDb() { if (Yii::$app->db === null) return ['Status'=>'not configured']; $db = Yii::$app->db; return [ 'Active'=>$this->valueBool($db->isActive), 'Driver name'=>$this->valueCode($db->driverName), 'DSN'=>$this->valueCode($db->dsn), 'Username'=>$this->valueCode($db->username), 'Password'=>$this->valueCode($db->password), 'Schema cache enabled'=>$this->valueBool($db->enableSchemaCache), 'Schema cache duration'=>$db->schemaCacheDuration . 's', 'Schema cache component'=>$this->valueCode($db->schemaCache instanceof Cache ? $db->schemaCache->className() : $db->schemaCache), 'Schema cache config'=>$db->schemaCache instanceof Cache ? $this->valueModal($this->valueVarDump($db->schemaCache)) : $this->valueCode('@see component \'' . $db->schemaCache . '\''), 'Query cache enabled'=>$this->valueBool($db->enableQueryCache), 'Query cache duration'=>$db->queryCacheDuration . 's', 'Query cache component'=>$this->valueCode($db->queryCache instanceof Cache ? $db->queryCache->className() : $db->queryCache), 'Query cache config'=>$db->queryCache instanceof Cache ? $this->valueModal($this->valueVarDump($db->queryCache)) : $this->valueCode('@see component \'' . $db->queryCache . '\''), ]; }
php
protected function sectionDb() { if (Yii::$app->db === null) return ['Status'=>'not configured']; $db = Yii::$app->db; return [ 'Active'=>$this->valueBool($db->isActive), 'Driver name'=>$this->valueCode($db->driverName), 'DSN'=>$this->valueCode($db->dsn), 'Username'=>$this->valueCode($db->username), 'Password'=>$this->valueCode($db->password), 'Schema cache enabled'=>$this->valueBool($db->enableSchemaCache), 'Schema cache duration'=>$db->schemaCacheDuration . 's', 'Schema cache component'=>$this->valueCode($db->schemaCache instanceof Cache ? $db->schemaCache->className() : $db->schemaCache), 'Schema cache config'=>$db->schemaCache instanceof Cache ? $this->valueModal($this->valueVarDump($db->schemaCache)) : $this->valueCode('@see component \'' . $db->schemaCache . '\''), 'Query cache enabled'=>$this->valueBool($db->enableQueryCache), 'Query cache duration'=>$db->queryCacheDuration . 's', 'Query cache component'=>$this->valueCode($db->queryCache instanceof Cache ? $db->queryCache->className() : $db->queryCache), 'Query cache config'=>$db->queryCache instanceof Cache ? $this->valueModal($this->valueVarDump($db->queryCache)) : $this->valueCode('@see component \'' . $db->queryCache . '\''), ]; }
[ "protected", "function", "sectionDb", "(", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "db", "===", "null", ")", "return", "[", "'Status'", "=>", "'not configured'", "]", ";", "$", "db", "=", "Yii", "::", "$", "app", "->", "db", ";", "return", "[", "'Active'", "=>", "$", "this", "->", "valueBool", "(", "$", "db", "->", "isActive", ")", ",", "'Driver name'", "=>", "$", "this", "->", "valueCode", "(", "$", "db", "->", "driverName", ")", ",", "'DSN'", "=>", "$", "this", "->", "valueCode", "(", "$", "db", "->", "dsn", ")", ",", "'Username'", "=>", "$", "this", "->", "valueCode", "(", "$", "db", "->", "username", ")", ",", "'Password'", "=>", "$", "this", "->", "valueCode", "(", "$", "db", "->", "password", ")", ",", "'Schema cache enabled'", "=>", "$", "this", "->", "valueBool", "(", "$", "db", "->", "enableSchemaCache", ")", ",", "'Schema cache duration'", "=>", "$", "db", "->", "schemaCacheDuration", ".", "'s'", ",", "'Schema cache component'", "=>", "$", "this", "->", "valueCode", "(", "$", "db", "->", "schemaCache", "instanceof", "Cache", "?", "$", "db", "->", "schemaCache", "->", "className", "(", ")", ":", "$", "db", "->", "schemaCache", ")", ",", "'Schema cache config'", "=>", "$", "db", "->", "schemaCache", "instanceof", "Cache", "?", "$", "this", "->", "valueModal", "(", "$", "this", "->", "valueVarDump", "(", "$", "db", "->", "schemaCache", ")", ")", ":", "$", "this", "->", "valueCode", "(", "'@see component \\''", ".", "$", "db", "->", "schemaCache", ".", "'\\''", ")", ",", "'Query cache enabled'", "=>", "$", "this", "->", "valueBool", "(", "$", "db", "->", "enableQueryCache", ")", ",", "'Query cache duration'", "=>", "$", "db", "->", "queryCacheDuration", ".", "'s'", ",", "'Query cache component'", "=>", "$", "this", "->", "valueCode", "(", "$", "db", "->", "queryCache", "instanceof", "Cache", "?", "$", "db", "->", "queryCache", "->", "className", "(", ")", ":", "$", "db", "->", "queryCache", ")", ",", "'Query cache config'", "=>", "$", "db", "->", "queryCache", "instanceof", "Cache", "?", "$", "this", "->", "valueModal", "(", "$", "this", "->", "valueVarDump", "(", "$", "db", "->", "queryCache", ")", ")", ":", "$", "this", "->", "valueCode", "(", "'@see component \\''", ".", "$", "db", "->", "queryCache", ".", "'\\''", ")", ",", "]", ";", "}" ]
Prepares the db section @return array the configuration of the section
[ "Prepares", "the", "db", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L248-L268
232,719
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionLocalization
protected function sectionLocalization() { $f = Yii::$app->formatter; return [ 'Locale'=>$f->locale, 'Language'=>Yii::$app->language, 'Source lang'=>Yii::$app->sourceLanguage, 'Timezone'=>Yii::$app->timeZone, 'Local time ' . Yii::$app->timeZone=>function() { $dtCur = new \DateTime('now', new \DateTimeZone(Yii::$app->timeZone)); return $dtCur->format('d.m.Y H:i:s') . ' ' . Html::tag('span', 'UTC-offset: ' . $dtCur->getOffset() . 's', ['class'=>'text-muted']); }, 'Local time UTC'=>function() { $dtUtc = new \DateTime('now', new \DateTimeZone('UTC')); return $dtUtc->format('d.m.Y H:i:s'); }, 'Date format'=>$this->valueCode($f->dateFormat), 'Time format'=>$this->valueCode($f->timeFormat), 'DateTime format'=>$this->valueCode($f->datetimeFormat), 'Boolean format'=>$this->valueVarDump($f->booleanFormat), ]; }
php
protected function sectionLocalization() { $f = Yii::$app->formatter; return [ 'Locale'=>$f->locale, 'Language'=>Yii::$app->language, 'Source lang'=>Yii::$app->sourceLanguage, 'Timezone'=>Yii::$app->timeZone, 'Local time ' . Yii::$app->timeZone=>function() { $dtCur = new \DateTime('now', new \DateTimeZone(Yii::$app->timeZone)); return $dtCur->format('d.m.Y H:i:s') . ' ' . Html::tag('span', 'UTC-offset: ' . $dtCur->getOffset() . 's', ['class'=>'text-muted']); }, 'Local time UTC'=>function() { $dtUtc = new \DateTime('now', new \DateTimeZone('UTC')); return $dtUtc->format('d.m.Y H:i:s'); }, 'Date format'=>$this->valueCode($f->dateFormat), 'Time format'=>$this->valueCode($f->timeFormat), 'DateTime format'=>$this->valueCode($f->datetimeFormat), 'Boolean format'=>$this->valueVarDump($f->booleanFormat), ]; }
[ "protected", "function", "sectionLocalization", "(", ")", "{", "$", "f", "=", "Yii", "::", "$", "app", "->", "formatter", ";", "return", "[", "'Locale'", "=>", "$", "f", "->", "locale", ",", "'Language'", "=>", "Yii", "::", "$", "app", "->", "language", ",", "'Source lang'", "=>", "Yii", "::", "$", "app", "->", "sourceLanguage", ",", "'Timezone'", "=>", "Yii", "::", "$", "app", "->", "timeZone", ",", "'Local time '", ".", "Yii", "::", "$", "app", "->", "timeZone", "=>", "function", "(", ")", "{", "$", "dtCur", "=", "new", "\\", "DateTime", "(", "'now'", ",", "new", "\\", "DateTimeZone", "(", "Yii", "::", "$", "app", "->", "timeZone", ")", ")", ";", "return", "$", "dtCur", "->", "format", "(", "'d.m.Y H:i:s'", ")", ".", "' '", ".", "Html", "::", "tag", "(", "'span'", ",", "'UTC-offset: '", ".", "$", "dtCur", "->", "getOffset", "(", ")", ".", "'s'", ",", "[", "'class'", "=>", "'text-muted'", "]", ")", ";", "}", ",", "'Local time UTC'", "=>", "function", "(", ")", "{", "$", "dtUtc", "=", "new", "\\", "DateTime", "(", "'now'", ",", "new", "\\", "DateTimeZone", "(", "'UTC'", ")", ")", ";", "return", "$", "dtUtc", "->", "format", "(", "'d.m.Y H:i:s'", ")", ";", "}", ",", "'Date format'", "=>", "$", "this", "->", "valueCode", "(", "$", "f", "->", "dateFormat", ")", ",", "'Time format'", "=>", "$", "this", "->", "valueCode", "(", "$", "f", "->", "timeFormat", ")", ",", "'DateTime format'", "=>", "$", "this", "->", "valueCode", "(", "$", "f", "->", "datetimeFormat", ")", ",", "'Boolean format'", "=>", "$", "this", "->", "valueVarDump", "(", "$", "f", "->", "booleanFormat", ")", ",", "]", ";", "}" ]
Prepares the localization section @return array the configuration of the section
[ "Prepares", "the", "localization", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L275-L297
232,720
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionCaching
protected function sectionCaching() { $ret = []; foreach (Yii::$app->components as $id=>$component) { $instance = Yii::$app->{$id}; if (!($instance instanceof Cache)) continue; $title = $this->valueCode($id); ob_start(); ActiveForm::begin(); echo $this->valueCode($instance->className()); echo $this->valueModal('Cache ' . $id, $this->valueVarDump($instance), 'Show config'); echo Html::hiddenInput('flush-cache', $id); echo Html::submitButton('Flush', [ 'class'=>'btn btn-xs btn-danger', 'data'=>['confirm'=>'Are you sure?'], ]); ActiveForm::end(); $ret[$title] = ob_get_clean(); } return $ret; }
php
protected function sectionCaching() { $ret = []; foreach (Yii::$app->components as $id=>$component) { $instance = Yii::$app->{$id}; if (!($instance instanceof Cache)) continue; $title = $this->valueCode($id); ob_start(); ActiveForm::begin(); echo $this->valueCode($instance->className()); echo $this->valueModal('Cache ' . $id, $this->valueVarDump($instance), 'Show config'); echo Html::hiddenInput('flush-cache', $id); echo Html::submitButton('Flush', [ 'class'=>'btn btn-xs btn-danger', 'data'=>['confirm'=>'Are you sure?'], ]); ActiveForm::end(); $ret[$title] = ob_get_clean(); } return $ret; }
[ "protected", "function", "sectionCaching", "(", ")", "{", "$", "ret", "=", "[", "]", ";", "foreach", "(", "Yii", "::", "$", "app", "->", "components", "as", "$", "id", "=>", "$", "component", ")", "{", "$", "instance", "=", "Yii", "::", "$", "app", "->", "{", "$", "id", "}", ";", "if", "(", "!", "(", "$", "instance", "instanceof", "Cache", ")", ")", "continue", ";", "$", "title", "=", "$", "this", "->", "valueCode", "(", "$", "id", ")", ";", "ob_start", "(", ")", ";", "ActiveForm", "::", "begin", "(", ")", ";", "echo", "$", "this", "->", "valueCode", "(", "$", "instance", "->", "className", "(", ")", ")", ";", "echo", "$", "this", "->", "valueModal", "(", "'Cache '", ".", "$", "id", ",", "$", "this", "->", "valueVarDump", "(", "$", "instance", ")", ",", "'Show config'", ")", ";", "echo", "Html", "::", "hiddenInput", "(", "'flush-cache'", ",", "$", "id", ")", ";", "echo", "Html", "::", "submitButton", "(", "'Flush'", ",", "[", "'class'", "=>", "'btn btn-xs btn-danger'", ",", "'data'", "=>", "[", "'confirm'", "=>", "'Are you sure?'", "]", ",", "]", ")", ";", "ActiveForm", "::", "end", "(", ")", ";", "$", "ret", "[", "$", "title", "]", "=", "ob_get_clean", "(", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Prepares the caching section @return array the configuration of the section
[ "Prepares", "the", "caching", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L304-L328
232,721
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionRbac
protected function sectionRbac() { if (Yii::$app->authManager === null) return ['Status'=>'not configured']; $am = Yii::$app->authManager; //get roles and permission $roles = []; $perms = []; foreach ($am->roles as $role) $roles[] = $this->valueCode($role->name); foreach ($am->permissions as $perm) $perms[] = $this->valueCode($perm->name); //rbac cache config if ($am->cache === null) { $cacheConfig = Yii::$app->formatter->nullDisplay; } else { $cacheConfig = $this->valueModal('RBAC cache config', $this->valueVarDump($am->cache), 'Show'); } return [ 'Auth manager'=>$this->valueCode($am->className()) . $this->valueModal($am->className(), $this->valueVarDump($am), 'Show config'), 'Roles'=>implode(', ', $roles), 'Permissions'=>implode(', ', $perms), 'RBAC cache enabled'=>$this->valueBool($am->cache !== null), 'RBAC cache config'=>$cacheConfig, ]; }
php
protected function sectionRbac() { if (Yii::$app->authManager === null) return ['Status'=>'not configured']; $am = Yii::$app->authManager; //get roles and permission $roles = []; $perms = []; foreach ($am->roles as $role) $roles[] = $this->valueCode($role->name); foreach ($am->permissions as $perm) $perms[] = $this->valueCode($perm->name); //rbac cache config if ($am->cache === null) { $cacheConfig = Yii::$app->formatter->nullDisplay; } else { $cacheConfig = $this->valueModal('RBAC cache config', $this->valueVarDump($am->cache), 'Show'); } return [ 'Auth manager'=>$this->valueCode($am->className()) . $this->valueModal($am->className(), $this->valueVarDump($am), 'Show config'), 'Roles'=>implode(', ', $roles), 'Permissions'=>implode(', ', $perms), 'RBAC cache enabled'=>$this->valueBool($am->cache !== null), 'RBAC cache config'=>$cacheConfig, ]; }
[ "protected", "function", "sectionRbac", "(", ")", "{", "if", "(", "Yii", "::", "$", "app", "->", "authManager", "===", "null", ")", "return", "[", "'Status'", "=>", "'not configured'", "]", ";", "$", "am", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "//get roles and permission", "$", "roles", "=", "[", "]", ";", "$", "perms", "=", "[", "]", ";", "foreach", "(", "$", "am", "->", "roles", "as", "$", "role", ")", "$", "roles", "[", "]", "=", "$", "this", "->", "valueCode", "(", "$", "role", "->", "name", ")", ";", "foreach", "(", "$", "am", "->", "permissions", "as", "$", "perm", ")", "$", "perms", "[", "]", "=", "$", "this", "->", "valueCode", "(", "$", "perm", "->", "name", ")", ";", "//rbac cache config", "if", "(", "$", "am", "->", "cache", "===", "null", ")", "{", "$", "cacheConfig", "=", "Yii", "::", "$", "app", "->", "formatter", "->", "nullDisplay", ";", "}", "else", "{", "$", "cacheConfig", "=", "$", "this", "->", "valueModal", "(", "'RBAC cache config'", ",", "$", "this", "->", "valueVarDump", "(", "$", "am", "->", "cache", ")", ",", "'Show'", ")", ";", "}", "return", "[", "'Auth manager'", "=>", "$", "this", "->", "valueCode", "(", "$", "am", "->", "className", "(", ")", ")", ".", "$", "this", "->", "valueModal", "(", "$", "am", "->", "className", "(", ")", ",", "$", "this", "->", "valueVarDump", "(", "$", "am", ")", ",", "'Show config'", ")", ",", "'Roles'", "=>", "implode", "(", "', '", ",", "$", "roles", ")", ",", "'Permissions'", "=>", "implode", "(", "', '", ",", "$", "perms", ")", ",", "'RBAC cache enabled'", "=>", "$", "this", "->", "valueBool", "(", "$", "am", "->", "cache", "!==", "null", ")", ",", "'RBAC cache config'", "=>", "$", "cacheConfig", ",", "]", ";", "}" ]
Prepares the rbac section @return array the configuration of the section
[ "Prepares", "the", "rbac", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L335-L360
232,722
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.sectionCurrentUser
protected function sectionCurrentUser() { $u = Yii::$app->user; if ($u->isGuest) return ['Is guest'=>$this->valueBool(true)]; //basics $identity = Yii::$app->user->identity; $ret = [ 'Is guest'=>$this->valueBool($u->isGuest), 'ID'=>$this->valueBool($u->id), 'Identity'=>$this->valueModal('Identity', $this->valueVarDump($identity), 'Show identity class'), ]; //rbac if (Yii::$app->authManager !== null) { $am = Yii::$app->authManager; $assigns = []; $roles = []; $perms = []; foreach ($am->getAssignments($u->id) as $assign) { $assigns[] = $this->valueCode($assign->roleName); } foreach ($am->roles as $role) { $roles[] = Html::tag('span', $role->name, ['class'=>'label label-' . ($u->can($role->name) ? 'success' : 'danger')]); } foreach ($am->permissions as $perm) { $perms[] = Html::tag('span', $perm->name, ['class'=>'label label-' . ($u->can($perm->name) ? 'success' : 'danger')]); } $ret['Assigned to'] = implode(', ', $assigns); $ret['Roles'] = implode(' ', $roles); $ret['Permissions'] = implode(' ', $perms); } return $ret; }
php
protected function sectionCurrentUser() { $u = Yii::$app->user; if ($u->isGuest) return ['Is guest'=>$this->valueBool(true)]; //basics $identity = Yii::$app->user->identity; $ret = [ 'Is guest'=>$this->valueBool($u->isGuest), 'ID'=>$this->valueBool($u->id), 'Identity'=>$this->valueModal('Identity', $this->valueVarDump($identity), 'Show identity class'), ]; //rbac if (Yii::$app->authManager !== null) { $am = Yii::$app->authManager; $assigns = []; $roles = []; $perms = []; foreach ($am->getAssignments($u->id) as $assign) { $assigns[] = $this->valueCode($assign->roleName); } foreach ($am->roles as $role) { $roles[] = Html::tag('span', $role->name, ['class'=>'label label-' . ($u->can($role->name) ? 'success' : 'danger')]); } foreach ($am->permissions as $perm) { $perms[] = Html::tag('span', $perm->name, ['class'=>'label label-' . ($u->can($perm->name) ? 'success' : 'danger')]); } $ret['Assigned to'] = implode(', ', $assigns); $ret['Roles'] = implode(' ', $roles); $ret['Permissions'] = implode(' ', $perms); } return $ret; }
[ "protected", "function", "sectionCurrentUser", "(", ")", "{", "$", "u", "=", "Yii", "::", "$", "app", "->", "user", ";", "if", "(", "$", "u", "->", "isGuest", ")", "return", "[", "'Is guest'", "=>", "$", "this", "->", "valueBool", "(", "true", ")", "]", ";", "//basics", "$", "identity", "=", "Yii", "::", "$", "app", "->", "user", "->", "identity", ";", "$", "ret", "=", "[", "'Is guest'", "=>", "$", "this", "->", "valueBool", "(", "$", "u", "->", "isGuest", ")", ",", "'ID'", "=>", "$", "this", "->", "valueBool", "(", "$", "u", "->", "id", ")", ",", "'Identity'", "=>", "$", "this", "->", "valueModal", "(", "'Identity'", ",", "$", "this", "->", "valueVarDump", "(", "$", "identity", ")", ",", "'Show identity class'", ")", ",", "]", ";", "//rbac", "if", "(", "Yii", "::", "$", "app", "->", "authManager", "!==", "null", ")", "{", "$", "am", "=", "Yii", "::", "$", "app", "->", "authManager", ";", "$", "assigns", "=", "[", "]", ";", "$", "roles", "=", "[", "]", ";", "$", "perms", "=", "[", "]", ";", "foreach", "(", "$", "am", "->", "getAssignments", "(", "$", "u", "->", "id", ")", "as", "$", "assign", ")", "{", "$", "assigns", "[", "]", "=", "$", "this", "->", "valueCode", "(", "$", "assign", "->", "roleName", ")", ";", "}", "foreach", "(", "$", "am", "->", "roles", "as", "$", "role", ")", "{", "$", "roles", "[", "]", "=", "Html", "::", "tag", "(", "'span'", ",", "$", "role", "->", "name", ",", "[", "'class'", "=>", "'label label-'", ".", "(", "$", "u", "->", "can", "(", "$", "role", "->", "name", ")", "?", "'success'", ":", "'danger'", ")", "]", ")", ";", "}", "foreach", "(", "$", "am", "->", "permissions", "as", "$", "perm", ")", "{", "$", "perms", "[", "]", "=", "Html", "::", "tag", "(", "'span'", ",", "$", "perm", "->", "name", ",", "[", "'class'", "=>", "'label label-'", ".", "(", "$", "u", "->", "can", "(", "$", "perm", "->", "name", ")", "?", "'success'", ":", "'danger'", ")", "]", ")", ";", "}", "$", "ret", "[", "'Assigned to'", "]", "=", "implode", "(", "', '", ",", "$", "assigns", ")", ";", "$", "ret", "[", "'Roles'", "]", "=", "implode", "(", "' '", ",", "$", "roles", ")", ";", "$", "ret", "[", "'Permissions'", "]", "=", "implode", "(", "' '", ",", "$", "perms", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Prepares the current user section @return array the configuration of the section
[ "Prepares", "the", "current", "user", "section" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L367-L403
232,723
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.valueBool
protected function valueBool($value) { if ($value !== false && empty($value)) return Yii::$app->formatter->nullDisplay; return Yii::$app->formatter->asBoolean($value); }
php
protected function valueBool($value) { if ($value !== false && empty($value)) return Yii::$app->formatter->nullDisplay; return Yii::$app->formatter->asBoolean($value); }
[ "protected", "function", "valueBool", "(", "$", "value", ")", "{", "if", "(", "$", "value", "!==", "false", "&&", "empty", "(", "$", "value", ")", ")", "return", "Yii", "::", "$", "app", "->", "formatter", "->", "nullDisplay", ";", "return", "Yii", "::", "$", "app", "->", "formatter", "->", "asBoolean", "(", "$", "value", ")", ";", "}" ]
Renders a boolean value @param string $value the value to render @return string the resulting html code
[ "Renders", "a", "boolean", "value" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L422-L426
232,724
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.valueCode
protected function valueCode($value) { if (empty($value)) return Yii::$app->formatter->nullDisplay; return html::tag('code', $value); }
php
protected function valueCode($value) { if (empty($value)) return Yii::$app->formatter->nullDisplay; return html::tag('code', $value); }
[ "protected", "function", "valueCode", "(", "$", "value", ")", "{", "if", "(", "empty", "(", "$", "value", ")", ")", "return", "Yii", "::", "$", "app", "->", "formatter", "->", "nullDisplay", ";", "return", "html", "::", "tag", "(", "'code'", ",", "$", "value", ")", ";", "}" ]
Renders the value in a code tag @param string $value the value to render @return string the resulting html code
[ "Renders", "the", "value", "in", "a", "code", "tag" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L434-L438
232,725
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.valueModal
protected function valueModal($title, $content, $buttonLabel=null) { $randomId = Yii::$app->security->generateRandomString(); return Button::widget([ 'label'=>$buttonLabel !== null ? $buttonLabel : Yii::t('app', 'Show'), 'options'=>[ 'class'=>'btn btn-xs btn-primary', 'onclick'=>new JsExpression("$('#" . $randomId . "').modal()"), ], ]) . str_replace( ['{id}', '{title}', '{content}'], [$randomId, $title, $content], $this->modalCode); }
php
protected function valueModal($title, $content, $buttonLabel=null) { $randomId = Yii::$app->security->generateRandomString(); return Button::widget([ 'label'=>$buttonLabel !== null ? $buttonLabel : Yii::t('app', 'Show'), 'options'=>[ 'class'=>'btn btn-xs btn-primary', 'onclick'=>new JsExpression("$('#" . $randomId . "').modal()"), ], ]) . str_replace( ['{id}', '{title}', '{content}'], [$randomId, $title, $content], $this->modalCode); }
[ "protected", "function", "valueModal", "(", "$", "title", ",", "$", "content", ",", "$", "buttonLabel", "=", "null", ")", "{", "$", "randomId", "=", "Yii", "::", "$", "app", "->", "security", "->", "generateRandomString", "(", ")", ";", "return", "Button", "::", "widget", "(", "[", "'label'", "=>", "$", "buttonLabel", "!==", "null", "?", "$", "buttonLabel", ":", "Yii", "::", "t", "(", "'app'", ",", "'Show'", ")", ",", "'options'", "=>", "[", "'class'", "=>", "'btn btn-xs btn-primary'", ",", "'onclick'", "=>", "new", "JsExpression", "(", "\"$('#\"", ".", "$", "randomId", ".", "\"').modal()\"", ")", ",", "]", ",", "]", ")", ".", "str_replace", "(", "[", "'{id}'", ",", "'{title}'", ",", "'{content}'", "]", ",", "[", "$", "randomId", ",", "$", "title", ",", "$", "content", "]", ",", "$", "this", "->", "modalCode", ")", ";", "}" ]
Renders the value in a modal window @param string $title the title of the modal @param string $content the content of the modal @param string $buttonLabel optional button label @return string the resulting html code
[ "Renders", "the", "value", "in", "a", "modal", "window" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L448-L461
232,726
asinfotrack/yii2-toolbox
actions/DebugAction.php
DebugAction.loadPhpInfo
protected function loadPhpInfo() { ob_start(); phpinfo(); $domDoc = new \DOMDocument(); $domDoc->loadHTML(ob_get_clean()); /* @var $node \DOMNode */ /* @var $childNode \DOMNode */ foreach ($domDoc->getElementsByTagName('table') as $node) { $node->setAttribute('class', 'table table-condensed table-striped table-bordered'); $node->removeAttribute('width'); $node->removeAttribute('border'); $node->removeAttribute('cellpadding'); } foreach ($domDoc->getElementsByTagName('tbody') as $node) { $node->setAttribute('style', 'overflow-x: auto;'); } $node = $domDoc->getElementsByTagName('body')->item(0); $this->phpInfo = ''; foreach ($node->childNodes as $childNode) { $this->phpInfo .= $node->ownerDocument->saveHTML($childNode); } }
php
protected function loadPhpInfo() { ob_start(); phpinfo(); $domDoc = new \DOMDocument(); $domDoc->loadHTML(ob_get_clean()); /* @var $node \DOMNode */ /* @var $childNode \DOMNode */ foreach ($domDoc->getElementsByTagName('table') as $node) { $node->setAttribute('class', 'table table-condensed table-striped table-bordered'); $node->removeAttribute('width'); $node->removeAttribute('border'); $node->removeAttribute('cellpadding'); } foreach ($domDoc->getElementsByTagName('tbody') as $node) { $node->setAttribute('style', 'overflow-x: auto;'); } $node = $domDoc->getElementsByTagName('body')->item(0); $this->phpInfo = ''; foreach ($node->childNodes as $childNode) { $this->phpInfo .= $node->ownerDocument->saveHTML($childNode); } }
[ "protected", "function", "loadPhpInfo", "(", ")", "{", "ob_start", "(", ")", ";", "phpinfo", "(", ")", ";", "$", "domDoc", "=", "new", "\\", "DOMDocument", "(", ")", ";", "$", "domDoc", "->", "loadHTML", "(", "ob_get_clean", "(", ")", ")", ";", "/* @var $node \\DOMNode */", "/* @var $childNode \\DOMNode */", "foreach", "(", "$", "domDoc", "->", "getElementsByTagName", "(", "'table'", ")", "as", "$", "node", ")", "{", "$", "node", "->", "setAttribute", "(", "'class'", ",", "'table table-condensed table-striped table-bordered'", ")", ";", "$", "node", "->", "removeAttribute", "(", "'width'", ")", ";", "$", "node", "->", "removeAttribute", "(", "'border'", ")", ";", "$", "node", "->", "removeAttribute", "(", "'cellpadding'", ")", ";", "}", "foreach", "(", "$", "domDoc", "->", "getElementsByTagName", "(", "'tbody'", ")", "as", "$", "node", ")", "{", "$", "node", "->", "setAttribute", "(", "'style'", ",", "'overflow-x: auto;'", ")", ";", "}", "$", "node", "=", "$", "domDoc", "->", "getElementsByTagName", "(", "'body'", ")", "->", "item", "(", "0", ")", ";", "$", "this", "->", "phpInfo", "=", "''", ";", "foreach", "(", "$", "node", "->", "childNodes", "as", "$", "childNode", ")", "{", "$", "this", "->", "phpInfo", ".=", "$", "node", "->", "ownerDocument", "->", "saveHTML", "(", "$", "childNode", ")", ";", "}", "}" ]
Loads and cleans the php info data
[ "Loads", "and", "cleans", "the", "php", "info", "data" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/actions/DebugAction.php#L466-L492
232,727
mcustiel/php-simple-request
src/RequestBuilder.php
RequestBuilder.parseRequest
public function parseRequest( $request, $className, $behavior = self::THROW_EXCEPTION_ON_FIRST_ERROR ) { $isArray = is_array($className); $className = $this->getClassName($className, $isArray); $parserObject = $this->generateRequestParserObject($className, new $behavior); return $this->executeParsing( $this->sanitizeRequestOrThrowExceptionIfInvalid($request), $parserObject, $isArray ); }
php
public function parseRequest( $request, $className, $behavior = self::THROW_EXCEPTION_ON_FIRST_ERROR ) { $isArray = is_array($className); $className = $this->getClassName($className, $isArray); $parserObject = $this->generateRequestParserObject($className, new $behavior); return $this->executeParsing( $this->sanitizeRequestOrThrowExceptionIfInvalid($request), $parserObject, $isArray ); }
[ "public", "function", "parseRequest", "(", "$", "request", ",", "$", "className", ",", "$", "behavior", "=", "self", "::", "THROW_EXCEPTION_ON_FIRST_ERROR", ")", "{", "$", "isArray", "=", "is_array", "(", "$", "className", ")", ";", "$", "className", "=", "$", "this", "->", "getClassName", "(", "$", "className", ",", "$", "isArray", ")", ";", "$", "parserObject", "=", "$", "this", "->", "generateRequestParserObject", "(", "$", "className", ",", "new", "$", "behavior", ")", ";", "return", "$", "this", "->", "executeParsing", "(", "$", "this", "->", "sanitizeRequestOrThrowExceptionIfInvalid", "(", "$", "request", ")", ",", "$", "parserObject", ",", "$", "isArray", ")", ";", "}" ]
Main method of this class. Used to convert a request to an object of a given class by using a requestParser. @param array|\stdClass $request The request to convert to an object. @param string|array $className The class of the object to which the request must be converted. @param string $behavior The behaviour of the parser.
[ "Main", "method", "of", "this", "class", ".", "Used", "to", "convert", "a", "request", "to", "an", "object", "of", "a", "given", "class", "by", "using", "a", "requestParser", "." ]
4d0fc06092ccdff3ea488c67b394225c7243428f
https://github.com/mcustiel/php-simple-request/blob/4d0fc06092ccdff3ea488c67b394225c7243428f/src/RequestBuilder.php#L64-L78
232,728
mpratt/RelativeTime
Lib/RelativeTime/Translation.php
Translation.translate
public function translate(array $units = array(), $direction = 0) { $lang = $this->loadLanguage(); if (empty($units)) { return $lang['now']; } $translation = array(); foreach ($units as $unit => $v) { if ($v == 1) { $translation[] = sprintf($lang[$unit]['singular'], $v); } else { $translation[] = sprintf($lang[$unit]['plural'], $v); } } $string = implode($this->config['separator'], $translation); if (!$this->config['suffix']) { return $string; } if ($direction > 0) { return sprintf($lang['ago'], $string); } else { return sprintf($lang['left'], $string); } }
php
public function translate(array $units = array(), $direction = 0) { $lang = $this->loadLanguage(); if (empty($units)) { return $lang['now']; } $translation = array(); foreach ($units as $unit => $v) { if ($v == 1) { $translation[] = sprintf($lang[$unit]['singular'], $v); } else { $translation[] = sprintf($lang[$unit]['plural'], $v); } } $string = implode($this->config['separator'], $translation); if (!$this->config['suffix']) { return $string; } if ($direction > 0) { return sprintf($lang['ago'], $string); } else { return sprintf($lang['left'], $string); } }
[ "public", "function", "translate", "(", "array", "$", "units", "=", "array", "(", ")", ",", "$", "direction", "=", "0", ")", "{", "$", "lang", "=", "$", "this", "->", "loadLanguage", "(", ")", ";", "if", "(", "empty", "(", "$", "units", ")", ")", "{", "return", "$", "lang", "[", "'now'", "]", ";", "}", "$", "translation", "=", "array", "(", ")", ";", "foreach", "(", "$", "units", "as", "$", "unit", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "==", "1", ")", "{", "$", "translation", "[", "]", "=", "sprintf", "(", "$", "lang", "[", "$", "unit", "]", "[", "'singular'", "]", ",", "$", "v", ")", ";", "}", "else", "{", "$", "translation", "[", "]", "=", "sprintf", "(", "$", "lang", "[", "$", "unit", "]", "[", "'plural'", "]", ",", "$", "v", ")", ";", "}", "}", "$", "string", "=", "implode", "(", "$", "this", "->", "config", "[", "'separator'", "]", ",", "$", "translation", ")", ";", "if", "(", "!", "$", "this", "->", "config", "[", "'suffix'", "]", ")", "{", "return", "$", "string", ";", "}", "if", "(", "$", "direction", ">", "0", ")", "{", "return", "sprintf", "(", "$", "lang", "[", "'ago'", "]", ",", "$", "string", ")", ";", "}", "else", "{", "return", "sprintf", "(", "$", "lang", "[", "'left'", "]", ",", "$", "string", ")", ";", "}", "}" ]
Actually translates the units into words @param array $units @param int $direction @return string
[ "Actually", "translates", "the", "units", "into", "words" ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/Translation.php#L53-L79
232,729
mpratt/RelativeTime
Lib/RelativeTime/Translation.php
Translation.LoadLanguage
protected function LoadLanguage() { if (is_object($this->config['language'])) { $l = $this->config['language']; } else { $languages = array( $this->config['language'], '\RelativeTime\Languages\\' . $this->config['language'], ); $l = null; foreach ($languages as $lang) { if (class_exists($lang)) { $l = new $lang(); break; } } } if ($l instanceof ArrayAccess) { return $l; } return new English(); }
php
protected function LoadLanguage() { if (is_object($this->config['language'])) { $l = $this->config['language']; } else { $languages = array( $this->config['language'], '\RelativeTime\Languages\\' . $this->config['language'], ); $l = null; foreach ($languages as $lang) { if (class_exists($lang)) { $l = new $lang(); break; } } } if ($l instanceof ArrayAccess) { return $l; } return new English(); }
[ "protected", "function", "LoadLanguage", "(", ")", "{", "if", "(", "is_object", "(", "$", "this", "->", "config", "[", "'language'", "]", ")", ")", "{", "$", "l", "=", "$", "this", "->", "config", "[", "'language'", "]", ";", "}", "else", "{", "$", "languages", "=", "array", "(", "$", "this", "->", "config", "[", "'language'", "]", ",", "'\\RelativeTime\\Languages\\\\'", ".", "$", "this", "->", "config", "[", "'language'", "]", ",", ")", ";", "$", "l", "=", "null", ";", "foreach", "(", "$", "languages", "as", "$", "lang", ")", "{", "if", "(", "class_exists", "(", "$", "lang", ")", ")", "{", "$", "l", "=", "new", "$", "lang", "(", ")", ";", "break", ";", "}", "}", "}", "if", "(", "$", "l", "instanceof", "ArrayAccess", ")", "{", "return", "$", "l", ";", "}", "return", "new", "English", "(", ")", ";", "}" ]
Loads the language definitions @return ArrayAccess
[ "Loads", "the", "language", "definitions" ]
cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5
https://github.com/mpratt/RelativeTime/blob/cee7b9b8bdbf05a0b96e9bda58501e5ca6e1dfa5/Lib/RelativeTime/Translation.php#L86-L110
232,730
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.getUsedQuotaMB
public function getUsedQuotaMB($round = 2) { $size = 0; foreach($this->Environments() as $environment) { foreach($environment->DataArchives()->filter('IsBackup', 0) as $archive) { $size += $archive->ArchiveFile()->getAbsoluteSize(); } } // convert bytes to megabytes and round return round(($size / 1024) / 1024, $round); }
php
public function getUsedQuotaMB($round = 2) { $size = 0; foreach($this->Environments() as $environment) { foreach($environment->DataArchives()->filter('IsBackup', 0) as $archive) { $size += $archive->ArchiveFile()->getAbsoluteSize(); } } // convert bytes to megabytes and round return round(($size / 1024) / 1024, $round); }
[ "public", "function", "getUsedQuotaMB", "(", "$", "round", "=", "2", ")", "{", "$", "size", "=", "0", ";", "foreach", "(", "$", "this", "->", "Environments", "(", ")", "as", "$", "environment", ")", "{", "foreach", "(", "$", "environment", "->", "DataArchives", "(", ")", "->", "filter", "(", "'IsBackup'", ",", "0", ")", "as", "$", "archive", ")", "{", "$", "size", "+=", "$", "archive", "->", "ArchiveFile", "(", ")", "->", "getAbsoluteSize", "(", ")", ";", "}", "}", "// convert bytes to megabytes and round", "return", "round", "(", "(", "$", "size", "/", "1024", ")", "/", "1024", ",", "$", "round", ")", ";", "}" ]
Return the used quota in MB. @param mixed $round Number of decimal places to round to @return string|int The used quota size in MB
[ "Return", "the", "used", "quota", "in", "MB", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L103-L114
232,731
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.getDiskQuotaMB
public function getDiskQuotaMB() { $size = $this->getField('DiskQuotaMB'); if(empty($size)) { $defaults = $this->config()->get('defaults'); $size = (isset($defaults['DiskQuotaMB'])) ? $defaults['DiskQuotaMB'] : 0; } return $size; }
php
public function getDiskQuotaMB() { $size = $this->getField('DiskQuotaMB'); if(empty($size)) { $defaults = $this->config()->get('defaults'); $size = (isset($defaults['DiskQuotaMB'])) ? $defaults['DiskQuotaMB'] : 0; } return $size; }
[ "public", "function", "getDiskQuotaMB", "(", ")", "{", "$", "size", "=", "$", "this", "->", "getField", "(", "'DiskQuotaMB'", ")", ";", "if", "(", "empty", "(", "$", "size", ")", ")", "{", "$", "defaults", "=", "$", "this", "->", "config", "(", ")", "->", "get", "(", "'defaults'", ")", ";", "$", "size", "=", "(", "isset", "(", "$", "defaults", "[", "'DiskQuotaMB'", "]", ")", ")", "?", "$", "defaults", "[", "'DiskQuotaMB'", "]", ":", "0", ";", "}", "return", "$", "size", ";", "}" ]
Getter for DiskQuotaMB field to provide a default for existing records that have no quota field set, as it will need to default to a globally set size. @return string|int The quota size in MB
[ "Getter", "for", "DiskQuotaMB", "field", "to", "provide", "a", "default", "for", "existing", "records", "that", "have", "no", "quota", "field", "set", "as", "it", "will", "need", "to", "default", "to", "a", "globally", "set", "size", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L123-L132
232,732
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.Menu
public function Menu() { $list = new ArrayList(); $list->push(new ArrayData(array( 'Link' => sprintf('naut/project/%s', $this->Name), 'Title' => 'Deploy', 'IsActive' => Controller::curr()->getAction() == 'project' ))); if(DNRoot::FlagSnapshotsEnabled()) { $list->push(new ArrayData(array( 'Link' => sprintf('naut/project/%s/snapshots', $this->Name), 'Title' => 'Snapshots', 'IsActive' => Controller::curr()->getAction() == 'snapshots' ))); } $this->extend('updateMenu', $list); return $list; }
php
public function Menu() { $list = new ArrayList(); $list->push(new ArrayData(array( 'Link' => sprintf('naut/project/%s', $this->Name), 'Title' => 'Deploy', 'IsActive' => Controller::curr()->getAction() == 'project' ))); if(DNRoot::FlagSnapshotsEnabled()) { $list->push(new ArrayData(array( 'Link' => sprintf('naut/project/%s/snapshots', $this->Name), 'Title' => 'Snapshots', 'IsActive' => Controller::curr()->getAction() == 'snapshots' ))); } $this->extend('updateMenu', $list); return $list; }
[ "public", "function", "Menu", "(", ")", "{", "$", "list", "=", "new", "ArrayList", "(", ")", ";", "$", "list", "->", "push", "(", "new", "ArrayData", "(", "array", "(", "'Link'", "=>", "sprintf", "(", "'naut/project/%s'", ",", "$", "this", "->", "Name", ")", ",", "'Title'", "=>", "'Deploy'", ",", "'IsActive'", "=>", "Controller", "::", "curr", "(", ")", "->", "getAction", "(", ")", "==", "'project'", ")", ")", ")", ";", "if", "(", "DNRoot", "::", "FlagSnapshotsEnabled", "(", ")", ")", "{", "$", "list", "->", "push", "(", "new", "ArrayData", "(", "array", "(", "'Link'", "=>", "sprintf", "(", "'naut/project/%s/snapshots'", ",", "$", "this", "->", "Name", ")", ",", "'Title'", "=>", "'Snapshots'", ",", "'IsActive'", "=>", "Controller", "::", "curr", "(", ")", "->", "getAction", "(", ")", "==", "'snapshots'", ")", ")", ")", ";", "}", "$", "this", "->", "extend", "(", "'updateMenu'", ",", "$", "list", ")", ";", "return", "$", "list", ";", "}" ]
Get the menu to be shown on projects @return ArrayList
[ "Get", "the", "menu", "to", "be", "shown", "on", "projects" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L155-L175
232,733
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.canView
public function canView($member = null) { if(!$member) $member = Member::currentUser(); if(Permission::checkMember($member, 'ADMIN')) return true; return $member->inGroups($this->Viewers()); }
php
public function canView($member = null) { if(!$member) $member = Member::currentUser(); if(Permission::checkMember($member, 'ADMIN')) return true; return $member->inGroups($this->Viewers()); }
[ "public", "function", "canView", "(", "$", "member", "=", "null", ")", "{", "if", "(", "!", "$", "member", ")", "$", "member", "=", "Member", "::", "currentUser", "(", ")", ";", "if", "(", "Permission", "::", "checkMember", "(", "$", "member", ",", "'ADMIN'", ")", ")", "return", "true", ";", "return", "$", "member", "->", "inGroups", "(", "$", "this", "->", "Viewers", "(", ")", ")", ";", "}" ]
Restrict access to viewing this project @param Member $member @return boolean
[ "Restrict", "access", "to", "viewing", "this", "project" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L183-L189
232,734
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.getProcessEnv
public function getProcessEnv() { if (file_exists($this->getPrivateKeyPath())) { // Key-pair is available, use it. $processEnv = array( 'IDENT_KEY' => $this->getPrivateKeyPath(), 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" ); } else { $processEnv = array(); } $this->extend('updateProcessEnv', $processEnv); return $processEnv; }
php
public function getProcessEnv() { if (file_exists($this->getPrivateKeyPath())) { // Key-pair is available, use it. $processEnv = array( 'IDENT_KEY' => $this->getPrivateKeyPath(), 'GIT_SSH' => BASE_PATH . "/deploynaut/git-deploy.sh" ); } else { $processEnv = array(); } $this->extend('updateProcessEnv', $processEnv); return $processEnv; }
[ "public", "function", "getProcessEnv", "(", ")", "{", "if", "(", "file_exists", "(", "$", "this", "->", "getPrivateKeyPath", "(", ")", ")", ")", "{", "// Key-pair is available, use it.", "$", "processEnv", "=", "array", "(", "'IDENT_KEY'", "=>", "$", "this", "->", "getPrivateKeyPath", "(", ")", ",", "'GIT_SSH'", "=>", "BASE_PATH", ".", "\"/deploynaut/git-deploy.sh\"", ")", ";", "}", "else", "{", "$", "processEnv", "=", "array", "(", ")", ";", "}", "$", "this", "->", "extend", "(", "'updateProcessEnv'", ",", "$", "processEnv", ")", ";", "return", "$", "processEnv", ";", "}" ]
Build an environment variable array to be used with this project. This is relevant if every project needs to use an individual SSH pubkey. Include this with all Gitonomy\Git\Repository, and \Symfony\Component\Process\Processes. @return array
[ "Build", "an", "environment", "variable", "array", "to", "be", "used", "with", "this", "project", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L240-L252
232,735
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.DNBranchList
public function DNBranchList() { if($this->CVSPath && !$this->repoExists()) { $this->cloneRepo(); } return DNBranchList::create($this, $this->DNData()); }
php
public function DNBranchList() { if($this->CVSPath && !$this->repoExists()) { $this->cloneRepo(); } return DNBranchList::create($this, $this->DNData()); }
[ "public", "function", "DNBranchList", "(", ")", "{", "if", "(", "$", "this", "->", "CVSPath", "&&", "!", "$", "this", "->", "repoExists", "(", ")", ")", "{", "$", "this", "->", "cloneRepo", "(", ")", ";", "}", "return", "DNBranchList", "::", "create", "(", "$", "this", ",", "$", "this", "->", "DNData", "(", ")", ")", ";", "}" ]
Provides a list of the branches in this project.
[ "Provides", "a", "list", "of", "the", "branches", "in", "this", "project", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L282-L287
232,736
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.DNTagList
public function DNTagList() { if($this->CVSPath && !$this->repoExists()) { $this->cloneRepo(); } return DNReferenceList::create($this, $this->DNData(), null, null, true); }
php
public function DNTagList() { if($this->CVSPath && !$this->repoExists()) { $this->cloneRepo(); } return DNReferenceList::create($this, $this->DNData(), null, null, true); }
[ "public", "function", "DNTagList", "(", ")", "{", "if", "(", "$", "this", "->", "CVSPath", "&&", "!", "$", "this", "->", "repoExists", "(", ")", ")", "{", "$", "this", "->", "cloneRepo", "(", ")", ";", "}", "return", "DNReferenceList", "::", "create", "(", "$", "this", ",", "$", "this", "->", "DNData", "(", ")", ",", "null", ",", "null", ",", "true", ")", ";", "}" ]
Provides a list of the tags in this project.
[ "Provides", "a", "list", "of", "the", "tags", "in", "this", "project", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L292-L297
232,737
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.currentBuilds
public function currentBuilds() { if(!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { $currentBuilds = array(); foreach($this->Environments() as $env) { $currentBuilds[$env->Name] = $env->CurrentBuild(); } self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; } return self::$relation_cache['currentBuilds.'.$this->ID]; }
php
public function currentBuilds() { if(!isset(self::$relation_cache['currentBuilds.'.$this->ID])) { $currentBuilds = array(); foreach($this->Environments() as $env) { $currentBuilds[$env->Name] = $env->CurrentBuild(); } self::$relation_cache['currentBuilds.'.$this->ID] = $currentBuilds; } return self::$relation_cache['currentBuilds.'.$this->ID]; }
[ "public", "function", "currentBuilds", "(", ")", "{", "if", "(", "!", "isset", "(", "self", "::", "$", "relation_cache", "[", "'currentBuilds.'", ".", "$", "this", "->", "ID", "]", ")", ")", "{", "$", "currentBuilds", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "Environments", "(", ")", "as", "$", "env", ")", "{", "$", "currentBuilds", "[", "$", "env", "->", "Name", "]", "=", "$", "env", "->", "CurrentBuild", "(", ")", ";", "}", "self", "::", "$", "relation_cache", "[", "'currentBuilds.'", ".", "$", "this", "->", "ID", "]", "=", "$", "currentBuilds", ";", "}", "return", "self", "::", "$", "relation_cache", "[", "'currentBuilds.'", ".", "$", "this", "->", "ID", "]", ";", "}" ]
Returns a map of envrionment name to build name
[ "Returns", "a", "map", "of", "envrionment", "name", "to", "build", "name" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L326-L335
232,738
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.setCreateProjectFolderField
public function setCreateProjectFolderField(&$fields) { // Check if the capistrano project folder exists if(!$this->Name) { return; } if($this->projectFolderExists()) { return; } $createFolderNotice = new LabelField('CreateEnvFolderNotice', 'Warning: No Capistrano project folder exists'); $createFolderNotice->addExtraClass('message warning'); $fields->insertBefore($createFolderNotice, 'Name'); $createFolderField = new CheckboxField('CreateEnvFolder', 'Create folder'); $createFolderField->setDescription('Would you like to create the capistrano project folder?'); $fields->insertAfter($createFolderField, 'CreateEnvFolderNotice'); }
php
public function setCreateProjectFolderField(&$fields) { // Check if the capistrano project folder exists if(!$this->Name) { return; } if($this->projectFolderExists()) { return; } $createFolderNotice = new LabelField('CreateEnvFolderNotice', 'Warning: No Capistrano project folder exists'); $createFolderNotice->addExtraClass('message warning'); $fields->insertBefore($createFolderNotice, 'Name'); $createFolderField = new CheckboxField('CreateEnvFolder', 'Create folder'); $createFolderField->setDescription('Would you like to create the capistrano project folder?'); $fields->insertAfter($createFolderField, 'CreateEnvFolderNotice'); }
[ "public", "function", "setCreateProjectFolderField", "(", "&", "$", "fields", ")", "{", "// Check if the capistrano project folder exists", "if", "(", "!", "$", "this", "->", "Name", ")", "{", "return", ";", "}", "if", "(", "$", "this", "->", "projectFolderExists", "(", ")", ")", "{", "return", ";", "}", "$", "createFolderNotice", "=", "new", "LabelField", "(", "'CreateEnvFolderNotice'", ",", "'Warning: No Capistrano project folder exists'", ")", ";", "$", "createFolderNotice", "->", "addExtraClass", "(", "'message warning'", ")", ";", "$", "fields", "->", "insertBefore", "(", "$", "createFolderNotice", ",", "'Name'", ")", ";", "$", "createFolderField", "=", "new", "CheckboxField", "(", "'CreateEnvFolder'", ",", "'Create folder'", ")", ";", "$", "createFolderField", "->", "setDescription", "(", "'Would you like to create the capistrano project folder?'", ")", ";", "$", "fields", "->", "insertAfter", "(", "$", "createFolderField", ",", "'CreateEnvFolderNotice'", ")", ";", "}" ]
If there isn't a capistrano env project folder, show options to create one @param FieldList $fields
[ "If", "there", "isn", "t", "a", "capistrano", "env", "project", "folder", "show", "options", "to", "create", "one" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L397-L413
232,739
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.checkProjectPath
protected function checkProjectPath() { // Create the project capistrano folder if($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) { mkdir($this->DNData()->getEnvironmentDir().'/'.$this->Name); } }
php
protected function checkProjectPath() { // Create the project capistrano folder if($this->CreateEnvFolder && !file_exists($this->getProjectFolderPath())) { mkdir($this->DNData()->getEnvironmentDir().'/'.$this->Name); } }
[ "protected", "function", "checkProjectPath", "(", ")", "{", "// Create the project capistrano folder", "if", "(", "$", "this", "->", "CreateEnvFolder", "&&", "!", "file_exists", "(", "$", "this", "->", "getProjectFolderPath", "(", ")", ")", ")", "{", "mkdir", "(", "$", "this", "->", "DNData", "(", ")", "->", "getEnvironmentDir", "(", ")", ".", "'/'", ".", "$", "this", "->", "Name", ")", ";", "}", "}" ]
Ensure the path for this project has been created
[ "Ensure", "the", "path", "for", "this", "project", "has", "been", "created" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L468-L473
232,740
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.checkCVSPath
protected function checkCVSPath() { $changedFields = $this->getChangedFields(true, 2); if (!$this->CVSPath) { return; } if (isset($changedFields['CVSPath']) || isset($changedFields['Name'])) { $this->cloneRepo(); } }
php
protected function checkCVSPath() { $changedFields = $this->getChangedFields(true, 2); if (!$this->CVSPath) { return; } if (isset($changedFields['CVSPath']) || isset($changedFields['Name'])) { $this->cloneRepo(); } }
[ "protected", "function", "checkCVSPath", "(", ")", "{", "$", "changedFields", "=", "$", "this", "->", "getChangedFields", "(", "true", ",", "2", ")", ";", "if", "(", "!", "$", "this", "->", "CVSPath", ")", "{", "return", ";", "}", "if", "(", "isset", "(", "$", "changedFields", "[", "'CVSPath'", "]", ")", "||", "isset", "(", "$", "changedFields", "[", "'Name'", "]", ")", ")", "{", "$", "this", "->", "cloneRepo", "(", ")", ";", "}", "}" ]
Check if the CVSPath has been changed, and if so, ensure the repository has been updated
[ "Check", "if", "the", "CVSPath", "has", "been", "changed", "and", "if", "so", "ensure", "the", "repository", "has", "been", "updated" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L478-L486
232,741
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.onAfterDelete
public function onAfterDelete() { parent::onAfterDelete(); // Delete related environments foreach($this->Environments() as $env) { $env->delete(); } if(!file_exists($this->getProjectFolderPath())) { return; } // Create a basic new environment config from a template if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) { FileSystem::removeFolder($this->getProjectFolderPath()); } }
php
public function onAfterDelete() { parent::onAfterDelete(); // Delete related environments foreach($this->Environments() as $env) { $env->delete(); } if(!file_exists($this->getProjectFolderPath())) { return; } // Create a basic new environment config from a template if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) { FileSystem::removeFolder($this->getProjectFolderPath()); } }
[ "public", "function", "onAfterDelete", "(", ")", "{", "parent", "::", "onAfterDelete", "(", ")", ";", "// Delete related environments", "foreach", "(", "$", "this", "->", "Environments", "(", ")", "as", "$", "env", ")", "{", "$", "env", "->", "delete", "(", ")", ";", "}", "if", "(", "!", "file_exists", "(", "$", "this", "->", "getProjectFolderPath", "(", ")", ")", ")", "{", "return", ";", "}", "// Create a basic new environment config from a template", "if", "(", "Config", "::", "inst", "(", ")", "->", "get", "(", "'DNEnvironment'", ",", "'allow_web_editing'", ")", ")", "{", "FileSystem", "::", "removeFolder", "(", "$", "this", "->", "getProjectFolderPath", "(", ")", ")", ";", "}", "}" ]
Delete related environments and folders
[ "Delete", "related", "environments", "and", "folders" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L491-L506
232,742
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.getPrivateKeyPath
public function getPrivateKeyPath() { if($keyDir = $this->getKeyDir()) { $filter = FileNameFilter::create(); $name = $filter->filter($this->Name); return $this->getKeyDir() . '/' . $name; } return null; }
php
public function getPrivateKeyPath() { if($keyDir = $this->getKeyDir()) { $filter = FileNameFilter::create(); $name = $filter->filter($this->Name); return $this->getKeyDir() . '/' . $name; } return null; }
[ "public", "function", "getPrivateKeyPath", "(", ")", "{", "if", "(", "$", "keyDir", "=", "$", "this", "->", "getKeyDir", "(", ")", ")", "{", "$", "filter", "=", "FileNameFilter", "::", "create", "(", ")", ";", "$", "name", "=", "$", "filter", "->", "filter", "(", "$", "this", "->", "Name", ")", ";", "return", "$", "this", "->", "getKeyDir", "(", ")", ".", "'/'", ".", "$", "name", ";", "}", "return", "null", ";", "}" ]
This returns that path of the private key if a key directory is set. It doesn't check whether the file exists. @return string|null
[ "This", "returns", "that", "path", "of", "the", "private", "key", "if", "a", "key", "directory", "is", "set", ".", "It", "doesn", "t", "check", "whether", "the", "file", "exists", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L538-L546
232,743
silverstripe-archive/deploynaut
code/model/DNProject.php
DNProject.setEnvironmentFields
protected function setEnvironmentFields(&$fields, $environments) { if(!$environments) { return; } $environments->getConfig()->addComponent(new GridFieldAddNewMultiClass()); $environments->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $environments->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter'); $environments->getConfig()->removeComponentsByType('GridFieldDeleteAction'); $environments->getConfig()->removeComponentsByType('GridFieldPageCount'); if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) { $addNewRelease = new GridFieldAddNewButton('toolbar-header-right'); $addNewRelease->setButtonName('Add'); $environments->getConfig()->addComponent($addNewRelease); } $fields->addFieldToTab("Root.Main", $environments); }
php
protected function setEnvironmentFields(&$fields, $environments) { if(!$environments) { return; } $environments->getConfig()->addComponent(new GridFieldAddNewMultiClass()); $environments->getConfig()->removeComponentsByType('GridFieldAddNewButton'); $environments->getConfig()->removeComponentsByType('GridFieldAddExistingAutocompleter'); $environments->getConfig()->removeComponentsByType('GridFieldDeleteAction'); $environments->getConfig()->removeComponentsByType('GridFieldPageCount'); if(Config::inst()->get('DNEnvironment', 'allow_web_editing')) { $addNewRelease = new GridFieldAddNewButton('toolbar-header-right'); $addNewRelease->setButtonName('Add'); $environments->getConfig()->addComponent($addNewRelease); } $fields->addFieldToTab("Root.Main", $environments); }
[ "protected", "function", "setEnvironmentFields", "(", "&", "$", "fields", ",", "$", "environments", ")", "{", "if", "(", "!", "$", "environments", ")", "{", "return", ";", "}", "$", "environments", "->", "getConfig", "(", ")", "->", "addComponent", "(", "new", "GridFieldAddNewMultiClass", "(", ")", ")", ";", "$", "environments", "->", "getConfig", "(", ")", "->", "removeComponentsByType", "(", "'GridFieldAddNewButton'", ")", ";", "$", "environments", "->", "getConfig", "(", ")", "->", "removeComponentsByType", "(", "'GridFieldAddExistingAutocompleter'", ")", ";", "$", "environments", "->", "getConfig", "(", ")", "->", "removeComponentsByType", "(", "'GridFieldDeleteAction'", ")", ";", "$", "environments", "->", "getConfig", "(", ")", "->", "removeComponentsByType", "(", "'GridFieldPageCount'", ")", ";", "if", "(", "Config", "::", "inst", "(", ")", "->", "get", "(", "'DNEnvironment'", ",", "'allow_web_editing'", ")", ")", "{", "$", "addNewRelease", "=", "new", "GridFieldAddNewButton", "(", "'toolbar-header-right'", ")", ";", "$", "addNewRelease", "->", "setButtonName", "(", "'Add'", ")", ";", "$", "environments", "->", "getConfig", "(", ")", "->", "addComponent", "(", "$", "addNewRelease", ")", ";", "}", "$", "fields", "->", "addFieldToTab", "(", "\"Root.Main\"", ",", "$", "environments", ")", ";", "}" ]
Setup a gridfield for the environment configs @param FieldList $fields @param $environments @return void
[ "Setup", "a", "gridfield", "for", "the", "environment", "configs" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNProject.php#L571-L588
232,744
bav-php/bav
classes/dataBackend/pdo/PDODataBackend.php
PDODataBackend.isInstalled
public function isInstalled() { try { switch ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { case "sqlite": $query = "SELECT count(*) FROM sqlite_master WHERE type='table' AND name = '{$this->prefix}meta'"; break; default: $query = "SELECT CASE WHEN EXISTS( (SELECT * FROM information_schema.tables WHERE table_name='{$this->prefix}meta') ) THEN 1 ELSE 0 END"; break; } $stmt = $this->statementContainer->prepare($query); $stmt->execute(); $result = $stmt->fetch(); if ($result === false) { throw new DataBackendException(); } $stmt->closeCursor(); return $result[0] == 1; } catch (\PDOException $e) { $stmt->closeCursor(); throw new DataBackendIOException($e->getMessage(), 0, $e); } }
php
public function isInstalled() { try { switch ($this->pdo->getAttribute(\PDO::ATTR_DRIVER_NAME)) { case "sqlite": $query = "SELECT count(*) FROM sqlite_master WHERE type='table' AND name = '{$this->prefix}meta'"; break; default: $query = "SELECT CASE WHEN EXISTS( (SELECT * FROM information_schema.tables WHERE table_name='{$this->prefix}meta') ) THEN 1 ELSE 0 END"; break; } $stmt = $this->statementContainer->prepare($query); $stmt->execute(); $result = $stmt->fetch(); if ($result === false) { throw new DataBackendException(); } $stmt->closeCursor(); return $result[0] == 1; } catch (\PDOException $e) { $stmt->closeCursor(); throw new DataBackendIOException($e->getMessage(), 0, $e); } }
[ "public", "function", "isInstalled", "(", ")", "{", "try", "{", "switch", "(", "$", "this", "->", "pdo", "->", "getAttribute", "(", "\\", "PDO", "::", "ATTR_DRIVER_NAME", ")", ")", "{", "case", "\"sqlite\"", ":", "$", "query", "=", "\"SELECT count(*) FROM sqlite_master\n WHERE type='table' AND name = '{$this->prefix}meta'\"", ";", "break", ";", "default", ":", "$", "query", "=", "\"SELECT CASE WHEN EXISTS(\n (SELECT * FROM information_schema.tables\n WHERE table_name='{$this->prefix}meta')\n ) THEN 1 ELSE 0 END\"", ";", "break", ";", "}", "$", "stmt", "=", "$", "this", "->", "statementContainer", "->", "prepare", "(", "$", "query", ")", ";", "$", "stmt", "->", "execute", "(", ")", ";", "$", "result", "=", "$", "stmt", "->", "fetch", "(", ")", ";", "if", "(", "$", "result", "===", "false", ")", "{", "throw", "new", "DataBackendException", "(", ")", ";", "}", "$", "stmt", "->", "closeCursor", "(", ")", ";", "return", "$", "result", "[", "0", "]", "==", "1", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "stmt", "->", "closeCursor", "(", ")", ";", "throw", "new", "DataBackendIOException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns true if the backend was installed. @return bool @throws DataBackendException
[ "Returns", "true", "if", "the", "backend", "was", "installed", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/dataBackend/pdo/PDODataBackend.php#L538-L573
232,745
bav-php/bav
classes/dataBackend/pdo/PDODataBackend.php
PDODataBackend.isValidBIC
public function isValidBIC($bic) { try { $stmt = $this->statementContainer->prepare( "SELECT bic FROM {$this->prefix}agency WHERE bic = :bic GROUP BY (bic)" ); $stmt->execute(array(":bic" => $bic)); $rows = $stmt->fetchAll(); return ! empty($rows); } catch (\PDOException $e) { $stmt->closeCursor(); throw new DataBackendIOException($e->getMessage(), 0, $e); } }
php
public function isValidBIC($bic) { try { $stmt = $this->statementContainer->prepare( "SELECT bic FROM {$this->prefix}agency WHERE bic = :bic GROUP BY (bic)" ); $stmt->execute(array(":bic" => $bic)); $rows = $stmt->fetchAll(); return ! empty($rows); } catch (\PDOException $e) { $stmt->closeCursor(); throw new DataBackendIOException($e->getMessage(), 0, $e); } }
[ "public", "function", "isValidBIC", "(", "$", "bic", ")", "{", "try", "{", "$", "stmt", "=", "$", "this", "->", "statementContainer", "->", "prepare", "(", "\"SELECT bic FROM {$this->prefix}agency WHERE bic = :bic GROUP BY (bic)\"", ")", ";", "$", "stmt", "->", "execute", "(", "array", "(", "\":bic\"", "=>", "$", "bic", ")", ")", ";", "$", "rows", "=", "$", "stmt", "->", "fetchAll", "(", ")", ";", "return", "!", "empty", "(", "$", "rows", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "stmt", "->", "closeCursor", "(", ")", ";", "throw", "new", "DataBackendIOException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "0", ",", "$", "e", ")", ";", "}", "}" ]
Returns if a bic is valid. @param string $bic BIC @return bool
[ "Returns", "if", "a", "bic", "is", "valid", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/dataBackend/pdo/PDODataBackend.php#L581-L597
232,746
networkteam/Networkteam.SentryClient
Classes/Context/PartyUserContext.php
PartyUserContext.getUserContext
public function getUserContext(Context $securityContext) { $account = $securityContext->getAccount(); if ($account) { $party = $this->partyRepository->findOneHavingAccount($account); $userContext = []; if ($party instanceof Person && $party->getPrimaryElectronicAddress() !== null) { $userContext['email'] = (string)$party->getPrimaryElectronicAddress(); } elseif ($party !== null && ObjectAccess::isPropertyGettable($party, 'emailAddress')) { $userContext['email'] = (string)ObjectAccess::getProperty($party, 'emailAddress'); } return $userContext; } return []; }
php
public function getUserContext(Context $securityContext) { $account = $securityContext->getAccount(); if ($account) { $party = $this->partyRepository->findOneHavingAccount($account); $userContext = []; if ($party instanceof Person && $party->getPrimaryElectronicAddress() !== null) { $userContext['email'] = (string)$party->getPrimaryElectronicAddress(); } elseif ($party !== null && ObjectAccess::isPropertyGettable($party, 'emailAddress')) { $userContext['email'] = (string)ObjectAccess::getProperty($party, 'emailAddress'); } return $userContext; } return []; }
[ "public", "function", "getUserContext", "(", "Context", "$", "securityContext", ")", "{", "$", "account", "=", "$", "securityContext", "->", "getAccount", "(", ")", ";", "if", "(", "$", "account", ")", "{", "$", "party", "=", "$", "this", "->", "partyRepository", "->", "findOneHavingAccount", "(", "$", "account", ")", ";", "$", "userContext", "=", "[", "]", ";", "if", "(", "$", "party", "instanceof", "Person", "&&", "$", "party", "->", "getPrimaryElectronicAddress", "(", ")", "!==", "null", ")", "{", "$", "userContext", "[", "'email'", "]", "=", "(", "string", ")", "$", "party", "->", "getPrimaryElectronicAddress", "(", ")", ";", "}", "elseif", "(", "$", "party", "!==", "null", "&&", "ObjectAccess", "::", "isPropertyGettable", "(", "$", "party", ",", "'emailAddress'", ")", ")", "{", "$", "userContext", "[", "'email'", "]", "=", "(", "string", ")", "ObjectAccess", "::", "getProperty", "(", "$", "party", ",", "'emailAddress'", ")", ";", "}", "return", "$", "userContext", ";", "}", "return", "[", "]", ";", "}" ]
Returns ContextData to be added to the sentry entry @param Context $securityContext @return array
[ "Returns", "ContextData", "to", "be", "added", "to", "the", "sentry", "entry" ]
ad5f7e0e32b0fd11da21b3e37a1ae8dc5e6c2cbc
https://github.com/networkteam/Networkteam.SentryClient/blob/ad5f7e0e32b0fd11da21b3e37a1ae8dc5e6c2cbc/Classes/Context/PartyUserContext.php#L25-L41
232,747
tedslittlerobot/html-table-builder
src/Elements/Cells/ContentCell.php
ContentCell.wrapContent
public function wrapContent(string $opening, string $content, string $closing) : ContentCell { $this->content = $opening . helpers\e($content) . $closing; return $this->raw(); }
php
public function wrapContent(string $opening, string $content, string $closing) : ContentCell { $this->content = $opening . helpers\e($content) . $closing; return $this->raw(); }
[ "public", "function", "wrapContent", "(", "string", "$", "opening", ",", "string", "$", "content", ",", "string", "$", "closing", ")", ":", "ContentCell", "{", "$", "this", "->", "content", "=", "$", "opening", ".", "helpers", "\\", "e", "(", "$", "content", ")", ".", "$", "closing", ";", "return", "$", "this", "->", "raw", "(", ")", ";", "}" ]
Set the cell's content, wrapping it in some html @param string $opening @param string $content @param string $closing @return \Tlr\Tables\Elements\ContentCell
[ "Set", "the", "cell", "s", "content", "wrapping", "it", "in", "some", "html" ]
12597f8c44dde9f002c74b0aeadefec2bdb2eafa
https://github.com/tedslittlerobot/html-table-builder/blob/12597f8c44dde9f002c74b0aeadefec2bdb2eafa/src/Elements/Cells/ContentCell.php#L46-L51
232,748
tedslittlerobot/html-table-builder
src/Elements/Cells/ContentCell.php
ContentCell.getContent
public function getContent() : string { return $this->escape ? helpers\e($this->content) : $this->content; }
php
public function getContent() : string { return $this->escape ? helpers\e($this->content) : $this->content; }
[ "public", "function", "getContent", "(", ")", ":", "string", "{", "return", "$", "this", "->", "escape", "?", "helpers", "\\", "e", "(", "$", "this", "->", "content", ")", ":", "$", "this", "->", "content", ";", "}" ]
Get the cell content @return string
[ "Get", "the", "cell", "content" ]
12597f8c44dde9f002c74b0aeadefec2bdb2eafa
https://github.com/tedslittlerobot/html-table-builder/blob/12597f8c44dde9f002c74b0aeadefec2bdb2eafa/src/Elements/Cells/ContentCell.php#L93-L96
232,749
asinfotrack/yii2-toolbox
console/ConsoleTarget.php
ConsoleTarget.formatLine
public function formatLine($text, $level, $category, $timestamp) { return sprintf( "%-19s [%-7s] [%s]\n %s", Yii::$app->formatter->asDatetime($timestamp, 'php:d.m.Y H:i:s'), strtoupper(Logger::getLevelName($level)), $category, $text ); }
php
public function formatLine($text, $level, $category, $timestamp) { return sprintf( "%-19s [%-7s] [%s]\n %s", Yii::$app->formatter->asDatetime($timestamp, 'php:d.m.Y H:i:s'), strtoupper(Logger::getLevelName($level)), $category, $text ); }
[ "public", "function", "formatLine", "(", "$", "text", ",", "$", "level", ",", "$", "category", ",", "$", "timestamp", ")", "{", "return", "sprintf", "(", "\"%-19s [%-7s] [%s]\\n %s\"", ",", "Yii", "::", "$", "app", "->", "formatter", "->", "asDatetime", "(", "$", "timestamp", ",", "'php:d.m.Y H:i:s'", ")", ",", "strtoupper", "(", "Logger", "::", "getLevelName", "(", "$", "level", ")", ")", ",", "$", "category", ",", "$", "text", ")", ";", "}" ]
Default line formatting @param string $text the actual log-text @param integer $level the log level @param string $category the log category @param integer $timestamp the events timestamp @return string the formatted line
[ "Default", "line", "formatting" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/console/ConsoleTarget.php#L71-L80
232,750
Zeindelf/badwords
src/Badwords.php
Badwords.verify
public static function verify($string, array $extra = null) { require_once __DIR__ . '/Config/Filter.php'; $string = static::doubleChars($string); $getFilter = Config::get('filter'); if ( !is_null($extra) ) { if ( array_key_exists('badwords', $extra) ) { $getFilter = array_merge($extra['badwords'], $getFilter); } if ( array_key_exists('ignored', $extra) ) { for ( $i = 0; $i < count($extra['ignored']); $i++ ) { $extra['ignored'][$i] = static::doubleChars($extra['ignored'][$i]); } for ( $i = 0; $i < count($getFilter); $i++ ) { foreach ( $extra['ignored'] as $ignored ) { if ( is_int(strripos($ignored, $getFilter[$i])) ) { $arr[] = $i; } } } if ( isset($arr) ) { foreach ( $arr as $a ) { unset($getFilter[$a]); } } } } foreach ( $getFilter as $filter ) { if ( is_int(strripos($string, $filter)) ) { return true; } } return false; }
php
public static function verify($string, array $extra = null) { require_once __DIR__ . '/Config/Filter.php'; $string = static::doubleChars($string); $getFilter = Config::get('filter'); if ( !is_null($extra) ) { if ( array_key_exists('badwords', $extra) ) { $getFilter = array_merge($extra['badwords'], $getFilter); } if ( array_key_exists('ignored', $extra) ) { for ( $i = 0; $i < count($extra['ignored']); $i++ ) { $extra['ignored'][$i] = static::doubleChars($extra['ignored'][$i]); } for ( $i = 0; $i < count($getFilter); $i++ ) { foreach ( $extra['ignored'] as $ignored ) { if ( is_int(strripos($ignored, $getFilter[$i])) ) { $arr[] = $i; } } } if ( isset($arr) ) { foreach ( $arr as $a ) { unset($getFilter[$a]); } } } } foreach ( $getFilter as $filter ) { if ( is_int(strripos($string, $filter)) ) { return true; } } return false; }
[ "public", "static", "function", "verify", "(", "$", "string", ",", "array", "$", "extra", "=", "null", ")", "{", "require_once", "__DIR__", ".", "'/Config/Filter.php'", ";", "$", "string", "=", "static", "::", "doubleChars", "(", "$", "string", ")", ";", "$", "getFilter", "=", "Config", "::", "get", "(", "'filter'", ")", ";", "if", "(", "!", "is_null", "(", "$", "extra", ")", ")", "{", "if", "(", "array_key_exists", "(", "'badwords'", ",", "$", "extra", ")", ")", "{", "$", "getFilter", "=", "array_merge", "(", "$", "extra", "[", "'badwords'", "]", ",", "$", "getFilter", ")", ";", "}", "if", "(", "array_key_exists", "(", "'ignored'", ",", "$", "extra", ")", ")", "{", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "extra", "[", "'ignored'", "]", ")", ";", "$", "i", "++", ")", "{", "$", "extra", "[", "'ignored'", "]", "[", "$", "i", "]", "=", "static", "::", "doubleChars", "(", "$", "extra", "[", "'ignored'", "]", "[", "$", "i", "]", ")", ";", "}", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "count", "(", "$", "getFilter", ")", ";", "$", "i", "++", ")", "{", "foreach", "(", "$", "extra", "[", "'ignored'", "]", "as", "$", "ignored", ")", "{", "if", "(", "is_int", "(", "strripos", "(", "$", "ignored", ",", "$", "getFilter", "[", "$", "i", "]", ")", ")", ")", "{", "$", "arr", "[", "]", "=", "$", "i", ";", "}", "}", "}", "if", "(", "isset", "(", "$", "arr", ")", ")", "{", "foreach", "(", "$", "arr", "as", "$", "a", ")", "{", "unset", "(", "$", "getFilter", "[", "$", "a", "]", ")", ";", "}", "}", "}", "}", "foreach", "(", "$", "getFilter", "as", "$", "filter", ")", "{", "if", "(", "is_int", "(", "strripos", "(", "$", "string", ",", "$", "filter", ")", ")", ")", "{", "return", "true", ";", "}", "}", "return", "false", ";", "}" ]
Verifica se a palavra informada existe no filtro No parâmetro $extra, informe um array com as chaves 'badwords' e/ou 'ignored'. Como valor das chaves, informe-os em um array, como: $extra = [ 'badwords' => ['palavraUm', 'palavraDois', ...], 'ignored' => ['palavraTres', 'palavraQuatro', ...], ]; 'badwords' são palavras que deseja acrescentar ao filtro 'ignored' são palavras que serão ignoradas pelo filtro @param string $string Palavra a ser verificada @param array $extra Array com informações adicionais @return boolean
[ "Verifica", "se", "a", "palavra", "informada", "existe", "no", "filtro" ]
95f785b4678e34d8cf451e7db41189ede47f2ba4
https://github.com/Zeindelf/badwords/blob/95f785b4678e34d8cf451e7db41189ede47f2ba4/src/Badwords.php#L39-L79
232,751
fondbot/drivers-vk
src/VkCommunityDriver.php
VkCommunityDriver.verifyRequest
public function verifyRequest(): void { $type = $this->request->getParameter('type'); $object = $this->request->getParameter('object'); if ($type === null || $type !== 'message_new') { throw new InvalidRequest('Invalid type'); } if ($object === null) { throw new InvalidRequest('Invalid object'); } if (!isset($object['user_id'])) { throw new InvalidRequest('Invalid user_id'); } if (!isset($object['body'])) { throw new InvalidRequest('Invalid body'); } }
php
public function verifyRequest(): void { $type = $this->request->getParameter('type'); $object = $this->request->getParameter('object'); if ($type === null || $type !== 'message_new') { throw new InvalidRequest('Invalid type'); } if ($object === null) { throw new InvalidRequest('Invalid object'); } if (!isset($object['user_id'])) { throw new InvalidRequest('Invalid user_id'); } if (!isset($object['body'])) { throw new InvalidRequest('Invalid body'); } }
[ "public", "function", "verifyRequest", "(", ")", ":", "void", "{", "$", "type", "=", "$", "this", "->", "request", "->", "getParameter", "(", "'type'", ")", ";", "$", "object", "=", "$", "this", "->", "request", "->", "getParameter", "(", "'object'", ")", ";", "if", "(", "$", "type", "===", "null", "||", "$", "type", "!==", "'message_new'", ")", "{", "throw", "new", "InvalidRequest", "(", "'Invalid type'", ")", ";", "}", "if", "(", "$", "object", "===", "null", ")", "{", "throw", "new", "InvalidRequest", "(", "'Invalid object'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "object", "[", "'user_id'", "]", ")", ")", "{", "throw", "new", "InvalidRequest", "(", "'Invalid user_id'", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "object", "[", "'body'", "]", ")", ")", "{", "throw", "new", "InvalidRequest", "(", "'Invalid body'", ")", ";", "}", "}" ]
Verify incoming request data. @throws InvalidRequest
[ "Verify", "incoming", "request", "data", "." ]
b4da296d19f0c58dacb7bae486b43d59b82da4c3
https://github.com/fondbot/drivers-vk/blob/b4da296d19f0c58dacb7bae486b43d59b82da4c3/src/VkCommunityDriver.php#L69-L89
232,752
fondbot/drivers-vk
src/VkCommunityDriver.php
VkCommunityDriver.getUser
public function getUser(): User { if ($this->sender !== null) { return $this->sender; } $userId = (string) $this->request->getParameter('object.user_id'); $request = $this->http->get(self::API_URL.'users.get', [ 'query' => [ 'user_ids' => $userId, 'v' => self::API_VERSION, ], ]); $response = json_decode($request->getBody()->getContents(), true); $user = $response['response'][0]; return $this->sender = new User( (string) $user['id'], $user['first_name'].' '.$user['last_name'] ); }
php
public function getUser(): User { if ($this->sender !== null) { return $this->sender; } $userId = (string) $this->request->getParameter('object.user_id'); $request = $this->http->get(self::API_URL.'users.get', [ 'query' => [ 'user_ids' => $userId, 'v' => self::API_VERSION, ], ]); $response = json_decode($request->getBody()->getContents(), true); $user = $response['response'][0]; return $this->sender = new User( (string) $user['id'], $user['first_name'].' '.$user['last_name'] ); }
[ "public", "function", "getUser", "(", ")", ":", "User", "{", "if", "(", "$", "this", "->", "sender", "!==", "null", ")", "{", "return", "$", "this", "->", "sender", ";", "}", "$", "userId", "=", "(", "string", ")", "$", "this", "->", "request", "->", "getParameter", "(", "'object.user_id'", ")", ";", "$", "request", "=", "$", "this", "->", "http", "->", "get", "(", "self", "::", "API_URL", ".", "'users.get'", ",", "[", "'query'", "=>", "[", "'user_ids'", "=>", "$", "userId", ",", "'v'", "=>", "self", "::", "API_VERSION", ",", "]", ",", "]", ")", ";", "$", "response", "=", "json_decode", "(", "$", "request", "->", "getBody", "(", ")", "->", "getContents", "(", ")", ",", "true", ")", ";", "$", "user", "=", "$", "response", "[", "'response'", "]", "[", "0", "]", ";", "return", "$", "this", "->", "sender", "=", "new", "User", "(", "(", "string", ")", "$", "user", "[", "'id'", "]", ",", "$", "user", "[", "'first_name'", "]", ".", "' '", ".", "$", "user", "[", "'last_name'", "]", ")", ";", "}" ]
Get message sender. @return User @throws InvalidRequest
[ "Get", "message", "sender", "." ]
b4da296d19f0c58dacb7bae486b43d59b82da4c3
https://github.com/fondbot/drivers-vk/blob/b4da296d19f0c58dacb7bae486b43d59b82da4c3/src/VkCommunityDriver.php#L110-L130
232,753
dmitriybelyy/yii2-cassandra-cql
phpcassa/Batch/Mutator.php
Mutator.insert
public function insert($column_family, $key, $columns, $timestamp=null, $ttl=null) { return $this->insert_cf($column_family, $key, $columns, $timestamp, $ttl); }
php
public function insert($column_family, $key, $columns, $timestamp=null, $ttl=null) { return $this->insert_cf($column_family, $key, $columns, $timestamp, $ttl); }
[ "public", "function", "insert", "(", "$", "column_family", ",", "$", "key", ",", "$", "columns", ",", "$", "timestamp", "=", "null", ",", "$", "ttl", "=", "null", ")", "{", "return", "$", "this", "->", "insert_cf", "(", "$", "column_family", ",", "$", "key", ",", "$", "columns", ",", "$", "timestamp", ",", "$", "ttl", ")", ";", "}" ]
Add an insertion to the buffer. @param phpcassa\ColumnFamily $column_family an initialized ColumnFamily instance @param mixed $key the row key @param mixed[] $columns an array of columns to insert, whose format should match $column_family->insert_format @param int $timestamp an optional timestamp (default is "now", when this function is called, not when send() is called) @param int $ttl a TTL to apply to all columns inserted here
[ "Add", "an", "insertion", "to", "the", "buffer", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/Batch/Mutator.php#L42-L44
232,754
dmitriybelyy/yii2-cassandra-cql
phpcassa/Batch/Mutator.php
Mutator.remove
public function remove($column_family, $key, $columns=null, $super_column=null, $timestamp=null) { return $this->remove_cf($column_family, $key, $columns, $super_column, $timestamp); }
php
public function remove($column_family, $key, $columns=null, $super_column=null, $timestamp=null) { return $this->remove_cf($column_family, $key, $columns, $super_column, $timestamp); }
[ "public", "function", "remove", "(", "$", "column_family", ",", "$", "key", ",", "$", "columns", "=", "null", ",", "$", "super_column", "=", "null", ",", "$", "timestamp", "=", "null", ")", "{", "return", "$", "this", "->", "remove_cf", "(", "$", "column_family", ",", "$", "key", ",", "$", "columns", ",", "$", "super_column", ",", "$", "timestamp", ")", ";", "}" ]
Add a deletion to the buffer. @param phpcassa\ColumnFamily $column_family an initialized ColumnFamily instance @param mixed $key the row key @param mixed[] $columns a list of columns or super columns to delete @param mixed $supercolumn if you want to delete only some subcolumns from a single super column, set this to the super column name @param int $timestamp an optional timestamp (default is "now", when this function is called, not when send() is called)
[ "Add", "a", "deletion", "to", "the", "buffer", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/Batch/Mutator.php#L58-L60
232,755
asinfotrack/yii2-toolbox
behaviors/StateQueryBehavior.php
StateQueryBehavior.lowerThanState
public function lowerThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_LOWER)]); return $this->owner; }
php
public function lowerThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_LOWER)]); return $this->owner; }
[ "public", "function", "lowerThanState", "(", "$", "stateValue", ")", "{", "//validate state", "$", "this", "->", "modelInstance", "->", "stateExists", "(", "$", "stateValue", ",", "true", ")", ";", "//apply to query", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "'IN'", ",", "$", "this", "->", "stateAttribute", ",", "$", "this", "->", "getStateSelection", "(", "$", "stateValue", ",", "static", "::", "STATES_LOWER", ")", "]", ")", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Named scope to fetch all models having a state lower than the one provided @param integer|string $stateValue the value of the state to check @return \asinfotrack\yii2\toolbox\behaviors\StateQueryBehavior
[ "Named", "scope", "to", "fetch", "all", "models", "having", "a", "state", "lower", "than", "the", "one", "provided" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/behaviors/StateQueryBehavior.php#L63-L70
232,756
asinfotrack/yii2-toolbox
behaviors/StateQueryBehavior.php
StateQueryBehavior.lowerOrEqualThanState
public function lowerOrEqualThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_LOWER_OR_EQUAL)]); return $this->owner; }
php
public function lowerOrEqualThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_LOWER_OR_EQUAL)]); return $this->owner; }
[ "public", "function", "lowerOrEqualThanState", "(", "$", "stateValue", ")", "{", "//validate state", "$", "this", "->", "modelInstance", "->", "stateExists", "(", "$", "stateValue", ",", "true", ")", ";", "//apply to query", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "'IN'", ",", "$", "this", "->", "stateAttribute", ",", "$", "this", "->", "getStateSelection", "(", "$", "stateValue", ",", "static", "::", "STATES_LOWER_OR_EQUAL", ")", "]", ")", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Named scope to fetch all models having a state lower or equal than the one provided @param integer|string $stateValue the value of the state to check @return \asinfotrack\yii2\toolbox\behaviors\StateQueryBehavior
[ "Named", "scope", "to", "fetch", "all", "models", "having", "a", "state", "lower", "or", "equal", "than", "the", "one", "provided" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/behaviors/StateQueryBehavior.php#L78-L85
232,757
asinfotrack/yii2-toolbox
behaviors/StateQueryBehavior.php
StateQueryBehavior.inState
public function inState($stateValue) { if (is_array($stateValue)) { //validate states foreach ($stateValue as $sv) { $this->modelInstance->stateExists($sv, true); } //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $stateValue]); } else { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere([$this->stateAttribute=>$stateValue]); } return $this->owner; }
php
public function inState($stateValue) { if (is_array($stateValue)) { //validate states foreach ($stateValue as $sv) { $this->modelInstance->stateExists($sv, true); } //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $stateValue]); } else { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere([$this->stateAttribute=>$stateValue]); } return $this->owner; }
[ "public", "function", "inState", "(", "$", "stateValue", ")", "{", "if", "(", "is_array", "(", "$", "stateValue", ")", ")", "{", "//validate states", "foreach", "(", "$", "stateValue", "as", "$", "sv", ")", "{", "$", "this", "->", "modelInstance", "->", "stateExists", "(", "$", "sv", ",", "true", ")", ";", "}", "//apply to query", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "'IN'", ",", "$", "this", "->", "stateAttribute", ",", "$", "stateValue", "]", ")", ";", "}", "else", "{", "//validate state", "$", "this", "->", "modelInstance", "->", "stateExists", "(", "$", "stateValue", ",", "true", ")", ";", "//apply to query", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "$", "this", "->", "stateAttribute", "=>", "$", "stateValue", "]", ")", ";", "}", "return", "$", "this", "->", "owner", ";", "}" ]
Named scope to filter models exactly in the provided state. Its also possible to provide an array of states. In this case all models with any of those states will be returned @param integer|string|integer[]|string[] $stateValue the value(s) of the state to check @return \asinfotrack\yii2\toolbox\behaviors\StateQueryBehavior
[ "Named", "scope", "to", "filter", "models", "exactly", "in", "the", "provided", "state", ".", "Its", "also", "possible", "to", "provide", "an", "array", "of", "states", ".", "In", "this", "case", "all", "models", "with", "any", "of", "those", "states", "will", "be", "returned" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/behaviors/StateQueryBehavior.php#L95-L112
232,758
asinfotrack/yii2-toolbox
behaviors/StateQueryBehavior.php
StateQueryBehavior.equalOrHigherThanState
public function equalOrHigherThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_EQUAL_OR_HIGHER)]); return $this->owner; }
php
public function equalOrHigherThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_EQUAL_OR_HIGHER)]); return $this->owner; }
[ "public", "function", "equalOrHigherThanState", "(", "$", "stateValue", ")", "{", "//validate state", "$", "this", "->", "modelInstance", "->", "stateExists", "(", "$", "stateValue", ",", "true", ")", ";", "//apply to query", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "'IN'", ",", "$", "this", "->", "stateAttribute", ",", "$", "this", "->", "getStateSelection", "(", "$", "stateValue", ",", "static", "::", "STATES_EQUAL_OR_HIGHER", ")", "]", ")", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Named scope to fetch all models having a state higher or equal than the one provided @param integer|string $stateValue the value of the state to check @return \asinfotrack\yii2\toolbox\behaviors\StateQueryBehavior
[ "Named", "scope", "to", "fetch", "all", "models", "having", "a", "state", "higher", "or", "equal", "than", "the", "one", "provided" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/behaviors/StateQueryBehavior.php#L120-L127
232,759
asinfotrack/yii2-toolbox
behaviors/StateQueryBehavior.php
StateQueryBehavior.higherThanState
public function higherThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_HIGHER)]); return $this->owner; }
php
public function higherThanState($stateValue) { //validate state $this->modelInstance->stateExists($stateValue, true); //apply to query $this->owner->andWhere(['IN', $this->stateAttribute, $this->getStateSelection($stateValue, static::STATES_HIGHER)]); return $this->owner; }
[ "public", "function", "higherThanState", "(", "$", "stateValue", ")", "{", "//validate state", "$", "this", "->", "modelInstance", "->", "stateExists", "(", "$", "stateValue", ",", "true", ")", ";", "//apply to query", "$", "this", "->", "owner", "->", "andWhere", "(", "[", "'IN'", ",", "$", "this", "->", "stateAttribute", ",", "$", "this", "->", "getStateSelection", "(", "$", "stateValue", ",", "static", "::", "STATES_HIGHER", ")", "]", ")", ";", "return", "$", "this", "->", "owner", ";", "}" ]
Named scope to fetch all models having a state higher than the one provided @param integer|string $stateValue the value of the state to check @return \asinfotrack\yii2\toolbox\behaviors\StateQueryBehavior
[ "Named", "scope", "to", "fetch", "all", "models", "having", "a", "state", "higher", "than", "the", "one", "provided" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/behaviors/StateQueryBehavior.php#L135-L142
232,760
asinfotrack/yii2-toolbox
behaviors/StateQueryBehavior.php
StateQueryBehavior.getStateSelection
protected function getStateSelection($stateValue, $which) { $ret = []; $foundCurrent = false; foreach (ArrayHelper::getColumn($this->stateConfig, 'value') as $val) { if ($stateValue == $val) { $foundCurrent = true; if ($which == static::STATES_LOWER) { break; } else if ($which == static::STATES_LOWER_OR_EQUAL || $which == static::STATES_EQUAL_OR_HIGHER) { $ret[] = $val; if ($which == static::STATES_LOWER_OR_EQUAL) { break; } else { continue; } } else if ($which == static::STATES_HIGHER) { continue; } } else { if (!$foundCurrent && ($which == static::STATES_EQUAL_OR_HIGHER || $which == static::STATES_HIGHER)) { continue; } $ret[] = $val; } } return $ret; }
php
protected function getStateSelection($stateValue, $which) { $ret = []; $foundCurrent = false; foreach (ArrayHelper::getColumn($this->stateConfig, 'value') as $val) { if ($stateValue == $val) { $foundCurrent = true; if ($which == static::STATES_LOWER) { break; } else if ($which == static::STATES_LOWER_OR_EQUAL || $which == static::STATES_EQUAL_OR_HIGHER) { $ret[] = $val; if ($which == static::STATES_LOWER_OR_EQUAL) { break; } else { continue; } } else if ($which == static::STATES_HIGHER) { continue; } } else { if (!$foundCurrent && ($which == static::STATES_EQUAL_OR_HIGHER || $which == static::STATES_HIGHER)) { continue; } $ret[] = $val; } } return $ret; }
[ "protected", "function", "getStateSelection", "(", "$", "stateValue", ",", "$", "which", ")", "{", "$", "ret", "=", "[", "]", ";", "$", "foundCurrent", "=", "false", ";", "foreach", "(", "ArrayHelper", "::", "getColumn", "(", "$", "this", "->", "stateConfig", ",", "'value'", ")", "as", "$", "val", ")", "{", "if", "(", "$", "stateValue", "==", "$", "val", ")", "{", "$", "foundCurrent", "=", "true", ";", "if", "(", "$", "which", "==", "static", "::", "STATES_LOWER", ")", "{", "break", ";", "}", "else", "if", "(", "$", "which", "==", "static", "::", "STATES_LOWER_OR_EQUAL", "||", "$", "which", "==", "static", "::", "STATES_EQUAL_OR_HIGHER", ")", "{", "$", "ret", "[", "]", "=", "$", "val", ";", "if", "(", "$", "which", "==", "static", "::", "STATES_LOWER_OR_EQUAL", ")", "{", "break", ";", "}", "else", "{", "continue", ";", "}", "}", "else", "if", "(", "$", "which", "==", "static", "::", "STATES_HIGHER", ")", "{", "continue", ";", "}", "}", "else", "{", "if", "(", "!", "$", "foundCurrent", "&&", "(", "$", "which", "==", "static", "::", "STATES_EQUAL_OR_HIGHER", "||", "$", "which", "==", "static", "::", "STATES_HIGHER", ")", ")", "{", "continue", ";", "}", "$", "ret", "[", "]", "=", "$", "val", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Gets a selection of states from the current state config @param integer|string $stateValue the value of the state to check @param integer $which selection constant of this class @return integer[]|string[] array the desired states
[ "Gets", "a", "selection", "of", "states", "from", "the", "current", "state", "config" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/behaviors/StateQueryBehavior.php#L151-L180
232,761
kuria/error
src/Screen/WebErrorScreen.php
WebErrorScreen.renderLayout
protected function renderLayout(bool $debug, string $title, string $content): void { ?> <!DOCTYPE html> <html> <head> <meta charset="<?= $this->escape(strtolower($this->htmlCharset)) ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php if ($debug) : ?> <link rel="icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gELDAY3msRFdQAAAUZJREFUWMPllztSwzAQhj9pmIE2OQO5QLgHDEtNzpG7uMlAlQLzuEe4AJzBaUnlFBEMD1lvYWbYxg9ZK+2/+3lt+O+mUie2h8OVubyTMXbfQtdCl+NDZyy+BCbAxJz/TgqM9MfA27ehE2AntRUwCzSWoUZqK2CiPwVeBh6ZAa9SSwHjeO14ZC21FDDRnwOPQG+Z+37vAniSSinoTOVz2fdfxu7Vh6utwLR4Cj5h57MoLFUqdg4ForDUGdj5LAhLlYpdgAJBWOpM7HzmxfIoALt5xgbm7cHHIJbaE/2qQNNcJaUgArssLFVEt0spQi+WaiD6G+Da4cz1Kh6yW4GFU4GAbpezASuWthRsQio/IQUAzwJnVgwLYReNpa6AXRSWugJ2UViqUOwKFeEPLHVit1MFvrAbMQqEYFfLZhp4GPHXcMy1/4jtATk5XgJfpXWMAAAAAElFTkSuQmCC"> <?php endif ?> <style> <?php $this->renderCss($debug) ?> </style> <title><?= $this->escape($title) ?></title> </head> <body> <div id="wrapper"> <div id="content"> <?= $content ?> </div> </div> <script> <?php $this->renderJs($debug) ?> </script> </body> </html><?php }
php
protected function renderLayout(bool $debug, string $title, string $content): void { ?> <!DOCTYPE html> <html> <head> <meta charset="<?= $this->escape(strtolower($this->htmlCharset)) ?>"> <meta name="viewport" content="width=device-width, initial-scale=1"> <?php if ($debug) : ?> <link rel="icon" type="image/x-icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gELDAY3msRFdQAAAUZJREFUWMPllztSwzAQhj9pmIE2OQO5QLgHDEtNzpG7uMlAlQLzuEe4AJzBaUnlFBEMD1lvYWbYxg9ZK+2/+3lt+O+mUie2h8OVubyTMXbfQtdCl+NDZyy+BCbAxJz/TgqM9MfA27ehE2AntRUwCzSWoUZqK2CiPwVeBh6ZAa9SSwHjeO14ZC21FDDRnwOPQG+Z+37vAniSSinoTOVz2fdfxu7Vh6utwLR4Cj5h57MoLFUqdg4ForDUGdj5LAhLlYpdgAJBWOpM7HzmxfIoALt5xgbm7cHHIJbaE/2qQNNcJaUgArssLFVEt0spQi+WaiD6G+Da4cz1Kh6yW4GFU4GAbpezASuWthRsQio/IQUAzwJnVgwLYReNpa6AXRSWugJ2UViqUOwKFeEPLHVit1MFvrAbMQqEYFfLZhp4GPHXcMy1/4jtATk5XgJfpXWMAAAAAElFTkSuQmCC"> <?php endif ?> <style> <?php $this->renderCss($debug) ?> </style> <title><?= $this->escape($title) ?></title> </head> <body> <div id="wrapper"> <div id="content"> <?= $content ?> </div> </div> <script> <?php $this->renderJs($debug) ?> </script> </body> </html><?php }
[ "protected", "function", "renderLayout", "(", "bool", "$", "debug", ",", "string", "$", "title", ",", "string", "$", "content", ")", ":", "void", "{", "?>\n<!DOCTYPE html>\n<html>\n<head>\n<meta charset=\"<?=", "$", "this", "->", "escape", "(", "strtolower", "(", "$", "this", "->", "htmlCharset", ")", ")", "?>\">\n<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n<?php", "if", "(", "$", "debug", ")", ":", "?>\n<link rel=\"icon\" type=\"image/x-icon\" href=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH4gELDAY3msRFdQAAAUZJREFUWMPllztSwzAQhj9pmIE2OQO5QLgHDEtNzpG7uMlAlQLzuEe4AJzBaUnlFBEMD1lvYWbYxg9ZK+2/+3lt+O+mUie2h8OVubyTMXbfQtdCl+NDZyy+BCbAxJz/TgqM9MfA27ehE2AntRUwCzSWoUZqK2CiPwVeBh6ZAa9SSwHjeO14ZC21FDDRnwOPQG+Z+37vAniSSinoTOVz2fdfxu7Vh6utwLR4Cj5h57MoLFUqdg4ForDUGdj5LAhLlYpdgAJBWOpM7HzmxfIoALt5xgbm7cHHIJbaE/2qQNNcJaUgArssLFVEt0spQi+WaiD6G+Da4cz1Kh6yW4GFU4GAbpezASuWthRsQio/IQUAzwJnVgwLYReNpa6AXRSWugJ2UViqUOwKFeEPLHVit1MFvrAbMQqEYFfLZhp4GPHXcMy1/4jtATk5XgJfpXWMAAAAAElFTkSuQmCC\">\n<?php", "endif", "?>\n<style>\n<?php", "$", "this", "->", "renderCss", "(", "$", "debug", ")", "?>\n</style>\n<title><?=", "$", "this", "->", "escape", "(", "$", "title", ")", "?></title>\n</head>\n\n<body>\n\n <div id=\"wrapper\">\n\n <div id=\"content\">\n\n<?=", "$", "content", "?>\n\n </div>\n\n </div>\n\n<script>\n<?php", "$", "this", "->", "renderJs", "(", "$", "debug", ")", "?>\n</script>\n</body>\n</html><?php", "}" ]
Render the HTML layout
[ "Render", "the", "HTML", "layout" ]
e1426256569e9e9253a940a3cec854d550b257eb
https://github.com/kuria/error/blob/e1426256569e9e9253a940a3cec854d550b257eb/src/Screen/WebErrorScreen.php#L160-L194
232,762
kuria/error
src/Screen/WebErrorScreen.php
WebErrorScreen.escape
protected function escape(string $string): string { return htmlspecialchars($string, ENT_QUOTES | ENT_IGNORE, $this->encoding); }
php
protected function escape(string $string): string { return htmlspecialchars($string, ENT_QUOTES | ENT_IGNORE, $this->encoding); }
[ "protected", "function", "escape", "(", "string", "$", "string", ")", ":", "string", "{", "return", "htmlspecialchars", "(", "$", "string", ",", "ENT_QUOTES", "|", "ENT_IGNORE", ",", "$", "this", "->", "encoding", ")", ";", "}" ]
Escape the given string string for HTML
[ "Escape", "the", "given", "string", "string", "for", "HTML" ]
e1426256569e9e9253a940a3cec854d550b257eb
https://github.com/kuria/error/blob/e1426256569e9e9253a940a3cec854d550b257eb/src/Screen/WebErrorScreen.php#L219-L222
232,763
ncaneldiee/rajaongkir
src/Domestic.php
Domestic.courier
public function courier($courier = null) { if ($courier) { $courier = mb_strtolower($courier); return array_key_exists($courier, $this->courier) ? $this->courier[$courier] : $this->courier; } return (object) $this->courier; }
php
public function courier($courier = null) { if ($courier) { $courier = mb_strtolower($courier); return array_key_exists($courier, $this->courier) ? $this->courier[$courier] : $this->courier; } return (object) $this->courier; }
[ "public", "function", "courier", "(", "$", "courier", "=", "null", ")", "{", "if", "(", "$", "courier", ")", "{", "$", "courier", "=", "mb_strtolower", "(", "$", "courier", ")", ";", "return", "array_key_exists", "(", "$", "courier", ",", "$", "this", "->", "courier", ")", "?", "$", "this", "->", "courier", "[", "$", "courier", "]", ":", "$", "this", "->", "courier", ";", "}", "return", "(", "object", ")", "$", "this", "->", "courier", ";", "}" ]
Get a list or detail of the courier. @param string|null $courier @return object
[ "Get", "a", "list", "or", "detail", "of", "the", "courier", "." ]
98e5c40a1b359953dcc913dd5070b8e8560a86a5
https://github.com/ncaneldiee/rajaongkir/blob/98e5c40a1b359953dcc913dd5070b8e8560a86a5/src/Domestic.php#L207-L216
232,764
ncaneldiee/rajaongkir
src/Domestic.php
Domestic.waybill
public function waybill($id, $courier) { $courier = mb_strtolower($courier); return $this->request('waybill', [ 'waybill' => $id, 'courier' => $courier, ], 'POST'); }
php
public function waybill($id, $courier) { $courier = mb_strtolower($courier); return $this->request('waybill', [ 'waybill' => $id, 'courier' => $courier, ], 'POST'); }
[ "public", "function", "waybill", "(", "$", "id", ",", "$", "courier", ")", "{", "$", "courier", "=", "mb_strtolower", "(", "$", "courier", ")", ";", "return", "$", "this", "->", "request", "(", "'waybill'", ",", "[", "'waybill'", "=>", "$", "id", ",", "'courier'", "=>", "$", "courier", ",", "]", ",", "'POST'", ")", ";", "}" ]
Track or find out delivery status. @param string $id @param string $courier @return object
[ "Track", "or", "find", "out", "delivery", "status", "." ]
98e5c40a1b359953dcc913dd5070b8e8560a86a5
https://github.com/ncaneldiee/rajaongkir/blob/98e5c40a1b359953dcc913dd5070b8e8560a86a5/src/Domestic.php#L263-L271
232,765
ncaneldiee/rajaongkir
src/Domestic.php
Domestic.shipment
protected function shipment($shipment) { $data = []; if (is_array($shipment)) { if (isset($shipment['length']) && isset($shipment['width']) && isset($shipment['height'])) { $volumetric = (($shipment['length'] * $shipment['width'] * $shipment['height']) / 6000) * 1000; $actual = isset($shipment['weight']) ? $shipment['weight'] : 0; $data['weight'] = $volumetric > $actual ? $volumetric : $actual; $data['length'] = $shipment['length']; $data['width'] = $shipment['width']; $data['height'] = $shipment['height']; } } else { $data['weight'] = $shipment; } return $data; }
php
protected function shipment($shipment) { $data = []; if (is_array($shipment)) { if (isset($shipment['length']) && isset($shipment['width']) && isset($shipment['height'])) { $volumetric = (($shipment['length'] * $shipment['width'] * $shipment['height']) / 6000) * 1000; $actual = isset($shipment['weight']) ? $shipment['weight'] : 0; $data['weight'] = $volumetric > $actual ? $volumetric : $actual; $data['length'] = $shipment['length']; $data['width'] = $shipment['width']; $data['height'] = $shipment['height']; } } else { $data['weight'] = $shipment; } return $data; }
[ "protected", "function", "shipment", "(", "$", "shipment", ")", "{", "$", "data", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "shipment", ")", ")", "{", "if", "(", "isset", "(", "$", "shipment", "[", "'length'", "]", ")", "&&", "isset", "(", "$", "shipment", "[", "'width'", "]", ")", "&&", "isset", "(", "$", "shipment", "[", "'height'", "]", ")", ")", "{", "$", "volumetric", "=", "(", "(", "$", "shipment", "[", "'length'", "]", "*", "$", "shipment", "[", "'width'", "]", "*", "$", "shipment", "[", "'height'", "]", ")", "/", "6000", ")", "*", "1000", ";", "$", "actual", "=", "isset", "(", "$", "shipment", "[", "'weight'", "]", ")", "?", "$", "shipment", "[", "'weight'", "]", ":", "0", ";", "$", "data", "[", "'weight'", "]", "=", "$", "volumetric", ">", "$", "actual", "?", "$", "volumetric", ":", "$", "actual", ";", "$", "data", "[", "'length'", "]", "=", "$", "shipment", "[", "'length'", "]", ";", "$", "data", "[", "'width'", "]", "=", "$", "shipment", "[", "'width'", "]", ";", "$", "data", "[", "'height'", "]", "=", "$", "shipment", "[", "'height'", "]", ";", "}", "}", "else", "{", "$", "data", "[", "'weight'", "]", "=", "$", "shipment", ";", "}", "return", "$", "data", ";", "}" ]
Shipment detail. @param string|array $shipment @return array
[ "Shipment", "detail", "." ]
98e5c40a1b359953dcc913dd5070b8e8560a86a5
https://github.com/ncaneldiee/rajaongkir/blob/98e5c40a1b359953dcc913dd5070b8e8560a86a5/src/Domestic.php#L343-L362
232,766
phillies2k/ratchet-bundle
WebSocket/Server/Bridge.php
Bridge.handle
protected function handle(ConnectionInterface $connection, Payload $payload) { switch ($payload->getEvent()) { case ConnectionEvent::SOCKET_AUTH_REQUEST: $this->handleAuthentication($connection, $payload); break; default: $this->eventDispatcher->dispatch($payload->getEvent(), new ConnectionEvent($connection, $payload)); $this->logger->notice(sprintf('Dispatched event: %s', $payload->getEvent())); } }
php
protected function handle(ConnectionInterface $connection, Payload $payload) { switch ($payload->getEvent()) { case ConnectionEvent::SOCKET_AUTH_REQUEST: $this->handleAuthentication($connection, $payload); break; default: $this->eventDispatcher->dispatch($payload->getEvent(), new ConnectionEvent($connection, $payload)); $this->logger->notice(sprintf('Dispatched event: %s', $payload->getEvent())); } }
[ "protected", "function", "handle", "(", "ConnectionInterface", "$", "connection", ",", "Payload", "$", "payload", ")", "{", "switch", "(", "$", "payload", "->", "getEvent", "(", ")", ")", "{", "case", "ConnectionEvent", "::", "SOCKET_AUTH_REQUEST", ":", "$", "this", "->", "handleAuthentication", "(", "$", "connection", ",", "$", "payload", ")", ";", "break", ";", "default", ":", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "$", "payload", "->", "getEvent", "(", ")", ",", "new", "ConnectionEvent", "(", "$", "connection", ",", "$", "payload", ")", ")", ";", "$", "this", "->", "logger", "->", "notice", "(", "sprintf", "(", "'Dispatched event: %s'", ",", "$", "payload", "->", "getEvent", "(", ")", ")", ")", ";", "}", "}" ]
Handles the the given payload received by the given connection. @param ConnectionInterface $connection @param Payload $payload
[ "Handles", "the", "the", "given", "payload", "received", "by", "the", "given", "connection", "." ]
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Server/Bridge.php#L153-L163
232,767
phillies2k/ratchet-bundle
WebSocket/Server/Bridge.php
Bridge.handleAuthentication
protected function handleAuthentication(ConnectionInterface $connection, Payload $payload) { if (! $this->connectionManager->authenticate($connection, $payload->getData())) { $connection->emit(new Payload(ConnectionEvent::SOCKET_AUTH_FAILURE, 'Invalid access token.')); $this->eventDispatcher->dispatch(ConnectionEvent::SOCKET_AUTH_FAILURE, new ConnectionEvent($connection)); $this->logger->notice( sprintf( 'Authentication error <info>#%s</info> (<comment>%s</comment>)', $connection->getId(), $connection->getRemoteAddress() ) ); return; } $response = new Payload(ConnectionEvent::SOCKET_AUTH_SUCCESS, $connection->getClient()->jsonSerialize()); $connection->emit($response); $this->eventDispatcher->dispatch(ConnectionEvent::SOCKET_AUTH_SUCCESS, new ConnectionEvent($connection)); $this->logger->notice( sprintf( 'Authenticated <info>#%s</info> (<comment>%s</comment>)', $connection->getId(), $connection->getRemoteAddress() ) ); }
php
protected function handleAuthentication(ConnectionInterface $connection, Payload $payload) { if (! $this->connectionManager->authenticate($connection, $payload->getData())) { $connection->emit(new Payload(ConnectionEvent::SOCKET_AUTH_FAILURE, 'Invalid access token.')); $this->eventDispatcher->dispatch(ConnectionEvent::SOCKET_AUTH_FAILURE, new ConnectionEvent($connection)); $this->logger->notice( sprintf( 'Authentication error <info>#%s</info> (<comment>%s</comment>)', $connection->getId(), $connection->getRemoteAddress() ) ); return; } $response = new Payload(ConnectionEvent::SOCKET_AUTH_SUCCESS, $connection->getClient()->jsonSerialize()); $connection->emit($response); $this->eventDispatcher->dispatch(ConnectionEvent::SOCKET_AUTH_SUCCESS, new ConnectionEvent($connection)); $this->logger->notice( sprintf( 'Authenticated <info>#%s</info> (<comment>%s</comment>)', $connection->getId(), $connection->getRemoteAddress() ) ); }
[ "protected", "function", "handleAuthentication", "(", "ConnectionInterface", "$", "connection", ",", "Payload", "$", "payload", ")", "{", "if", "(", "!", "$", "this", "->", "connectionManager", "->", "authenticate", "(", "$", "connection", ",", "$", "payload", "->", "getData", "(", ")", ")", ")", "{", "$", "connection", "->", "emit", "(", "new", "Payload", "(", "ConnectionEvent", "::", "SOCKET_AUTH_FAILURE", ",", "'Invalid access token.'", ")", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ConnectionEvent", "::", "SOCKET_AUTH_FAILURE", ",", "new", "ConnectionEvent", "(", "$", "connection", ")", ")", ";", "$", "this", "->", "logger", "->", "notice", "(", "sprintf", "(", "'Authentication error <info>#%s</info> (<comment>%s</comment>)'", ",", "$", "connection", "->", "getId", "(", ")", ",", "$", "connection", "->", "getRemoteAddress", "(", ")", ")", ")", ";", "return", ";", "}", "$", "response", "=", "new", "Payload", "(", "ConnectionEvent", "::", "SOCKET_AUTH_SUCCESS", ",", "$", "connection", "->", "getClient", "(", ")", "->", "jsonSerialize", "(", ")", ")", ";", "$", "connection", "->", "emit", "(", "$", "response", ")", ";", "$", "this", "->", "eventDispatcher", "->", "dispatch", "(", "ConnectionEvent", "::", "SOCKET_AUTH_SUCCESS", ",", "new", "ConnectionEvent", "(", "$", "connection", ")", ")", ";", "$", "this", "->", "logger", "->", "notice", "(", "sprintf", "(", "'Authenticated <info>#%s</info> (<comment>%s</comment>)'", ",", "$", "connection", "->", "getId", "(", ")", ",", "$", "connection", "->", "getRemoteAddress", "(", ")", ")", ")", ";", "}" ]
Handles the connection authentication. @param ConnectionInterface $connection @param Payload $payload
[ "Handles", "the", "connection", "authentication", "." ]
1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3
https://github.com/phillies2k/ratchet-bundle/blob/1ea60f42d04c6e5e2c63c7f8c53262d382b0b5f3/WebSocket/Server/Bridge.php#L171-L201
232,768
juanmf/PdfManager
Fpdi/Traits/FpdiPdfManagerMergeTrait.php
FpdiPdfManagerMergeTrait.merge
public function merge(array $pdfs = array()) { $outPdf = $this->getPdfInstance(array_shift($pdfs)); foreach ($pdfs as $pdf) { $outPdf->importPdf($pdf, ($pdf instanceof Pdf)); } return $outPdf; }
php
public function merge(array $pdfs = array()) { $outPdf = $this->getPdfInstance(array_shift($pdfs)); foreach ($pdfs as $pdf) { $outPdf->importPdf($pdf, ($pdf instanceof Pdf)); } return $outPdf; }
[ "public", "function", "merge", "(", "array", "$", "pdfs", "=", "array", "(", ")", ")", "{", "$", "outPdf", "=", "$", "this", "->", "getPdfInstance", "(", "array_shift", "(", "$", "pdfs", ")", ")", ";", "foreach", "(", "$", "pdfs", "as", "$", "pdf", ")", "{", "$", "outPdf", "->", "importPdf", "(", "$", "pdf", ",", "(", "$", "pdf", "instanceof", "Pdf", ")", ")", ";", "}", "return", "$", "outPdf", ";", "}" ]
Merges all pdfs in the given array into One. Enlarging the first Pdf in Array. @param string[]|Pdf[] $pdfs Each element could be PDF path or Pdf Object. @return Pdf the PDF
[ "Merges", "all", "pdfs", "in", "the", "given", "array", "into", "One", ".", "Enlarging", "the", "first", "Pdf", "in", "Array", "." ]
0b2a199981486a08206d015e7f1e5e26397301f0
https://github.com/juanmf/PdfManager/blob/0b2a199981486a08206d015e7f1e5e26397301f0/Fpdi/Traits/FpdiPdfManagerMergeTrait.php#L21-L29
232,769
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.server
public function server(string $key = null, $default = null) { if (is_null($key)) { return $this->getServerParams(); } return $this->getServerParams()[$key] ?? $default; }
php
public function server(string $key = null, $default = null) { if (is_null($key)) { return $this->getServerParams(); } return $this->getServerParams()[$key] ?? $default; }
[ "public", "function", "server", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "getServerParams", "(", ")", ";", "}", "return", "$", "this", "->", "getServerParams", "(", ")", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
Retrieve a server variable from the request @param null|string $key @param null|mixed $default @return array|string|mixed
[ "Retrieve", "a", "server", "variable", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L26-L32
232,770
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.header
public function header(string $key = null, $default = null) { if (is_null($key)) { return $this->getHeaders(); } return $this->getHeader($key) ?? $default; }
php
public function header(string $key = null, $default = null) { if (is_null($key)) { return $this->getHeaders(); } return $this->getHeader($key) ?? $default; }
[ "public", "function", "header", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "getHeaders", "(", ")", ";", "}", "return", "$", "this", "->", "getHeader", "(", "$", "key", ")", "??", "$", "default", ";", "}" ]
Retrieve a header from the request @param null|string $key @param null|mixed $default @return array|string|mixed
[ "Retrieve", "a", "header", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L41-L47
232,771
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.query
public function query(string $key = null, $default = null) { if (is_null($key)) { return $this->getQueryParams(); } return $this->getQueryParams()[$key] ?? $default; }
php
public function query(string $key = null, $default = null) { if (is_null($key)) { return $this->getQueryParams(); } return $this->getQueryParams()[$key] ?? $default; }
[ "public", "function", "query", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "getQueryParams", "(", ")", ";", "}", "return", "$", "this", "->", "getQueryParams", "(", ")", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
Retrieve a query string from the request @param null|string $key @param null|mixed $default @return array|string|mixed
[ "Retrieve", "a", "query", "string", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L56-L62
232,772
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.post
public function post(string $key = null, $default = null) { if (is_null($key)) { return $this->getParsedBody(); } return $this->getParsedBody()[$key] ?? $default; }
php
public function post(string $key = null, $default = null) { if (is_null($key)) { return $this->getParsedBody(); } return $this->getParsedBody()[$key] ?? $default; }
[ "public", "function", "post", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "getParsedBody", "(", ")", ";", "}", "return", "$", "this", "->", "getParsedBody", "(", ")", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
Retrieve a post item from the request @param null|string $key @param null|mixed $default @return array|string|mixed
[ "Retrieve", "a", "post", "item", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L71-L77
232,773
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.input
public function input(string $key = null, $default = null) { $inputs = $this->getQueryParams() + $this->getParsedBody(); if (is_null($key)) { return $inputs; } return $inputs[$key] ?? $default; }
php
public function input(string $key = null, $default = null) { $inputs = $this->getQueryParams() + $this->getParsedBody(); if (is_null($key)) { return $inputs; } return $inputs[$key] ?? $default; }
[ "public", "function", "input", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "$", "inputs", "=", "$", "this", "->", "getQueryParams", "(", ")", "+", "$", "this", "->", "getParsedBody", "(", ")", ";", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "inputs", ";", "}", "return", "$", "inputs", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
Retrieve a input item from the request @param null|string $key @param null|mixed $default @return array|string|mixed
[ "Retrieve", "a", "input", "item", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L86-L93
232,774
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.cookie
public function cookie(string $key = null, $default = null) { if (is_null($key)) { return $this->getCookieParams(); } return $this->getCookieParams()[$key] ?? $default; }
php
public function cookie(string $key = null, $default = null) { if (is_null($key)) { return $this->getCookieParams(); } return $this->getCookieParams()[$key] ?? $default; }
[ "public", "function", "cookie", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "getCookieParams", "(", ")", ";", "}", "return", "$", "this", "->", "getCookieParams", "(", ")", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
Retrieve a cookie from the request @param null|string $key @param null|mixed $default @return array|string|mixed
[ "Retrieve", "a", "cookie", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L102-L108
232,775
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.raw
public function raw($default = null) { $body = $this->getBody(); $raw = $default; if ($body instanceof SwooleStream) { $raw = $body->getContents(); } return $raw; }
php
public function raw($default = null) { $body = $this->getBody(); $raw = $default; if ($body instanceof SwooleStream) { $raw = $body->getContents(); } return $raw; }
[ "public", "function", "raw", "(", "$", "default", "=", "null", ")", "{", "$", "body", "=", "$", "this", "->", "getBody", "(", ")", ";", "$", "raw", "=", "$", "default", ";", "if", "(", "$", "body", "instanceof", "SwooleStream", ")", "{", "$", "raw", "=", "$", "body", "->", "getContents", "(", ")", ";", "}", "return", "$", "raw", ";", "}" ]
Retrieve raw body from the request @param null|mixed $default @return array|string|mixed
[ "Retrieve", "raw", "body", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L116-L124
232,776
swoft-cloud/swoft-http-message
src/Server/Concerns/InteractsWithInput.php
InteractsWithInput.file
public function file(string $key = null, $default = null) { if (is_null($key)) { return $this->getUploadedFiles(); } return $this->getUploadedFiles()[$key] ?? $default; }
php
public function file(string $key = null, $default = null) { if (is_null($key)) { return $this->getUploadedFiles(); } return $this->getUploadedFiles()[$key] ?? $default; }
[ "public", "function", "file", "(", "string", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "key", ")", ")", "{", "return", "$", "this", "->", "getUploadedFiles", "(", ")", ";", "}", "return", "$", "this", "->", "getUploadedFiles", "(", ")", "[", "$", "key", "]", "??", "$", "default", ";", "}" ]
Retrieve a upload item from the request @param string|null $key @param null $default @return array|\Swoft\Web\UploadedFile|null
[ "Retrieve", "a", "upload", "item", "from", "the", "request" ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Server/Concerns/InteractsWithInput.php#L165-L171
232,777
asinfotrack/yii2-toolbox
console/Migration.php
Migration.isTableEmpty
public function isTableEmpty($tableName) { $tableNameQuoted = $this->getDb()->quoteTableName($tableName); $cmd = sprintf('SELECT COUNT(*) FROM %s', $tableNameQuoted); return $this->getDb()->createCommand($cmd)->queryScalar() === 0; }
php
public function isTableEmpty($tableName) { $tableNameQuoted = $this->getDb()->quoteTableName($tableName); $cmd = sprintf('SELECT COUNT(*) FROM %s', $tableNameQuoted); return $this->getDb()->createCommand($cmd)->queryScalar() === 0; }
[ "public", "function", "isTableEmpty", "(", "$", "tableName", ")", "{", "$", "tableNameQuoted", "=", "$", "this", "->", "getDb", "(", ")", "->", "quoteTableName", "(", "$", "tableName", ")", ";", "$", "cmd", "=", "sprintf", "(", "'SELECT COUNT(*) FROM %s'", ",", "$", "tableNameQuoted", ")", ";", "return", "$", "this", "->", "getDb", "(", ")", "->", "createCommand", "(", "$", "cmd", ")", "->", "queryScalar", "(", ")", "===", "0", ";", "}" ]
Returns whether or not a table is empty @param string $tableName name of the table @return bool true if empty
[ "Returns", "whether", "or", "not", "a", "table", "is", "empty" ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/console/Migration.php#L23-L29
232,778
asinfotrack/yii2-toolbox
console/Migration.php
Migration.createAuditedTable
public function createAuditedTable($table, $columns, $options=null, $createdField='created', $createdByField='created_by', $updatedField='updated', $updatedByField='updated_by', $userTableName='{{%user}}', $userIdField='id', $createdOnDelete='SET NULL', $updatedOnDelete='SET NULL') { //first create the table $this->createTable($table, $columns, $options); //alter table and add audit fields $this->addColumn($table, $createdField, Schema::TYPE_INTEGER); $this->addColumn($table, $createdByField, Schema::TYPE_INTEGER); $this->addColumn($table, $updatedField, Schema::TYPE_INTEGER); $this->addColumn($table, $updatedByField, Schema::TYPE_INTEGER); //get actual table names $tableNameThis = $this->db->quoteSql($table); $tableNameUser = $this->db->quoteSql($userTableName); //create names for created and updated by relations $str = 'FK_%s_%s_%s'; $fkCreatedBy = str_replace('`', '', sprintf($str, $tableNameThis, $tableNameUser, 'created')); $fkUpdatedBy = str_replace('`', '', sprintf($str, $tableNameThis, $tableNameUser, 'updated')); //create the foreign keys $this->addForeignKey($fkCreatedBy, $table, $createdByField, $userTableName, $userIdField, $createdOnDelete, 'CASCADE'); $this->addForeignKey($fkUpdatedBy, $table, $updatedByField, $userTableName, $userIdField, $updatedOnDelete, 'CASCADE'); }
php
public function createAuditedTable($table, $columns, $options=null, $createdField='created', $createdByField='created_by', $updatedField='updated', $updatedByField='updated_by', $userTableName='{{%user}}', $userIdField='id', $createdOnDelete='SET NULL', $updatedOnDelete='SET NULL') { //first create the table $this->createTable($table, $columns, $options); //alter table and add audit fields $this->addColumn($table, $createdField, Schema::TYPE_INTEGER); $this->addColumn($table, $createdByField, Schema::TYPE_INTEGER); $this->addColumn($table, $updatedField, Schema::TYPE_INTEGER); $this->addColumn($table, $updatedByField, Schema::TYPE_INTEGER); //get actual table names $tableNameThis = $this->db->quoteSql($table); $tableNameUser = $this->db->quoteSql($userTableName); //create names for created and updated by relations $str = 'FK_%s_%s_%s'; $fkCreatedBy = str_replace('`', '', sprintf($str, $tableNameThis, $tableNameUser, 'created')); $fkUpdatedBy = str_replace('`', '', sprintf($str, $tableNameThis, $tableNameUser, 'updated')); //create the foreign keys $this->addForeignKey($fkCreatedBy, $table, $createdByField, $userTableName, $userIdField, $createdOnDelete, 'CASCADE'); $this->addForeignKey($fkUpdatedBy, $table, $updatedByField, $userTableName, $userIdField, $updatedOnDelete, 'CASCADE'); }
[ "public", "function", "createAuditedTable", "(", "$", "table", ",", "$", "columns", ",", "$", "options", "=", "null", ",", "$", "createdField", "=", "'created'", ",", "$", "createdByField", "=", "'created_by'", ",", "$", "updatedField", "=", "'updated'", ",", "$", "updatedByField", "=", "'updated_by'", ",", "$", "userTableName", "=", "'{{%user}}'", ",", "$", "userIdField", "=", "'id'", ",", "$", "createdOnDelete", "=", "'SET NULL'", ",", "$", "updatedOnDelete", "=", "'SET NULL'", ")", "{", "//first create the table", "$", "this", "->", "createTable", "(", "$", "table", ",", "$", "columns", ",", "$", "options", ")", ";", "//alter table and add audit fields", "$", "this", "->", "addColumn", "(", "$", "table", ",", "$", "createdField", ",", "Schema", "::", "TYPE_INTEGER", ")", ";", "$", "this", "->", "addColumn", "(", "$", "table", ",", "$", "createdByField", ",", "Schema", "::", "TYPE_INTEGER", ")", ";", "$", "this", "->", "addColumn", "(", "$", "table", ",", "$", "updatedField", ",", "Schema", "::", "TYPE_INTEGER", ")", ";", "$", "this", "->", "addColumn", "(", "$", "table", ",", "$", "updatedByField", ",", "Schema", "::", "TYPE_INTEGER", ")", ";", "//get actual table names", "$", "tableNameThis", "=", "$", "this", "->", "db", "->", "quoteSql", "(", "$", "table", ")", ";", "$", "tableNameUser", "=", "$", "this", "->", "db", "->", "quoteSql", "(", "$", "userTableName", ")", ";", "//create names for created and updated by relations", "$", "str", "=", "'FK_%s_%s_%s'", ";", "$", "fkCreatedBy", "=", "str_replace", "(", "'`'", ",", "''", ",", "sprintf", "(", "$", "str", ",", "$", "tableNameThis", ",", "$", "tableNameUser", ",", "'created'", ")", ")", ";", "$", "fkUpdatedBy", "=", "str_replace", "(", "'`'", ",", "''", ",", "sprintf", "(", "$", "str", ",", "$", "tableNameThis", ",", "$", "tableNameUser", ",", "'updated'", ")", ")", ";", "//create the foreign keys", "$", "this", "->", "addForeignKey", "(", "$", "fkCreatedBy", ",", "$", "table", ",", "$", "createdByField", ",", "$", "userTableName", ",", "$", "userIdField", ",", "$", "createdOnDelete", ",", "'CASCADE'", ")", ";", "$", "this", "->", "addForeignKey", "(", "$", "fkUpdatedBy", ",", "$", "table", ",", "$", "updatedByField", ",", "$", "userTableName", ",", "$", "userIdField", ",", "$", "updatedOnDelete", ",", "'CASCADE'", ")", ";", "}" ]
Builds and executes a SQL statement for creating a new DB table. This method also creates the fields and relations needed for audit trail functionality. The columns in the new table should be specified as name-definition pairs (e.g. 'name' => 'string'), where name stands for a column name which will be properly quoted by the method, and definition stands for the column type which can contain an abstract DB type. The [[QueryBuilder::getColumnType()]] method will be invoked to convert any abstract type into a physical one. If a column is specified with definition only (e.g. 'PRIMARY KEY (name, type)'), it will be directly put into the generated SQL. @param string $table the name of the table to be created. The name will be properly quoted by the method. @param array $columns the columns (name => definition) in the new table. @param string $options additional SQL fragment that will be appended to the generated SQL. @param string $createdField field name holding the created timstamp @param string $createdByField field name holding the id of the user creating a record @param string $updatedField field name holding the updated timstamp @param string $updatedByField field name holding the id of the user updating a record @param string $userTableName user table name @param string $userIdField id field of the user table @param string $createdOnDelete fk option whend a user gets deleted @param string $updatedOnDelete fk option whend a user gets deleted
[ "Builds", "and", "executes", "a", "SQL", "statement", "for", "creating", "a", "new", "DB", "table", ".", "This", "method", "also", "creates", "the", "fields", "and", "relations", "needed", "for", "audit", "trail", "functionality", "." ]
236f41e4b6e30117b3d7f9b1a5598633c5aed376
https://github.com/asinfotrack/yii2-toolbox/blob/236f41e4b6e30117b3d7f9b1a5598633c5aed376/console/Migration.php#L56-L83
232,779
silverstripe-archive/deploynaut
code/model/DNBranchList.php
DNBranchList.byName
public function byName($name) { if($this->loaded == false) { $this->getIterator(); } if(isset($this->items[$name])) return $this->items[$name]; }
php
public function byName($name) { if($this->loaded == false) { $this->getIterator(); } if(isset($this->items[$name])) return $this->items[$name]; }
[ "public", "function", "byName", "(", "$", "name", ")", "{", "if", "(", "$", "this", "->", "loaded", "==", "false", ")", "{", "$", "this", "->", "getIterator", "(", ")", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "items", "[", "$", "name", "]", ")", ")", "return", "$", "this", "->", "items", "[", "$", "name", "]", ";", "}" ]
Find a branch in this set by branch name.
[ "Find", "a", "branch", "in", "this", "set", "by", "branch", "name", "." ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/model/DNBranchList.php#L55-L61
232,780
CottaCush/phalcon-user-auth
src/Models/UserType.php
UserType.validation
public function validation() { $validator = new Validation(); $validator->add('name', new PresenceOf([ 'message' => 'User type name must be supplied' ])); $validator->add('name', new Uniqueness([ 'message' => 'Sorry, the user type already exists' ])); return $this->validate($validator); }
php
public function validation() { $validator = new Validation(); $validator->add('name', new PresenceOf([ 'message' => 'User type name must be supplied' ])); $validator->add('name', new Uniqueness([ 'message' => 'Sorry, the user type already exists' ])); return $this->validate($validator); }
[ "public", "function", "validation", "(", ")", "{", "$", "validator", "=", "new", "Validation", "(", ")", ";", "$", "validator", "->", "add", "(", "'name'", ",", "new", "PresenceOf", "(", "[", "'message'", "=>", "'User type name must be supplied'", "]", ")", ")", ";", "$", "validator", "->", "add", "(", "'name'", ",", "new", "Uniqueness", "(", "[", "'message'", "=>", "'Sorry, the user type already exists'", "]", ")", ")", ";", "return", "$", "this", "->", "validate", "(", "$", "validator", ")", ";", "}" ]
Validate user type entered @return bool
[ "Validate", "user", "type", "entered" ]
89c8a1ae5e6f712591ba66bc2dd5e8a9f73b9d54
https://github.com/CottaCush/phalcon-user-auth/blob/89c8a1ae5e6f712591ba66bc2dd5e8a9f73b9d54/src/Models/UserType.php#L112-L126
232,781
ameliaikeda/backblaze
src/BackblazeServiceProvider.php
BackblazeServiceProvider.boot
public function boot() { Storage::extend('b2', function ($app, $config) { $client = new Client($config['account'], $config['key']); $adapter = new Adapter($client, $config['bucket'], $config['host']); return new Filesystem($adapter); }); }
php
public function boot() { Storage::extend('b2', function ($app, $config) { $client = new Client($config['account'], $config['key']); $adapter = new Adapter($client, $config['bucket'], $config['host']); return new Filesystem($adapter); }); }
[ "public", "function", "boot", "(", ")", "{", "Storage", "::", "extend", "(", "'b2'", ",", "function", "(", "$", "app", ",", "$", "config", ")", "{", "$", "client", "=", "new", "Client", "(", "$", "config", "[", "'account'", "]", ",", "$", "config", "[", "'key'", "]", ")", ";", "$", "adapter", "=", "new", "Adapter", "(", "$", "client", ",", "$", "config", "[", "'bucket'", "]", ",", "$", "config", "[", "'host'", "]", ")", ";", "return", "new", "Filesystem", "(", "$", "adapter", ")", ";", "}", ")", ";", "}" ]
Boot this service provider. @return void
[ "Boot", "this", "service", "provider", "." ]
72dd26a55549e3bfd7a551e019b9eefad7e50f5e
https://github.com/ameliaikeda/backblaze/blob/72dd26a55549e3bfd7a551e019b9eefad7e50f5e/src/BackblazeServiceProvider.php#L16-L25
232,782
bav-php/bav
classes/validator/validators/ValidatorD5.php
ValidatorD5.validate
protected function validate() { $this->validator = substr($this->account, 2, 2) == 99 ? $this->validator1 : $this->validatorChain; }
php
protected function validate() { $this->validator = substr($this->account, 2, 2) == 99 ? $this->validator1 : $this->validatorChain; }
[ "protected", "function", "validate", "(", ")", "{", "$", "this", "->", "validator", "=", "substr", "(", "$", "this", "->", "account", ",", "2", ",", "2", ")", "==", "99", "?", "$", "this", "->", "validator1", ":", "$", "this", "->", "validatorChain", ";", "}" ]
decide which validators are used @return void
[ "decide", "which", "validators", "are", "used" ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/validators/ValidatorD5.php#L88-L94
232,783
swoft-cloud/swoft-http-message
src/Base/Request.php
Request.withMethod
public function withMethod($method) { $method = strtoupper($method); $methods = ['GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'HEAD']; if (! in_array($method, $methods)) { throw new \InvalidArgumentException('Invalid Method'); } $new = clone $this; $new->method = $method; return $new; }
php
public function withMethod($method) { $method = strtoupper($method); $methods = ['GET', 'POST', 'PATCH', 'PUT', 'DELETE', 'HEAD']; if (! in_array($method, $methods)) { throw new \InvalidArgumentException('Invalid Method'); } $new = clone $this; $new->method = $method; return $new; }
[ "public", "function", "withMethod", "(", "$", "method", ")", "{", "$", "method", "=", "strtoupper", "(", "$", "method", ")", ";", "$", "methods", "=", "[", "'GET'", ",", "'POST'", ",", "'PATCH'", ",", "'PUT'", ",", "'DELETE'", ",", "'HEAD'", "]", ";", "if", "(", "!", "in_array", "(", "$", "method", ",", "$", "methods", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid Method'", ")", ";", "}", "$", "new", "=", "clone", "$", "this", ";", "$", "new", "->", "method", "=", "$", "method", ";", "return", "$", "new", ";", "}" ]
Return an instance with the provided HTTP method. While HTTP method names are typically all uppercase characters, HTTP method names are case-sensitive and thus implementations SHOULD NOT modify the given string. This method MUST be implemented in such a way as to retain the immutability of the message, and MUST return an instance that has the changed request method. @param string $method Case-sensitive method. @return static @throws \InvalidArgumentException for invalid HTTP methods.
[ "Return", "an", "instance", "with", "the", "provided", "HTTP", "method", ".", "While", "HTTP", "method", "names", "are", "typically", "all", "uppercase", "characters", "HTTP", "method", "names", "are", "case", "-", "sensitive", "and", "thus", "implementations", "SHOULD", "NOT", "modify", "the", "given", "string", ".", "This", "method", "MUST", "be", "implemented", "in", "such", "a", "way", "as", "to", "retain", "the", "immutability", "of", "the", "message", "and", "MUST", "return", "an", "instance", "that", "has", "the", "changed", "request", "method", "." ]
5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a
https://github.com/swoft-cloud/swoft-http-message/blob/5cc36c68b24d8ff9bc75cd0f6c8492bcc452f73a/src/Base/Request.php#L155-L165
232,784
bav-php/bav
classes/validator/Validator.php
Validator.isValid
public function isValid($account) { try { if ($account == null) { return false; } $this->checkType($account); $this->init($account); $this->validate(); return ltrim($account, "0") != "" && $this->getResult(); } catch (ValidatorOutOfBoundsException $e) { return false; } }
php
public function isValid($account) { try { if ($account == null) { return false; } $this->checkType($account); $this->init($account); $this->validate(); return ltrim($account, "0") != "" && $this->getResult(); } catch (ValidatorOutOfBoundsException $e) { return false; } }
[ "public", "function", "isValid", "(", "$", "account", ")", "{", "try", "{", "if", "(", "$", "account", "==", "null", ")", "{", "return", "false", ";", "}", "$", "this", "->", "checkType", "(", "$", "account", ")", ";", "$", "this", "->", "init", "(", "$", "account", ")", ";", "$", "this", "->", "validate", "(", ")", ";", "return", "ltrim", "(", "$", "account", ",", "\"0\"", ")", "!=", "\"\"", "&&", "$", "this", "->", "getResult", "(", ")", ";", "}", "catch", "(", "ValidatorOutOfBoundsException", "$", "e", ")", "{", "return", "false", ";", "}", "}" ]
Validates a bank account. Null is considered invalid. Note: The parameter $account should be a string. If it's not a string an E_USER_WARNING will be raised. Bank accounts may start with leading zeros, wich lead to unexpected results if not treated as a string ( e.g. (int) 0020012357 evaluates to (string) '4199663'). @param string $account bank account @return bool
[ "Validates", "a", "bank", "account", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/Validator.php#L99-L115
232,785
bav-php/bav
classes/validator/Validator.php
Validator.getNormalizedPosition
protected function getNormalizedPosition($pos) { if ($pos >= strlen($this->account) || $pos < -strlen($this->account)) { throw new ValidatorOutOfBoundsException("Cannot access offset $pos in String $this->account"); } if ($pos >= 0) { return $pos; } return strlen($this->account) + $pos; }
php
protected function getNormalizedPosition($pos) { if ($pos >= strlen($this->account) || $pos < -strlen($this->account)) { throw new ValidatorOutOfBoundsException("Cannot access offset $pos in String $this->account"); } if ($pos >= 0) { return $pos; } return strlen($this->account) + $pos; }
[ "protected", "function", "getNormalizedPosition", "(", "$", "pos", ")", "{", "if", "(", "$", "pos", ">=", "strlen", "(", "$", "this", "->", "account", ")", "||", "$", "pos", "<", "-", "strlen", "(", "$", "this", "->", "account", ")", ")", "{", "throw", "new", "ValidatorOutOfBoundsException", "(", "\"Cannot access offset $pos in String $this->account\"", ")", ";", "}", "if", "(", "$", "pos", ">=", "0", ")", "{", "return", "$", "pos", ";", "}", "return", "strlen", "(", "$", "this", "->", "account", ")", "+", "$", "pos", ";", "}" ]
converts negative positions. @param int $pos @return int @throws ValidatorOutOfBoundsException
[ "converts", "negative", "positions", "." ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/Validator.php#L161-L173
232,786
bav-php/bav
classes/validator/Validator.php
Validator.crossSum
protected function crossSum($int) { $sum = 0; $str_int = (string) $int; for ($i = 0; $i < strlen($str_int); $i++) { //$sum = bcadd($str_int{$i}, $sum); $sum += $str_int{$i}; } return $sum; }
php
protected function crossSum($int) { $sum = 0; $str_int = (string) $int; for ($i = 0; $i < strlen($str_int); $i++) { //$sum = bcadd($str_int{$i}, $sum); $sum += $str_int{$i}; } return $sum; }
[ "protected", "function", "crossSum", "(", "$", "int", ")", "{", "$", "sum", "=", "0", ";", "$", "str_int", "=", "(", "string", ")", "$", "int", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "strlen", "(", "$", "str_int", ")", ";", "$", "i", "++", ")", "{", "//$sum = bcadd($str_int{$i}, $sum);", "$", "sum", "+=", "$", "str_int", "{", "$", "i", "}", ";", "}", "return", "$", "sum", ";", "}" ]
Some validators need this @param int $int @return int
[ "Some", "validators", "need", "this" ]
2ad288cfc065d5c1ce31184de05aa0693e94bdb9
https://github.com/bav-php/bav/blob/2ad288cfc065d5c1ce31184de05aa0693e94bdb9/classes/validator/Validator.php#L181-L191
232,787
laraplug/product-module
Traits/FeaturedImageTrait.php
FeaturedImageTrait.getMediumThumbAttribute
public function getMediumThumbAttribute() { if ($image = $this->images->first()) { return app(Imagy::class)->getThumbnail($image->path, 'mediumThumb'); } return Module::asset('product:images/placeholder_mediumThumb.jpg'); }
php
public function getMediumThumbAttribute() { if ($image = $this->images->first()) { return app(Imagy::class)->getThumbnail($image->path, 'mediumThumb'); } return Module::asset('product:images/placeholder_mediumThumb.jpg'); }
[ "public", "function", "getMediumThumbAttribute", "(", ")", "{", "if", "(", "$", "image", "=", "$", "this", "->", "images", "->", "first", "(", ")", ")", "{", "return", "app", "(", "Imagy", "::", "class", ")", "->", "getThumbnail", "(", "$", "image", "->", "path", ",", "'mediumThumb'", ")", ";", "}", "return", "Module", "::", "asset", "(", "'product:images/placeholder_mediumThumb.jpg'", ")", ";", "}" ]
Returns thumnail url
[ "Returns", "thumnail", "url" ]
0a835482d2888a05bfe145e1b453926832185ae0
https://github.com/laraplug/product-module/blob/0a835482d2888a05bfe145e1b453926832185ae0/Traits/FeaturedImageTrait.php#L64-L71
232,788
dmitriybelyy/yii2-cassandra-cql
phpcassa/UUID.php
UUID.mint
public static function mint($ver = 1, $node = NULL, $ns = NULL, $time = NULL, $sequence = NULL ) { switch((int) $ver) { case 1: return new self(self::mintTime($node, $time, $sequence)); case 2: // Version 2 is not supported throw new UUIDException("Version 2 is unsupported."); case 3: return new self(self::mintName(self::MD5, $node, $ns)); case 4: return new self(self::mintRand()); case 5: return new self(self::mintName(self::SHA1, $node, $ns)); default: throw new UUIDException("Selected version is invalid or unsupported."); } }
php
public static function mint($ver = 1, $node = NULL, $ns = NULL, $time = NULL, $sequence = NULL ) { switch((int) $ver) { case 1: return new self(self::mintTime($node, $time, $sequence)); case 2: // Version 2 is not supported throw new UUIDException("Version 2 is unsupported."); case 3: return new self(self::mintName(self::MD5, $node, $ns)); case 4: return new self(self::mintRand()); case 5: return new self(self::mintName(self::SHA1, $node, $ns)); default: throw new UUIDException("Selected version is invalid or unsupported."); } }
[ "public", "static", "function", "mint", "(", "$", "ver", "=", "1", ",", "$", "node", "=", "NULL", ",", "$", "ns", "=", "NULL", ",", "$", "time", "=", "NULL", ",", "$", "sequence", "=", "NULL", ")", "{", "switch", "(", "(", "int", ")", "$", "ver", ")", "{", "case", "1", ":", "return", "new", "self", "(", "self", "::", "mintTime", "(", "$", "node", ",", "$", "time", ",", "$", "sequence", ")", ")", ";", "case", "2", ":", "// Version 2 is not supported ", "throw", "new", "UUIDException", "(", "\"Version 2 is unsupported.\"", ")", ";", "case", "3", ":", "return", "new", "self", "(", "self", "::", "mintName", "(", "self", "::", "MD5", ",", "$", "node", ",", "$", "ns", ")", ")", ";", "case", "4", ":", "return", "new", "self", "(", "self", "::", "mintRand", "(", ")", ")", ";", "case", "5", ":", "return", "new", "self", "(", "self", "::", "mintName", "(", "self", "::", "SHA1", ",", "$", "node", ",", "$", "ns", ")", ")", ";", "default", ":", "throw", "new", "UUIDException", "(", "\"Selected version is invalid or unsupported.\"", ")", ";", "}", "}" ]
Create a new UUID based on provided data. @param int $ver the UUID version to generate. @param string|null $node MAC address, bin or hex @param string|null $ns UUID namespace @param int|null $time Unix time, NB: microseconds = time() * 1000000 @param string|null $sequence Do not use unless need fully deterministic UUID @return UUID @throws UUID\UUIDException
[ "Create", "a", "new", "UUID", "based", "on", "provided", "data", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/UUID.php#L142-L158
232,789
dmitriybelyy/yii2-cassandra-cql
phpcassa/UUID.php
UUID.compare
public static function compare($a, $b) { if (self::makeBin($a, 16)==self::makeBin($b, 16)) return TRUE; else return FALSE; }
php
public static function compare($a, $b) { if (self::makeBin($a, 16)==self::makeBin($b, 16)) return TRUE; else return FALSE; }
[ "public", "static", "function", "compare", "(", "$", "a", ",", "$", "b", ")", "{", "if", "(", "self", "::", "makeBin", "(", "$", "a", ",", "16", ")", "==", "self", "::", "makeBin", "(", "$", "b", ",", "16", ")", ")", "return", "TRUE", ";", "else", "return", "FALSE", ";", "}" ]
Compare the binary representations of two UUIDs. The comparison will return true if they are bit-exact, or if neither is valid.
[ "Compare", "the", "binary", "representations", "of", "two", "UUIDs", ".", "The", "comparison", "will", "return", "true", "if", "they", "are", "bit", "-", "exact", "or", "if", "neither", "is", "valid", "." ]
fa0fd4914444f64baba20848c7d4146c1b430346
https://github.com/dmitriybelyy/yii2-cassandra-cql/blob/fa0fd4914444f64baba20848c7d4146c1b430346/phpcassa/UUID.php#L165-L170
232,790
silverstripe-archive/deploynaut
code/control/DeployForm.php
DeployForm_ValidatorBase.validateCommit
protected function validateCommit($sha, $field) { // Check selected commit if(empty($sha)) { $this->validationError( $field, "No valid release selected", "required" ); return false; } // Check validity of commit if (!preg_match('/^[a-f0-9]{40}$/', $sha)) { $this->validationError( $field, "Invalid release SHA: " . Convert::raw2xml($sha), "error" ); return false; } return true; }
php
protected function validateCommit($sha, $field) { // Check selected commit if(empty($sha)) { $this->validationError( $field, "No valid release selected", "required" ); return false; } // Check validity of commit if (!preg_match('/^[a-f0-9]{40}$/', $sha)) { $this->validationError( $field, "Invalid release SHA: " . Convert::raw2xml($sha), "error" ); return false; } return true; }
[ "protected", "function", "validateCommit", "(", "$", "sha", ",", "$", "field", ")", "{", "// Check selected commit", "if", "(", "empty", "(", "$", "sha", ")", ")", "{", "$", "this", "->", "validationError", "(", "$", "field", ",", "\"No valid release selected\"", ",", "\"required\"", ")", ";", "return", "false", ";", "}", "// Check validity of commit", "if", "(", "!", "preg_match", "(", "'/^[a-f0-9]{40}$/'", ",", "$", "sha", ")", ")", "{", "$", "this", "->", "validationError", "(", "$", "field", ",", "\"Invalid release SHA: \"", ".", "Convert", "::", "raw2xml", "(", "$", "sha", ")", ",", "\"error\"", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate a commit sha @param string $sha @return boolean
[ "Validate", "a", "commit", "sha" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DeployForm.php#L23-L45
232,791
silverstripe-archive/deploynaut
code/control/DeployForm.php
DeployForm.buildPipelineField
protected function buildPipelineField($commits) { // Get filtered commits $filteredCommits = array(); foreach ($commits as $commit) { $title = sprintf( "%s (%s, %s old)", $commit->Message, substr($commit->SHA,0,8), $commit->dbObject('Created')->TimeDiff() ); $filteredCommits[$commit->SHA] = $title; } if($filteredCommits) { return new DropdownField('FilteredCommits', '', $filteredCommits); } else { return DropdownField::create('FilteredCommits)', '') ->setEmptyString('No deployments available') ->performDisabledTransformation(); } }
php
protected function buildPipelineField($commits) { // Get filtered commits $filteredCommits = array(); foreach ($commits as $commit) { $title = sprintf( "%s (%s, %s old)", $commit->Message, substr($commit->SHA,0,8), $commit->dbObject('Created')->TimeDiff() ); $filteredCommits[$commit->SHA] = $title; } if($filteredCommits) { return new DropdownField('FilteredCommits', '', $filteredCommits); } else { return DropdownField::create('FilteredCommits)', '') ->setEmptyString('No deployments available') ->performDisabledTransformation(); } }
[ "protected", "function", "buildPipelineField", "(", "$", "commits", ")", "{", "// Get filtered commits", "$", "filteredCommits", "=", "array", "(", ")", ";", "foreach", "(", "$", "commits", "as", "$", "commit", ")", "{", "$", "title", "=", "sprintf", "(", "\"%s (%s, %s old)\"", ",", "$", "commit", "->", "Message", ",", "substr", "(", "$", "commit", "->", "SHA", ",", "0", ",", "8", ")", ",", "$", "commit", "->", "dbObject", "(", "'Created'", ")", "->", "TimeDiff", "(", ")", ")", ";", "$", "filteredCommits", "[", "$", "commit", "->", "SHA", "]", "=", "$", "title", ";", "}", "if", "(", "$", "filteredCommits", ")", "{", "return", "new", "DropdownField", "(", "'FilteredCommits'", ",", "''", ",", "$", "filteredCommits", ")", ";", "}", "else", "{", "return", "DropdownField", "::", "create", "(", "'FilteredCommits)'", ",", "''", ")", "->", "setEmptyString", "(", "'No deployments available'", ")", "->", "performDisabledTransformation", "(", ")", ";", "}", "}" ]
Generate fields necessary to select from a filtered commit list @param DNEnvironment $environment @param DataList $commits List of commits @return FormField
[ "Generate", "fields", "necessary", "to", "select", "from", "a", "filtered", "commit", "list" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DeployForm.php#L280-L299
232,792
silverstripe-archive/deploynaut
code/control/DeployForm.php
DeployForm.getSelectedBuild
public function getSelectedBuild($data) { if(isset($data['SelectRelease']) && !empty($data[$data['SelectRelease']])) { // Filter out the tag/branch name if required $array = explode('-', $data[$data['SelectRelease']]); return reset($array); } if(isset($data['FilteredCommits']) && !empty($data['FilteredCommits'])) { return $data['FilteredCommits']; } }
php
public function getSelectedBuild($data) { if(isset($data['SelectRelease']) && !empty($data[$data['SelectRelease']])) { // Filter out the tag/branch name if required $array = explode('-', $data[$data['SelectRelease']]); return reset($array); } if(isset($data['FilteredCommits']) && !empty($data['FilteredCommits'])) { return $data['FilteredCommits']; } }
[ "public", "function", "getSelectedBuild", "(", "$", "data", ")", "{", "if", "(", "isset", "(", "$", "data", "[", "'SelectRelease'", "]", ")", "&&", "!", "empty", "(", "$", "data", "[", "$", "data", "[", "'SelectRelease'", "]", "]", ")", ")", "{", "// Filter out the tag/branch name if required", "$", "array", "=", "explode", "(", "'-'", ",", "$", "data", "[", "$", "data", "[", "'SelectRelease'", "]", "]", ")", ";", "return", "reset", "(", "$", "array", ")", ";", "}", "if", "(", "isset", "(", "$", "data", "[", "'FilteredCommits'", "]", ")", "&&", "!", "empty", "(", "$", "data", "[", "'FilteredCommits'", "]", ")", ")", "{", "return", "$", "data", "[", "'FilteredCommits'", "]", ";", "}", "}" ]
Get the build selected from the given data @param array $data @return string SHA of selected build
[ "Get", "the", "build", "selected", "from", "the", "given", "data" ]
0b04dadcd089f606d99728f7ee57f374a06211c9
https://github.com/silverstripe-archive/deploynaut/blob/0b04dadcd089f606d99728f7ee57f374a06211c9/code/control/DeployForm.php#L307-L316
232,793
irishdan/PDFTronBundle
Services/PDFJoiner.php
PDFJoiner.joinPDFs
public function joinPDFs(array $PDFPaths, $outputDestination = null) { foreach ($PDFPaths as $key => $PDFPath) { if ($key > 0) { $this->joinTwoPDFs($PDFPaths[$key - 1], $PDFPath, $outputDestination); } } }
php
public function joinPDFs(array $PDFPaths, $outputDestination = null) { foreach ($PDFPaths as $key => $PDFPath) { if ($key > 0) { $this->joinTwoPDFs($PDFPaths[$key - 1], $PDFPath, $outputDestination); } } }
[ "public", "function", "joinPDFs", "(", "array", "$", "PDFPaths", ",", "$", "outputDestination", "=", "null", ")", "{", "foreach", "(", "$", "PDFPaths", "as", "$", "key", "=>", "$", "PDFPath", ")", "{", "if", "(", "$", "key", ">", "0", ")", "{", "$", "this", "->", "joinTwoPDFs", "(", "$", "PDFPaths", "[", "$", "key", "-", "1", "]", ",", "$", "PDFPath", ",", "$", "outputDestination", ")", ";", "}", "}", "}" ]
Merge PDFs sequentially. @param array $PDFPaths @param null $outputDestination
[ "Merge", "PDFs", "sequentially", "." ]
72926bf9a39256a8438b320f61ec071be3c5a655
https://github.com/irishdan/PDFTronBundle/blob/72926bf9a39256a8438b320f61ec071be3c5a655/Services/PDFJoiner.php#L33-L40
232,794
irishdan/PDFTronBundle
Services/PDFJoiner.php
PDFJoiner.joinTwoPDFs
public function joinTwoPDFs($firstPDFPath, $secondPDFPath, $outputDestination = null) { $firstPDF = new \PDFDoc($firstPDFPath); $firstPDF->InitSecurityHandler(); $secondPDF = new \PDFDoc($secondPDFPath); $firstPDF->InsertPages(1, $secondPDF, 1, $secondPDF->GetPageCount(), \PDFDoc::e_none); $secondPDF->Close(); if (!empty($outputDestination)) { $firstPDF->Save($outputDestination, \SDFDoc::e_remove_unused); } else { $firstPDF->Save($firstPDFPath, \SDFDoc::e_remove_unused); } }
php
public function joinTwoPDFs($firstPDFPath, $secondPDFPath, $outputDestination = null) { $firstPDF = new \PDFDoc($firstPDFPath); $firstPDF->InitSecurityHandler(); $secondPDF = new \PDFDoc($secondPDFPath); $firstPDF->InsertPages(1, $secondPDF, 1, $secondPDF->GetPageCount(), \PDFDoc::e_none); $secondPDF->Close(); if (!empty($outputDestination)) { $firstPDF->Save($outputDestination, \SDFDoc::e_remove_unused); } else { $firstPDF->Save($firstPDFPath, \SDFDoc::e_remove_unused); } }
[ "public", "function", "joinTwoPDFs", "(", "$", "firstPDFPath", ",", "$", "secondPDFPath", ",", "$", "outputDestination", "=", "null", ")", "{", "$", "firstPDF", "=", "new", "\\", "PDFDoc", "(", "$", "firstPDFPath", ")", ";", "$", "firstPDF", "->", "InitSecurityHandler", "(", ")", ";", "$", "secondPDF", "=", "new", "\\", "PDFDoc", "(", "$", "secondPDFPath", ")", ";", "$", "firstPDF", "->", "InsertPages", "(", "1", ",", "$", "secondPDF", ",", "1", ",", "$", "secondPDF", "->", "GetPageCount", "(", ")", ",", "\\", "PDFDoc", "::", "e_none", ")", ";", "$", "secondPDF", "->", "Close", "(", ")", ";", "if", "(", "!", "empty", "(", "$", "outputDestination", ")", ")", "{", "$", "firstPDF", "->", "Save", "(", "$", "outputDestination", ",", "\\", "SDFDoc", "::", "e_remove_unused", ")", ";", "}", "else", "{", "$", "firstPDF", "->", "Save", "(", "$", "firstPDFPath", ",", "\\", "SDFDoc", "::", "e_remove_unused", ")", ";", "}", "}" ]
Merge two PDFs one after the other. @param $firstPDFPath @param $secondPDFPath @param null $outputDestination
[ "Merge", "two", "PDFs", "one", "after", "the", "other", "." ]
72926bf9a39256a8438b320f61ec071be3c5a655
https://github.com/irishdan/PDFTronBundle/blob/72926bf9a39256a8438b320f61ec071be3c5a655/Services/PDFJoiner.php#L49-L64
232,795
laravel-notification-channels/hipchat
src/Card.php
Card.text
public function text($content = '') { $this->format = 'text'; if (! str_empty($content)) { $this->content($content); } return $this; }
php
public function text($content = '') { $this->format = 'text'; if (! str_empty($content)) { $this->content($content); } return $this; }
[ "public", "function", "text", "(", "$", "content", "=", "''", ")", "{", "$", "this", "->", "format", "=", "'text'", ";", "if", "(", "!", "str_empty", "(", "$", "content", ")", ")", "{", "$", "this", "->", "content", "(", "$", "content", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the format to plain text and optionally the content. @param string $content @return $this
[ "Sets", "the", "format", "to", "plain", "text", "and", "optionally", "the", "content", "." ]
c24bca85f7cf9f6804635aa206c961783e22e888
https://github.com/laravel-notification-channels/hipchat/blob/c24bca85f7cf9f6804635aa206c961783e22e888/src/Card.php#L214-L223
232,796
laravel-notification-channels/hipchat
src/Card.php
Card.html
public function html($content = '') { $this->format = 'html'; if (! str_empty($content)) { $this->content($content); } return $this; }
php
public function html($content = '') { $this->format = 'html'; if (! str_empty($content)) { $this->content($content); } return $this; }
[ "public", "function", "html", "(", "$", "content", "=", "''", ")", "{", "$", "this", "->", "format", "=", "'html'", ";", "if", "(", "!", "str_empty", "(", "$", "content", ")", ")", "{", "$", "this", "->", "content", "(", "$", "content", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the format to html and optionally the content. @param string $content @return $this
[ "Sets", "the", "format", "to", "html", "and", "optionally", "the", "content", "." ]
c24bca85f7cf9f6804635aa206c961783e22e888
https://github.com/laravel-notification-channels/hipchat/blob/c24bca85f7cf9f6804635aa206c961783e22e888/src/Card.php#L231-L240
232,797
laravel-notification-channels/hipchat
src/Card.php
Card.thumbnail
public function thumbnail($icon, $icon2 = null, $width = null, $height = null) { $this->thumbnail = trim($icon); if (! str_empty($icon2)) { $this->thumbnail2 = trim($icon2); } if (! is_null($width)) { $this->thumbnailWidth = $width; } if (! is_null($height)) { $this->thumbnailHeight = $height; } return $this; }
php
public function thumbnail($icon, $icon2 = null, $width = null, $height = null) { $this->thumbnail = trim($icon); if (! str_empty($icon2)) { $this->thumbnail2 = trim($icon2); } if (! is_null($width)) { $this->thumbnailWidth = $width; } if (! is_null($height)) { $this->thumbnailHeight = $height; } return $this; }
[ "public", "function", "thumbnail", "(", "$", "icon", ",", "$", "icon2", "=", "null", ",", "$", "width", "=", "null", ",", "$", "height", "=", "null", ")", "{", "$", "this", "->", "thumbnail", "=", "trim", "(", "$", "icon", ")", ";", "if", "(", "!", "str_empty", "(", "$", "icon2", ")", ")", "{", "$", "this", "->", "thumbnail2", "=", "trim", "(", "$", "icon2", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "width", ")", ")", "{", "$", "this", "->", "thumbnailWidth", "=", "$", "width", ";", "}", "if", "(", "!", "is_null", "(", "$", "height", ")", ")", "{", "$", "this", "->", "thumbnailHeight", "=", "$", "height", ";", "}", "return", "$", "this", ";", "}" ]
Sets the thumbnail of the card. @param string $icon @param string|null $icon2 @param int|null $width @param int|null $height @return $this
[ "Sets", "the", "thumbnail", "of", "the", "card", "." ]
c24bca85f7cf9f6804635aa206c961783e22e888
https://github.com/laravel-notification-channels/hipchat/blob/c24bca85f7cf9f6804635aa206c961783e22e888/src/Card.php#L277-L294
232,798
laravel-notification-channels/hipchat
src/Card.php
Card.activity
public function activity($html, $icon = null, $icon2 = null) { $this->activity = trim($html); if (! str_empty($icon)) { $this->activityIcon = trim($icon); } if (! str_empty($icon2)) { $this->activityIcon2 = trim($icon2); } return $this; }
php
public function activity($html, $icon = null, $icon2 = null) { $this->activity = trim($html); if (! str_empty($icon)) { $this->activityIcon = trim($icon); } if (! str_empty($icon2)) { $this->activityIcon2 = trim($icon2); } return $this; }
[ "public", "function", "activity", "(", "$", "html", ",", "$", "icon", "=", "null", ",", "$", "icon2", "=", "null", ")", "{", "$", "this", "->", "activity", "=", "trim", "(", "$", "html", ")", ";", "if", "(", "!", "str_empty", "(", "$", "icon", ")", ")", "{", "$", "this", "->", "activityIcon", "=", "trim", "(", "$", "icon", ")", ";", "}", "if", "(", "!", "str_empty", "(", "$", "icon2", ")", ")", "{", "$", "this", "->", "activityIcon2", "=", "trim", "(", "$", "icon2", ")", ";", "}", "return", "$", "this", ";", "}" ]
Sets the activity of the card. @param string $html @param string|null $icon @param string|null $icon2 @return $this
[ "Sets", "the", "activity", "of", "the", "card", "." ]
c24bca85f7cf9f6804635aa206c961783e22e888
https://github.com/laravel-notification-channels/hipchat/blob/c24bca85f7cf9f6804635aa206c961783e22e888/src/Card.php#L304-L317
232,799
laravel-notification-channels/hipchat
src/Card.php
Card.addAttribute
public function addAttribute($attribute) { if ($attribute instanceof CardAttribute) { $this->attributes[] = $attribute; return $this; } if ($attribute instanceof Closure) { $attribute($new = new CardAttribute()); $this->attributes[] = $new; return $this; } throw new InvalidArgumentException( 'Invalid attribute type. Expected '.CardAttribute::class.' or '.Closure::class.'.' ); }
php
public function addAttribute($attribute) { if ($attribute instanceof CardAttribute) { $this->attributes[] = $attribute; return $this; } if ($attribute instanceof Closure) { $attribute($new = new CardAttribute()); $this->attributes[] = $new; return $this; } throw new InvalidArgumentException( 'Invalid attribute type. Expected '.CardAttribute::class.' or '.Closure::class.'.' ); }
[ "public", "function", "addAttribute", "(", "$", "attribute", ")", "{", "if", "(", "$", "attribute", "instanceof", "CardAttribute", ")", "{", "$", "this", "->", "attributes", "[", "]", "=", "$", "attribute", ";", "return", "$", "this", ";", "}", "if", "(", "$", "attribute", "instanceof", "Closure", ")", "{", "$", "attribute", "(", "$", "new", "=", "new", "CardAttribute", "(", ")", ")", ";", "$", "this", "->", "attributes", "[", "]", "=", "$", "new", ";", "return", "$", "this", ";", "}", "throw", "new", "InvalidArgumentException", "(", "'Invalid attribute type. Expected '", ".", "CardAttribute", "::", "class", ".", "' or '", ".", "Closure", "::", "class", ".", "'.'", ")", ";", "}" ]
Adds a CardAttribute to the card. @param CardAttribute|Closure $attribute @return $this
[ "Adds", "a", "CardAttribute", "to", "the", "card", "." ]
c24bca85f7cf9f6804635aa206c961783e22e888
https://github.com/laravel-notification-channels/hipchat/blob/c24bca85f7cf9f6804635aa206c961783e22e888/src/Card.php#L343-L361