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 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
alevilar/account | Model/Gasto.php | Gasto.importePagado | public function importePagado($id = null){
$importePagado = 0;
if (empty($id)) {
$id = $this->id;
}
$fieldContain['recursive'] = -1;
$fieldContain['contain'] = 'Egreso';
$fieldContain['conditions'] = array('Gasto.id'=>$id);
$coso = parent::find('first', $fieldContain);
if (!empty($coso['Egreso'])) {
foreach ($coso['Egreso'] as $eg){
if ($eg['AccountEgresosGasto']['gasto_id'] == $id ) {
$importePagado += $eg['AccountEgresosGasto']['importe'];
}
}
}
return $importePagado;
} | php | public function importePagado($id = null){
$importePagado = 0;
if (empty($id)) {
$id = $this->id;
}
$fieldContain['recursive'] = -1;
$fieldContain['contain'] = 'Egreso';
$fieldContain['conditions'] = array('Gasto.id'=>$id);
$coso = parent::find('first', $fieldContain);
if (!empty($coso['Egreso'])) {
foreach ($coso['Egreso'] as $eg){
if ($eg['AccountEgresosGasto']['gasto_id'] == $id ) {
$importePagado += $eg['AccountEgresosGasto']['importe'];
}
}
}
return $importePagado;
} | [
"public",
"function",
"importePagado",
"(",
"$",
"id",
"=",
"null",
")",
"{",
"$",
"importePagado",
"=",
"0",
";",
"if",
"(",
"empty",
"(",
"$",
"id",
")",
")",
"{",
"$",
"id",
"=",
"$",
"this",
"->",
"id",
";",
"}",
"$",
"fieldContain",
"[",
"... | Indica la sumatoria de todos los pagos realizados para ese gasto
@param integer $id gasto_id
@return $ importe pagado | [
"Indica",
"la",
"sumatoria",
"de",
"todos",
"los",
"pagos",
"realizados",
"para",
"ese",
"gasto"
] | dfb3744d2c5db2875bc49ba39132fec6946d0cca | https://github.com/alevilar/account/blob/dfb3744d2c5db2875bc49ba39132fec6946d0cca/Model/Gasto.php#L365-L385 | train |
arnold-almeida/UIKit | src/Almeida/UIKit/Collections/Tables/AbstractTable.php | AbstractTable.extractHeaders | protected function extractHeaders($data)
{
$headers = array_keys($data[0]);
// Remove hidden fields from headers if supplied
foreach ($this->options['hiddenFields'] as $hiddenField) {
if (in_array($hiddenField, $headers)) {
array_splice($headers, array_search($hiddenField, $headers), 1);
}
}
if (!empty($this->options['actions'])) {
$headers[] = 'Actions';
}
return $headers;
} | php | protected function extractHeaders($data)
{
$headers = array_keys($data[0]);
// Remove hidden fields from headers if supplied
foreach ($this->options['hiddenFields'] as $hiddenField) {
if (in_array($hiddenField, $headers)) {
array_splice($headers, array_search($hiddenField, $headers), 1);
}
}
if (!empty($this->options['actions'])) {
$headers[] = 'Actions';
}
return $headers;
} | [
"protected",
"function",
"extractHeaders",
"(",
"$",
"data",
")",
"{",
"$",
"headers",
"=",
"array_keys",
"(",
"$",
"data",
"[",
"0",
"]",
")",
";",
"// Remove hidden fields from headers if supplied",
"foreach",
"(",
"$",
"this",
"->",
"options",
"[",
"'hidden... | Get Table headers from data | [
"Get",
"Table",
"headers",
"from",
"data"
] | cc52f46df011ec2f3676245c90c376da20c40e41 | https://github.com/arnold-almeida/UIKit/blob/cc52f46df011ec2f3676245c90c376da20c40e41/src/Almeida/UIKit/Collections/Tables/AbstractTable.php#L195-L211 | train |
hamjoint/mustard-commerce | src/lib/Purchase.php | Purchase.getGrandTotalAttribute | public function getGrandTotalAttribute()
{
if (!$this->deliveryOption) return $this->total;
return (float) round($this->total + $this->deliveryOption->price, 2);
} | php | public function getGrandTotalAttribute()
{
if (!$this->deliveryOption) return $this->total;
return (float) round($this->total + $this->deliveryOption->price, 2);
} | [
"public",
"function",
"getGrandTotalAttribute",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"deliveryOption",
")",
"return",
"$",
"this",
"->",
"total",
";",
"return",
"(",
"float",
")",
"round",
"(",
"$",
"this",
"->",
"total",
"+",
"$",
"this",... | Calculate grand total in respect to quantity and delivery.
@return float | [
"Calculate",
"grand",
"total",
"in",
"respect",
"to",
"quantity",
"and",
"delivery",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Purchase.php#L95-L100 | train |
hamjoint/mustard-commerce | src/lib/Purchase.php | Purchase.useAddress | public function useAddress(PostalAddress $postalAddress)
{
$this->name = $postalAddress->name;
$this->street1 = $postalAddress->street1;
$this->street2 = $postalAddress->street2;
$this->city = $postalAddress->city;
$this->county = $postalAddress->county;
$this->postcode = $postalAddress->postcode;
$this->country = $postalAddress->country;
} | php | public function useAddress(PostalAddress $postalAddress)
{
$this->name = $postalAddress->name;
$this->street1 = $postalAddress->street1;
$this->street2 = $postalAddress->street2;
$this->city = $postalAddress->city;
$this->county = $postalAddress->county;
$this->postcode = $postalAddress->postcode;
$this->country = $postalAddress->country;
} | [
"public",
"function",
"useAddress",
"(",
"PostalAddress",
"$",
"postalAddress",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"$",
"postalAddress",
"->",
"name",
";",
"$",
"this",
"->",
"street1",
"=",
"$",
"postalAddress",
"->",
"street1",
";",
"$",
"this",
... | Mass-assignment method for using a postal address.
@param \Hamjoint\Mustard\Commerce\PostalAddress $postalAddress
@return void | [
"Mass",
"-",
"assignment",
"method",
"for",
"using",
"a",
"postal",
"address",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Purchase.php#L128-L137 | train |
hamjoint/mustard-commerce | src/lib/Purchase.php | Purchase.averageAmount | public static function averageAmount($since = 0, $until = null)
{
$until = $until ?: time();
return (int) self::where('created', '>=', $since)
->where('created', '<=', $until)
->avg('total');
} | php | public static function averageAmount($since = 0, $until = null)
{
$until = $until ?: time();
return (int) self::where('created', '>=', $since)
->where('created', '<=', $until)
->avg('total');
} | [
"public",
"static",
"function",
"averageAmount",
"(",
"$",
"since",
"=",
"0",
",",
"$",
"until",
"=",
"null",
")",
"{",
"$",
"until",
"=",
"$",
"until",
"?",
":",
"time",
"(",
")",
";",
"return",
"(",
"int",
")",
"self",
"::",
"where",
"(",
"'cre... | Return the average amount of purchases.
@param integer $since UNIX timestamp to optionally specify a lower selection boundary.
@param integer $until UNIX timestamp to optionally specify an upper selection boundary.
@return integer | [
"Return",
"the",
"average",
"amount",
"of",
"purchases",
"."
] | 886caeb5a88d827c8e9201e90020b64651dd87ad | https://github.com/hamjoint/mustard-commerce/blob/886caeb5a88d827c8e9201e90020b64651dd87ad/src/lib/Purchase.php#L202-L209 | train |
integratedfordevelopers/integrated-solr-bundle | Solr/Type/FieldMapperType.php | FieldMapperType.convert | protected function convert($data)
{
if ($data instanceof DateTime) {
$data = clone $data; // don't change to original value
return $data->setTimezone($this->timezone)->format('Y-m-d\TG:i:s\Z');
}
if (is_object($data) && !method_exists($data, '__toString')) {
return null; // can't convert object to a string.
}
if (is_array($data)) {
return null; // can't convert a array to a string.
}
if (is_bool($data)) {
return $data ? '1' : '0'; // would otherwise be empty if converted to a string
}
return $data !== null ? (string)$data : null;
} | php | protected function convert($data)
{
if ($data instanceof DateTime) {
$data = clone $data; // don't change to original value
return $data->setTimezone($this->timezone)->format('Y-m-d\TG:i:s\Z');
}
if (is_object($data) && !method_exists($data, '__toString')) {
return null; // can't convert object to a string.
}
if (is_array($data)) {
return null; // can't convert a array to a string.
}
if (is_bool($data)) {
return $data ? '1' : '0'; // would otherwise be empty if converted to a string
}
return $data !== null ? (string)$data : null;
} | [
"protected",
"function",
"convert",
"(",
"$",
"data",
")",
"{",
"if",
"(",
"$",
"data",
"instanceof",
"DateTime",
")",
"{",
"$",
"data",
"=",
"clone",
"$",
"data",
";",
"// don't change to original value",
"return",
"$",
"data",
"->",
"setTimezone",
"(",
"... | Convert the data to a string.
If the value can not be converted to a string then return null.
@param mixed $data
@return null | string | [
"Convert",
"the",
"data",
"to",
"a",
"string",
"."
] | 9d9bb4071e13ed4686fbc97b6286a475ac5b2162 | https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Solr/Type/FieldMapperType.php#L247-L267 | train |
integratedfordevelopers/integrated-solr-bundle | Solr/Type/FieldMapperType.php | FieldMapperType.combine | protected function combine(array $data, $separator)
{
$results = array_shift($data);
$results = is_array($results) ? $results : [$results];
while ($value = array_shift($data)) {
if (is_array($value)) {
$replacement = [];
foreach ($value as $array_value) {
foreach ($results as $result_value) {
$replacement[] = $result_value . $separator . $array_value;
}
}
$results = $replacement;
} else {
foreach ($results as $key => $result_value) {
$results[$key] = $result_value . $separator . $value;
}
}
}
return array_filter($results);
} | php | protected function combine(array $data, $separator)
{
$results = array_shift($data);
$results = is_array($results) ? $results : [$results];
while ($value = array_shift($data)) {
if (is_array($value)) {
$replacement = [];
foreach ($value as $array_value) {
foreach ($results as $result_value) {
$replacement[] = $result_value . $separator . $array_value;
}
}
$results = $replacement;
} else {
foreach ($results as $key => $result_value) {
$results[$key] = $result_value . $separator . $value;
}
}
}
return array_filter($results);
} | [
"protected",
"function",
"combine",
"(",
"array",
"$",
"data",
",",
"$",
"separator",
")",
"{",
"$",
"results",
"=",
"array_shift",
"(",
"$",
"data",
")",
";",
"$",
"results",
"=",
"is_array",
"(",
"$",
"results",
")",
"?",
"$",
"results",
":",
"[",
... | Combine all the data into strings.
For every array in the data all strings will be multiplied by the number of items in that
array to cover every possible string combination.
@param array $data
@param string $separator
@return string[] | [
"Combine",
"all",
"the",
"data",
"into",
"strings",
"."
] | 9d9bb4071e13ed4686fbc97b6286a475ac5b2162 | https://github.com/integratedfordevelopers/integrated-solr-bundle/blob/9d9bb4071e13ed4686fbc97b6286a475ac5b2162/Solr/Type/FieldMapperType.php#L280-L304 | train |
tekkla/core-security | Core/Security/User/Activation.php | Activation.activateUser | public function activateUser($key)
{
// Get tokendate from db
$tokenhandler = new ActivationToken($this->db);
$tokenhandler->setSelectorTokenString($key);
// Store the current to extracted from selector:token string ($key)
$token_from_key = $tokenhandler->getToken();
// Load the tokendata by using the selector from selector:token string ($key)
$tokenhandler->loadTokenData();
// Get user id
$id_user = $tokenhandler->getUserId();
// No user id means the activation must fail
if (empty($id_user)) {
return false;
}
// Get the token loaded from db via selector from selector:token string ($key)
$token_from_db = $tokenhandler->getToken();
// Matching hashes?
if (!hash_equals($token_from_key, $token_from_db)) {
return false;
}
// Activate user
$this->db->qb([
'table' => 'core_users',
'method' => 'UPDATE',
'fields' => 'state',
'filter' => 'id_user=:id_user',
'params' => [
':state' => 0,
':id_user' => $id_user
]
], true);
// and delete the token of this user
$tokenhandler->deleteActivationTokenByUserId($id_user);
// And finally return user id
return $id_user;
} | php | public function activateUser($key)
{
// Get tokendate from db
$tokenhandler = new ActivationToken($this->db);
$tokenhandler->setSelectorTokenString($key);
// Store the current to extracted from selector:token string ($key)
$token_from_key = $tokenhandler->getToken();
// Load the tokendata by using the selector from selector:token string ($key)
$tokenhandler->loadTokenData();
// Get user id
$id_user = $tokenhandler->getUserId();
// No user id means the activation must fail
if (empty($id_user)) {
return false;
}
// Get the token loaded from db via selector from selector:token string ($key)
$token_from_db = $tokenhandler->getToken();
// Matching hashes?
if (!hash_equals($token_from_key, $token_from_db)) {
return false;
}
// Activate user
$this->db->qb([
'table' => 'core_users',
'method' => 'UPDATE',
'fields' => 'state',
'filter' => 'id_user=:id_user',
'params' => [
':state' => 0,
':id_user' => $id_user
]
], true);
// and delete the token of this user
$tokenhandler->deleteActivationTokenByUserId($id_user);
// And finally return user id
return $id_user;
} | [
"public",
"function",
"activateUser",
"(",
"$",
"key",
")",
"{",
"// Get tokendate from db",
"$",
"tokenhandler",
"=",
"new",
"ActivationToken",
"(",
"$",
"this",
"->",
"db",
")",
";",
"$",
"tokenhandler",
"->",
"setSelectorTokenString",
"(",
"$",
"key",
")",
... | Actives user by using a key
@param string $key
Key to use for activation | [
"Actives",
"user",
"by",
"using",
"a",
"key"
] | 66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582 | https://github.com/tekkla/core-security/blob/66a09ca63a2f5a2239ea7537d2d6bdaa89b0a582/Core/Security/User/Activation.php#L75-L121 | train |
dreadlokeur/Midi-ChloriansPHP | src/network/Http.php | Http.redirect | public static function redirect($url, $permanent = false, $timer = 0, $die = true, $noForceJsRedirect = false) {
if (headers_sent()) {
if ($noForceJsRedirect) {
echo '<script language="javascript" type="text/javascript">window.setTimeout("location=(\'' . $url . '\');", ' . $timer . '*1000);</script>';
// if javascript deactived, redirect with meta
echo '<noscript><meta http-equiv="refresh" content="' . $timer . ';url=' . $url . '" /></noscript>';
}
} else {
if ($timer != 0)
header('refresh: ' . $timer . ';location=' . $url);
else
header('location:' . $url);
if ($permanent)
header('Status: 301 Moved Permanently', false, 301);
}
if ($die)
exit();
} | php | public static function redirect($url, $permanent = false, $timer = 0, $die = true, $noForceJsRedirect = false) {
if (headers_sent()) {
if ($noForceJsRedirect) {
echo '<script language="javascript" type="text/javascript">window.setTimeout("location=(\'' . $url . '\');", ' . $timer . '*1000);</script>';
// if javascript deactived, redirect with meta
echo '<noscript><meta http-equiv="refresh" content="' . $timer . ';url=' . $url . '" /></noscript>';
}
} else {
if ($timer != 0)
header('refresh: ' . $timer . ';location=' . $url);
else
header('location:' . $url);
if ($permanent)
header('Status: 301 Moved Permanently', false, 301);
}
if ($die)
exit();
} | [
"public",
"static",
"function",
"redirect",
"(",
"$",
"url",
",",
"$",
"permanent",
"=",
"false",
",",
"$",
"timer",
"=",
"0",
",",
"$",
"die",
"=",
"true",
",",
"$",
"noForceJsRedirect",
"=",
"false",
")",
"{",
"if",
"(",
"headers_sent",
"(",
")",
... | Redirection to another url. With Javascript if header was alreadry send
@access public
@static
@param String $url Redirection of redirection
@param Boolean $permanent Set if this is a permanently redirection or not
@param Mixed $timer Redirect time: in seconds (optional: default 0)
@param Boolean $die Die script after redirected
@return void | [
"Redirection",
"to",
"another",
"url",
".",
"With",
"Javascript",
"if",
"header",
"was",
"alreadry",
"send"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/network/Http.php#L168-L186 | train |
dreadlokeur/Midi-ChloriansPHP | src/network/Http.php | Http._getDataFromArray | protected static function _getDataFromArray(&$array, $key = false, $default = null, $allowHtmlTags = false) {
if ($key === null)
return !$allowHtmlTags ? self::_secure($array, $allowHtmlTags) : $array;
else {
if (!array_key_exists($key, $array))
return $default;
return !$allowHtmlTags ? self::_secure($array[$key], $allowHtmlTags) : $array[$key];
}
} | php | protected static function _getDataFromArray(&$array, $key = false, $default = null, $allowHtmlTags = false) {
if ($key === null)
return !$allowHtmlTags ? self::_secure($array, $allowHtmlTags) : $array;
else {
if (!array_key_exists($key, $array))
return $default;
return !$allowHtmlTags ? self::_secure($array[$key], $allowHtmlTags) : $array[$key];
}
} | [
"protected",
"static",
"function",
"_getDataFromArray",
"(",
"&",
"$",
"array",
",",
"$",
"key",
"=",
"false",
",",
"$",
"default",
"=",
"null",
",",
"$",
"allowHtmlTags",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"key",
"===",
"null",
")",
"return",
"... | Get a data from a reference array
@access protected
@static
@param Array $array
@param String $key
@param Mixed $default
@param Mixed $allowHtmlTags By default false : Remove all HTML tags, can be true : allow all html tags, can be a list of accepted HTML tags (see strip_tags documentation)
@return Mixed | [
"Get",
"a",
"data",
"from",
"a",
"reference",
"array"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/network/Http.php#L266-L275 | train |
dreadlokeur/Midi-ChloriansPHP | src/network/Http.php | Http._secure | protected static function _secure($value, $allowHtmlTags) {
if (is_array($value)) {
foreach ($value as &$v)
$v = self::_secure($v, $allowHtmlTags);
} elseif (is_string($value))
$value = htmlspecialchars(strip_tags($value, ((is_string($allowHtmlTags) && !empty($allowHtmlTags)) ? $allowHtmlTags : null)), ENT_QUOTES);
return $value;
} | php | protected static function _secure($value, $allowHtmlTags) {
if (is_array($value)) {
foreach ($value as &$v)
$v = self::_secure($v, $allowHtmlTags);
} elseif (is_string($value))
$value = htmlspecialchars(strip_tags($value, ((is_string($allowHtmlTags) && !empty($allowHtmlTags)) ? $allowHtmlTags : null)), ENT_QUOTES);
return $value;
} | [
"protected",
"static",
"function",
"_secure",
"(",
"$",
"value",
",",
"$",
"allowHtmlTags",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"foreach",
"(",
"$",
"value",
"as",
"&",
"$",
"v",
")",
"$",
"v",
"=",
"self",
"::",
"_... | Secure a value, remove all, or allow html tags
@access protected
@static
@param Mixed $value Value to secure
@param Mixed $allowHtmlTags It can be a string with HTML tags to allow (see strip_tags documentation)
@see http://www.php.net/strip_tags
@return Mixed | [
"Secure",
"a",
"value",
"remove",
"all",
"or",
"allow",
"html",
"tags"
] | 4842e0a662c8b9448e69c8e5da35f55066f3bd9e | https://github.com/dreadlokeur/Midi-ChloriansPHP/blob/4842e0a662c8b9448e69c8e5da35f55066f3bd9e/src/network/Http.php#L287-L294 | train |
harvestcloud/CoreBundle | Controller/Seller/SellerHubRefController.php | SellerHubRefController.add_pickup_windowAction | public function add_pickup_windowAction(Request $request)
{
$id = $request->get('id');
$hub = $this->getRepo('Profile')->find($id);
$seller = $this->getUser()->getCurrentProfile();
if (!$hub)
{
throw $this->createNotFoundException('No hub found for id '.$id);
}
$sellerHubRef = $this->getRepo('SellerHubRef')->findOneBySellerAndHub($seller, $hub);
if (!$sellerHubRef)
{
throw $this->createNotFoundException('No SellerHubRef found for Seller/Hub combination');
}
$pickupWindow = new SellerHubPickupWindow();
$pickupWindow->setSellerHubRef($sellerHubRef);
$form = $this->createForm(new SellerHubPickupWindowType(), $pickupWindow);
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$em = $this->getDoctrine()->getEntityManager();
$em->persist($pickupWindow);
$em->flush();
return $this->redirect($this->generateUrl('Seller_hub_show', array(
'id' => $hub->getId(),
)));
}
}
return $this->render('HarvestCloudCoreBundle:Seller/SellerHubRef:add_pickup_window.html.twig', array(
'hub' => $hub,
'form' => $form->createView(),
));
} | php | public function add_pickup_windowAction(Request $request)
{
$id = $request->get('id');
$hub = $this->getRepo('Profile')->find($id);
$seller = $this->getUser()->getCurrentProfile();
if (!$hub)
{
throw $this->createNotFoundException('No hub found for id '.$id);
}
$sellerHubRef = $this->getRepo('SellerHubRef')->findOneBySellerAndHub($seller, $hub);
if (!$sellerHubRef)
{
throw $this->createNotFoundException('No SellerHubRef found for Seller/Hub combination');
}
$pickupWindow = new SellerHubPickupWindow();
$pickupWindow->setSellerHubRef($sellerHubRef);
$form = $this->createForm(new SellerHubPickupWindowType(), $pickupWindow);
if ($request->getMethod() == 'POST')
{
$form->bindRequest($request);
if ($form->isValid())
{
$em = $this->getDoctrine()->getEntityManager();
$em->persist($pickupWindow);
$em->flush();
return $this->redirect($this->generateUrl('Seller_hub_show', array(
'id' => $hub->getId(),
)));
}
}
return $this->render('HarvestCloudCoreBundle:Seller/SellerHubRef:add_pickup_window.html.twig', array(
'hub' => $hub,
'form' => $form->createView(),
));
} | [
"public",
"function",
"add_pickup_windowAction",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"id",
"=",
"$",
"request",
"->",
"get",
"(",
"'id'",
")",
";",
"$",
"hub",
"=",
"$",
"this",
"->",
"getRepo",
"(",
"'Profile'",
")",
"->",
"find",
"(",
"$... | add pickup window
@author Tom Haskins-Vaughan <tom@harvestcloud.com>
@since 2012-04-29
@todo Reduce number of queries on this page
@todo Make sure we don't create a PickupWindow when the Hub is closed
@todo Refcator to model
@param Request $request | [
"add",
"pickup",
"window"
] | f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc | https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Controller/Seller/SellerHubRefController.php#L36-L80 | train |
bellisq/type-map | src/Base/TypeMapAbstract.php | TypeMapAbstract.get | final public function get(string $type): object
{
if ($this->supports($type)) {
$ret = $this->getObject($type);
if ($ret instanceof $type) {
return $ret;
}
throw new TypeError;
}
throw new UnavailableTypeException;
} | php | final public function get(string $type): object
{
if ($this->supports($type)) {
$ret = $this->getObject($type);
if ($ret instanceof $type) {
return $ret;
}
throw new TypeError;
}
throw new UnavailableTypeException;
} | [
"final",
"public",
"function",
"get",
"(",
"string",
"$",
"type",
")",
":",
"object",
"{",
"if",
"(",
"$",
"this",
"->",
"supports",
"(",
"$",
"type",
")",
")",
"{",
"$",
"ret",
"=",
"$",
"this",
"->",
"getObject",
"(",
"$",
"type",
")",
";",
"... | Get an object of the type.
Check if the type is supported.
If the type is supported, call getObject.
If not, throw an exception.
@param string $type
@return object
@throws TypeError
@throws UnavailableTypeException | [
"Get",
"an",
"object",
"of",
"the",
"type",
"."
] | 8a453cc3b0820a85d4f8a6ec2dd967ea800fa6f3 | https://github.com/bellisq/type-map/blob/8a453cc3b0820a85d4f8a6ec2dd967ea800fa6f3/src/Base/TypeMapAbstract.php#L47-L58 | train |
neat-php/http | classes/Message.php | Message.headers | public function headers()
{
$headers = [];
foreach ($this->headers as $header) {
$headers[$header->name()] = $header->value();
}
return $headers;
} | php | public function headers()
{
$headers = [];
foreach ($this->headers as $header) {
$headers[$header->name()] = $header->value();
}
return $headers;
} | [
"public",
"function",
"headers",
"(",
")",
"{",
"$",
"headers",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"headers",
"as",
"$",
"header",
")",
"{",
"$",
"headers",
"[",
"$",
"header",
"->",
"name",
"(",
")",
"]",
"=",
"$",
"header",
... | Get header values
@return array | [
"Get",
"header",
"values"
] | 5d4781a8481c1f708fd642292e44244435a8369c | https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Message.php#L77-L85 | train |
acplo/AcploLog | src/AcploLog/Log/EntityLogger.php | EntityLogger.onFlush | public function onFlush(OnFlushEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
$this->debug('Inserting entity '.get_class($entity).'. Fields: '.
json_encode($uow->getEntityChangeSet($entity)));
}
foreach ($uow->getScheduledEntityUpdates() as $entity) {
$add = '';
if (method_exists($entity, '__toString')) {
$add = ' '.$entity->__toString();
} elseif (method_exists($entity, 'getId')) {
$add = ' with id '.$entity->getId();
}
$this->debug('Updating entity '.get_class($entity).$add.'. Data: '.
json_encode($uow->getEntityChangeSet($entity)));
}
foreach ($uow->getScheduledEntityDeletions() as $entity) {
$add = '';
if (method_exists($entity, '__toString')) {
$add = ' '.$entity->__toString();
} elseif (method_exists($entity, 'getId')) {
$add = ' with id '.$entity->getId();
}
$this->debug('Deleting entity '.get_class($entity).$add.'.');
}
} | php | public function onFlush(OnFlushEventArgs $eventArgs)
{
$em = $eventArgs->getEntityManager();
$uow = $em->getUnitOfWork();
foreach ($uow->getScheduledEntityInsertions() as $entity) {
$this->debug('Inserting entity '.get_class($entity).'. Fields: '.
json_encode($uow->getEntityChangeSet($entity)));
}
foreach ($uow->getScheduledEntityUpdates() as $entity) {
$add = '';
if (method_exists($entity, '__toString')) {
$add = ' '.$entity->__toString();
} elseif (method_exists($entity, 'getId')) {
$add = ' with id '.$entity->getId();
}
$this->debug('Updating entity '.get_class($entity).$add.'. Data: '.
json_encode($uow->getEntityChangeSet($entity)));
}
foreach ($uow->getScheduledEntityDeletions() as $entity) {
$add = '';
if (method_exists($entity, '__toString')) {
$add = ' '.$entity->__toString();
} elseif (method_exists($entity, 'getId')) {
$add = ' with id '.$entity->getId();
}
$this->debug('Deleting entity '.get_class($entity).$add.'.');
}
} | [
"public",
"function",
"onFlush",
"(",
"OnFlushEventArgs",
"$",
"eventArgs",
")",
"{",
"$",
"em",
"=",
"$",
"eventArgs",
"->",
"getEntityManager",
"(",
")",
";",
"$",
"uow",
"=",
"$",
"em",
"->",
"getUnitOfWork",
"(",
")",
";",
"foreach",
"(",
"$",
"uow... | Logs the entity changes
@param \Doctrine\ORM\Event\OnFlushEventArgs $eventArgs | [
"Logs",
"the",
"entity",
"changes"
] | 9cebcd92ccfaf5dcd67f77ecba358ad5d6cee2a2 | https://github.com/acplo/AcploLog/blob/9cebcd92ccfaf5dcd67f77ecba358ad5d6cee2a2/src/AcploLog/Log/EntityLogger.php#L45-L77 | train |
promaker/Base | Repository/ARepository.php | ARepository.setLimit | public function setLimit($limit)
{
if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) {
throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance.");
}
$this->_persistence->setLimit($limit);
return $this;
} | php | public function setLimit($limit)
{
if (!isset($this->_persistence) || !($this->_persistence instanceof IPersistance)) {
throw new Exception("Repository Exception : No existe la interfaz de la persistencia o no implementa la interfaz IPersistance.");
}
$this->_persistence->setLimit($limit);
return $this;
} | [
"public",
"function",
"setLimit",
"(",
"$",
"limit",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"_persistence",
")",
"||",
"!",
"(",
"$",
"this",
"->",
"_persistence",
"instanceof",
"IPersistance",
")",
")",
"{",
"throw",
"new",
"Except... | Setea el limite para efectuar en las operaciones de lectura
@param Int $limit
@return self | [
"Setea",
"el",
"limite",
"para",
"efectuar",
"en",
"las",
"operaciones",
"de",
"lectura"
] | 042c1a53f0fafdb79a854252ad3f0b4c7e8ab716 | https://github.com/promaker/Base/blob/042c1a53f0fafdb79a854252ad3f0b4c7e8ab716/Repository/ARepository.php#L70-L79 | train |
deasilworks/cms | src/CEF/Data/Manager/PageDataManager.php | PageDataManager.setPage | public function setPage(PageDataModel $pageModel)
{
$pageModel
->setModified(new \DateTime())
->setEntityManager($this)
->save();
return true;
} | php | public function setPage(PageDataModel $pageModel)
{
$pageModel
->setModified(new \DateTime())
->setEntityManager($this)
->save();
return true;
} | [
"public",
"function",
"setPage",
"(",
"PageDataModel",
"$",
"pageModel",
")",
"{",
"$",
"pageModel",
"->",
"setModified",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
"->",
"setEntityManager",
"(",
"$",
"this",
")",
"->",
"save",
"(",
")",
";",
"return",... | Set Page.
@ApiAction()
@param PageDataModel $pageModel
@return bool | [
"Set",
"Page",
"."
] | 759d05a4e79656b62ff26ea55834f64c61fd1fd4 | https://github.com/deasilworks/cms/blob/759d05a4e79656b62ff26ea55834f64c61fd1fd4/src/CEF/Data/Manager/PageDataManager.php#L86-L94 | train |
deasilworks/cms | src/CEF/Data/Manager/PageDataManager.php | PageDataManager.getPage | public function getPage($stub)
{
$this->logger->addNotice(print_r($this->cfg->getAll(), 1));
$stmtManager = $this->getStatementManager(Simple::class);
/** @var Select $stmtBuilder */
$stmtBuilder = $stmtManager->getStatementBuilder(Select::class);
/** @var PageCollection $collection */
$collection = $stmtManager->setStatement($stmtBuilder->setWhere(['stub = :stub']))
->setArguments(['stub' => $stub])
->execute();
/** @var PageDataModel $c */
$c = $collection->current();
return $c;
} | php | public function getPage($stub)
{
$this->logger->addNotice(print_r($this->cfg->getAll(), 1));
$stmtManager = $this->getStatementManager(Simple::class);
/** @var Select $stmtBuilder */
$stmtBuilder = $stmtManager->getStatementBuilder(Select::class);
/** @var PageCollection $collection */
$collection = $stmtManager->setStatement($stmtBuilder->setWhere(['stub = :stub']))
->setArguments(['stub' => $stub])
->execute();
/** @var PageDataModel $c */
$c = $collection->current();
return $c;
} | [
"public",
"function",
"getPage",
"(",
"$",
"stub",
")",
"{",
"$",
"this",
"->",
"logger",
"->",
"addNotice",
"(",
"print_r",
"(",
"$",
"this",
"->",
"cfg",
"->",
"getAll",
"(",
")",
",",
"1",
")",
")",
";",
"$",
"stmtManager",
"=",
"$",
"this",
"... | Get Page.
@ApiAction()
@param string $stub the url friendly name of the page.
@return PageDataModel | [
"Get",
"Page",
"."
] | 759d05a4e79656b62ff26ea55834f64c61fd1fd4 | https://github.com/deasilworks/cms/blob/759d05a4e79656b62ff26ea55834f64c61fd1fd4/src/CEF/Data/Manager/PageDataManager.php#L105-L123 | train |
deasilworks/cms | src/CEF/Data/Manager/PageDataManager.php | PageDataManager.getPages | public function getPages(ECParams $params)
{
$stmtManager = $this->getStatementManager(Simple::class);
/** @var Select $stmtBuilder */
$stmtBuilder = $stmtManager->getStatementBuilder(Select::class);
/** @var PageCollection $collection */
$collection = $stmtManager->setStatement($stmtBuilder->setColumns(['stub']))
->execute();
return $collection->setEcParams($params);
} | php | public function getPages(ECParams $params)
{
$stmtManager = $this->getStatementManager(Simple::class);
/** @var Select $stmtBuilder */
$stmtBuilder = $stmtManager->getStatementBuilder(Select::class);
/** @var PageCollection $collection */
$collection = $stmtManager->setStatement($stmtBuilder->setColumns(['stub']))
->execute();
return $collection->setEcParams($params);
} | [
"public",
"function",
"getPages",
"(",
"ECParams",
"$",
"params",
")",
"{",
"$",
"stmtManager",
"=",
"$",
"this",
"->",
"getStatementManager",
"(",
"Simple",
"::",
"class",
")",
";",
"/** @var Select $stmtBuilder */",
"$",
"stmtBuilder",
"=",
"$",
"stmtManager",... | Get all Pages.
@ApiAction()
@return PageCollection | [
"Get",
"all",
"Pages",
"."
] | 759d05a4e79656b62ff26ea55834f64c61fd1fd4 | https://github.com/deasilworks/cms/blob/759d05a4e79656b62ff26ea55834f64c61fd1fd4/src/CEF/Data/Manager/PageDataManager.php#L132-L144 | train |
philliphq/phillip | src/Phillip/Coverage.php | Coverage.output | public function output()
{
$data = [
'classes' => [],
'files' => [],
];
foreach ($this->processed as $type => $classes) {
foreach ($classes as $name => $values) {
$covered = $values['covered'];
$total = $values['total'];
$pct = (((int) $covered / (int) $total) * 100);
$covered = str_pad((string) $covered, 7, ' ', STR_PAD_LEFT);
$total = str_pad((string) $total, 5, ' ', STR_PAD_LEFT);
$percentage = number_format($pct, 2).'%';
$percentage = str_pad((string) $percentage, 10, ' ', STR_PAD_LEFT);
if ($pct < 25) {
$covered = $this->output->red($covered);
$total = $this->output->red($total);
$percentage = $this->output->red($percentage);
}
if ($pct < 75) {
$covered = $this->output->black->yellow($covered);
$total = $this->output->black->yellow($total);
$percentage = $this->output->black->yellow($percentage);
}
if ($pct >= 75) {
$covered = $this->output->green($covered);
$total = $this->output->green($total);
$percentage = $this->output->green($percentage);
}
$data[$type][] = [$name, $covered, $total, $percentage];
}
}
$out = [];
if (count($data['classes']) > 0) {
array_unshift($data['classes'], ['Class', 'Covered', 'Lines', 'Percentage']);
$out[] = new Table($data['classes'], [
'headerColor' => Graphite::YELLOW,
'columnSeparator' => '',
'headerSeparator' => '',
'cellPadding' => 1,
]);
}
if (count($data['files']) > 0) {
array_unshift($data['files'], ['File', 'Covered', 'Lines', 'Percentage']);
$out[] = new Table($data['files'], [
'headerColor' => Graphite::YELLOW,
'columnSeparator' => '',
'headerSeparator' => '',
'cellPadding' => 1,
]);
}
return $this->output->render(implode("\n\n", $out));
} | php | public function output()
{
$data = [
'classes' => [],
'files' => [],
];
foreach ($this->processed as $type => $classes) {
foreach ($classes as $name => $values) {
$covered = $values['covered'];
$total = $values['total'];
$pct = (((int) $covered / (int) $total) * 100);
$covered = str_pad((string) $covered, 7, ' ', STR_PAD_LEFT);
$total = str_pad((string) $total, 5, ' ', STR_PAD_LEFT);
$percentage = number_format($pct, 2).'%';
$percentage = str_pad((string) $percentage, 10, ' ', STR_PAD_LEFT);
if ($pct < 25) {
$covered = $this->output->red($covered);
$total = $this->output->red($total);
$percentage = $this->output->red($percentage);
}
if ($pct < 75) {
$covered = $this->output->black->yellow($covered);
$total = $this->output->black->yellow($total);
$percentage = $this->output->black->yellow($percentage);
}
if ($pct >= 75) {
$covered = $this->output->green($covered);
$total = $this->output->green($total);
$percentage = $this->output->green($percentage);
}
$data[$type][] = [$name, $covered, $total, $percentage];
}
}
$out = [];
if (count($data['classes']) > 0) {
array_unshift($data['classes'], ['Class', 'Covered', 'Lines', 'Percentage']);
$out[] = new Table($data['classes'], [
'headerColor' => Graphite::YELLOW,
'columnSeparator' => '',
'headerSeparator' => '',
'cellPadding' => 1,
]);
}
if (count($data['files']) > 0) {
array_unshift($data['files'], ['File', 'Covered', 'Lines', 'Percentage']);
$out[] = new Table($data['files'], [
'headerColor' => Graphite::YELLOW,
'columnSeparator' => '',
'headerSeparator' => '',
'cellPadding' => 1,
]);
}
return $this->output->render(implode("\n\n", $out));
} | [
"public",
"function",
"output",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'classes'",
"=>",
"[",
"]",
",",
"'files'",
"=>",
"[",
"]",
",",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"processed",
"as",
"$",
"type",
"=>",
"$",
"classes",
")",
"{",
... | Output the coverage tables.
@return string The rendered tables | [
"Output",
"the",
"coverage",
"tables",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Coverage.php#L106-L169 | train |
philliphq/phillip | src/Phillip/Coverage.php | Coverage.isCovered | private function isCovered($file)
{
return in_array($file, $this->includedFiles)
&& !in_array($file, $this->excludedFiles)
&& isset($this->covered[$file]);
} | php | private function isCovered($file)
{
return in_array($file, $this->includedFiles)
&& !in_array($file, $this->excludedFiles)
&& isset($this->covered[$file]);
} | [
"private",
"function",
"isCovered",
"(",
"$",
"file",
")",
"{",
"return",
"in_array",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"includedFiles",
")",
"&&",
"!",
"in_array",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"excludedFiles",
")",
"&&",
"isset",
... | Check if a file should be included in coverage calculations.
@param string $file The filename
@return bool | [
"Check",
"if",
"a",
"file",
"should",
"be",
"included",
"in",
"coverage",
"calculations",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Coverage.php#L261-L266 | train |
philliphq/phillip | src/Phillip/Coverage.php | Coverage.processRawData | private function processRawData()
{
// Get the raw data from Xdebug
$data = xdebug_get_code_coverage();
// Create an array for storing processed coverage data
$processed = [
'classes' => [],
'files' => [],
];
// Loop through each of the files in the coverage data
foreach ($data as $file => $lines) {
// Check if this file is covered
if ($this->isCovered($file)) {
// Filter out dead code from the results
$filter = function ($value, $line = null) {
return $value !== self::DEAD;
};
$executable = array_filter($lines, $filter);
// Filter out unused code to get the lines covered
$object = $this;
$filter = function ($value, $line) use ($object, $file) {
if (in_array($line, $object->covered[$file])) {
return $value === 1;
}
};
$covered = array_filter($lines, $filter, ARRAY_FILTER_USE_BOTH);
// Store the counts for this file
$coverage = [
'covered' => count($covered),
'total' => count($executable),
];
// If a classname exists in the file,
// store the counts against it
if ($class = $this->getClassForFile($file)) {
$processed['classes'][$class] = $coverage;
continue;
}
// If no class has been found, store the counts
// directly against the file name
$name = str_replace($this->runner->pwd.'/', '', $file);
$processed['files'][$name] = $coverage;
}
}
// Store the processed data
return $this->processed = $processed;
} | php | private function processRawData()
{
// Get the raw data from Xdebug
$data = xdebug_get_code_coverage();
// Create an array for storing processed coverage data
$processed = [
'classes' => [],
'files' => [],
];
// Loop through each of the files in the coverage data
foreach ($data as $file => $lines) {
// Check if this file is covered
if ($this->isCovered($file)) {
// Filter out dead code from the results
$filter = function ($value, $line = null) {
return $value !== self::DEAD;
};
$executable = array_filter($lines, $filter);
// Filter out unused code to get the lines covered
$object = $this;
$filter = function ($value, $line) use ($object, $file) {
if (in_array($line, $object->covered[$file])) {
return $value === 1;
}
};
$covered = array_filter($lines, $filter, ARRAY_FILTER_USE_BOTH);
// Store the counts for this file
$coverage = [
'covered' => count($covered),
'total' => count($executable),
];
// If a classname exists in the file,
// store the counts against it
if ($class = $this->getClassForFile($file)) {
$processed['classes'][$class] = $coverage;
continue;
}
// If no class has been found, store the counts
// directly against the file name
$name = str_replace($this->runner->pwd.'/', '', $file);
$processed['files'][$name] = $coverage;
}
}
// Store the processed data
return $this->processed = $processed;
} | [
"private",
"function",
"processRawData",
"(",
")",
"{",
"// Get the raw data from Xdebug",
"$",
"data",
"=",
"xdebug_get_code_coverage",
"(",
")",
";",
"// Create an array for storing processed coverage data",
"$",
"processed",
"=",
"[",
"'classes'",
"=>",
"[",
"]",
","... | Process the raw coverage data.
@return array | [
"Process",
"the",
"raw",
"coverage",
"data",
"."
] | 42dac9d0f52fb77b49054b15b8baecca031151dc | https://github.com/philliphq/phillip/blob/42dac9d0f52fb77b49054b15b8baecca031151dc/src/Phillip/Coverage.php#L354-L407 | train |
sgoendoer/sonic | src/Identity/UOID.php | UOID.createUOID | public static function createUOID($gid = NULL, $id = NULL)
{
if($gid == NULL)
$gid = Sonic::getContextGlobalID();
if($id == NULL)
$id = Random::getUniqueRandom();
$uoid = $gid . UOID::SEPARATOR . $id;
return $uoid;
} | php | public static function createUOID($gid = NULL, $id = NULL)
{
if($gid == NULL)
$gid = Sonic::getContextGlobalID();
if($id == NULL)
$id = Random::getUniqueRandom();
$uoid = $gid . UOID::SEPARATOR . $id;
return $uoid;
} | [
"public",
"static",
"function",
"createUOID",
"(",
"$",
"gid",
"=",
"NULL",
",",
"$",
"id",
"=",
"NULL",
")",
"{",
"if",
"(",
"$",
"gid",
"==",
"NULL",
")",
"$",
"gid",
"=",
"Sonic",
"::",
"getContextGlobalID",
"(",
")",
";",
"if",
"(",
"$",
"id"... | Creates a new UOID for the current Sonic context
@param $gid String The global id part of the UOID
@param $id String The local id part of the UOID
@return A UOID | [
"Creates",
"a",
"new",
"UOID",
"for",
"the",
"current",
"Sonic",
"context"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/UOID.php#L26-L37 | train |
sgoendoer/sonic | src/Identity/UOID.php | UOID.isValid | public static function isValid($uoid)
{
$uoid = explode(UOID::SEPARATOR, $uoid);
if(count($uoid) != 2)
return false;
// check GID
if(!GID::isValid($uoid[0]))
return false;
// check id
if(!preg_match("/^[a-zA-Z0-9]+$/", $uoid[1]) || strlen($uoid[1]) != 16)
{
return false;
}
return true;
} | php | public static function isValid($uoid)
{
$uoid = explode(UOID::SEPARATOR, $uoid);
if(count($uoid) != 2)
return false;
// check GID
if(!GID::isValid($uoid[0]))
return false;
// check id
if(!preg_match("/^[a-zA-Z0-9]+$/", $uoid[1]) || strlen($uoid[1]) != 16)
{
return false;
}
return true;
} | [
"public",
"static",
"function",
"isValid",
"(",
"$",
"uoid",
")",
"{",
"$",
"uoid",
"=",
"explode",
"(",
"UOID",
"::",
"SEPARATOR",
",",
"$",
"uoid",
")",
";",
"if",
"(",
"count",
"(",
"$",
"uoid",
")",
"!=",
"2",
")",
"return",
"false",
";",
"//... | Verifies, if a given UOID is valid
@param $uoid String The UOID to verify
@return true, of the UOID is valid, else false | [
"Verifies",
"if",
"a",
"given",
"UOID",
"is",
"valid"
] | 2c32ebd78607dc3e8558f10a0b7bf881d37fc168 | https://github.com/sgoendoer/sonic/blob/2c32ebd78607dc3e8558f10a0b7bf881d37fc168/src/Identity/UOID.php#L46-L64 | train |
agentmedia/phine-news | src/News/Modules/Backend/ArticleListForm.php | ArticleListForm.AddArticlePageSelector | private function AddArticlePageSelector()
{
$name = 'ArticlePage';
$this->articlePageSelector = new PageSelector($name, Trans($this->Label($name)),
$this->articleList->GetArticlePage());
$this->articlePageSelector->SetSite($this->Page()->GetSite());
$this->Elements()->AddElement($name, $this->articlePageSelector);
} | php | private function AddArticlePageSelector()
{
$name = 'ArticlePage';
$this->articlePageSelector = new PageSelector($name, Trans($this->Label($name)),
$this->articleList->GetArticlePage());
$this->articlePageSelector->SetSite($this->Page()->GetSite());
$this->Elements()->AddElement($name, $this->articlePageSelector);
} | [
"private",
"function",
"AddArticlePageSelector",
"(",
")",
"{",
"$",
"name",
"=",
"'ArticlePage'",
";",
"$",
"this",
"->",
"articlePageSelector",
"=",
"new",
"PageSelector",
"(",
"$",
"name",
",",
"Trans",
"(",
"$",
"this",
"->",
"Label",
"(",
"$",
"name",... | Adds the article page selector element | [
"Adds",
"the",
"article",
"page",
"selector",
"element"
] | 51abc830fecd1325f0b7d28391ecd924cdc7c945 | https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L106-L114 | train |
agentmedia/phine-news | src/News/Modules/Backend/ArticleListForm.php | ArticleListForm.SaveElement | protected function SaveElement()
{
$this->articleList->SetArticlePage($this->articlePageSelector->GetPage());
$archiveCat = explode('-', $this->Value('ArchiveCategory'));
$this->CleanPageArticleLists();
if (count($archiveCat) == 1) {
$this->SaveArchivePage($archiveCat[0]);
}
else if (count($archiveCat) == 2) {
$this->SaveCategoryPage($archiveCat[1]);
}
return $this->articleList;
} | php | protected function SaveElement()
{
$this->articleList->SetArticlePage($this->articlePageSelector->GetPage());
$archiveCat = explode('-', $this->Value('ArchiveCategory'));
$this->CleanPageArticleLists();
if (count($archiveCat) == 1) {
$this->SaveArchivePage($archiveCat[0]);
}
else if (count($archiveCat) == 2) {
$this->SaveCategoryPage($archiveCat[1]);
}
return $this->articleList;
} | [
"protected",
"function",
"SaveElement",
"(",
")",
"{",
"$",
"this",
"->",
"articleList",
"->",
"SetArticlePage",
"(",
"$",
"this",
"->",
"articlePageSelector",
"->",
"GetPage",
"(",
")",
")",
";",
"$",
"archiveCat",
"=",
"explode",
"(",
"'-'",
",",
"$",
... | Saves article list and attaches current page to chosen archive or category | [
"Saves",
"article",
"list",
"and",
"attaches",
"current",
"page",
"to",
"chosen",
"archive",
"or",
"category"
] | 51abc830fecd1325f0b7d28391ecd924cdc7c945 | https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L139-L151 | train |
agentmedia/phine-news | src/News/Modules/Backend/ArticleListForm.php | ArticleListForm.SaveArchivePage | private function SaveArchivePage($archiveID)
{
$archive = Archive::Schema()->ByID($archiveID);
if ($archive) {
$archive->SetPage($this->Page());
$archive->Save();
}
} | php | private function SaveArchivePage($archiveID)
{
$archive = Archive::Schema()->ByID($archiveID);
if ($archive) {
$archive->SetPage($this->Page());
$archive->Save();
}
} | [
"private",
"function",
"SaveArchivePage",
"(",
"$",
"archiveID",
")",
"{",
"$",
"archive",
"=",
"Archive",
"::",
"Schema",
"(",
")",
"->",
"ByID",
"(",
"$",
"archiveID",
")",
";",
"if",
"(",
"$",
"archive",
")",
"{",
"$",
"archive",
"->",
"SetPage",
... | Sets the current page to the chosen archive, if no category chosen
@param int $archiveID The id of the archive | [
"Sets",
"the",
"current",
"page",
"to",
"the",
"chosen",
"archive",
"if",
"no",
"category",
"chosen"
] | 51abc830fecd1325f0b7d28391ecd924cdc7c945 | https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L174-L181 | train |
agentmedia/phine-news | src/News/Modules/Backend/ArticleListForm.php | ArticleListForm.SaveCategoryPage | private function SaveCategoryPage($categoryID)
{
$category = Category::Schema()->ByID($categoryID);
if ($category) {
$category->SetPage($this->Page());
$category->Save();
}
} | php | private function SaveCategoryPage($categoryID)
{
$category = Category::Schema()->ByID($categoryID);
if ($category) {
$category->SetPage($this->Page());
$category->Save();
}
} | [
"private",
"function",
"SaveCategoryPage",
"(",
"$",
"categoryID",
")",
"{",
"$",
"category",
"=",
"Category",
"::",
"Schema",
"(",
")",
"->",
"ByID",
"(",
"$",
"categoryID",
")",
";",
"if",
"(",
"$",
"category",
")",
"{",
"$",
"category",
"->",
"SetPa... | Sets the current page tor the chosen category, if no archive chosen
@param int $categoryID The id of the category | [
"Sets",
"the",
"current",
"page",
"tor",
"the",
"chosen",
"category",
"if",
"no",
"archive",
"chosen"
] | 51abc830fecd1325f0b7d28391ecd924cdc7c945 | https://github.com/agentmedia/phine-news/blob/51abc830fecd1325f0b7d28391ecd924cdc7c945/src/News/Modules/Backend/ArticleListForm.php#L187-L194 | train |
Stratadox/HydrationMapping | src/Property/Relationship/HasManyEmbedded.php | HasManyEmbedded.inProperty | public static function inProperty(
string $name,
DeserializesCollections $collection,
Deserializes $item,
string $key = 'key'
): MapsProperty {
return new self($name, $collection, $item, $key);
} | php | public static function inProperty(
string $name,
DeserializesCollections $collection,
Deserializes $item,
string $key = 'key'
): MapsProperty {
return new self($name, $collection, $item, $key);
} | [
"public",
"static",
"function",
"inProperty",
"(",
"string",
"$",
"name",
",",
"DeserializesCollections",
"$",
"collection",
",",
"Deserializes",
"$",
"item",
",",
"string",
"$",
"key",
"=",
"'key'",
")",
":",
"MapsProperty",
"{",
"return",
"new",
"self",
"(... | Creates a new embedded has-many mapping.
@param string $name The name of the property.
@param DeserializesCollections $collection The deserializer for the
collection.
@param Deserializes $item The deserializer for the
individual items.
@param string $key The array key to assign to
the scalars, used by the
deserializer for individual
items.
@return MapsProperty The embedded has-many mapping. | [
"Creates",
"a",
"new",
"embedded",
"has",
"-",
"many",
"mapping",
"."
] | b145deaaf76ab8c8060f0cba1a8c6f73da375982 | https://github.com/Stratadox/HydrationMapping/blob/b145deaaf76ab8c8060f0cba1a8c6f73da375982/src/Property/Relationship/HasManyEmbedded.php#L53-L60 | train |
rseyferth/chickenwire | src/ChickenWire/Application.php | Application._configure | protected function _configure() {
// Create my settings object
$this->config = new Core\Configuration();
// Define some paths
define("CHICKENWIRE_PATH", dirname(__FILE__));
define("APP_PATH", APP_ROOT . "/Application");
define("CONFIG_PATH", APP_PATH . "/Config");
define("CONTROLLER_PATH", APP_PATH . "/Controllers");
define("LAYOUT_PATH", APP_PATH . "/Layouts");
define("MODEL_PATH", APP_PATH . "/Models");
define("VIEW_PATH", APP_PATH . "/Views");
define("PUBLIC_PATH", APP_PATH . "/Public");
define("MODULE_PATH", APP_ROOT . "/Modules");
define("MODEL_NS", $this->config->applicationNamespace . "\\Models");
// Include all php files in the config directory
$dh = opendir(CONFIG_PATH);
$configFiles = scandir(CONFIG_PATH, SCANDIR_SORT_ASCENDING);
foreach ($configFiles as $file) {
// PHP?
if (preg_match("/\.php$/", $file)) {
// Load it
$this->config->load(CONFIG_PATH . '/' . $file);
}
}
// Initalize database configuration
$dbConnections = $this->config->allFor("database");
$environment = $this->config->environment;
\ActiveRecord\Config::initialize(function($config) use ($dbConnections, $environment) {
// Set model path
$config->setModelDirectory(MODEL_PATH);
// Apply connections
$config->setConnections($dbConnections);
// Set default to my environment
$config->setDefaultConnection($environment);
});
// Set the timezone
if ($this->config->timezone == '') {
throw new \Exception("You need to specify the timezone in the Application configuration.", 1);
}
date_default_timezone_set($this->config->timezone);
// Set self closing slash
\HtmlObject\Traits\Tag::$useSelfClosingSlash = $this->config->htmlSelfClosingSlash;
// Set the webPath
$this->config->webPath = rtrim($this->config->webPath, ' /');
} | php | protected function _configure() {
// Create my settings object
$this->config = new Core\Configuration();
// Define some paths
define("CHICKENWIRE_PATH", dirname(__FILE__));
define("APP_PATH", APP_ROOT . "/Application");
define("CONFIG_PATH", APP_PATH . "/Config");
define("CONTROLLER_PATH", APP_PATH . "/Controllers");
define("LAYOUT_PATH", APP_PATH . "/Layouts");
define("MODEL_PATH", APP_PATH . "/Models");
define("VIEW_PATH", APP_PATH . "/Views");
define("PUBLIC_PATH", APP_PATH . "/Public");
define("MODULE_PATH", APP_ROOT . "/Modules");
define("MODEL_NS", $this->config->applicationNamespace . "\\Models");
// Include all php files in the config directory
$dh = opendir(CONFIG_PATH);
$configFiles = scandir(CONFIG_PATH, SCANDIR_SORT_ASCENDING);
foreach ($configFiles as $file) {
// PHP?
if (preg_match("/\.php$/", $file)) {
// Load it
$this->config->load(CONFIG_PATH . '/' . $file);
}
}
// Initalize database configuration
$dbConnections = $this->config->allFor("database");
$environment = $this->config->environment;
\ActiveRecord\Config::initialize(function($config) use ($dbConnections, $environment) {
// Set model path
$config->setModelDirectory(MODEL_PATH);
// Apply connections
$config->setConnections($dbConnections);
// Set default to my environment
$config->setDefaultConnection($environment);
});
// Set the timezone
if ($this->config->timezone == '') {
throw new \Exception("You need to specify the timezone in the Application configuration.", 1);
}
date_default_timezone_set($this->config->timezone);
// Set self closing slash
\HtmlObject\Traits\Tag::$useSelfClosingSlash = $this->config->htmlSelfClosingSlash;
// Set the webPath
$this->config->webPath = rtrim($this->config->webPath, ' /');
} | [
"protected",
"function",
"_configure",
"(",
")",
"{",
"// Create my settings object",
"$",
"this",
"->",
"config",
"=",
"new",
"Core",
"\\",
"Configuration",
"(",
")",
";",
"// Define some paths",
"define",
"(",
"\"CHICKENWIRE_PATH\"",
",",
"dirname",
"(",
"__FILE... | Load and apply configuration files
@return void
@ignore | [
"Load",
"and",
"apply",
"configuration",
"files"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Application.php#L361-L422 | train |
rseyferth/chickenwire | src/ChickenWire/Application.php | Application._loadModules | protected function _loadModules()
{
// Check module directories
$dh = opendir(MODULE_PATH);
while (false !== ($filename = readdir($dh))) {
// Directory?
if (is_dir(MODULE_PATH . "/" . $filename) && !preg_match('/^\./', $filename)) {
// Load the module
Module::load($filename);
}
}
} | php | protected function _loadModules()
{
// Check module directories
$dh = opendir(MODULE_PATH);
while (false !== ($filename = readdir($dh))) {
// Directory?
if (is_dir(MODULE_PATH . "/" . $filename) && !preg_match('/^\./', $filename)) {
// Load the module
Module::load($filename);
}
}
} | [
"protected",
"function",
"_loadModules",
"(",
")",
"{",
"// Check module directories",
"$",
"dh",
"=",
"opendir",
"(",
"MODULE_PATH",
")",
";",
"while",
"(",
"false",
"!==",
"(",
"$",
"filename",
"=",
"readdir",
"(",
"$",
"dh",
")",
")",
")",
"{",
"// Di... | Load all modules in the Modules directory
@return void
@ignore | [
"Load",
"all",
"modules",
"in",
"the",
"Modules",
"directory"
] | 74921f0a0d489366602e25df43eda894719e43d3 | https://github.com/rseyferth/chickenwire/blob/74921f0a0d489366602e25df43eda894719e43d3/src/ChickenWire/Application.php#L429-L446 | train |
Aurora-Framework/Helper | src/Helper/ArrayTrait.php | ArrayTrait.set | public function set($path = null, $value = null)
{
if ($path === null) {
$this->data = $value;
return $this;
}
$at =& $this->data;
$keys = explode(".", $path);
$keyCount = count($keys);
for ($i=0; $i < $keyCount; $i++) {
if (($keyCount-1) === $i) {
if (is_array($at)) {
$at[$keys[$i]] = $value;
} else {
throw new \RuntimeException("Can not set value at this path ($path) because is not array.");
}
} else {
$key = $keys[$i];
if (!isset($at[$key])) {
$at[$key] = [];
}
$at =& $at[$key];
}
}
return $this;
} | php | public function set($path = null, $value = null)
{
if ($path === null) {
$this->data = $value;
return $this;
}
$at =& $this->data;
$keys = explode(".", $path);
$keyCount = count($keys);
for ($i=0; $i < $keyCount; $i++) {
if (($keyCount-1) === $i) {
if (is_array($at)) {
$at[$keys[$i]] = $value;
} else {
throw new \RuntimeException("Can not set value at this path ($path) because is not array.");
}
} else {
$key = $keys[$i];
if (!isset($at[$key])) {
$at[$key] = [];
}
$at =& $at[$key];
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"$",
"path",
"=",
"null",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"path",
"===",
"null",
")",
"{",
"$",
"this",
"->",
"data",
"=",
"$",
"value",
";",
"return",
"$",
"this",
";",
"}",
"$",
"a... | Set new key for data, this can also
ovewrite existing data
@access public
@param string $key Key identifier
@param mixed $value Value assigned for key | [
"Set",
"new",
"key",
"for",
"data",
"this",
"can",
"also",
"ovewrite",
"existing",
"data"
] | 1d0fa09d641d994cf7d8136f4aff220342419804 | https://github.com/Aurora-Framework/Helper/blob/1d0fa09d641d994cf7d8136f4aff220342419804/src/Helper/ArrayTrait.php#L183-L211 | train |
Aurora-Framework/Helper | src/Helper/ArrayTrait.php | ArrayTrait.get | public function get($key = null, $default = null)
{
$return = $this->data;
if ($key !== null) {
$keys = explode('.', $key);
foreach ($keys as $key) {
if (isset($return[(string) $key])) {
$return = $return[$key];
} else {
$return = $default;
break;
}
}
}
return $return;
} | php | public function get($key = null, $default = null)
{
$return = $this->data;
if ($key !== null) {
$keys = explode('.', $key);
foreach ($keys as $key) {
if (isset($return[(string) $key])) {
$return = $return[$key];
} else {
$return = $default;
break;
}
}
}
return $return;
} | [
"public",
"function",
"get",
"(",
"$",
"key",
"=",
"null",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"return",
"=",
"$",
"this",
"->",
"data",
";",
"if",
"(",
"$",
"key",
"!==",
"null",
")",
"{",
"$",
"keys",
"=",
"explode",
"(",
"'.'",
... | Get value assigned for key
@access public
@param string|int $key Identifier for $data
@return mixed|null Value given for key | [
"Get",
"value",
"assigned",
"for",
"key"
] | 1d0fa09d641d994cf7d8136f4aff220342419804 | https://github.com/Aurora-Framework/Helper/blob/1d0fa09d641d994cf7d8136f4aff220342419804/src/Helper/ArrayTrait.php#L260-L278 | train |
bugotech/phar | src/Maker.php | Maker.makePhar | protected function makePhar()
{
$phar = new Phar($this->filePhar, 0, $this->alias);
$phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering();
// Adicionar arquivos
$this->addFiles($phar);
// Adicionar arquivo bin
$this->addBinFile($phar);
// Adicionar Stup
$this->addStub($phar);
// Adicionar licenca
$this->addLicence($phar);
// Adicionar arquivo de update
//$this->addUpdateFile($phar);
// Finalizar phar.
$phar->stopBuffering();
unset($phar);
} | php | protected function makePhar()
{
$phar = new Phar($this->filePhar, 0, $this->alias);
$phar->setSignatureAlgorithm(\Phar::SHA1);
$phar->startBuffering();
// Adicionar arquivos
$this->addFiles($phar);
// Adicionar arquivo bin
$this->addBinFile($phar);
// Adicionar Stup
$this->addStub($phar);
// Adicionar licenca
$this->addLicence($phar);
// Adicionar arquivo de update
//$this->addUpdateFile($phar);
// Finalizar phar.
$phar->stopBuffering();
unset($phar);
} | [
"protected",
"function",
"makePhar",
"(",
")",
"{",
"$",
"phar",
"=",
"new",
"Phar",
"(",
"$",
"this",
"->",
"filePhar",
",",
"0",
",",
"$",
"this",
"->",
"alias",
")",
";",
"$",
"phar",
"->",
"setSignatureAlgorithm",
"(",
"\\",
"Phar",
"::",
"SHA1",... | Gerar arquivo PHAR. | [
"Gerar",
"arquivo",
"PHAR",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L96-L120 | train |
bugotech/phar | src/Maker.php | Maker.makeBat | protected function makeBat()
{
$content = $this->files->get(__DIR__ . '/../stubs/bat.stub');
$content = str_replace('DubbyAlias', $this->alias, $content);
$this->files->put($this->fileBat, $content);
} | php | protected function makeBat()
{
$content = $this->files->get(__DIR__ . '/../stubs/bat.stub');
$content = str_replace('DubbyAlias', $this->alias, $content);
$this->files->put($this->fileBat, $content);
} | [
"protected",
"function",
"makeBat",
"(",
")",
"{",
"$",
"content",
"=",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"__DIR__",
".",
"'/../stubs/bat.stub'",
")",
";",
"$",
"content",
"=",
"str_replace",
"(",
"'DubbyAlias'",
",",
"$",
"this",
"->",
"alia... | Gerar arquivo BAT. | [
"Gerar",
"arquivo",
"BAT",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L125-L130 | train |
bugotech/phar | src/Maker.php | Maker.resetPhar | protected function resetPhar()
{
if ($this->files->exists($this->filePhar)) {
$this->files->delete($this->filePhar);
}
if ($this->files->exists($this->fileBat)) {
$this->files->delete($this->fileBat);
}
} | php | protected function resetPhar()
{
if ($this->files->exists($this->filePhar)) {
$this->files->delete($this->filePhar);
}
if ($this->files->exists($this->fileBat)) {
$this->files->delete($this->fileBat);
}
} | [
"protected",
"function",
"resetPhar",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"this",
"->",
"filePhar",
")",
")",
"{",
"$",
"this",
"->",
"files",
"->",
"delete",
"(",
"$",
"this",
"->",
"filePhar",
")",
";",... | Reiniciar arquivos compilados. | [
"Reiniciar",
"arquivos",
"compilados",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L135-L144 | train |
bugotech/phar | src/Maker.php | Maker.setName | public function setName($name)
{
$this->name = $name;
$this->alias = $name . '.phar';
$this->filePhar = $this->files->combine($this->pathBase, $this->alias);
$this->fileBat = $this->files->combine($this->pathBase, $name . '.bat');
} | php | public function setName($name)
{
$this->name = $name;
$this->alias = $name . '.phar';
$this->filePhar = $this->files->combine($this->pathBase, $this->alias);
$this->fileBat = $this->files->combine($this->pathBase, $name . '.bat');
} | [
"public",
"function",
"setName",
"(",
"$",
"name",
")",
"{",
"$",
"this",
"->",
"name",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"alias",
"=",
"$",
"name",
".",
"'.phar'",
";",
"$",
"this",
"->",
"filePhar",
"=",
"$",
"this",
"->",
"files",
"->"... | Set name app.
@param string $name | [
"Set",
"name",
"app",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L150-L156 | train |
bugotech/phar | src/Maker.php | Maker.addFiles | public function addFiles(Phar $phar)
{
$finder = new Finder();
$finder->files()
->ignoreVCS(true)
->name('*.php')
->name('*.stub')
->exclude('Tests')
->exclude('tests')
->exclude('/storage')
->exclude('/config')
->exclude('/build')
->in($this->pathBase);
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
} | php | public function addFiles(Phar $phar)
{
$finder = new Finder();
$finder->files()
->ignoreVCS(true)
->name('*.php')
->name('*.stub')
->exclude('Tests')
->exclude('tests')
->exclude('/storage')
->exclude('/config')
->exclude('/build')
->in($this->pathBase);
foreach ($finder as $file) {
$this->addFile($phar, $file);
}
} | [
"public",
"function",
"addFiles",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"finder",
"=",
"new",
"Finder",
"(",
")",
";",
"$",
"finder",
"->",
"files",
"(",
")",
"->",
"ignoreVCS",
"(",
"true",
")",
"->",
"name",
"(",
"'*.php'",
")",
"->",
"name",
... | Adicionar arquivos.
@param Phar $phar | [
"Adicionar",
"arquivos",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L189-L205 | train |
bugotech/phar | src/Maker.php | Maker.addFile | private function addFile(Phar $phar, SplFileInfo $file, $strip = false)
{
// Forçar tirar espaços de PHP.
$strip = ($file->getExtension() == 'php') ? true : $strip;
$this->fireEvent($file->getRealPath());
$path = str_replace($this->pathBase, '', $file->getRealPath());
$content = $this->files->get($file);
// Tratar espacos?
if ($strip) {
$content = $this->stripWhitespace($content);
}
// Eh arquivo de licenca?
if ('LICENSE' === basename($file)) {
$content = "\n" . $content . "\n";
}
// Tratar parametros
foreach ($this->params as $pk => $pv) {
$pk = sprintf('@%s@', $pk);
$content = str_replace($pk, $pv, $content);
}
$phar->addFromString($path, $content);
} | php | private function addFile(Phar $phar, SplFileInfo $file, $strip = false)
{
// Forçar tirar espaços de PHP.
$strip = ($file->getExtension() == 'php') ? true : $strip;
$this->fireEvent($file->getRealPath());
$path = str_replace($this->pathBase, '', $file->getRealPath());
$content = $this->files->get($file);
// Tratar espacos?
if ($strip) {
$content = $this->stripWhitespace($content);
}
// Eh arquivo de licenca?
if ('LICENSE' === basename($file)) {
$content = "\n" . $content . "\n";
}
// Tratar parametros
foreach ($this->params as $pk => $pv) {
$pk = sprintf('@%s@', $pk);
$content = str_replace($pk, $pv, $content);
}
$phar->addFromString($path, $content);
} | [
"private",
"function",
"addFile",
"(",
"Phar",
"$",
"phar",
",",
"SplFileInfo",
"$",
"file",
",",
"$",
"strip",
"=",
"false",
")",
"{",
"// Forçar tirar espaços de PHP.",
"$",
"strip",
"=",
"(",
"$",
"file",
"->",
"getExtension",
"(",
")",
"==",
"'php'",
... | Adicionar arquivo tratado no phar.
@param Phar $phar
@param SplFileInfo $file
@param bool $strip | [
"Adicionar",
"arquivo",
"tratado",
"no",
"phar",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L214-L240 | train |
bugotech/phar | src/Maker.php | Maker.addBinFile | protected function addBinFile(Phar $phar)
{
$fileBin = $this->files->combine($this->pathBase, $this->fileNameBin);
if (! $this->files->exists($fileBin)) {
return;
}
$this->fireEvent('BIN: file main');
$content = $this->files->get($fileBin);
$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
$phar->addFromString('artisan', $content);
} | php | protected function addBinFile(Phar $phar)
{
$fileBin = $this->files->combine($this->pathBase, $this->fileNameBin);
if (! $this->files->exists($fileBin)) {
return;
}
$this->fireEvent('BIN: file main');
$content = $this->files->get($fileBin);
$content = preg_replace('{^#!/usr/bin/env php\s*}', '', $content);
$phar->addFromString('artisan', $content);
} | [
"protected",
"function",
"addBinFile",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"fileBin",
"=",
"$",
"this",
"->",
"files",
"->",
"combine",
"(",
"$",
"this",
"->",
"pathBase",
",",
"$",
"this",
"->",
"fileNameBin",
")",
";",
"if",
"(",
"!",
"$",
"... | Adicionar arquivo BIN.
@param Phar $phar | [
"Adicionar",
"arquivo",
"BIN",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L246-L258 | train |
bugotech/phar | src/Maker.php | Maker.addStub | protected function addStub(Phar $phar)
{
$this->fireEvent('STUB');
// Add warning once the phar is older than 30 days
$defineTime = '';
if (array_key_exists('package_version', $this->params)) {
$warningTime = time() + 30 * 86400;
$defineTime = "define('PHAR_DEV_WARNING_TIME', $warningTime);\n";
}
$content = $this->files->get(__DIR__ . '/../stubs/compile.stub');
$content = str_replace('DubbyAlias', $this->alias, $content);
$content = str_replace('DubbyDefineDateTime', $defineTime, $content);
$phar->setStub($content);
} | php | protected function addStub(Phar $phar)
{
$this->fireEvent('STUB');
// Add warning once the phar is older than 30 days
$defineTime = '';
if (array_key_exists('package_version', $this->params)) {
$warningTime = time() + 30 * 86400;
$defineTime = "define('PHAR_DEV_WARNING_TIME', $warningTime);\n";
}
$content = $this->files->get(__DIR__ . '/../stubs/compile.stub');
$content = str_replace('DubbyAlias', $this->alias, $content);
$content = str_replace('DubbyDefineDateTime', $defineTime, $content);
$phar->setStub($content);
} | [
"protected",
"function",
"addStub",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"this",
"->",
"fireEvent",
"(",
"'STUB'",
")",
";",
"// Add warning once the phar is older than 30 days",
"$",
"defineTime",
"=",
"''",
";",
"if",
"(",
"array_key_exists",
"(",
"'packag... | Adicionar Stub.
@param Phar $phar | [
"Adicionar",
"Stub",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L264-L280 | train |
bugotech/phar | src/Maker.php | Maker.addLicence | protected function addLicence(Phar $phar)
{
$file = $this->files->combine($this->pathBase, 'LICENSE');
if (! $this->files->exists($file)) {
return;
}
$this->fireEvent('LICENCE');
$this->addFile($phar, new SplFileInfo($file), false);
} | php | protected function addLicence(Phar $phar)
{
$file = $this->files->combine($this->pathBase, 'LICENSE');
if (! $this->files->exists($file)) {
return;
}
$this->fireEvent('LICENCE');
$this->addFile($phar, new SplFileInfo($file), false);
} | [
"protected",
"function",
"addLicence",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"files",
"->",
"combine",
"(",
"$",
"this",
"->",
"pathBase",
",",
"'LICENSE'",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"files",
"-... | Adicionar arquivo de licenca.
@param Phar $phar | [
"Adicionar",
"arquivo",
"de",
"licenca",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L286-L295 | train |
bugotech/phar | src/Maker.php | Maker.addUpdateFile | protected function addUpdateFile(Phar $phar)
{
$file = $this->files->combine($this->pathBase, 'update.json');
if ($this->files->exists($file)) {
$this->addFile($phar, new SplFileInfo($file), false);
}
} | php | protected function addUpdateFile(Phar $phar)
{
$file = $this->files->combine($this->pathBase, 'update.json');
if ($this->files->exists($file)) {
$this->addFile($phar, new SplFileInfo($file), false);
}
} | [
"protected",
"function",
"addUpdateFile",
"(",
"Phar",
"$",
"phar",
")",
"{",
"$",
"file",
"=",
"$",
"this",
"->",
"files",
"->",
"combine",
"(",
"$",
"this",
"->",
"pathBase",
",",
"'update.json'",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"-... | Adicionar arquivo para update.
@param Phar $phar | [
"Adicionar",
"arquivo",
"para",
"update",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L301-L307 | train |
bugotech/phar | src/Maker.php | Maker.stripWhitespace | private function stripWhitespace($source)
{
// Verificar se token_get_all existe
if (! function_exists('token_get_all')) {
return $source;
}
$output = '';
foreach (token_get_all($source) as $token) {
if (is_string($token)) {
$output .= $token;
} elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
$output .= str_repeat("\n", substr_count($token[1], "\n"));
} elseif (T_WHITESPACE === $token[0]) {
// reduce wide spaces
$whitespace = preg_replace('{[ \t]+}', ' ', $token[1]);
// normalize newlines to \n
$whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace);
// trim leading spaces
$whitespace = preg_replace('{\n +}', "\n", $whitespace);
$output .= $whitespace;
} else {
$output .= $token[1];
}
}
return $output;
} | php | private function stripWhitespace($source)
{
// Verificar se token_get_all existe
if (! function_exists('token_get_all')) {
return $source;
}
$output = '';
foreach (token_get_all($source) as $token) {
if (is_string($token)) {
$output .= $token;
} elseif (in_array($token[0], [T_COMMENT, T_DOC_COMMENT])) {
$output .= str_repeat("\n", substr_count($token[1], "\n"));
} elseif (T_WHITESPACE === $token[0]) {
// reduce wide spaces
$whitespace = preg_replace('{[ \t]+}', ' ', $token[1]);
// normalize newlines to \n
$whitespace = preg_replace('{(?:\r\n|\r|\n)}', "\n", $whitespace);
// trim leading spaces
$whitespace = preg_replace('{\n +}', "\n", $whitespace);
$output .= $whitespace;
} else {
$output .= $token[1];
}
}
return $output;
} | [
"private",
"function",
"stripWhitespace",
"(",
"$",
"source",
")",
"{",
"// Verificar se token_get_all existe",
"if",
"(",
"!",
"function_exists",
"(",
"'token_get_all'",
")",
")",
"{",
"return",
"$",
"source",
";",
"}",
"$",
"output",
"=",
"''",
";",
"foreach... | Removes whitespace from a PHP source string while preserving line numbers.
@param string $source A PHP string
@return string The PHP string with the whitespace removed | [
"Removes",
"whitespace",
"from",
"a",
"PHP",
"source",
"string",
"while",
"preserving",
"line",
"numbers",
"."
] | 96f226d2c4bb1787fd41a3c67fe64b10de22b7af | https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Maker.php#L315-L342 | train |
frankfoerster/cakephp-filter | src/Model/Table/FiltersTable.php | FiltersTable.findFilterDataBySlug | public function findFilterDataBySlug(Query $query, array $options)
{
if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) {
user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.');
}
$encryptedFilterData = $this->_findEncryptedFilterData($query, $options['request'])->first();
if ($encryptedFilterData) {
$encryptedFilterData = $encryptedFilterData->toArray();
return $this->_decodeFilterData($encryptedFilterData['filter_data']);
}
return [];
} | php | public function findFilterDataBySlug(Query $query, array $options)
{
if (!isset($options['request']) || get_class($options['request']) !== ServerRequest::class) {
user_error('The request query option must exist and must be of type Cake\Http\ServerRequest.');
}
$encryptedFilterData = $this->_findEncryptedFilterData($query, $options['request'])->first();
if ($encryptedFilterData) {
$encryptedFilterData = $encryptedFilterData->toArray();
return $this->_decodeFilterData($encryptedFilterData['filter_data']);
}
return [];
} | [
"public",
"function",
"findFilterDataBySlug",
"(",
"Query",
"$",
"query",
",",
"array",
"$",
"options",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"options",
"[",
"'request'",
"]",
")",
"||",
"get_class",
"(",
"$",
"options",
"[",
"'request'",
"]",
"... | Find stored filter data for a given slug.
@param Query $query
@param array $options
@return array | [
"Find",
"stored",
"filter",
"data",
"for",
"a",
"given",
"slug",
"."
] | 539ec2d5c01c9b00766a6db98b60f32832fa5dee | https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L70-L84 | train |
frankfoerster/cakephp-filter | src/Model/Table/FiltersTable.php | FiltersTable.createFilterForFilterData | public function createFilterForFilterData(ServerRequest $request, array $filterData)
{
$charlist = 'abcdefghikmnopqrstuvwxyz';
do {
$slug = '';
for ($i = 0; $i < 14; $i++) {
$slug .= substr($charlist, rand(0, 31), 1);
}
} while ($this->_slugExists($slug, $request));
$this->save(new Filter([
'plugin' => $request->getParam('plugin'),
'controller' => $request->getParam('controller'),
'action' => $request->getParam('action'),
'slug' => $slug,
'filter_data' => $this->_encodeFilterData($filterData)
]));
return $slug;
} | php | public function createFilterForFilterData(ServerRequest $request, array $filterData)
{
$charlist = 'abcdefghikmnopqrstuvwxyz';
do {
$slug = '';
for ($i = 0; $i < 14; $i++) {
$slug .= substr($charlist, rand(0, 31), 1);
}
} while ($this->_slugExists($slug, $request));
$this->save(new Filter([
'plugin' => $request->getParam('plugin'),
'controller' => $request->getParam('controller'),
'action' => $request->getParam('action'),
'slug' => $slug,
'filter_data' => $this->_encodeFilterData($filterData)
]));
return $slug;
} | [
"public",
"function",
"createFilterForFilterData",
"(",
"ServerRequest",
"$",
"request",
",",
"array",
"$",
"filterData",
")",
"{",
"$",
"charlist",
"=",
"'abcdefghikmnopqrstuvwxyz'",
";",
"do",
"{",
"$",
"slug",
"=",
"''",
";",
"for",
"(",
"$",
"i",
"=",
... | Create a new filter entry for the given request and filter data.
@param ServerRequest $request
@param array $filterData
@return string The slug representing the given $filterData. | [
"Create",
"a",
"new",
"filter",
"entry",
"for",
"the",
"given",
"request",
"and",
"filter",
"data",
"."
] | 539ec2d5c01c9b00766a6db98b60f32832fa5dee | https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L93-L113 | train |
frankfoerster/cakephp-filter | src/Model/Table/FiltersTable.php | FiltersTable._pluginCondition | protected function _pluginCondition(ServerRequest $request)
{
if ($request->getParam('plugin') !== null) {
return [$this->getAlias() . '.plugin' => $request->getParam('plugin')];
}
return [$this->getAlias() . '.plugin IS NULL'];
} | php | protected function _pluginCondition(ServerRequest $request)
{
if ($request->getParam('plugin') !== null) {
return [$this->getAlias() . '.plugin' => $request->getParam('plugin')];
}
return [$this->getAlias() . '.plugin IS NULL'];
} | [
"protected",
"function",
"_pluginCondition",
"(",
"ServerRequest",
"$",
"request",
")",
"{",
"if",
"(",
"$",
"request",
"->",
"getParam",
"(",
"'plugin'",
")",
"!==",
"null",
")",
"{",
"return",
"[",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.plugi... | Get the plugin query condition for a given request.
@param ServerRequest $request
@return array | [
"Get",
"the",
"plugin",
"query",
"condition",
"for",
"a",
"given",
"request",
"."
] | 539ec2d5c01c9b00766a6db98b60f32832fa5dee | https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L143-L150 | train |
frankfoerster/cakephp-filter | src/Model/Table/FiltersTable.php | FiltersTable._slugExists | protected function _slugExists($slug, ServerRequest $request)
{
$existingSlug = $this->find('all')
->select($this->getAlias() . '.slug')
->where([
$this->getAlias() . '.slug' => $slug,
$this->getAlias() . '.controller' => $request->getParam('controller'),
$this->getAlias() . '.action' => $request->getParam('action')
])
->where($this->_pluginCondition($request))
->enableHydration(false)
->first();
return $existingSlug !== null;
} | php | protected function _slugExists($slug, ServerRequest $request)
{
$existingSlug = $this->find('all')
->select($this->getAlias() . '.slug')
->where([
$this->getAlias() . '.slug' => $slug,
$this->getAlias() . '.controller' => $request->getParam('controller'),
$this->getAlias() . '.action' => $request->getParam('action')
])
->where($this->_pluginCondition($request))
->enableHydration(false)
->first();
return $existingSlug !== null;
} | [
"protected",
"function",
"_slugExists",
"(",
"$",
"slug",
",",
"ServerRequest",
"$",
"request",
")",
"{",
"$",
"existingSlug",
"=",
"$",
"this",
"->",
"find",
"(",
"'all'",
")",
"->",
"select",
"(",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.slug... | Check if a slug for the given request params already exists.
@param string $slug
@param ServerRequest $request
@return bool | [
"Check",
"if",
"a",
"slug",
"for",
"the",
"given",
"request",
"params",
"already",
"exists",
"."
] | 539ec2d5c01c9b00766a6db98b60f32832fa5dee | https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L159-L173 | train |
frankfoerster/cakephp-filter | src/Model/Table/FiltersTable.php | FiltersTable._findEncryptedFilterData | protected function _findEncryptedFilterData(Query $query, ServerRequest $request)
{
return $query
->select($this->getAlias() . '.filter_data')
->where([
$this->getAlias() . '.controller' => $request->getParam('controller'),
$this->getAlias() . '.action' => $request->getParam('action'),
$this->getAlias() . '.slug' => $request->getParam('sluggedFilter')
])
->where($this->_pluginCondition($request));
} | php | protected function _findEncryptedFilterData(Query $query, ServerRequest $request)
{
return $query
->select($this->getAlias() . '.filter_data')
->where([
$this->getAlias() . '.controller' => $request->getParam('controller'),
$this->getAlias() . '.action' => $request->getParam('action'),
$this->getAlias() . '.slug' => $request->getParam('sluggedFilter')
])
->where($this->_pluginCondition($request));
} | [
"protected",
"function",
"_findEncryptedFilterData",
"(",
"Query",
"$",
"query",
",",
"ServerRequest",
"$",
"request",
")",
"{",
"return",
"$",
"query",
"->",
"select",
"(",
"$",
"this",
"->",
"getAlias",
"(",
")",
".",
"'.filter_data'",
")",
"->",
"where",
... | Find encrypted filter data for the given request and the provided sluggedFilter.
@param Query $query
@param ServerRequest $request
@return Query | [
"Find",
"encrypted",
"filter",
"data",
"for",
"the",
"given",
"request",
"and",
"the",
"provided",
"sluggedFilter",
"."
] | 539ec2d5c01c9b00766a6db98b60f32832fa5dee | https://github.com/frankfoerster/cakephp-filter/blob/539ec2d5c01c9b00766a6db98b60f32832fa5dee/src/Model/Table/FiltersTable.php#L182-L192 | train |
nia-php/requestresponse-http | sources/HttpRequest.php | HttpRequest.determineMethod | private function determineMethod(array $server): string
{
$mapping = [
'GET' => self::METHOD_GET,
'POST' => self::METHOD_POST,
'PUT' => self::METHOD_PUT,
'PATCH' => self::METHOD_PATCH,
'DELETE' => self::METHOD_DELETE,
'HEAD' => self::METHOD_HEAD,
'OPTIONS' => self::METHOD_OPTIONS,
'CONNECT' => self::METHOD_CONNECT,
'TRACE' => self::METHOD_TRACE
];
$method = $server['REQUEST_METHOD'];
if (array_key_exists($method, $mapping)) {
return $mapping[$method];
}
return self::METHOD_GET;
} | php | private function determineMethod(array $server): string
{
$mapping = [
'GET' => self::METHOD_GET,
'POST' => self::METHOD_POST,
'PUT' => self::METHOD_PUT,
'PATCH' => self::METHOD_PATCH,
'DELETE' => self::METHOD_DELETE,
'HEAD' => self::METHOD_HEAD,
'OPTIONS' => self::METHOD_OPTIONS,
'CONNECT' => self::METHOD_CONNECT,
'TRACE' => self::METHOD_TRACE
];
$method = $server['REQUEST_METHOD'];
if (array_key_exists($method, $mapping)) {
return $mapping[$method];
}
return self::METHOD_GET;
} | [
"private",
"function",
"determineMethod",
"(",
"array",
"$",
"server",
")",
":",
"string",
"{",
"$",
"mapping",
"=",
"[",
"'GET'",
"=>",
"self",
"::",
"METHOD_GET",
",",
"'POST'",
"=>",
"self",
"::",
"METHOD_POST",
",",
"'PUT'",
"=>",
"self",
"::",
"METH... | Determines the used method by using passed server configuration.
@param string[] $server
The server configuration.
@return string The determined method. | [
"Determines",
"the",
"used",
"method",
"by",
"using",
"passed",
"server",
"configuration",
"."
] | 9c9c4c5344812aff9dc50f4c930051241af2f989 | https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L345-L366 | train |
nia-php/requestresponse-http | sources/HttpRequest.php | HttpRequest.determineHeader | private function determineHeader(array $server): MapInterface
{
$header = new Map();
foreach ($server as $name => $value) {
if (strpos($name, 'HTTP_') === 0) {
$name = substr($name, 5);
$name = explode('_', $name);
$name = array_map('strtolower', $name);
$name = array_map('ucfirst', $name);
$name = implode('-', $name);
$header->set($name, $value);
}
}
return new ReadOnlyMap($header);
} | php | private function determineHeader(array $server): MapInterface
{
$header = new Map();
foreach ($server as $name => $value) {
if (strpos($name, 'HTTP_') === 0) {
$name = substr($name, 5);
$name = explode('_', $name);
$name = array_map('strtolower', $name);
$name = array_map('ucfirst', $name);
$name = implode('-', $name);
$header->set($name, $value);
}
}
return new ReadOnlyMap($header);
} | [
"private",
"function",
"determineHeader",
"(",
"array",
"$",
"server",
")",
":",
"MapInterface",
"{",
"$",
"header",
"=",
"new",
"Map",
"(",
")",
";",
"foreach",
"(",
"$",
"server",
"as",
"$",
"name",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"strpos"... | Determines the header by using passed server configuration.
@param string[] $server
The server configuration.
@return MapInterface The determined header as a map. | [
"Determines",
"the",
"header",
"by",
"using",
"passed",
"server",
"configuration",
"."
] | 9c9c4c5344812aff9dc50f4c930051241af2f989 | https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L375-L392 | train |
nia-php/requestresponse-http | sources/HttpRequest.php | HttpRequest.determinePath | private function determinePath(array $server): string
{
$path = '';
if (strpos($server['SCRIPT_NAME'], 'index.php') !== false) {
$path = str_replace('index.php', '', $server['SCRIPT_NAME']);
}
$parts = explode('?', $server['REQUEST_URI']);
$length = 0;
if ($path !== '' && strpos($parts[0], $path) === 0) {
$length = strlen($path);
}
return '/' . ltrim(substr($parts[0], $length), '/');
} | php | private function determinePath(array $server): string
{
$path = '';
if (strpos($server['SCRIPT_NAME'], 'index.php') !== false) {
$path = str_replace('index.php', '', $server['SCRIPT_NAME']);
}
$parts = explode('?', $server['REQUEST_URI']);
$length = 0;
if ($path !== '' && strpos($parts[0], $path) === 0) {
$length = strlen($path);
}
return '/' . ltrim(substr($parts[0], $length), '/');
} | [
"private",
"function",
"determinePath",
"(",
"array",
"$",
"server",
")",
":",
"string",
"{",
"$",
"path",
"=",
"''",
";",
"if",
"(",
"strpos",
"(",
"$",
"server",
"[",
"'SCRIPT_NAME'",
"]",
",",
"'index.php'",
")",
"!==",
"false",
")",
"{",
"$",
"pa... | Determines the used path by using passed server configuration.
@param string[] $server
The server configuration.
@return string The determined path. | [
"Determines",
"the",
"used",
"path",
"by",
"using",
"passed",
"server",
"configuration",
"."
] | 9c9c4c5344812aff9dc50f4c930051241af2f989 | https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L401-L416 | train |
nia-php/requestresponse-http | sources/HttpRequest.php | HttpRequest.determineRemoteIpAddress | private function determineRemoteIpAddress(array $server): string
{
if (array_key_exists('HTTP_X_FORWARDED_FOR', $server) && filter_var($server['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) {
return $server['HTTP_X_FORWARDED_FOR'];
} elseif (array_key_exists('HTTP_CLIENT_IP', $server) && filter_var($server['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) {
return $server['HTTP_CLIENT_IP'];
} elseif (array_key_exists('HTTP_TRUE_CLIENT_IP', $server) && filter_var($server['HTTP_TRUE_CLIENT_IP'], FILTER_VALIDATE_IP)) {
return $server['HTTP_TRUE_CLIENT_IP'];
}
return $server['REMOTE_ADDR'];
} | php | private function determineRemoteIpAddress(array $server): string
{
if (array_key_exists('HTTP_X_FORWARDED_FOR', $server) && filter_var($server['HTTP_X_FORWARDED_FOR'], FILTER_VALIDATE_IP)) {
return $server['HTTP_X_FORWARDED_FOR'];
} elseif (array_key_exists('HTTP_CLIENT_IP', $server) && filter_var($server['HTTP_CLIENT_IP'], FILTER_VALIDATE_IP)) {
return $server['HTTP_CLIENT_IP'];
} elseif (array_key_exists('HTTP_TRUE_CLIENT_IP', $server) && filter_var($server['HTTP_TRUE_CLIENT_IP'], FILTER_VALIDATE_IP)) {
return $server['HTTP_TRUE_CLIENT_IP'];
}
return $server['REMOTE_ADDR'];
} | [
"private",
"function",
"determineRemoteIpAddress",
"(",
"array",
"$",
"server",
")",
":",
"string",
"{",
"if",
"(",
"array_key_exists",
"(",
"'HTTP_X_FORWARDED_FOR'",
",",
"$",
"server",
")",
"&&",
"filter_var",
"(",
"$",
"server",
"[",
"'HTTP_X_FORWARDED_FOR'",
... | Determines the remote ip address by using passed server configuration.
@param string[] $server
The server configuration.
@return string The determined remote ip address. | [
"Determines",
"the",
"remote",
"ip",
"address",
"by",
"using",
"passed",
"server",
"configuration",
"."
] | 9c9c4c5344812aff9dc50f4c930051241af2f989 | https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L425-L436 | train |
nia-php/requestresponse-http | sources/HttpRequest.php | HttpRequest.narrowArray | private function narrowArray(array $array, string $key = null)
{
if ($key) {
$key .= '--';
}
$result = [];
foreach ($array as $index => $value) {
if (is_array($value)) {
$result = array_merge($result, $this->narrowArray($value, $key . $index));
} else {
$result[$key . $index] = $value;
}
}
return $result;
} | php | private function narrowArray(array $array, string $key = null)
{
if ($key) {
$key .= '--';
}
$result = [];
foreach ($array as $index => $value) {
if (is_array($value)) {
$result = array_merge($result, $this->narrowArray($value, $key . $index));
} else {
$result[$key . $index] = $value;
}
}
return $result;
} | [
"private",
"function",
"narrowArray",
"(",
"array",
"$",
"array",
",",
"string",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"key",
")",
"{",
"$",
"key",
".=",
"'--'",
";",
"}",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"ar... | Narrows PHP's native nested map into a non-nested map.
@param mixed[] $array
The nested map to narrow.
@param string|null $key
The parent key.
@return string[] Narrowed map. | [
"Narrows",
"PHP",
"s",
"native",
"nested",
"map",
"into",
"a",
"non",
"-",
"nested",
"map",
"."
] | 9c9c4c5344812aff9dc50f4c930051241af2f989 | https://github.com/nia-php/requestresponse-http/blob/9c9c4c5344812aff9dc50f4c930051241af2f989/sources/HttpRequest.php#L459-L476 | train |
bishopb/vanilla | applications/dashboard/controllers/class.modulecontroller.php | ModuleController.Index | public function Index($Module, $AppFolder = '', $DeliveryType = '') {
if (!$DeliveryType)
$this->DeliveryType(DELIVERY_TYPE_VIEW);
$ModuleClassExists = class_exists($Module);
if ($ModuleClassExists) {
// Make sure that the class implements Gdn_IModule
$ReflectionClass = new ReflectionClass($Module);
if ($ReflectionClass->implementsInterface("Gdn_IModule")) {
// Set the proper application folder on this controller so that things render properly.
if ($AppFolder) {
$this->ApplicationFolder = $AppFolder;
} else {
$Filename = str_replace('\\', '/', substr($ReflectionClass->getFileName(), strlen(PATH_ROOT)));
// Figure our the application folder for the module.
$Parts = explode('/', trim($Filename, '/'));
if ($Parts[0] == 'applications') {
$this->ApplicationFolder = $Parts[1];
}
}
$ModuleInstance = new $Module($this);
$ModuleInstance->Visible = TRUE;
$WhiteList = array('Limit', 'Help');
foreach ($this->Request->Get() as $Key => $Value) {
if (in_array($Key, $WhiteList)) {
$ModuleInstance->$Key = $Value;
}
}
$this->SetData('_Module', $ModuleInstance);
$this->Render('Index', FALSE, 'dashboard');
return;
}
}
throw NotFoundException($Module);
} | php | public function Index($Module, $AppFolder = '', $DeliveryType = '') {
if (!$DeliveryType)
$this->DeliveryType(DELIVERY_TYPE_VIEW);
$ModuleClassExists = class_exists($Module);
if ($ModuleClassExists) {
// Make sure that the class implements Gdn_IModule
$ReflectionClass = new ReflectionClass($Module);
if ($ReflectionClass->implementsInterface("Gdn_IModule")) {
// Set the proper application folder on this controller so that things render properly.
if ($AppFolder) {
$this->ApplicationFolder = $AppFolder;
} else {
$Filename = str_replace('\\', '/', substr($ReflectionClass->getFileName(), strlen(PATH_ROOT)));
// Figure our the application folder for the module.
$Parts = explode('/', trim($Filename, '/'));
if ($Parts[0] == 'applications') {
$this->ApplicationFolder = $Parts[1];
}
}
$ModuleInstance = new $Module($this);
$ModuleInstance->Visible = TRUE;
$WhiteList = array('Limit', 'Help');
foreach ($this->Request->Get() as $Key => $Value) {
if (in_array($Key, $WhiteList)) {
$ModuleInstance->$Key = $Value;
}
}
$this->SetData('_Module', $ModuleInstance);
$this->Render('Index', FALSE, 'dashboard');
return;
}
}
throw NotFoundException($Module);
} | [
"public",
"function",
"Index",
"(",
"$",
"Module",
",",
"$",
"AppFolder",
"=",
"''",
",",
"$",
"DeliveryType",
"=",
"''",
")",
"{",
"if",
"(",
"!",
"$",
"DeliveryType",
")",
"$",
"this",
"->",
"DeliveryType",
"(",
"DELIVERY_TYPE_VIEW",
")",
";",
"$",
... | Creates and renders an instance of a module. | [
"Creates",
"and",
"renders",
"an",
"instance",
"of",
"a",
"module",
"."
] | 8494eb4a4ad61603479015a8054d23ff488364e8 | https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/controllers/class.modulecontroller.php#L17-L56 | train |
phlexible/tree-bundle | Pattern/PatternResolver.php | PatternResolver.replace | public function replace($patternName, Siteroot $siteroot, ElementVersion $elementVersion, $language)
{
if (!isset($this->patterns[$patternName])) {
$pattern = '%p';
} else {
$pattern = $this->patterns[$patternName];
}
return $this->replacePattern($pattern, $siteroot, $elementVersion, $language);
} | php | public function replace($patternName, Siteroot $siteroot, ElementVersion $elementVersion, $language)
{
if (!isset($this->patterns[$patternName])) {
$pattern = '%p';
} else {
$pattern = $this->patterns[$patternName];
}
return $this->replacePattern($pattern, $siteroot, $elementVersion, $language);
} | [
"public",
"function",
"replace",
"(",
"$",
"patternName",
",",
"Siteroot",
"$",
"siteroot",
",",
"ElementVersion",
"$",
"elementVersion",
",",
"$",
"language",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"patterns",
"[",
"$",
"patternName",
... | Resolved page title by configured pattern.
@param string $patternName
@param Siteroot $siteroot
@param ElementVersion $elementVersion
@param string $language
@return string | [
"Resolved",
"page",
"title",
"by",
"configured",
"pattern",
"."
] | 0fd07efdf1edf2d0f74f71519c476d534457701c | https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Pattern/PatternResolver.php#L57-L66 | train |
phlexible/tree-bundle | Pattern/PatternResolver.php | PatternResolver.replacePattern | public function replacePattern($pattern, Siteroot $siteroot, ElementVersion $elementVersion, $language)
{
$replace = [
'%s' => $siteroot->getTitle(),
'%b' => $elementVersion->getBackendTitle($language),
'%p' => $elementVersion->getPageTitle($language),
'%n' => $elementVersion->getNavigationTitle($language),
'%r' => $this->projectTitle,
];
return str_replace(array_keys($replace), array_values($replace), $pattern);
} | php | public function replacePattern($pattern, Siteroot $siteroot, ElementVersion $elementVersion, $language)
{
$replace = [
'%s' => $siteroot->getTitle(),
'%b' => $elementVersion->getBackendTitle($language),
'%p' => $elementVersion->getPageTitle($language),
'%n' => $elementVersion->getNavigationTitle($language),
'%r' => $this->projectTitle,
];
return str_replace(array_keys($replace), array_values($replace), $pattern);
} | [
"public",
"function",
"replacePattern",
"(",
"$",
"pattern",
",",
"Siteroot",
"$",
"siteroot",
",",
"ElementVersion",
"$",
"elementVersion",
",",
"$",
"language",
")",
"{",
"$",
"replace",
"=",
"[",
"'%s'",
"=>",
"$",
"siteroot",
"->",
"getTitle",
"(",
")"... | Resolve page title by pattern.
@param string $pattern
@param Siteroot $siteroot
@param ElementVersion $elementVersion
@param string $language
@return string | [
"Resolve",
"page",
"title",
"by",
"pattern",
"."
] | 0fd07efdf1edf2d0f74f71519c476d534457701c | https://github.com/phlexible/tree-bundle/blob/0fd07efdf1edf2d0f74f71519c476d534457701c/Pattern/PatternResolver.php#L78-L89 | train |
gbprod/elastica-extra-bundle | src/ElasticaExtraBundle/Handler/AddAliasHandler.php | AddAliasHandler.handle | public function handle(Client $client, $index, $alias, $replace = false)
{
$client
->getIndex($index)
->addAlias($alias, $replace)
;
} | php | public function handle(Client $client, $index, $alias, $replace = false)
{
$client
->getIndex($index)
->addAlias($alias, $replace)
;
} | [
"public",
"function",
"handle",
"(",
"Client",
"$",
"client",
",",
"$",
"index",
",",
"$",
"alias",
",",
"$",
"replace",
"=",
"false",
")",
"{",
"$",
"client",
"->",
"getIndex",
"(",
"$",
"index",
")",
"->",
"addAlias",
"(",
"$",
"alias",
",",
"$",... | Handle add alias command
@param Client $client
@param string $index
@param string $alias
@param bool $replace | [
"Handle",
"add",
"alias",
"command"
] | 7a3d925c79903a328a3d07fefe998c0056be7e59 | https://github.com/gbprod/elastica-extra-bundle/blob/7a3d925c79903a328a3d07fefe998c0056be7e59/src/ElasticaExtraBundle/Handler/AddAliasHandler.php#L22-L28 | train |
Clastic/BackofficeBundle | Controller/NavigationController.php | NavigationController.getModuleSortCallback | private function getModuleSortCallback()
{
return function (ModuleInterface $left, ModuleInterface $right) {
return strcmp($left->getName(), $right->getName());
};
} | php | private function getModuleSortCallback()
{
return function (ModuleInterface $left, ModuleInterface $right) {
return strcmp($left->getName(), $right->getName());
};
} | [
"private",
"function",
"getModuleSortCallback",
"(",
")",
"{",
"return",
"function",
"(",
"ModuleInterface",
"$",
"left",
",",
"ModuleInterface",
"$",
"right",
")",
"{",
"return",
"strcmp",
"(",
"$",
"left",
"->",
"getName",
"(",
")",
",",
"$",
"right",
"-... | Callback to sort the Modules by name.
@return callable | [
"Callback",
"to",
"sort",
"the",
"Modules",
"by",
"name",
"."
] | f40b2589a56ef37507d22788c3e8faa996e71758 | https://github.com/Clastic/BackofficeBundle/blob/f40b2589a56ef37507d22788c3e8faa996e71758/Controller/NavigationController.php#L46-L51 | train |
AthensFramework/Core | src/form/Form.php | Form.validate | protected function validate()
{
$this->isValid = true;
foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
if ($writable instanceof FieldInterface) {
$writable->validate();
}
}
foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
if (array_key_exists($name, $this->validators) === true) {
foreach ($this->validators[$name] as $validator) {
call_user_func_array($validator, [$writable, $this]);
}
}
}
foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
if ($writable instanceof FieldInterface && $writable->isValid() === false) {
$this->isValid = false;
$this->addError("Please correct the indicated errors and resubmit the form.");
break;
}
}
foreach ($this->getWritableBearer()->getWritables() as $writable) {
// Force validation on each subform via isValid()
// If subform isn't valid and this form is not yet invalid, mark it as invalid
if ($writable instanceof FormInterface) {
if ($writable->isValid() === false && $this->isValid === true) {
$this->isValid = false;
$this->addError("Please correct the indicated errors and resubmit the form.");
}
}
}
if ($this->errors !== []) {
$this->isValid = false;
}
} | php | protected function validate()
{
$this->isValid = true;
foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
if ($writable instanceof FieldInterface) {
$writable->validate();
}
}
foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
if (array_key_exists($name, $this->validators) === true) {
foreach ($this->validators[$name] as $validator) {
call_user_func_array($validator, [$writable, $this]);
}
}
}
foreach ($this->getWritableBearer()->getWritables() as $name => $writable) {
if ($writable instanceof FieldInterface && $writable->isValid() === false) {
$this->isValid = false;
$this->addError("Please correct the indicated errors and resubmit the form.");
break;
}
}
foreach ($this->getWritableBearer()->getWritables() as $writable) {
// Force validation on each subform via isValid()
// If subform isn't valid and this form is not yet invalid, mark it as invalid
if ($writable instanceof FormInterface) {
if ($writable->isValid() === false && $this->isValid === true) {
$this->isValid = false;
$this->addError("Please correct the indicated errors and resubmit the form.");
}
}
}
if ($this->errors !== []) {
$this->isValid = false;
}
} | [
"protected",
"function",
"validate",
"(",
")",
"{",
"$",
"this",
"->",
"isValid",
"=",
"true",
";",
"foreach",
"(",
"$",
"this",
"->",
"getWritableBearer",
"(",
")",
"->",
"getWritables",
"(",
")",
"as",
"$",
"name",
"=>",
"$",
"writable",
")",
"{",
... | Determine whether the form is valid.
Updates $this->isValid and $this->errors according to whether the form is
valid and whether it has errors.
@return void | [
"Determine",
"whether",
"the",
"form",
"is",
"valid",
"."
] | 6237b914b9f6aef6b2fcac23094b657a86185340 | https://github.com/AthensFramework/Core/blob/6237b914b9f6aef6b2fcac23094b657a86185340/src/form/Form.php#L28-L68 | train |
snowiow/cocurl | src/League.php | League.create | public static function create(array $data): League
{
$league = new League();
parent::fill($data, $league);
return $league;
} | php | public static function create(array $data): League
{
$league = new League();
parent::fill($data, $league);
return $league;
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"data",
")",
":",
"League",
"{",
"$",
"league",
"=",
"new",
"League",
"(",
")",
";",
"parent",
"::",
"fill",
"(",
"$",
"data",
",",
"$",
"league",
")",
";",
"return",
"$",
"league",
";",
... | Creates a league object with the given data
@param array $data an associative array to fill up the members of the
league class
@return League a league object with the data given as it's members | [
"Creates",
"a",
"league",
"object",
"with",
"the",
"given",
"data"
] | 583df05bd3c8f24fd99f294da9906a3e4b1a9c7b | https://github.com/snowiow/cocurl/blob/583df05bd3c8f24fd99f294da9906a3e4b1a9c7b/src/League.php#L40-L45 | train |
oschildt/SmartFactory | src/SmartFactory/DatabaseWorkers/MySQL_DBWorker.php | MySQL_DBWorker.field_count | public function field_count()
{
if ($this->statement) {
return $this->statement->field_count;
}
if (!$this->mysqli_result) {
return false;
}
return $this->mysqli_result->field_count;
} | php | public function field_count()
{
if ($this->statement) {
return $this->statement->field_count;
}
if (!$this->mysqli_result) {
return false;
}
return $this->mysqli_result->field_count;
} | [
"public",
"function",
"field_count",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"statement",
")",
"{",
"return",
"$",
"this",
"->",
"statement",
"->",
"field_count",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"mysqli_result",
")",
"{",
"return",
... | Returns the number of the fields in the result of the last retrieving query.
@return int|false
Returns the number of the fields in the result of the last retrieving query. In the case
of any error returns false.
@author Oleg Schildt | [
"Returns",
"the",
"number",
"of",
"the",
"fields",
"in",
"the",
"result",
"of",
"the",
"last",
"retrieving",
"query",
"."
] | efd289961a720d5f3103a3c696e2beee16e9644d | https://github.com/oschildt/SmartFactory/blob/efd289961a720d5f3103a3c696e2beee16e9644d/src/SmartFactory/DatabaseWorkers/MySQL_DBWorker.php#L1139-L1150 | train |
zepi/turbo-base | Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php | PermissionsDataSourceDoctrine.hasPermissionForId | public function hasPermissionForId($id)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$permission = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->find($id);
if ($permission !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is a permission for the given id "' . $id . '".', 0, $e);
}
} | php | public function hasPermissionForId($id)
{
try {
$em = $this->entityManager->getDoctrineEntityManager();
$permission = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->find($id);
if ($permission !== null) {
return true;
}
return false;
} catch (\Exception $e) {
throw new Exception('Cannot check if there is a permission for the given id "' . $id . '".', 0, $e);
}
} | [
"public",
"function",
"hasPermissionForId",
"(",
"$",
"id",
")",
"{",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
"->",
"entityManager",
"->",
"getDoctrineEntityManager",
"(",
")",
";",
"$",
"permission",
"=",
"$",
"em",
"->",
"getRepository",
"(",
"'\\\\Zepi... | Returns true if there is a permission for the given id
@access public
@param integer $id
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot check if there is a permission for the given id "{id}". | [
"Returns",
"true",
"if",
"there",
"is",
"a",
"permission",
"for",
"the",
"given",
"id"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L101-L115 | train |
zepi/turbo-base | Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php | PermissionsDataSourceDoctrine.hasAccess | public function hasAccess($accessEntityUuid, $accessLevel)
{
// Do not check the database if we haven't all data
if ($accessEntityUuid == '' || $accessLevel == '') {
return false;
}
try {
$queryBuilder = $this->entityManager->getQueryBuilder();
$queryBuilder->select($queryBuilder->expr()->count('p.id'))
->from('\\Zepi\\Core\\AccessControl\\Entity\\Permission', 'p')
->where('p.accessEntityUuid = :accessEntityUuid')
->andWhere('p.accessLevelKey = :accessLevel')
->setParameter('accessEntityUuid', $accessEntityUuid)
->setParameter('accessLevel', $accessLevel);
$data = $queryBuilder->getQuery();
if ($data === false) {
return false;
}
return ($data->getSingleScalarResult() > 0);
} catch (\Exception $e) {
throw new Exception('Cannot verify the permission for uuid "' . $accessEntityUuid . '" and access level "' . $accessLevel . '".', 0, $e);
}
} | php | public function hasAccess($accessEntityUuid, $accessLevel)
{
// Do not check the database if we haven't all data
if ($accessEntityUuid == '' || $accessLevel == '') {
return false;
}
try {
$queryBuilder = $this->entityManager->getQueryBuilder();
$queryBuilder->select($queryBuilder->expr()->count('p.id'))
->from('\\Zepi\\Core\\AccessControl\\Entity\\Permission', 'p')
->where('p.accessEntityUuid = :accessEntityUuid')
->andWhere('p.accessLevelKey = :accessLevel')
->setParameter('accessEntityUuid', $accessEntityUuid)
->setParameter('accessLevel', $accessLevel);
$data = $queryBuilder->getQuery();
if ($data === false) {
return false;
}
return ($data->getSingleScalarResult() > 0);
} catch (\Exception $e) {
throw new Exception('Cannot verify the permission for uuid "' . $accessEntityUuid . '" and access level "' . $accessLevel . '".', 0, $e);
}
} | [
"public",
"function",
"hasAccess",
"(",
"$",
"accessEntityUuid",
",",
"$",
"accessLevel",
")",
"{",
"// Do not check the database if we haven't all data",
"if",
"(",
"$",
"accessEntityUuid",
"==",
"''",
"||",
"$",
"accessLevel",
"==",
"''",
")",
"{",
"return",
"fa... | Returns true if the given access entity uuid has already access to the
access level
@access public
@param string $accessEntityUuid
@param string $accessLevel
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot verifiy the permission for uuid "{uuid}" and access level {accessLevel}. | [
"Returns",
"true",
"if",
"the",
"given",
"access",
"entity",
"uuid",
"has",
"already",
"access",
"to",
"the",
"access",
"level"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L153-L178 | train |
zepi/turbo-base | Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php | PermissionsDataSourceDoctrine.getPermissionsRawForUuid | public function getPermissionsRawForUuid($accessEntityUuid)
{
// Do not check the database if we haven't all data
if ($accessEntityUuid == '') {
return array();
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array(
'accessEntityUuid' => $accessEntityUuid
));
$accessLevels = array();
foreach ($permissions as $permission) {
$accessLevels[] = $permission->getAccessLevelKey();
}
return $accessLevels;
} catch (\Exception $e) {
throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e);
}
} | php | public function getPermissionsRawForUuid($accessEntityUuid)
{
// Do not check the database if we haven't all data
if ($accessEntityUuid == '') {
return array();
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array(
'accessEntityUuid' => $accessEntityUuid
));
$accessLevels = array();
foreach ($permissions as $permission) {
$accessLevels[] = $permission->getAccessLevelKey();
}
return $accessLevels;
} catch (\Exception $e) {
throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e);
}
} | [
"public",
"function",
"getPermissionsRawForUuid",
"(",
"$",
"accessEntityUuid",
")",
"{",
"// Do not check the database if we haven't all data",
"if",
"(",
"$",
"accessEntityUuid",
"==",
"''",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"try",
"{",
"$",
"em",... | Returns an array with all granted access levels for the given
access entity uuid whithout resolving the group access levels.
@access public
@param string $accessEntityUuid
@return array|false
@throws \Zepi\Core\AccessControl\Exception Cannot load the permission for the given uuid "{uuid}". | [
"Returns",
"an",
"array",
"with",
"all",
"granted",
"access",
"levels",
"for",
"the",
"given",
"access",
"entity",
"uuid",
"whithout",
"resolving",
"the",
"group",
"access",
"levels",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L190-L212 | train |
zepi/turbo-base | Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php | PermissionsDataSourceDoctrine.getPermissionsForUuid | public function getPermissionsForUuid($accessEntityUuid)
{
// Do not check the database if we haven't all data
if ($accessEntityUuid == '') {
return array();
}
try {
$accessLevels = $this->getPermissionsRawForUuid($accessEntityUuid);
$accessLevels = $this->runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\PermissionsBackend\\ResolvePermissions', $accessLevels);
return $accessLevels;
} catch (\Exception $e) {
throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e);
}
} | php | public function getPermissionsForUuid($accessEntityUuid)
{
// Do not check the database if we haven't all data
if ($accessEntityUuid == '') {
return array();
}
try {
$accessLevels = $this->getPermissionsRawForUuid($accessEntityUuid);
$accessLevels = $this->runtimeManager->executeFilter('\\Zepi\\Core\\AccessControl\\Filter\\PermissionsBackend\\ResolvePermissions', $accessLevels);
return $accessLevels;
} catch (\Exception $e) {
throw new Exception('Cannot load the permission for the given uuid "' . $accessEntityUuid . '".', 0, $e);
}
} | [
"public",
"function",
"getPermissionsForUuid",
"(",
"$",
"accessEntityUuid",
")",
"{",
"// Do not check the database if we haven't all data",
"if",
"(",
"$",
"accessEntityUuid",
"==",
"''",
")",
"{",
"return",
"array",
"(",
")",
";",
"}",
"try",
"{",
"$",
"accessL... | Returns an array with all granted access levels for the given
access entity uuid
@access public
@param string $accessEntityUuid
@return array|false
@throws \Zepi\Core\AccessControl\Exception Cannot load the permission for the given uuid "{uuid}". | [
"Returns",
"an",
"array",
"with",
"all",
"granted",
"access",
"levels",
"for",
"the",
"given",
"access",
"entity",
"uuid"
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L224-L240 | train |
zepi/turbo-base | Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php | PermissionsDataSourceDoctrine.revokePermissions | public function revokePermissions($accessLevel)
{
// Do not revoke the permissions if we haven't all data
if ($accessLevel == '') {
return false;
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array(
'accessLevelKey' => $accessLevel
));
foreach ($permissions as $permission) {
$em->remove($permission);
}
$em->flush();
} catch (\Exception $e) {
throw new Exception('Cannot revoke the access levels "' . $accessLevel . '".', 0, $e);
}
} | php | public function revokePermissions($accessLevel)
{
// Do not revoke the permissions if we haven't all data
if ($accessLevel == '') {
return false;
}
try {
$em = $this->entityManager->getDoctrineEntityManager();
$permissions = $em->getRepository('\\Zepi\\Core\\AccessControl\\Entity\\Permission')->findBy(array(
'accessLevelKey' => $accessLevel
));
foreach ($permissions as $permission) {
$em->remove($permission);
}
$em->flush();
} catch (\Exception $e) {
throw new Exception('Cannot revoke the access levels "' . $accessLevel . '".', 0, $e);
}
} | [
"public",
"function",
"revokePermissions",
"(",
"$",
"accessLevel",
")",
"{",
"// Do not revoke the permissions if we haven't all data",
"if",
"(",
"$",
"accessLevel",
"==",
"''",
")",
"{",
"return",
"false",
";",
"}",
"try",
"{",
"$",
"em",
"=",
"$",
"this",
... | Revokes the permission for the given access level.
@access public
@param string $accessLevel
@return boolean
@throws \Zepi\Core\AccessControl\Exception Cannot revoke the access levels "{accessLevel}". | [
"Revokes",
"the",
"permission",
"for",
"the",
"given",
"access",
"level",
"."
] | 9a36d8c7649317f55f91b2adf386bd1f04ec02a3 | https://github.com/zepi/turbo-base/blob/9a36d8c7649317f55f91b2adf386bd1f04ec02a3/Zepi/Core/AccessControl/src/DataSource/PermissionsDataSourceDoctrine.php#L327-L347 | train |
antaresproject/tester | src/Http/Presenters/CollectivePresenter.php | CollectivePresenter.prepare | protected function prepare()
{
$active = app('antares.memory')->get("extensions.active");
$memory = app('antares.memory')->make('tests');
$tests = $memory->all();
$return = [];
foreach ($tests as $index => $data) {
if (!isset($data['executor'])) {
$memory->forget($index);
continue;
}
try {
$reflection = new ReflectionClass($data['executor']);
if (!$reflection->hasMethod('addTestButton')) {
throw new Exception('Form Configuration is invalid. Form with test must contains Testable Trait.');
}
} catch (Exception $e) {
Log::emergency($e);
$memory->forget($index);
continue;
}
$name = $data['component'];
$fullName = isset($active[$name]) ? $active[$name]['full_name'] : 'Foundation';
$return[$fullName][$data['name']][$index] = $data;
}
$memory->finish();
return $return;
} | php | protected function prepare()
{
$active = app('antares.memory')->get("extensions.active");
$memory = app('antares.memory')->make('tests');
$tests = $memory->all();
$return = [];
foreach ($tests as $index => $data) {
if (!isset($data['executor'])) {
$memory->forget($index);
continue;
}
try {
$reflection = new ReflectionClass($data['executor']);
if (!$reflection->hasMethod('addTestButton')) {
throw new Exception('Form Configuration is invalid. Form with test must contains Testable Trait.');
}
} catch (Exception $e) {
Log::emergency($e);
$memory->forget($index);
continue;
}
$name = $data['component'];
$fullName = isset($active[$name]) ? $active[$name]['full_name'] : 'Foundation';
$return[$fullName][$data['name']][$index] = $data;
}
$memory->finish();
return $return;
} | [
"protected",
"function",
"prepare",
"(",
")",
"{",
"$",
"active",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"get",
"(",
"\"extensions.active\"",
")",
";",
"$",
"memory",
"=",
"app",
"(",
"'antares.memory'",
")",
"->",
"make",
"(",
"'tests'",
")",
"... | script prepare before round robin launch
@return array
@throws Exception | [
"script",
"prepare",
"before",
"round",
"robin",
"launch"
] | 23e9b4dd7880475769486a8c8f979ab6530c99df | https://github.com/antaresproject/tester/blob/23e9b4dd7880475769486a8c8f979ab6530c99df/src/Http/Presenters/CollectivePresenter.php#L69-L96 | train |
phplegends/http | src/Message.php | Message.removeHeader | protected function removeHeader($name)
{
if (! $this->hasHeader($name))
{
return false;
}
$value = $this->getHeader($name);
unset($this->headers[$name]);
return $value;
} | php | protected function removeHeader($name)
{
if (! $this->hasHeader($name))
{
return false;
}
$value = $this->getHeader($name);
unset($this->headers[$name]);
return $value;
} | [
"protected",
"function",
"removeHeader",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"hasHeader",
"(",
"$",
"name",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"getHeader",
"(",
"$",
"name",
... | Remove a item of header
@return array | false | [
"Remove",
"a",
"item",
"of",
"header"
] | a172792b71d12c88a05ac15faacc3a8ab110fb25 | https://github.com/phplegends/http/blob/a172792b71d12c88a05ac15faacc3a8ab110fb25/src/Message.php#L99-L111 | train |
colorium/routing | src/Colorium/Routing/Router.php | Router.add | public function add($query, $resource, array $meta = [])
{
$query = static::clean($query);
list($method, $uri) = explode(' ', $query);
$this->routes[$query] = new Route($method, $uri, $resource, $meta);
return $this;
} | php | public function add($query, $resource, array $meta = [])
{
$query = static::clean($query);
list($method, $uri) = explode(' ', $query);
$this->routes[$query] = new Route($method, $uri, $resource, $meta);
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"query",
",",
"$",
"resource",
",",
"array",
"$",
"meta",
"=",
"[",
"]",
")",
"{",
"$",
"query",
"=",
"static",
"::",
"clean",
"(",
"$",
"query",
")",
";",
"list",
"(",
"$",
"method",
",",
"$",
"uri",
")",... | Add route definition
@param string $query
@param $resource
@param array $meta
@return $this | [
"Add",
"route",
"definition"
] | 6b6b96321f581164e4f8fb639fd8920d68fbee21 | https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L44-L52 | train |
colorium/routing | src/Colorium/Routing/Router.php | Router.parse | public function parse($class, array $meta = [])
{
$methods = get_class_methods($class);
foreach($methods as $method) {
$query = Annotation::ofMethod($class, $method, 'uri');
if($query) {
$this->add($query, [$class, $method], $meta);
}
}
return $this;
} | php | public function parse($class, array $meta = [])
{
$methods = get_class_methods($class);
foreach($methods as $method) {
$query = Annotation::ofMethod($class, $method, 'uri');
if($query) {
$this->add($query, [$class, $method], $meta);
}
}
return $this;
} | [
"public",
"function",
"parse",
"(",
"$",
"class",
",",
"array",
"$",
"meta",
"=",
"[",
"]",
")",
"{",
"$",
"methods",
"=",
"get_class_methods",
"(",
"$",
"class",
")",
";",
"foreach",
"(",
"$",
"methods",
"as",
"$",
"method",
")",
"{",
"$",
"query"... | Parse class methods annotation and add route
@param string $class
@param array $meta
@return $this | [
"Parse",
"class",
"methods",
"annotation",
"and",
"add",
"route"
] | 6b6b96321f581164e4f8fb639fd8920d68fbee21 | https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L62-L73 | train |
colorium/routing | src/Colorium/Routing/Router.php | Router.mount | public function mount($prefix, RouterInterface $router, array $meta = [])
{
$prefix = '/' . trim($prefix, '/');
foreach($router->routes() as $route) {
$route->uri = $prefix . $route->uri;
$route->meta = array_merge($route->meta, $meta);
$query = static::clean($route->method . ' ' . $route->uri);
$this->routes[$query] = $route;
}
return $this;
} | php | public function mount($prefix, RouterInterface $router, array $meta = [])
{
$prefix = '/' . trim($prefix, '/');
foreach($router->routes() as $route) {
$route->uri = $prefix . $route->uri;
$route->meta = array_merge($route->meta, $meta);
$query = static::clean($route->method . ' ' . $route->uri);
$this->routes[$query] = $route;
}
return $this;
} | [
"public",
"function",
"mount",
"(",
"$",
"prefix",
",",
"RouterInterface",
"$",
"router",
",",
"array",
"$",
"meta",
"=",
"[",
"]",
")",
"{",
"$",
"prefix",
"=",
"'/'",
".",
"trim",
"(",
"$",
"prefix",
",",
"'/'",
")",
";",
"foreach",
"(",
"$",
"... | Mount router under prefix query
@param $prefix
@param RouterInterface $router
@param array $meta
@return $this | [
"Mount",
"router",
"under",
"prefix",
"query"
] | 6b6b96321f581164e4f8fb639fd8920d68fbee21 | https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L84-L95 | train |
colorium/routing | src/Colorium/Routing/Router.php | Router.reverse | public function reverse($resource, array $params = [])
{
// search in all routes
if($key = array_search($resource, $this->routes)) {
$route = $this->routes[$key];
$route->params = $params;
return $route;
}
} | php | public function reverse($resource, array $params = [])
{
// search in all routes
if($key = array_search($resource, $this->routes)) {
$route = $this->routes[$key];
$route->params = $params;
return $route;
}
} | [
"public",
"function",
"reverse",
"(",
"$",
"resource",
",",
"array",
"$",
"params",
"=",
"[",
"]",
")",
"{",
"// search in all routes",
"if",
"(",
"$",
"key",
"=",
"array_search",
"(",
"$",
"resource",
",",
"$",
"this",
"->",
"routes",
")",
")",
"{",
... | Reverse finding by resource
@param $resource
@param array $params
@return Route | [
"Reverse",
"finding",
"by",
"resource"
] | 6b6b96321f581164e4f8fb639fd8920d68fbee21 | https://github.com/colorium/routing/blob/6b6b96321f581164e4f8fb639fd8920d68fbee21/src/Colorium/Routing/Router.php#L139-L147 | train |
webriq/core | module/Core/src/Grid/Core/Model/Translate.php | Translate.textDomain | public function textDomain( $textDomain = self::DEFAULT_TEXT_DOMAIN,
$locale = null )
{
$translator = $this->getTranslator();
$locale = $locale ?: $translator->getLocale();
if ( ! isset( $translator->myMessages[$textDomain][$locale] ) )
{
$translator->loadMyMessages( $textDomain, $locale );
}
if ( ! isset( $translator->messages[$textDomain][$locale] ) )
{
$translator->loadMessages( $textDomain, $locale );
}
$my = $translator->myMessages[$textDomain][$locale];
$global = $translator->messages[$textDomain][$locale];
if ( $my instanceof TextDomain )
{
$my = $my->getArrayCopy();
}
else if ( empty( $my ) )
{
$my = array();
}
if ( $global instanceof TextDomain )
{
$global = $global->getArrayCopy();
}
else if ( empty( $global ) )
{
$global = array();
}
return array_replace( $global, $my );
} | php | public function textDomain( $textDomain = self::DEFAULT_TEXT_DOMAIN,
$locale = null )
{
$translator = $this->getTranslator();
$locale = $locale ?: $translator->getLocale();
if ( ! isset( $translator->myMessages[$textDomain][$locale] ) )
{
$translator->loadMyMessages( $textDomain, $locale );
}
if ( ! isset( $translator->messages[$textDomain][$locale] ) )
{
$translator->loadMessages( $textDomain, $locale );
}
$my = $translator->myMessages[$textDomain][$locale];
$global = $translator->messages[$textDomain][$locale];
if ( $my instanceof TextDomain )
{
$my = $my->getArrayCopy();
}
else if ( empty( $my ) )
{
$my = array();
}
if ( $global instanceof TextDomain )
{
$global = $global->getArrayCopy();
}
else if ( empty( $global ) )
{
$global = array();
}
return array_replace( $global, $my );
} | [
"public",
"function",
"textDomain",
"(",
"$",
"textDomain",
"=",
"self",
"::",
"DEFAULT_TEXT_DOMAIN",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"translator",
"=",
"$",
"this",
"->",
"getTranslator",
"(",
")",
";",
"$",
"locale",
"=",
"$",
"locale",... | Get a whole text-domain
@param string $textDomain
@param string|null $locale
@return array | [
"Get",
"a",
"whole",
"text",
"-",
"domain"
] | cfeb6e8a4732561c2215ec94e736c07f9b8bc990 | https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Translate.php#L113-L151 | train |
diskerror/Utilities | src/Ldap.php | Ldap.searchAll | public function searchAll($filter, array $attributes = [])
{
$ldap = $this->getResource();
// $ds is a valid link identifier (see ldap_connect)
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
$cookie = '';
$result = [];
do {
ldap_control_paged_result($ldap, self::PAGE_SIZE, true, $cookie);
Stdlib\ErrorHandler::start(E_WARNING);
$search = ldap_search($ldap, $this->getBaseDn(), $filter, $attributes);
Stdlib\ErrorHandler::stop();
if ($search === false) {
throw new Lp\Exception\LdapException($this, 'searching: ' . $filter);
}
$entries = $this->createCollection(new Lp\Collection\DefaultIterator($this, $search), null);
foreach ( $entries as $es ) {
$result[] = $es;
}
ldap_control_paged_result_response($ldap, $search, $cookie);
} while ($cookie !== null && $cookie != '');
return $result;
} | php | public function searchAll($filter, array $attributes = [])
{
$ldap = $this->getResource();
// $ds is a valid link identifier (see ldap_connect)
ldap_set_option($ldap, LDAP_OPT_PROTOCOL_VERSION, 3);
$cookie = '';
$result = [];
do {
ldap_control_paged_result($ldap, self::PAGE_SIZE, true, $cookie);
Stdlib\ErrorHandler::start(E_WARNING);
$search = ldap_search($ldap, $this->getBaseDn(), $filter, $attributes);
Stdlib\ErrorHandler::stop();
if ($search === false) {
throw new Lp\Exception\LdapException($this, 'searching: ' . $filter);
}
$entries = $this->createCollection(new Lp\Collection\DefaultIterator($this, $search), null);
foreach ( $entries as $es ) {
$result[] = $es;
}
ldap_control_paged_result_response($ldap, $search, $cookie);
} while ($cookie !== null && $cookie != '');
return $result;
} | [
"public",
"function",
"searchAll",
"(",
"$",
"filter",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"$",
"ldap",
"=",
"$",
"this",
"->",
"getResource",
"(",
")",
";",
"// $ds is a valid link identifier (see ldap_connect)",
"ldap_set_option",
"(",
... | Search LDAP registry for entries matching filter and optional attributes
and return ALL values, including those beyond the usual 1000 entries, as an array.
@param string $filter
@param array $attributes -OPTIONAL
@return array
@throws Exception\LdapException | [
"Search",
"LDAP",
"registry",
"for",
"entries",
"matching",
"filter",
"and",
"optional",
"attributes",
"and",
"return",
"ALL",
"values",
"including",
"those",
"beyond",
"the",
"usual",
"1000",
"entries",
"as",
"an",
"array",
"."
] | cc5eec2417f7c2c76a84584ebd5237197dc54236 | https://github.com/diskerror/Utilities/blob/cc5eec2417f7c2c76a84584ebd5237197dc54236/src/Ldap.php#L25-L54 | train |
FiveLab/Resource | src/Serializer/Normalizer/ErrorCollectionObjectNormalizer.php | ErrorCollectionObjectNormalizer.appendCollectionAttributes | public function appendCollectionAttributes(
array $data,
ErrorCollection $error,
string $format,
array $context
): array {
$innerError = new ErrorResource(
$error->getMessage(),
$error->getReason(),
$error->getPath(),
$error->getAttributes(),
$error->getIdentifier()
);
foreach ($error->getRelations() as $relation) {
$innerError->addRelation($relation);
}
$normalizedInnerError = $this->normalizer->normalize($innerError, $format, $context);
return array_merge($normalizedInnerError, $data);
} | php | public function appendCollectionAttributes(
array $data,
ErrorCollection $error,
string $format,
array $context
): array {
$innerError = new ErrorResource(
$error->getMessage(),
$error->getReason(),
$error->getPath(),
$error->getAttributes(),
$error->getIdentifier()
);
foreach ($error->getRelations() as $relation) {
$innerError->addRelation($relation);
}
$normalizedInnerError = $this->normalizer->normalize($innerError, $format, $context);
return array_merge($normalizedInnerError, $data);
} | [
"public",
"function",
"appendCollectionAttributes",
"(",
"array",
"$",
"data",
",",
"ErrorCollection",
"$",
"error",
",",
"string",
"$",
"format",
",",
"array",
"$",
"context",
")",
":",
"array",
"{",
"$",
"innerError",
"=",
"new",
"ErrorResource",
"(",
"$",... | Append collection attributes to
@param array $data
@param ErrorCollection $error
@param string $format
@param array $context
@return array | [
"Append",
"collection",
"attributes",
"to"
] | f2864924212dd4e2d1a3e7a1ad8a863d9db26127 | https://github.com/FiveLab/Resource/blob/f2864924212dd4e2d1a3e7a1ad8a863d9db26127/src/Serializer/Normalizer/ErrorCollectionObjectNormalizer.php#L67-L88 | train |
rozaverta/cmf | core/Events/SingletonEvent.php | SingletonEvent.addSingleton | public function addSingleton( string $name, $singleton ): self
{
$name = Str::studly($name);
if( isset($this->ci[$name]) )
{
throw new \InvalidArgumentException("Duplicated class name '{$name}' for singleton instance object");
}
$this->ci[$name] = $singleton;
return $this;
} | php | public function addSingleton( string $name, $singleton ): self
{
$name = Str::studly($name);
if( isset($this->ci[$name]) )
{
throw new \InvalidArgumentException("Duplicated class name '{$name}' for singleton instance object");
}
$this->ci[$name] = $singleton;
return $this;
} | [
"public",
"function",
"addSingleton",
"(",
"string",
"$",
"name",
",",
"$",
"singleton",
")",
":",
"self",
"{",
"$",
"name",
"=",
"Str",
"::",
"studly",
"(",
"$",
"name",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"ci",
"[",
"$",
"name... | Add new singleton
@param string|object $name
@param $singleton
@return SingletonEvent | [
"Add",
"new",
"singleton"
] | 95ed38362e397d1c700ee255f7200234ef98d356 | https://github.com/rozaverta/cmf/blob/95ed38362e397d1c700ee255f7200234ef98d356/core/Events/SingletonEvent.php#L24-L34 | train |
jurchiks/commons | src/http/Uri.php | Uri.get | public function get(bool $isRawUrl = false): string
{
if ($this->sourceChanged)
{
return $this->getAbsolute($isRawUrl);
}
return $this->getRelative($isRawUrl);
} | php | public function get(bool $isRawUrl = false): string
{
if ($this->sourceChanged)
{
return $this->getAbsolute($isRawUrl);
}
return $this->getRelative($isRawUrl);
} | [
"public",
"function",
"get",
"(",
"bool",
"$",
"isRawUrl",
"=",
"false",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"sourceChanged",
")",
"{",
"return",
"$",
"this",
"->",
"getAbsolute",
"(",
"$",
"isRawUrl",
")",
";",
"}",
"return",
"$",... | Get the URL contained in this object. May return a relative or absolute URL depending on
whether the absolute part has changed.
@param bool $isRawUrl : if true, spaces in query parameters are encoded as %20, otherwise as +
@return string the link to the required route
@see getRelative
@see getAbsolute | [
"Get",
"the",
"URL",
"contained",
"in",
"this",
"object",
".",
"May",
"return",
"a",
"relative",
"or",
"absolute",
"URL",
"depending",
"on",
"whether",
"the",
"absolute",
"part",
"has",
"changed",
"."
] | be9e1eca6a94380647160a882b8476bee3e4d8f8 | https://github.com/jurchiks/commons/blob/be9e1eca6a94380647160a882b8476bee3e4d8f8/src/http/Uri.php#L328-L336 | train |
xinc-develop/xinc-core | src/Config/Xml.php | Xml.getConfigurationSources | public function getConfigurationSources(ConfigInterface $conf)
{
if ($conf->hasOption('config-file')) {
$file = $conf->getOption('config-file');
if (isset($file)) {
if (!strstr($file, '/')) {
$file = $conf->getOption('config-dir').$file;
}
return array($file);
}
}
// load every xml file in config dir
$dir = $conf->getOption('config-dir');
$list = glob("{$dir}*.xml", GLOB_ERR);
if ($list === false) {
throw new IOException($dir, null,
"config-dir '$dir' is not readable",
IOException::FAILURE_NOT_READABLE);
}
return $list;
} | php | public function getConfigurationSources(ConfigInterface $conf)
{
if ($conf->hasOption('config-file')) {
$file = $conf->getOption('config-file');
if (isset($file)) {
if (!strstr($file, '/')) {
$file = $conf->getOption('config-dir').$file;
}
return array($file);
}
}
// load every xml file in config dir
$dir = $conf->getOption('config-dir');
$list = glob("{$dir}*.xml", GLOB_ERR);
if ($list === false) {
throw new IOException($dir, null,
"config-dir '$dir' is not readable",
IOException::FAILURE_NOT_READABLE);
}
return $list;
} | [
"public",
"function",
"getConfigurationSources",
"(",
"ConfigInterface",
"$",
"conf",
")",
"{",
"if",
"(",
"$",
"conf",
"->",
"hasOption",
"(",
"'config-file'",
")",
")",
"{",
"$",
"file",
"=",
"$",
"conf",
"->",
"getOption",
"(",
"'config-file'",
")",
";"... | Finds the configured configuration sources.
The config needs at least a valid config-dir or config-file
option.
@throw Xinc::Core::Exception::IOException
@return array with configured sources | [
"Finds",
"the",
"configured",
"configuration",
"sources",
"."
] | 4bb69a6afe19e1186950a3122cbfe0989823e0d6 | https://github.com/xinc-develop/xinc-core/blob/4bb69a6afe19e1186950a3122cbfe0989823e0d6/src/Config/Xml.php#L64-L86 | train |
potfur/statemachine | src/StateMachine/Process.php | Process.triggerEvent | public function triggerEvent($event, Payload $payload): string
{
return $this->state($payload->state())->triggerEvent($event, $payload);
} | php | public function triggerEvent($event, Payload $payload): string
{
return $this->state($payload->state())->triggerEvent($event, $payload);
} | [
"public",
"function",
"triggerEvent",
"(",
"$",
"event",
",",
"Payload",
"$",
"payload",
")",
":",
"string",
"{",
"return",
"$",
"this",
"->",
"state",
"(",
"$",
"payload",
"->",
"state",
"(",
")",
")",
"->",
"triggerEvent",
"(",
"$",
"event",
",",
"... | Trigger event for payload
Return next state name
@param string $event
@param Payload $payload
@return string | [
"Trigger",
"event",
"for",
"payload",
"Return",
"next",
"state",
"name"
] | 6b68535e6c94b10bf618a7809a48f6a8f6d30deb | https://github.com/potfur/statemachine/blob/6b68535e6c94b10bf618a7809a48f6a8f6d30deb/src/StateMachine/Process.php#L124-L127 | train |
anklimsk/cakephp-extended-test | Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php | Tag.setAttribute | public function setAttribute($key, $value)
{
$key = strtolower($key);
if ( ! is_array($value)) {
$value = [
'value' => $value,
'doubleQuote' => true,
];
}
$this->attr[$key] = $value;
return $this;
} | php | public function setAttribute($key, $value)
{
$key = strtolower($key);
if ( ! is_array($value)) {
$value = [
'value' => $value,
'doubleQuote' => true,
];
}
$this->attr[$key] = $value;
return $this;
} | [
"public",
"function",
"setAttribute",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"$",
"key",
"=",
"strtolower",
"(",
"$",
"key",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"$",
"value",
"=",
"[",
"'value'",
"=>",
... | Set an attribute for this tag.
@param string $key
@param string|array $value
@return $this | [
"Set",
"an",
"attribute",
"for",
"this",
"tag",
"."
] | 21691a3be8a198419feb92fb6ed3b35a14dc24b1 | https://github.com/anklimsk/cakephp-extended-test/blob/21691a3be8a198419feb92fb6ed3b35a14dc24b1/Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php#L142-L154 | train |
anklimsk/cakephp-extended-test | Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php | Tag.getAttribute | public function getAttribute($key)
{
if ( ! isset($this->attr[$key])) {
return null;
}
$value = $this->attr[$key]['value'];
if (is_string($value) && ! is_null($this->encode)) {
// convert charset
$this->attr[$key]['value'] = $this->encode->convert($value);
}
return $this->attr[$key];
} | php | public function getAttribute($key)
{
if ( ! isset($this->attr[$key])) {
return null;
}
$value = $this->attr[$key]['value'];
if (is_string($value) && ! is_null($this->encode)) {
// convert charset
$this->attr[$key]['value'] = $this->encode->convert($value);
}
return $this->attr[$key];
} | [
"public",
"function",
"getAttribute",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"attr",
"[",
"$",
"key",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"attr",
"[",
"$",
... | Returns an attribute by the key
@param string $key
@return mixed | [
"Returns",
"an",
"attribute",
"by",
"the",
"key"
] | 21691a3be8a198419feb92fb6ed3b35a14dc24b1 | https://github.com/anklimsk/cakephp-extended-test/blob/21691a3be8a198419feb92fb6ed3b35a14dc24b1/Vendor/PHPHtmlParser/paquettg/php-html-parser/src/PHPHtmlParser/Dom/Tag.php#L214-L226 | train |
aloframework/handlers | src/class/Config/AbstractConfig.php | AbstractConfig.setDefaults | private static function setDefaults() {
if (!self::$defaults) {
self::$defaults =
[self::CFG_CSS_PATH => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR . 'error.min.css',
self::CFG_TRACE_MAX_DEPTH => 50,
self::CFG_BACKGROUND => 'default',
self::CFG_FOREGROUND_NOTICE => 'cyan',
self::CFG_FOREGROUND_WARNING => 'yellow',
self::CFG_FOREGROUND_ERROR => 'red',
self::CFG_FORCE_HTML => false];
}
} | php | private static function setDefaults() {
if (!self::$defaults) {
self::$defaults =
[self::CFG_CSS_PATH => __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . '..' .
DIRECTORY_SEPARATOR . 'error.min.css',
self::CFG_TRACE_MAX_DEPTH => 50,
self::CFG_BACKGROUND => 'default',
self::CFG_FOREGROUND_NOTICE => 'cyan',
self::CFG_FOREGROUND_WARNING => 'yellow',
self::CFG_FOREGROUND_ERROR => 'red',
self::CFG_FORCE_HTML => false];
}
} | [
"private",
"static",
"function",
"setDefaults",
"(",
")",
"{",
"if",
"(",
"!",
"self",
"::",
"$",
"defaults",
")",
"{",
"self",
"::",
"$",
"defaults",
"=",
"[",
"self",
"::",
"CFG_CSS_PATH",
"=>",
"__DIR__",
".",
"DIRECTORY_SEPARATOR",
".",
"'..'",
".",
... | Sets default config
@author Art <a.molcanovas@gmail.com> | [
"Sets",
"default",
"config"
] | 3f17510c5e9221855d39c332710d0e512ec8b42d | https://github.com/aloframework/handlers/blob/3f17510c5e9221855d39c332710d0e512ec8b42d/src/class/Config/AbstractConfig.php#L113-L125 | train |
devbr/pack-blog | Model/Article.php | Article.mountById | function mountById($id)
{
$db = new Db();
if ($this->where != false || $this->where != '') {
$where = ' AND '.$this->where;
}
$res = $db->query('SELECT * FROM '.$this->table.' WHERE id = :id '.$where, [':id'=>0 + $id]);
if (isset($res[0])) {
$this->load($res[0]->getAll());
//Access counter
$db->query('UPDATE article
SET access = access + 1
WHERE id = '.$this->id);
return $this;
}
return false;
} | php | function mountById($id)
{
$db = new Db();
if ($this->where != false || $this->where != '') {
$where = ' AND '.$this->where;
}
$res = $db->query('SELECT * FROM '.$this->table.' WHERE id = :id '.$where, [':id'=>0 + $id]);
if (isset($res[0])) {
$this->load($res[0]->getAll());
//Access counter
$db->query('UPDATE article
SET access = access + 1
WHERE id = '.$this->id);
return $this;
}
return false;
} | [
"function",
"mountById",
"(",
"$",
"id",
")",
"{",
"$",
"db",
"=",
"new",
"Db",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"where",
"!=",
"false",
"||",
"$",
"this",
"->",
"where",
"!=",
"''",
")",
"{",
"$",
"where",
"=",
"' AND '",
".",
"$... | Mount from DataBase - search by ID
@param integer $id id in database
@return bool|object $this object or false | [
"Mount",
"from",
"DataBase",
"-",
"search",
"by",
"ID"
] | 4693e36521ee3d08077f0db3e013afb99785cc9d | https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L77-L97 | train |
devbr/pack-blog | Model/Article.php | Article.requestNew | function requestNew()
{
$db = new Db;
//Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours.
$result = $db->query('SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid
FROM article
WHERE status = 6
OR (status = 5 AND editdate <= STR_TO_DATE(\''.date('Y-m-d H:i:s', time()-86400).'\', \'%Y-%m-%d %H:%i:%s\'))');
if (isset($result[0])) {
$this->editdate = date('Y-m-d H:i:s');
$this->pubdate = $this->editdate;
//Criando novo registro
if ($result[0]->get('id') == null) {
$this->id = $result[0]->get('nid');
$db->query('INSERT INTO articlecontent
SET article = '.$this->id.',
content = "",
editdate = "'.$this->editdate.'"');
$db->query('INSERT INTO article
SET id = '.$this->id.',
status = 5,
editdate = \''.$this->editdate.'\'');
//Atualizando o registro
} else {
$this->id = $result[0]->get('id');
$db->query('UPDATE article
SET status = 5,
pubdate = \''.$this->pubdate.'\',
editdate = \''.$this->editdate.'\',
rateup = 0,
ratedown = 0,
access = 0,
link = "",
tags = "",
title = "",
media = "{}",
resume = ""
WHERE id = '.$this->id.'');
$db->query('UPDATE articlecontent
SET content = "",
editdate = \''.$this->editdate.'\'
WHERE article = '.$this->id.'');
}
//Make dir clean (delete all files)
$this->clearDir();
return $this;
}
return false;
} | php | function requestNew()
{
$db = new Db;
//Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours.
$result = $db->query('SELECT MIN(id)id, (SELECT MAX(id+1) FROM article)nid
FROM article
WHERE status = 6
OR (status = 5 AND editdate <= STR_TO_DATE(\''.date('Y-m-d H:i:s', time()-86400).'\', \'%Y-%m-%d %H:%i:%s\'))');
if (isset($result[0])) {
$this->editdate = date('Y-m-d H:i:s');
$this->pubdate = $this->editdate;
//Criando novo registro
if ($result[0]->get('id') == null) {
$this->id = $result[0]->get('nid');
$db->query('INSERT INTO articlecontent
SET article = '.$this->id.',
content = "",
editdate = "'.$this->editdate.'"');
$db->query('INSERT INTO article
SET id = '.$this->id.',
status = 5,
editdate = \''.$this->editdate.'\'');
//Atualizando o registro
} else {
$this->id = $result[0]->get('id');
$db->query('UPDATE article
SET status = 5,
pubdate = \''.$this->pubdate.'\',
editdate = \''.$this->editdate.'\',
rateup = 0,
ratedown = 0,
access = 0,
link = "",
tags = "",
title = "",
media = "{}",
resume = ""
WHERE id = '.$this->id.'');
$db->query('UPDATE articlecontent
SET content = "",
editdate = \''.$this->editdate.'\'
WHERE article = '.$this->id.'');
}
//Make dir clean (delete all files)
$this->clearDir();
return $this;
}
return false;
} | [
"function",
"requestNew",
"(",
")",
"{",
"$",
"db",
"=",
"new",
"Db",
";",
"//Search from first register with [article.status] 5 and [article.editdate] <= datetime - 24 hours.",
"$",
"result",
"=",
"$",
"db",
"->",
"query",
"(",
"'SELECT MIN(id)id, (SELECT MAX(id+1) FROM arti... | Get Row in DB
@return bool|integer New ID or false | [
"Get",
"Row",
"in",
"DB"
] | 4693e36521ee3d08077f0db3e013afb99785cc9d | https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L133-L193 | train |
devbr/pack-blog | Model/Article.php | Article.getAll | function getAll()
{
foreach ($this as $k => $v) {
if ($k == 'table' || $k == 'where') {
continue;
}
$data[$k] = $v;
}
return $data;
} | php | function getAll()
{
foreach ($this as $k => $v) {
if ($k == 'table' || $k == 'where') {
continue;
}
$data[$k] = $v;
}
return $data;
} | [
"function",
"getAll",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"as",
"$",
"k",
"=>",
"$",
"v",
")",
"{",
"if",
"(",
"$",
"k",
"==",
"'table'",
"||",
"$",
"k",
"==",
"'where'",
")",
"{",
"continue",
";",
"}",
"$",
"data",
"[",
"$",
"k",
"... | Get All data
@return array array of fields name X data | [
"Get",
"All",
"data"
] | 4693e36521ee3d08077f0db3e013afb99785cc9d | https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L199-L208 | train |
devbr/pack-blog | Model/Article.php | Article.save | function save()
{
if ($this->id != false || $this->id != 0) {
return $this->update();
} else {
return $this->insert();
}
} | php | function save()
{
if ($this->id != false || $this->id != 0) {
return $this->update();
} else {
return $this->insert();
}
} | [
"function",
"save",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"id",
"!=",
"false",
"||",
"$",
"this",
"->",
"id",
"!=",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"update",
"(",
")",
";",
"}",
"else",
"{",
"return",
"$",
"this",
"->",
"in... | SAVE a new or UPDATE this
@return bool status of success | [
"SAVE",
"a",
"new",
"or",
"UPDATE",
"this"
] | 4693e36521ee3d08077f0db3e013afb99785cc9d | https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L244-L251 | train |
devbr/pack-blog | Model/Article.php | Article.clearDir | function clearDir()
{
$dir = _WWW.$this->patch.$this->id.'/';
foreach (scandir($dir) as $file) {
if ($file == '.' || $file == '..') {
continue;
}
unlink($dir.$file);
}
} | php | function clearDir()
{
$dir = _WWW.$this->patch.$this->id.'/';
foreach (scandir($dir) as $file) {
if ($file == '.' || $file == '..') {
continue;
}
unlink($dir.$file);
}
} | [
"function",
"clearDir",
"(",
")",
"{",
"$",
"dir",
"=",
"_WWW",
".",
"$",
"this",
"->",
"patch",
".",
"$",
"this",
"->",
"id",
".",
"'/'",
";",
"foreach",
"(",
"scandir",
"(",
"$",
"dir",
")",
"as",
"$",
"file",
")",
"{",
"if",
"(",
"$",
"fil... | Delete all files in article directory
@return void Clear directory | [
"Delete",
"all",
"files",
"in",
"article",
"directory"
] | 4693e36521ee3d08077f0db3e013afb99785cc9d | https://github.com/devbr/pack-blog/blob/4693e36521ee3d08077f0db3e013afb99785cc9d/Model/Article.php#L277-L286 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/pdo/connection.php | Database_PDO_Connection.driver_name | public function driver_name()
{
// Make sure the database is connected
$this->_connection or $this->connect();
// Getting driver name
return $this->_connection->getAttribute(\PDO::ATTR_DRIVER_NAME);
} | php | public function driver_name()
{
// Make sure the database is connected
$this->_connection or $this->connect();
// Getting driver name
return $this->_connection->getAttribute(\PDO::ATTR_DRIVER_NAME);
} | [
"public",
"function",
"driver_name",
"(",
")",
"{",
"// Make sure the database is connected",
"$",
"this",
"->",
"_connection",
"or",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"// Getting driver name",
"return",
"$",
"this",
"->",
"_connection",
"->",
"getAttri... | Get the current PDO Driver name
@return string | [
"Get",
"the",
"current",
"PDO",
"Driver",
"name"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/pdo/connection.php#L139-L146 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/pdo/connection.php | Database_PDO_Connection.set_charset | public function set_charset($charset)
{
// Make sure the database is connected
$this->_connection or $this->connect();
// Set Charset for SQL Server connection
if (strtolower($this->driver_name()) == 'sqlsrv')
{
$this->_connection->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_SYSTEM);
}
// Set Charset for SQLite connection
elseif (strtolower($this->driver_name()) == 'sqlite')
{
// Execute a raw PRAGMA encoding query
$this->_connection->exec('PRAGMA encoding = ' . $this->quote($charset));
}
// Set Charset for any connection except ODBC, as it throws exception
elseif (strtolower($this->driver_name()) != 'odbc')
{
// Execute a raw SET NAMES query
$this->_connection->exec('SET NAMES '.$this->quote($charset));
}
} | php | public function set_charset($charset)
{
// Make sure the database is connected
$this->_connection or $this->connect();
// Set Charset for SQL Server connection
if (strtolower($this->driver_name()) == 'sqlsrv')
{
$this->_connection->setAttribute(\PDO::SQLSRV_ATTR_ENCODING, \PDO::SQLSRV_ENCODING_SYSTEM);
}
// Set Charset for SQLite connection
elseif (strtolower($this->driver_name()) == 'sqlite')
{
// Execute a raw PRAGMA encoding query
$this->_connection->exec('PRAGMA encoding = ' . $this->quote($charset));
}
// Set Charset for any connection except ODBC, as it throws exception
elseif (strtolower($this->driver_name()) != 'odbc')
{
// Execute a raw SET NAMES query
$this->_connection->exec('SET NAMES '.$this->quote($charset));
}
} | [
"public",
"function",
"set_charset",
"(",
"$",
"charset",
")",
"{",
"// Make sure the database is connected",
"$",
"this",
"->",
"_connection",
"or",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"// Set Charset for SQL Server connection",
"if",
"(",
"strtolower",
"(... | Set the charset
@param string $charset | [
"Set",
"the",
"charset"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/pdo/connection.php#L153-L175 | train |
indigophp-archive/codeception-fuel-module | fuel/fuel/core/classes/database/pdo/connection.php | Database_PDO_Connection.escape | public function escape($value)
{
// Make sure the database is connected
$this->_connection or $this->connect();
$result = $this->_connection->quote($value);
// poor-mans workaround for the fact that not all drivers implement quote()
if (empty($result))
{
$result = "'".str_replace("'", "''", $value)."'";
}
return $result;
} | php | public function escape($value)
{
// Make sure the database is connected
$this->_connection or $this->connect();
$result = $this->_connection->quote($value);
// poor-mans workaround for the fact that not all drivers implement quote()
if (empty($result))
{
$result = "'".str_replace("'", "''", $value)."'";
}
return $result;
} | [
"public",
"function",
"escape",
"(",
"$",
"value",
")",
"{",
"// Make sure the database is connected",
"$",
"this",
"->",
"_connection",
"or",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"$",
"result",
"=",
"$",
"this",
"->",
"_connection",
"->",
"quote",
... | Escape a value
@param mixed $value
@return string | [
"Escape",
"a",
"value"
] | 0973b7cbd540a0e89cc5bb7af94627f77f09bf49 | https://github.com/indigophp-archive/codeception-fuel-module/blob/0973b7cbd540a0e89cc5bb7af94627f77f09bf49/fuel/fuel/core/classes/database/pdo/connection.php#L457-L469 | train |
wigedev/simple-mvc | src/Renderer/ViewHelper/StylesheetHelper.php | StylesheetHelper.init | public function init(?string $configuration = 'stylesheets'): void
{
$config = Core::i()->config->getConfiguration($configuration);
foreach ($config as $script) {
$this->append($script);
}
} | php | public function init(?string $configuration = 'stylesheets'): void
{
$config = Core::i()->config->getConfiguration($configuration);
foreach ($config as $script) {
$this->append($script);
}
} | [
"public",
"function",
"init",
"(",
"?",
"string",
"$",
"configuration",
"=",
"'stylesheets'",
")",
":",
"void",
"{",
"$",
"config",
"=",
"Core",
"::",
"i",
"(",
")",
"->",
"config",
"->",
"getConfiguration",
"(",
"$",
"configuration",
")",
";",
"foreach"... | Get the stylesheets that are defined in the configuration.
@param string|null $configuration The name of the settings array in the configuration
@return array|void
@throws \Exception | [
"Get",
"the",
"stylesheets",
"that",
"are",
"defined",
"in",
"the",
"configuration",
"."
] | b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94 | https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L30-L36 | train |
wigedev/simple-mvc | src/Renderer/ViewHelper/StylesheetHelper.php | StylesheetHelper.prepend | public function prepend(): void
{
$script = $this->parseArgs(func_get_args());
if ($script !== false) {
array_unshift($this->members, $script);
}
} | php | public function prepend(): void
{
$script = $this->parseArgs(func_get_args());
if ($script !== false) {
array_unshift($this->members, $script);
}
} | [
"public",
"function",
"prepend",
"(",
")",
":",
"void",
"{",
"$",
"script",
"=",
"$",
"this",
"->",
"parseArgs",
"(",
"func_get_args",
"(",
")",
")",
";",
"if",
"(",
"$",
"script",
"!==",
"false",
")",
"{",
"array_unshift",
"(",
"$",
"this",
"->",
... | Add a new stylesheet to the beginning of the list
@param string ... The location of the stylesheet
@param string ... The type of stylesheet | [
"Add",
"a",
"new",
"stylesheet",
"to",
"the",
"beginning",
"of",
"the",
"list"
] | b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94 | https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L44-L50 | train |
wigedev/simple-mvc | src/Renderer/ViewHelper/StylesheetHelper.php | StylesheetHelper.append | public function append(): void
{
$script = $this->parseArgs(func_get_args());
if ($script !== false) {
array_push($this->members, $script);
}
} | php | public function append(): void
{
$script = $this->parseArgs(func_get_args());
if ($script !== false) {
array_push($this->members, $script);
}
} | [
"public",
"function",
"append",
"(",
")",
":",
"void",
"{",
"$",
"script",
"=",
"$",
"this",
"->",
"parseArgs",
"(",
"func_get_args",
"(",
")",
")",
";",
"if",
"(",
"$",
"script",
"!==",
"false",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"mem... | Add a new stylesheet to the end of the list
@param string ... The location of the stylesheet
@param string ... The type of stylesheet | [
"Add",
"a",
"new",
"stylesheet",
"to",
"the",
"end",
"of",
"the",
"list"
] | b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94 | https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L58-L64 | train |
wigedev/simple-mvc | src/Renderer/ViewHelper/StylesheetHelper.php | StylesheetHelper.makeLink | private function makeLink($args)
{
if (!isset($args['href'])) {
Core::i()->log->warning('Unable to add stylesheet, no href attribute.');
return false;
}
if (!isset($args['rel'])) {
$args['rel'] = 'stylesheet';
}
if (!isset($args['type']) && $args['rel'] == 'stylesheet') {
$args['type'] = 'text/css';
}
$link = '<link';
foreach ($args as $key => $value) {
$link .= ' ' . $key . '="' . $value . '"';
}
$link .= ' />';
return $link;
} | php | private function makeLink($args)
{
if (!isset($args['href'])) {
Core::i()->log->warning('Unable to add stylesheet, no href attribute.');
return false;
}
if (!isset($args['rel'])) {
$args['rel'] = 'stylesheet';
}
if (!isset($args['type']) && $args['rel'] == 'stylesheet') {
$args['type'] = 'text/css';
}
$link = '<link';
foreach ($args as $key => $value) {
$link .= ' ' . $key . '="' . $value . '"';
}
$link .= ' />';
return $link;
} | [
"private",
"function",
"makeLink",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"args",
"[",
"'href'",
"]",
")",
")",
"{",
"Core",
"::",
"i",
"(",
")",
"->",
"log",
"->",
"warning",
"(",
"'Unable to add stylesheet, no href attribute.'",... | Generate a link to the stylesheet based on the passed parameters.
@param $args
@return bool|string | [
"Generate",
"a",
"link",
"to",
"the",
"stylesheet",
"based",
"on",
"the",
"passed",
"parameters",
"."
] | b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94 | https://github.com/wigedev/simple-mvc/blob/b722eff02c5dcd8c6f09c8d78f72bc71cb9e1a94/src/Renderer/ViewHelper/StylesheetHelper.php#L128-L147 | train |
strident/Trident | src/Trident/Component/Caching/CachingFactory.php | CachingFactory.build | public function build($name = null)
{
$caching = new Caching();
$caching->setStack(new DebugStack());
if ($this->debug && isset($this->debugDriver)) {
$caching->setDriver($this->resolveDriver($this->debugDriver));
return $caching;
}
if (null === $name) {
$name = $this->configuration->get('caching.default', 'null');
}
$driver = $this->resolveDriver($name);
$caching->setDriver($driver);
return $caching;
} | php | public function build($name = null)
{
$caching = new Caching();
$caching->setStack(new DebugStack());
if ($this->debug && isset($this->debugDriver)) {
$caching->setDriver($this->resolveDriver($this->debugDriver));
return $caching;
}
if (null === $name) {
$name = $this->configuration->get('caching.default', 'null');
}
$driver = $this->resolveDriver($name);
$caching->setDriver($driver);
return $caching;
} | [
"public",
"function",
"build",
"(",
"$",
"name",
"=",
"null",
")",
"{",
"$",
"caching",
"=",
"new",
"Caching",
"(",
")",
";",
"$",
"caching",
"->",
"setStack",
"(",
"new",
"DebugStack",
"(",
")",
")",
";",
"if",
"(",
"$",
"this",
"->",
"debug",
"... | Build cache driver.
@param string $name
@return DriverInterface | [
"Build",
"cache",
"driver",
"."
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Caching/CachingFactory.php#L67-L86 | train |
strident/Trident | src/Trident/Component/Caching/CachingFactory.php | CachingFactory.resolveDriver | protected function resolveDriver($name)
{
if ( ! isset($this->drivers[$name]) || ! $this->container->has($this->drivers[$name])) {
throw new \RuntimeException(sprintf(
'Caching driver "%s" does not exist or is not registered as a service.',
$name
));
}
$driver = $this->container->get($this->drivers[$name]);
if ( ! $driver instanceof DriverInterface) {
throw new \RuntimeException(sprintf(
'Service "%s" is not a valid caching driver.',
$this->drivers[$name]
));
}
return $driver;
} | php | protected function resolveDriver($name)
{
if ( ! isset($this->drivers[$name]) || ! $this->container->has($this->drivers[$name])) {
throw new \RuntimeException(sprintf(
'Caching driver "%s" does not exist or is not registered as a service.',
$name
));
}
$driver = $this->container->get($this->drivers[$name]);
if ( ! $driver instanceof DriverInterface) {
throw new \RuntimeException(sprintf(
'Service "%s" is not a valid caching driver.',
$this->drivers[$name]
));
}
return $driver;
} | [
"protected",
"function",
"resolveDriver",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"drivers",
"[",
"$",
"name",
"]",
")",
"||",
"!",
"$",
"this",
"->",
"container",
"->",
"has",
"(",
"$",
"this",
"->",
"drivers",... | Resolve caching driver from name.
@param string $name
@return DriverInterface | [
"Resolve",
"caching",
"driver",
"from",
"name",
"."
] | a112f0b75601b897c470a49d85791dc386c29952 | https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Component/Caching/CachingFactory.php#L107-L126 | train |
tenside/core-bundle | src/Annotation/TensideApiDocHandler.php | TensideApiDocHandler.convertField | private function convertField($array)
{
$result = [];
// Copy over well known keys.
foreach (static::$convertFields as $key) {
if (isset($array[$key])) {
$result[$key] = $array[$key];
}
}
if (isset($array['dataType'])) {
$result['dataType'] = $this->inferType($array['dataType']);
} else {
$result['dataType'] = isset($array['children']) ? 'object' : DataTypes::STRING;
}
$result['required'] = isset($array['required']) && (bool) $array['required'];
$result['readonly'] = isset($array['readonly']) && (bool) $array['readonly'];
$result = $this->convertChildren($array, $result);
return $result;
} | php | private function convertField($array)
{
$result = [];
// Copy over well known keys.
foreach (static::$convertFields as $key) {
if (isset($array[$key])) {
$result[$key] = $array[$key];
}
}
if (isset($array['dataType'])) {
$result['dataType'] = $this->inferType($array['dataType']);
} else {
$result['dataType'] = isset($array['children']) ? 'object' : DataTypes::STRING;
}
$result['required'] = isset($array['required']) && (bool) $array['required'];
$result['readonly'] = isset($array['readonly']) && (bool) $array['readonly'];
$result = $this->convertChildren($array, $result);
return $result;
} | [
"private",
"function",
"convertField",
"(",
"$",
"array",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"// Copy over well known keys.",
"foreach",
"(",
"static",
"::",
"$",
"convertFields",
"as",
"$",
"key",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"array... | Convert the annotation for a field.
@param array $array The information for the field.
@return array | [
"Convert",
"the",
"annotation",
"for",
"a",
"field",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Annotation/TensideApiDocHandler.php#L86-L109 | train |
tenside/core-bundle | src/Annotation/TensideApiDocHandler.php | TensideApiDocHandler.convertChildren | private function convertChildren($array, $result)
{
if (isset($array['children'])) {
foreach ($array['children'] as $key => $value) {
$result['children'][$key] = $this->convertField($value);
if (isset($result['children'][$key]['required'])) {
$result['required'] = $result['required'] || (bool) $result['children'][$key]['required'];
}
}
return $result;
}
return $result;
} | php | private function convertChildren($array, $result)
{
if (isset($array['children'])) {
foreach ($array['children'] as $key => $value) {
$result['children'][$key] = $this->convertField($value);
if (isset($result['children'][$key]['required'])) {
$result['required'] = $result['required'] || (bool) $result['children'][$key]['required'];
}
}
return $result;
}
return $result;
} | [
"private",
"function",
"convertChildren",
"(",
"$",
"array",
",",
"$",
"result",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"array",
"[",
"'children'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"array",
"[",
"'children'",
"]",
"as",
"$",
"key",
"=>",
"... | Convert the children key of an array.
@param array $array The source array.
@param array $result The partly converted array.
@return array | [
"Convert",
"the",
"children",
"key",
"of",
"an",
"array",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Annotation/TensideApiDocHandler.php#L120-L134 | train |
tenside/core-bundle | src/Annotation/TensideApiDocHandler.php | TensideApiDocHandler.inferType | public function inferType($type)
{
if (DataTypes::isPrimitive($type)) {
return $type;
} elseif (DataTypes::COLLECTION === strtolower($type)) {
return $type;
}
return DataTypes::STRING;
} | php | public function inferType($type)
{
if (DataTypes::isPrimitive($type)) {
return $type;
} elseif (DataTypes::COLLECTION === strtolower($type)) {
return $type;
}
return DataTypes::STRING;
} | [
"public",
"function",
"inferType",
"(",
"$",
"type",
")",
"{",
"if",
"(",
"DataTypes",
"::",
"isPrimitive",
"(",
"$",
"type",
")",
")",
"{",
"return",
"$",
"type",
";",
"}",
"elseif",
"(",
"DataTypes",
"::",
"COLLECTION",
"===",
"strtolower",
"(",
"$",... | Convert the type.
@param string $type The type name.
@return string | [
"Convert",
"the",
"type",
"."
] | a7ffad3649cddac1e5594b4f8b65a5504363fccd | https://github.com/tenside/core-bundle/blob/a7ffad3649cddac1e5594b4f8b65a5504363fccd/src/Annotation/TensideApiDocHandler.php#L143-L151 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.