id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
14,900 | sulu/SuluSalesShippingBundle | src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php | CartManager.addProduct | public function addProduct($data, $user = null, $locale = null)
{
//TODO: locale
// get cart
$cart = $this->getUserCart($user, $locale, null, true);
// define user-id
$userId = $user ? $user->getId() : null;
$item = $this->orderManager->addItem($data, $locale, $userId, $cart);
$this->validateIfItemProductActive($item->getEntity());
$this->orderManager->updateApiEntity($cart, $locale);
return $cart;
} | php | public function addProduct($data, $user = null, $locale = null)
{
//TODO: locale
// get cart
$cart = $this->getUserCart($user, $locale, null, true);
// define user-id
$userId = $user ? $user->getId() : null;
$item = $this->orderManager->addItem($data, $locale, $userId, $cart);
$this->validateIfItemProductActive($item->getEntity());
$this->orderManager->updateApiEntity($cart, $locale);
return $cart;
} | [
"public",
"function",
"addProduct",
"(",
"$",
"data",
",",
"$",
"user",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"//TODO: locale",
"// get cart",
"$",
"cart",
"=",
"$",
"this",
"->",
"getUserCart",
"(",
"$",
"user",
",",
"$",
"locale",
",",
"null",
",",
"true",
")",
";",
"// define user-id",
"$",
"userId",
"=",
"$",
"user",
"?",
"$",
"user",
"->",
"getId",
"(",
")",
":",
"null",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"orderManager",
"->",
"addItem",
"(",
"$",
"data",
",",
"$",
"locale",
",",
"$",
"userId",
",",
"$",
"cart",
")",
";",
"$",
"this",
"->",
"validateIfItemProductActive",
"(",
"$",
"item",
"->",
"getEntity",
"(",
")",
")",
";",
"$",
"this",
"->",
"orderManager",
"->",
"updateApiEntity",
"(",
"$",
"cart",
",",
"$",
"locale",
")",
";",
"return",
"$",
"cart",
";",
"}"
]
| Adds a product to cart
@param array $data
@param UserInterface|null $user
@param string|null $locale
@return null|Order | [
"Adds",
"a",
"product",
"to",
"cart"
]
| 0d39de262d58579e5679db99a77dbf717d600b5e | https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php#L553-L568 |
14,901 | sulu/SuluSalesShippingBundle | src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php | CartManager.updateItem | public function updateItem($itemId, $data, $user = null, $locale = null)
{
$cart = $this->getUserCart($user, $locale);
$userId = $user ? $user->getId() : null;
$this->validateOrCreateAddresses($cart, $user);
$item = $this->orderManager->getOrderItemById($itemId, $cart->getEntity());
$this->orderManager->updateItem($item, $data, $locale, $userId);
$this->removeOrderAddressIfContactAddressIdIsEqualTo(
$item,
$cart->getDeliveryAddress()->getContactAddress()->getId()
);
$this->orderManager->updateApiEntity($cart, $locale);
return $cart;
} | php | public function updateItem($itemId, $data, $user = null, $locale = null)
{
$cart = $this->getUserCart($user, $locale);
$userId = $user ? $user->getId() : null;
$this->validateOrCreateAddresses($cart, $user);
$item = $this->orderManager->getOrderItemById($itemId, $cart->getEntity());
$this->orderManager->updateItem($item, $data, $locale, $userId);
$this->removeOrderAddressIfContactAddressIdIsEqualTo(
$item,
$cart->getDeliveryAddress()->getContactAddress()->getId()
);
$this->orderManager->updateApiEntity($cart, $locale);
return $cart;
} | [
"public",
"function",
"updateItem",
"(",
"$",
"itemId",
",",
"$",
"data",
",",
"$",
"user",
"=",
"null",
",",
"$",
"locale",
"=",
"null",
")",
"{",
"$",
"cart",
"=",
"$",
"this",
"->",
"getUserCart",
"(",
"$",
"user",
",",
"$",
"locale",
")",
";",
"$",
"userId",
"=",
"$",
"user",
"?",
"$",
"user",
"->",
"getId",
"(",
")",
":",
"null",
";",
"$",
"this",
"->",
"validateOrCreateAddresses",
"(",
"$",
"cart",
",",
"$",
"user",
")",
";",
"$",
"item",
"=",
"$",
"this",
"->",
"orderManager",
"->",
"getOrderItemById",
"(",
"$",
"itemId",
",",
"$",
"cart",
"->",
"getEntity",
"(",
")",
")",
";",
"$",
"this",
"->",
"orderManager",
"->",
"updateItem",
"(",
"$",
"item",
",",
"$",
"data",
",",
"$",
"locale",
",",
"$",
"userId",
")",
";",
"$",
"this",
"->",
"removeOrderAddressIfContactAddressIdIsEqualTo",
"(",
"$",
"item",
",",
"$",
"cart",
"->",
"getDeliveryAddress",
"(",
")",
"->",
"getContactAddress",
"(",
")",
"->",
"getId",
"(",
")",
")",
";",
"$",
"this",
"->",
"orderManager",
"->",
"updateApiEntity",
"(",
"$",
"cart",
",",
"$",
"locale",
")",
";",
"return",
"$",
"cart",
";",
"}"
]
| Update item data
@param int $itemId
@param array $data
@param null|UserInterface $user
@param null|string $locale
@throws ItemNotFoundException
@return null|Order | [
"Update",
"item",
"data"
]
| 0d39de262d58579e5679db99a77dbf717d600b5e | https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php#L582-L601 |
14,902 | sulu/SuluSalesShippingBundle | src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php | CartManager.createEmptyCart | protected function createEmptyCart($user, $persist, $currencyCode = null)
{
$cart = new Order();
$cart->setCreator($user);
$cart->setChanger($user);
$cart->setCreated(new \DateTime());
$cart->setChanged(new \DateTime());
$cart->setOrderDate(new \DateTime());
// set currency - if not defined use default
$currencyCode = $currencyCode ?: $this->defaultCurrency;
$cart->setCurrencyCode($currencyCode);
// get address from contact and account
$contact = $user->getContact();
$account = $contact->getMainAccount();
$cart->setCustomerContact($contact);
$cart->setCustomerAccount($account);
/** Account $account */
if ($account && $account->getResponsiblePerson()) {
$cart->setResponsibleContact($account->getResponsiblePerson());
}
$addressSource = $contact;
if ($account) {
$addressSource = $account;
}
// get billing address
$invoiceOrderAddress = null;
$invoiceAddress = $this->accountManager->getBillingAddress($addressSource, true);
if ($invoiceAddress) {
// convert to order-address
$invoiceOrderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddress(
$invoiceAddress,
$contact,
$account
);
$cart->setInvoiceAddress($invoiceOrderAddress);
}
$deliveryOrderAddress = null;
$deliveryAddress = $this->accountManager->getDeliveryAddress($addressSource, true);
if ($deliveryAddress) {
// convert to order-address
$deliveryOrderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddress(
$deliveryAddress,
$contact,
$account
);
$cart->setDeliveryAddress($deliveryOrderAddress);
}
// TODO: anonymous order
// set order type
if ($user) {
$name = $user->getContact()->getFullName();
$cart->setType($this->orderManager->getOrderTypeEntityById(OrderType::SHOP));
} else {
$name = 'Anonymous';
$cart->setType($this->orderManager->getOrderTypeEntityById(OrderType::ANONYMOUS));
}
$cart->setCustomerName($name);
$this->orderManager->convertStatus($cart, OrderStatus::STATUS_IN_CART, false, $persist);
if ($persist) {
$this->em->persist($cart);
if ($invoiceOrderAddress) {
$this->em->persist($invoiceOrderAddress);
}
if ($deliveryOrderAddress) {
$this->em->persist($deliveryOrderAddress);
}
}
return $cart;
} | php | protected function createEmptyCart($user, $persist, $currencyCode = null)
{
$cart = new Order();
$cart->setCreator($user);
$cart->setChanger($user);
$cart->setCreated(new \DateTime());
$cart->setChanged(new \DateTime());
$cart->setOrderDate(new \DateTime());
// set currency - if not defined use default
$currencyCode = $currencyCode ?: $this->defaultCurrency;
$cart->setCurrencyCode($currencyCode);
// get address from contact and account
$contact = $user->getContact();
$account = $contact->getMainAccount();
$cart->setCustomerContact($contact);
$cart->setCustomerAccount($account);
/** Account $account */
if ($account && $account->getResponsiblePerson()) {
$cart->setResponsibleContact($account->getResponsiblePerson());
}
$addressSource = $contact;
if ($account) {
$addressSource = $account;
}
// get billing address
$invoiceOrderAddress = null;
$invoiceAddress = $this->accountManager->getBillingAddress($addressSource, true);
if ($invoiceAddress) {
// convert to order-address
$invoiceOrderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddress(
$invoiceAddress,
$contact,
$account
);
$cart->setInvoiceAddress($invoiceOrderAddress);
}
$deliveryOrderAddress = null;
$deliveryAddress = $this->accountManager->getDeliveryAddress($addressSource, true);
if ($deliveryAddress) {
// convert to order-address
$deliveryOrderAddress = $this->orderAddressManager->getAndSetOrderAddressByContactAddress(
$deliveryAddress,
$contact,
$account
);
$cart->setDeliveryAddress($deliveryOrderAddress);
}
// TODO: anonymous order
// set order type
if ($user) {
$name = $user->getContact()->getFullName();
$cart->setType($this->orderManager->getOrderTypeEntityById(OrderType::SHOP));
} else {
$name = 'Anonymous';
$cart->setType($this->orderManager->getOrderTypeEntityById(OrderType::ANONYMOUS));
}
$cart->setCustomerName($name);
$this->orderManager->convertStatus($cart, OrderStatus::STATUS_IN_CART, false, $persist);
if ($persist) {
$this->em->persist($cart);
if ($invoiceOrderAddress) {
$this->em->persist($invoiceOrderAddress);
}
if ($deliveryOrderAddress) {
$this->em->persist($deliveryOrderAddress);
}
}
return $cart;
} | [
"protected",
"function",
"createEmptyCart",
"(",
"$",
"user",
",",
"$",
"persist",
",",
"$",
"currencyCode",
"=",
"null",
")",
"{",
"$",
"cart",
"=",
"new",
"Order",
"(",
")",
";",
"$",
"cart",
"->",
"setCreator",
"(",
"$",
"user",
")",
";",
"$",
"cart",
"->",
"setChanger",
"(",
"$",
"user",
")",
";",
"$",
"cart",
"->",
"setCreated",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"$",
"cart",
"->",
"setChanged",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"$",
"cart",
"->",
"setOrderDate",
"(",
"new",
"\\",
"DateTime",
"(",
")",
")",
";",
"// set currency - if not defined use default",
"$",
"currencyCode",
"=",
"$",
"currencyCode",
"?",
":",
"$",
"this",
"->",
"defaultCurrency",
";",
"$",
"cart",
"->",
"setCurrencyCode",
"(",
"$",
"currencyCode",
")",
";",
"// get address from contact and account",
"$",
"contact",
"=",
"$",
"user",
"->",
"getContact",
"(",
")",
";",
"$",
"account",
"=",
"$",
"contact",
"->",
"getMainAccount",
"(",
")",
";",
"$",
"cart",
"->",
"setCustomerContact",
"(",
"$",
"contact",
")",
";",
"$",
"cart",
"->",
"setCustomerAccount",
"(",
"$",
"account",
")",
";",
"/** Account $account */",
"if",
"(",
"$",
"account",
"&&",
"$",
"account",
"->",
"getResponsiblePerson",
"(",
")",
")",
"{",
"$",
"cart",
"->",
"setResponsibleContact",
"(",
"$",
"account",
"->",
"getResponsiblePerson",
"(",
")",
")",
";",
"}",
"$",
"addressSource",
"=",
"$",
"contact",
";",
"if",
"(",
"$",
"account",
")",
"{",
"$",
"addressSource",
"=",
"$",
"account",
";",
"}",
"// get billing address",
"$",
"invoiceOrderAddress",
"=",
"null",
";",
"$",
"invoiceAddress",
"=",
"$",
"this",
"->",
"accountManager",
"->",
"getBillingAddress",
"(",
"$",
"addressSource",
",",
"true",
")",
";",
"if",
"(",
"$",
"invoiceAddress",
")",
"{",
"// convert to order-address",
"$",
"invoiceOrderAddress",
"=",
"$",
"this",
"->",
"orderAddressManager",
"->",
"getAndSetOrderAddressByContactAddress",
"(",
"$",
"invoiceAddress",
",",
"$",
"contact",
",",
"$",
"account",
")",
";",
"$",
"cart",
"->",
"setInvoiceAddress",
"(",
"$",
"invoiceOrderAddress",
")",
";",
"}",
"$",
"deliveryOrderAddress",
"=",
"null",
";",
"$",
"deliveryAddress",
"=",
"$",
"this",
"->",
"accountManager",
"->",
"getDeliveryAddress",
"(",
"$",
"addressSource",
",",
"true",
")",
";",
"if",
"(",
"$",
"deliveryAddress",
")",
"{",
"// convert to order-address",
"$",
"deliveryOrderAddress",
"=",
"$",
"this",
"->",
"orderAddressManager",
"->",
"getAndSetOrderAddressByContactAddress",
"(",
"$",
"deliveryAddress",
",",
"$",
"contact",
",",
"$",
"account",
")",
";",
"$",
"cart",
"->",
"setDeliveryAddress",
"(",
"$",
"deliveryOrderAddress",
")",
";",
"}",
"// TODO: anonymous order",
"// set order type",
"if",
"(",
"$",
"user",
")",
"{",
"$",
"name",
"=",
"$",
"user",
"->",
"getContact",
"(",
")",
"->",
"getFullName",
"(",
")",
";",
"$",
"cart",
"->",
"setType",
"(",
"$",
"this",
"->",
"orderManager",
"->",
"getOrderTypeEntityById",
"(",
"OrderType",
"::",
"SHOP",
")",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"'Anonymous'",
";",
"$",
"cart",
"->",
"setType",
"(",
"$",
"this",
"->",
"orderManager",
"->",
"getOrderTypeEntityById",
"(",
"OrderType",
"::",
"ANONYMOUS",
")",
")",
";",
"}",
"$",
"cart",
"->",
"setCustomerName",
"(",
"$",
"name",
")",
";",
"$",
"this",
"->",
"orderManager",
"->",
"convertStatus",
"(",
"$",
"cart",
",",
"OrderStatus",
"::",
"STATUS_IN_CART",
",",
"false",
",",
"$",
"persist",
")",
";",
"if",
"(",
"$",
"persist",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"cart",
")",
";",
"if",
"(",
"$",
"invoiceOrderAddress",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"invoiceOrderAddress",
")",
";",
"}",
"if",
"(",
"$",
"deliveryOrderAddress",
")",
"{",
"$",
"this",
"->",
"em",
"->",
"persist",
"(",
"$",
"deliveryOrderAddress",
")",
";",
"}",
"}",
"return",
"$",
"cart",
";",
"}"
]
| Function creates an empty cart
this means an order with status 'in_cart' is created and all necessary data is set
@param UserInterface $user
@param bool $persist
@param null|string $currencyCode
@return Order
@throws \Sulu\Component\Rest\Exception\EntityNotFoundException | [
"Function",
"creates",
"an",
"empty",
"cart",
"this",
"means",
"an",
"order",
"with",
"status",
"in_cart",
"is",
"created",
"and",
"all",
"necessary",
"data",
"is",
"set"
]
| 0d39de262d58579e5679db99a77dbf717d600b5e | https://github.com/sulu/SuluSalesShippingBundle/blob/0d39de262d58579e5679db99a77dbf717d600b5e/src/Sulu/Bundle/Sales/OrderBundle/Cart/CartManager.php#L636-L712 |
14,903 | faustbrian/Laravel-Countries | src/Console/Commands/SeedCurrencies.php | SeedCurrencies.getCurrencySymbol | private function getCurrencySymbol(string $currencyCode, string $locale): string
{
$formatter = new NumberFormatter($locale.'@currency='.$currencyCode, NumberFormatter::CURRENCY);
return $formatter->getSymbol(NumberFormatter::CURRENCY_SYMBOL);
} | php | private function getCurrencySymbol(string $currencyCode, string $locale): string
{
$formatter = new NumberFormatter($locale.'@currency='.$currencyCode, NumberFormatter::CURRENCY);
return $formatter->getSymbol(NumberFormatter::CURRENCY_SYMBOL);
} | [
"private",
"function",
"getCurrencySymbol",
"(",
"string",
"$",
"currencyCode",
",",
"string",
"$",
"locale",
")",
":",
"string",
"{",
"$",
"formatter",
"=",
"new",
"NumberFormatter",
"(",
"$",
"locale",
".",
"'@currency='",
".",
"$",
"currencyCode",
",",
"NumberFormatter",
"::",
"CURRENCY",
")",
";",
"return",
"$",
"formatter",
"->",
"getSymbol",
"(",
"NumberFormatter",
"::",
"CURRENCY_SYMBOL",
")",
";",
"}"
]
| Get the symbol value for the given locale.
@param string $currencyCode
@param string $locale
@return string | [
"Get",
"the",
"symbol",
"value",
"for",
"the",
"given",
"locale",
"."
]
| 3d72301acd37e7f351d9b991dba41807ab68362b | https://github.com/faustbrian/Laravel-Countries/blob/3d72301acd37e7f351d9b991dba41807ab68362b/src/Console/Commands/SeedCurrencies.php#L65-L70 |
14,904 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.getVenue | public function getVenue($venueId)
{
$resource = '/venues/' . $venueId;
$response = $this->makeApiRequest($resource);
return $response->venue;
} | php | public function getVenue($venueId)
{
$resource = '/venues/' . $venueId;
$response = $this->makeApiRequest($resource);
return $response->venue;
} | [
"public",
"function",
"getVenue",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"response",
"->",
"venue",
";",
"}"
]
| Get venue by ID
@param string $venueId
@return object | [
"Get",
"venue",
"by",
"ID"
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L12-L18 |
14,905 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.categories | public function categories()
{
$resource = '/venues/categories';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'categories')) {
return $response->categories;
}
return array();
} | php | public function categories()
{
$resource = '/venues/categories';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'categories')) {
return $response->categories;
}
return array();
} | [
"public",
"function",
"categories",
"(",
")",
"{",
"$",
"resource",
"=",
"'/venues/categories'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'categories'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"categories",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns a hierarchical list of categories applied to venues.
When designing client applications, please download this list
only once per session, but also avoid caching this data for
longer than a week to avoid stale information.
@return array | [
"Returns",
"a",
"hierarchical",
"list",
"of",
"categories",
"applied",
"to",
"venues",
".",
"When",
"designing",
"client",
"applications",
"please",
"download",
"this",
"list",
"only",
"once",
"per",
"session",
"but",
"also",
"avoid",
"caching",
"this",
"data",
"for",
"longer",
"than",
"a",
"week",
"to",
"avoid",
"stale",
"information",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L32-L42 |
14,906 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.managed | public function managed()
{
$resource = '/venues/managed';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'venues')) {
return $response->venues;
}
return array();
} | php | public function managed()
{
$resource = '/venues/managed';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'venues')) {
return $response->venues;
}
return array();
} | [
"public",
"function",
"managed",
"(",
")",
"{",
"$",
"resource",
"=",
"'/venues/managed'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'venues'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"venues",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Get a list of venues the current user manages.
@return array | [
"Get",
"a",
"list",
"of",
"venues",
"the",
"current",
"user",
"manages",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L51-L61 |
14,907 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.search | public function search(array $params = array())
{
$resource = '/venues/search';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'venues')) {
return $response->venues;
}
return array();
} | php | public function search(array $params = array())
{
$resource = '/venues/search';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'venues')) {
return $response->venues;
}
return array();
} | [
"public",
"function",
"search",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"resource",
"=",
"'/venues/search'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
",",
"$",
"params",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'venues'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"venues",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns a list of venues near the current location, optionally matching a search term.
@see https://developer.foursquare.com/docs/venues/search
@param array $params
@return array | [
"Returns",
"a",
"list",
"of",
"venues",
"near",
"the",
"current",
"location",
"optionally",
"matching",
"a",
"search",
"term",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L69-L79 |
14,908 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.suggestCompletion | public function suggestCompletion(array $params = array())
{
$resource = '/venues/suggestcompletion';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'minivenues')) {
return $response->minivenues;
}
return array();
} | php | public function suggestCompletion(array $params = array())
{
$resource = '/venues/suggestcompletion';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'minivenues')) {
return $response->minivenues;
}
return array();
} | [
"public",
"function",
"suggestCompletion",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"resource",
"=",
"'/venues/suggestcompletion'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
",",
"$",
"params",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'minivenues'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"minivenues",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns a list of mini-venues partially matching the search term, near the location.
@see https://developer.foursquare.com/docs/venues/suggestcompletion
@param array $params
@return array | [
"Returns",
"a",
"list",
"of",
"mini",
"-",
"venues",
"partially",
"matching",
"the",
"search",
"term",
"near",
"the",
"location",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L87-L97 |
14,909 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.timeSeries | public function timeSeries(array $params = array())
{
$resource = '/venues/timeseries';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'timeseries')) {
return $response->timeseries;
}
return array();
} | php | public function timeSeries(array $params = array())
{
$resource = '/venues/timeseries';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'timeseries')) {
return $response->timeseries;
}
return array();
} | [
"public",
"function",
"timeSeries",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"resource",
"=",
"'/venues/timeseries'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
",",
"$",
"params",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'timeseries'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"timeseries",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Get daily venue stats for a list of venues over a time range.
User must be venue manager.
@see https://developer.foursquare.com/docs/venues/timeseries
@param array $params
@return array | [
"Get",
"daily",
"venue",
"stats",
"for",
"a",
"list",
"of",
"venues",
"over",
"a",
"time",
"range",
".",
"User",
"must",
"be",
"venue",
"manager",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L106-L116 |
14,910 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.trending | public function trending(array $params = array())
{
$resource = '/venues/trending';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'venues')) {
return $response->venues;
}
return array();
} | php | public function trending(array $params = array())
{
$resource = '/venues/trending';
$response = $this->makeApiRequest($resource, $params);
if(property_exists($response, 'venues')) {
return $response->venues;
}
return array();
} | [
"public",
"function",
"trending",
"(",
"array",
"$",
"params",
"=",
"array",
"(",
")",
")",
"{",
"$",
"resource",
"=",
"'/venues/trending'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
",",
"$",
"params",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'venues'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"venues",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns a list of venues near the current location with the most people currently checked in.
@see https://developer.foursquare.com/docs/venues/trending
@param array $params
@return array | [
"Returns",
"a",
"list",
"of",
"venues",
"near",
"the",
"current",
"location",
"with",
"the",
"most",
"people",
"currently",
"checked",
"in",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L124-L134 |
14,911 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.events | public function events($venueId)
{
$resource = '/venues/' . $venueId . '/events';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'events')) {
return $response->events->items;
}
return array();
} | php | public function events($venueId)
{
$resource = '/venues/' . $venueId . '/events';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'events')) {
return $response->events->items;
}
return array();
} | [
"public",
"function",
"events",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/events'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'events'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"events",
"->",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Allows you to access information about the current events at a place.
@param string $venueId
@return array | [
"Allows",
"you",
"to",
"access",
"information",
"about",
"the",
"current",
"events",
"at",
"a",
"place",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L141-L153 |
14,912 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.hereNow | public function hereNow($venueId)
{
$resource = '/venues/' . $venueId . '/herenow';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'hereNow')) {
return $response->hereNow->count;
}
return 0;
} | php | public function hereNow($venueId)
{
$resource = '/venues/' . $venueId . '/herenow';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'hereNow')) {
return $response->hereNow->count;
}
return 0;
} | [
"public",
"function",
"hereNow",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/herenow'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'hereNow'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"hereNow",
"->",
"count",
";",
"}",
"return",
"0",
";",
"}"
]
| Provides a count of how many people are at a given venue.
@param string $venueId
@return int | [
"Provides",
"a",
"count",
"of",
"how",
"many",
"people",
"are",
"at",
"a",
"given",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L160-L172 |
14,913 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.hours | public function hours($venueId)
{
$resource = '/venues/' . $venueId . '/hours';
$response = $this->makeApiRequest($resource);
return $response->hours;
} | php | public function hours($venueId)
{
$resource = '/venues/' . $venueId . '/hours';
$response = $this->makeApiRequest($resource);
return $response->hours;
} | [
"public",
"function",
"hours",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/hours'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"response",
"->",
"hours",
";",
"}"
]
| Returns hours for a venue.
@param string $venueId
@return array | [
"Returns",
"hours",
"for",
"a",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L179-L187 |
14,914 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.likes | public function likes($venueId)
{
$resource = '/venues/' . $venueId . '/likes';
$response = $this->makeApiRequest($resource);
return $response->likes;
} | php | public function likes($venueId)
{
$resource = '/venues/' . $venueId . '/likes';
$response = $this->makeApiRequest($resource);
return $response->likes;
} | [
"public",
"function",
"likes",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/likes'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"response",
"->",
"likes",
";",
"}"
]
| Returns friends and a total count of users who have liked this venue.
@param string $venueId
@return array | [
"Returns",
"friends",
"and",
"a",
"total",
"count",
"of",
"users",
"who",
"have",
"liked",
"this",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L194-L202 |
14,915 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.links | public function links($venueId)
{
$resource = '/venues/' . $venueId . '/links';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'links')) {
return $response->links->items;
}
return array();
} | php | public function links($venueId)
{
$resource = '/venues/' . $venueId . '/links';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'links')) {
return $response->links->items;
}
return array();
} | [
"public",
"function",
"links",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/links'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'links'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"links",
"->",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns URLs or identifiers from third parties that have been applied to this venue.
@param string $venueId
@return array | [
"Returns",
"URLs",
"or",
"identifiers",
"from",
"third",
"parties",
"that",
"have",
"been",
"applied",
"to",
"this",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L209-L221 |
14,916 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.lists | public function lists($venueId)
{
$resource = '/venues/' . $venueId . '/listed';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'lists')) {
return $response->lists->groups;
}
return array();
} | php | public function lists($venueId)
{
$resource = '/venues/' . $venueId . '/listed';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'lists')) {
return $response->lists->groups;
}
return array();
} | [
"public",
"function",
"lists",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/listed'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'lists'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"lists",
"->",
"groups",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| The lists that this venue appears on.
@param string $venueId
@return array | [
"The",
"lists",
"that",
"this",
"venue",
"appears",
"on",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L228-L240 |
14,917 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.nextVenues | public function nextVenues($venueId)
{
$resource = '/venues/' . $venueId . '/nextvenues';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'nextVenues')) {
return $response->nextVenues->items;
}
return array();
} | php | public function nextVenues($venueId)
{
$resource = '/venues/' . $venueId . '/nextvenues';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'nextVenues')) {
return $response->nextVenues->items;
}
return array();
} | [
"public",
"function",
"nextVenues",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/nextvenues'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'nextVenues'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"nextVenues",
"->",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns venues that people often check in to after the current venue.
@param $venueId
@return array | [
"Returns",
"venues",
"that",
"people",
"often",
"check",
"in",
"to",
"after",
"the",
"current",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L250-L262 |
14,918 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.photos | public function photos($venueId)
{
$resource = '/venues/' . $venueId . '/photos';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'photos')) {
return $response->photos->items;
}
return array();
} | php | public function photos($venueId)
{
$resource = '/venues/' . $venueId . '/photos';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'photos')) {
return $response->photos->items;
}
return array();
} | [
"public",
"function",
"photos",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/photos'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'photos'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"photos",
"->",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns photos for a venue.
@param $venueId
@return array | [
"Returns",
"photos",
"for",
"a",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L269-L281 |
14,919 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.similar | public function similar($venueId)
{
$resource = '/venues/' . $venueId . '/similar';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'similarVenues')) {
return $response->similarVenues->items;
}
return array();
} | php | public function similar($venueId)
{
$resource = '/venues/' . $venueId . '/similar';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'similarVenues')) {
return $response->similarVenues->items;
}
return array();
} | [
"public",
"function",
"similar",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/similar'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'similarVenues'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"similarVenues",
"->",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns a list of venues similar to the specified venue.
@param $venueId
@return array | [
"Returns",
"a",
"list",
"of",
"venues",
"similar",
"to",
"the",
"specified",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L288-L300 |
14,920 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.stats | public function stats($venueId)
{
$resource = '/venues/' . $venueId . '/stats';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'stats')) {
return $response->stats;
}
return array();
} | php | public function stats($venueId)
{
$resource = '/venues/' . $venueId . '/stats';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'stats')) {
return $response->stats;
}
return array();
} | [
"public",
"function",
"stats",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/stats'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'stats'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"stats",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Get venue stats over a given time range. Only available to the manager of a venue.
User must be venue manager.
@param $venueId
@return array | [
"Get",
"venue",
"stats",
"over",
"a",
"given",
"time",
"range",
".",
"Only",
"available",
"to",
"the",
"manager",
"of",
"a",
"venue",
".",
"User",
"must",
"be",
"venue",
"manager",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L308-L320 |
14,921 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/VenuesGateway.php | VenuesGateway.tips | public function tips($venueId)
{
$resource = '/venues/' . $venueId . '/tips';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'tips')) {
return $response->tips->items;
}
return array();
} | php | public function tips($venueId)
{
$resource = '/venues/' . $venueId . '/tips';
$response = $this->makeApiRequest($resource);
if(property_exists($response, 'tips')) {
return $response->tips->items;
}
return array();
} | [
"public",
"function",
"tips",
"(",
"$",
"venueId",
")",
"{",
"$",
"resource",
"=",
"'/venues/'",
".",
"$",
"venueId",
".",
"'/tips'",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"if",
"(",
"property_exists",
"(",
"$",
"response",
",",
"'tips'",
")",
")",
"{",
"return",
"$",
"response",
"->",
"tips",
"->",
"items",
";",
"}",
"return",
"array",
"(",
")",
";",
"}"
]
| Returns tips for a venue.
@param $venueId
@return array | [
"Returns",
"tips",
"for",
"a",
"venue",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/VenuesGateway.php#L327-L339 |
14,922 | FrenchFrogs/framework | src/Renderer/Renderer.php | Renderer.addRenderer | public function addRenderer($index, $method = null)
{
$this->renderers[$index] = is_null($method) ? $index : $method;
return $this;
} | php | public function addRenderer($index, $method = null)
{
$this->renderers[$index] = is_null($method) ? $index : $method;
return $this;
} | [
"public",
"function",
"addRenderer",
"(",
"$",
"index",
",",
"$",
"method",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"renderers",
"[",
"$",
"index",
"]",
"=",
"is_null",
"(",
"$",
"method",
")",
"?",
"$",
"index",
":",
"$",
"method",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a single renderer to the renderers container
@param $index
@param $method
@return $this | [
"Add",
"a",
"single",
"renderer",
"to",
"the",
"renderers",
"container"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Renderer/Renderer.php#L77-L81 |
14,923 | codeburnerframework/router | src/Parser.php | Parser.parsePattern | public function parsePattern($pattern)
{
$withoutClosing = rtrim($pattern, "]");
$closingNumber = strlen($pattern) - strlen($withoutClosing);
$segments = preg_split("~" . self::DYNAMIC_REGEX . "(*SKIP)(*F)|\[~x", $withoutClosing);
$this->parseSegments($segments, $closingNumber, $withoutClosing);
return $this->buildSegments($segments);
} | php | public function parsePattern($pattern)
{
$withoutClosing = rtrim($pattern, "]");
$closingNumber = strlen($pattern) - strlen($withoutClosing);
$segments = preg_split("~" . self::DYNAMIC_REGEX . "(*SKIP)(*F)|\[~x", $withoutClosing);
$this->parseSegments($segments, $closingNumber, $withoutClosing);
return $this->buildSegments($segments);
} | [
"public",
"function",
"parsePattern",
"(",
"$",
"pattern",
")",
"{",
"$",
"withoutClosing",
"=",
"rtrim",
"(",
"$",
"pattern",
",",
"\"]\"",
")",
";",
"$",
"closingNumber",
"=",
"strlen",
"(",
"$",
"pattern",
")",
"-",
"strlen",
"(",
"$",
"withoutClosing",
")",
";",
"$",
"segments",
"=",
"preg_split",
"(",
"\"~\"",
".",
"self",
"::",
"DYNAMIC_REGEX",
".",
"\"(*SKIP)(*F)|\\[~x\"",
",",
"$",
"withoutClosing",
")",
";",
"$",
"this",
"->",
"parseSegments",
"(",
"$",
"segments",
",",
"$",
"closingNumber",
",",
"$",
"withoutClosing",
")",
";",
"return",
"$",
"this",
"->",
"buildSegments",
"(",
"$",
"segments",
")",
";",
"}"
]
| Separate routes pattern with optional parts into n new patterns.
@param string $pattern
@throws BadRouteException
@return array | [
"Separate",
"routes",
"pattern",
"with",
"optional",
"parts",
"into",
"n",
"new",
"patterns",
"."
]
| 2b0e8030303dd08d3fadfc4c57aa37b184a408cd | https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Parser.php#L61-L70 |
14,924 | codeburnerframework/router | src/Parser.php | Parser.parseSegments | protected function parseSegments(array $segments, $closingNumber, $withoutClosing)
{
if ($closingNumber !== count($segments) - 1) {
if (preg_match("~" . self::DYNAMIC_REGEX . "(*SKIP)(*F)|\]~x", $withoutClosing)) {
throw new BadRouteException(BadRouteException::OPTIONAL_SEGMENTS_ON_MIDDLE);
} else throw new BadRouteException(BadRouteException::UNCLOSED_OPTIONAL_SEGMENTS);
}
} | php | protected function parseSegments(array $segments, $closingNumber, $withoutClosing)
{
if ($closingNumber !== count($segments) - 1) {
if (preg_match("~" . self::DYNAMIC_REGEX . "(*SKIP)(*F)|\]~x", $withoutClosing)) {
throw new BadRouteException(BadRouteException::OPTIONAL_SEGMENTS_ON_MIDDLE);
} else throw new BadRouteException(BadRouteException::UNCLOSED_OPTIONAL_SEGMENTS);
}
} | [
"protected",
"function",
"parseSegments",
"(",
"array",
"$",
"segments",
",",
"$",
"closingNumber",
",",
"$",
"withoutClosing",
")",
"{",
"if",
"(",
"$",
"closingNumber",
"!==",
"count",
"(",
"$",
"segments",
")",
"-",
"1",
")",
"{",
"if",
"(",
"preg_match",
"(",
"\"~\"",
".",
"self",
"::",
"DYNAMIC_REGEX",
".",
"\"(*SKIP)(*F)|\\]~x\"",
",",
"$",
"withoutClosing",
")",
")",
"{",
"throw",
"new",
"BadRouteException",
"(",
"BadRouteException",
"::",
"OPTIONAL_SEGMENTS_ON_MIDDLE",
")",
";",
"}",
"else",
"throw",
"new",
"BadRouteException",
"(",
"BadRouteException",
"::",
"UNCLOSED_OPTIONAL_SEGMENTS",
")",
";",
"}",
"}"
]
| Parse all the possible patterns seeking for an incorrect or incompatible pattern.
@param string[] $segments Segments are all the possible patterns made on top of a pattern with optional segments.
@param int $closingNumber The count of optional segments.
@param string $withoutClosing The pattern without the closing token of an optional segment. aka: ]
@throws BadRouteException | [
"Parse",
"all",
"the",
"possible",
"patterns",
"seeking",
"for",
"an",
"incorrect",
"or",
"incompatible",
"pattern",
"."
]
| 2b0e8030303dd08d3fadfc4c57aa37b184a408cd | https://github.com/codeburnerframework/router/blob/2b0e8030303dd08d3fadfc4c57aa37b184a408cd/src/Parser.php#L82-L89 |
14,925 | acasademont/wurfl | WURFL/Logger/LoggerFactory.php | WURFL_Logger_LoggerFactory.createUndetectedDeviceLogger | public static function createUndetectedDeviceLogger($wurflConfig=null)
{
if (self::isLoggingConfigured($wurflConfig)) {
return self::createFileLogger($wurflConfig, "undetected_devices.log");
}
return new WURFL_Logger_NullLogger();
} | php | public static function createUndetectedDeviceLogger($wurflConfig=null)
{
if (self::isLoggingConfigured($wurflConfig)) {
return self::createFileLogger($wurflConfig, "undetected_devices.log");
}
return new WURFL_Logger_NullLogger();
} | [
"public",
"static",
"function",
"createUndetectedDeviceLogger",
"(",
"$",
"wurflConfig",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"isLoggingConfigured",
"(",
"$",
"wurflConfig",
")",
")",
"{",
"return",
"self",
"::",
"createFileLogger",
"(",
"$",
"wurflConfig",
",",
"\"undetected_devices.log\"",
")",
";",
"}",
"return",
"new",
"WURFL_Logger_NullLogger",
"(",
")",
";",
"}"
]
| Create Logger for undetected devices with filename undetected_devices.log
@param WURFL_Configuration_Config $wurflConfig
@return WURFL_Logger_Interface Logger object | [
"Create",
"Logger",
"for",
"undetected",
"devices",
"with",
"filename",
"undetected_devices",
".",
"log"
]
| 0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2 | https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Logger/LoggerFactory.php#L30-L36 |
14,926 | acasademont/wurfl | WURFL/Logger/LoggerFactory.php | WURFL_Logger_LoggerFactory.createFileLogger | private static function createFileLogger($wurflConfig, $fileName)
{
$logFileName = self::createLogFile($wurflConfig->logDir, $fileName);
return new WURFL_Logger_FileLogger($logFileName);
} | php | private static function createFileLogger($wurflConfig, $fileName)
{
$logFileName = self::createLogFile($wurflConfig->logDir, $fileName);
return new WURFL_Logger_FileLogger($logFileName);
} | [
"private",
"static",
"function",
"createFileLogger",
"(",
"$",
"wurflConfig",
",",
"$",
"fileName",
")",
"{",
"$",
"logFileName",
"=",
"self",
"::",
"createLogFile",
"(",
"$",
"wurflConfig",
"->",
"logDir",
",",
"$",
"fileName",
")",
";",
"return",
"new",
"WURFL_Logger_FileLogger",
"(",
"$",
"logFileName",
")",
";",
"}"
]
| Creates a new file logger
@param WURFL_Configuration_Config $wurflConfig
@param string $fileName
@return WURFL_Logger_FileLogger File logger | [
"Creates",
"a",
"new",
"file",
"logger"
]
| 0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2 | https://github.com/acasademont/wurfl/blob/0f4fb6e06b452ba95ad1d15e7d8226d0974b60c2/WURFL/Logger/LoggerFactory.php#L57-L61 |
14,927 | awethemes/wp-session | src/WP_Session.php | WP_Session.hooks | public function hooks() {
// Start and commit the session.
add_action( 'plugins_loaded', [ $this, 'start_session' ] );
add_action( 'shutdown', [ $this, 'commit_session' ] );
// Register the garbage collector.
add_action( 'wp', [ $this, 'register_garbage_collection' ] );
add_action( $this->get_schedule_name(), [ $this, 'cleanup_expired_sessions' ] );
} | php | public function hooks() {
// Start and commit the session.
add_action( 'plugins_loaded', [ $this, 'start_session' ] );
add_action( 'shutdown', [ $this, 'commit_session' ] );
// Register the garbage collector.
add_action( 'wp', [ $this, 'register_garbage_collection' ] );
add_action( $this->get_schedule_name(), [ $this, 'cleanup_expired_sessions' ] );
} | [
"public",
"function",
"hooks",
"(",
")",
"{",
"// Start and commit the session.",
"add_action",
"(",
"'plugins_loaded'",
",",
"[",
"$",
"this",
",",
"'start_session'",
"]",
")",
";",
"add_action",
"(",
"'shutdown'",
",",
"[",
"$",
"this",
",",
"'commit_session'",
"]",
")",
";",
"// Register the garbage collector.",
"add_action",
"(",
"'wp'",
",",
"[",
"$",
"this",
",",
"'register_garbage_collection'",
"]",
")",
";",
"add_action",
"(",
"$",
"this",
"->",
"get_schedule_name",
"(",
")",
",",
"[",
"$",
"this",
",",
"'cleanup_expired_sessions'",
"]",
")",
";",
"}"
]
| Hooks into WordPress to start, commit and run garbage collector.
@return void | [
"Hooks",
"into",
"WordPress",
"to",
"start",
"commit",
"and",
"run",
"garbage",
"collector",
"."
]
| 4819c6392a0dbcbbf547027b70d5af88e7a89d61 | https://github.com/awethemes/wp-session/blob/4819c6392a0dbcbbf547027b70d5af88e7a89d61/src/WP_Session.php#L50-L58 |
14,928 | keiosweb/moneyright | src/Currency.php | Currency.getCurrencyFromIsoCode | protected function getCurrencyFromIsoCode($isoCode)
{
$this->prepareCurrencies();
$isoCode = strtolower($isoCode);
if (!array_key_exists($isoCode, self::$currencies)) {
throw new UnknownCurrencyException('Currency with '.$isoCode.' iso code does not exist!');
}
return self::$currencies[$isoCode];
} | php | protected function getCurrencyFromIsoCode($isoCode)
{
$this->prepareCurrencies();
$isoCode = strtolower($isoCode);
if (!array_key_exists($isoCode, self::$currencies)) {
throw new UnknownCurrencyException('Currency with '.$isoCode.' iso code does not exist!');
}
return self::$currencies[$isoCode];
} | [
"protected",
"function",
"getCurrencyFromIsoCode",
"(",
"$",
"isoCode",
")",
"{",
"$",
"this",
"->",
"prepareCurrencies",
"(",
")",
";",
"$",
"isoCode",
"=",
"strtolower",
"(",
"$",
"isoCode",
")",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"isoCode",
",",
"self",
"::",
"$",
"currencies",
")",
")",
"{",
"throw",
"new",
"UnknownCurrencyException",
"(",
"'Currency with '",
".",
"$",
"isoCode",
".",
"' iso code does not exist!'",
")",
";",
"}",
"return",
"self",
"::",
"$",
"currencies",
"[",
"$",
"isoCode",
"]",
";",
"}"
]
| Loads currency information from preloaded data by ISO index
@param $isoCode
@return array
@throws \Keios\MoneyRight\Exceptions\UnknownCurrencyException | [
"Loads",
"currency",
"information",
"from",
"preloaded",
"data",
"by",
"ISO",
"index"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Currency.php#L124-L135 |
14,929 | keiosweb/moneyright | src/Currency.php | Currency.fill | protected function fill(array $data)
{
$this->isoCode = $data['iso_code'];
$this->name = $data['name'];
$this->symbol = $data['symbol'];
$this->subunit = $data['subunit'];
$this->symbolFirst = $data['symbol_first'];
$this->htmlEntity = $data['html_entity'];
$this->decimalMark = $data['decimal_mark'];
$this->thousandsSeparator = $data['thousands_separator'];
$this->isoNumeric = $data['iso_numeric'];
if (array_key_exists('alternate_symbols', $data)) {
$this->alternateSymbols = $data['alternate_symbols'];
}
if (array_key_exists('disambiguate_symbol', $data)) {
$this->disambiguateSymbol = $data['disambiguate_symbol'];
}
} | php | protected function fill(array $data)
{
$this->isoCode = $data['iso_code'];
$this->name = $data['name'];
$this->symbol = $data['symbol'];
$this->subunit = $data['subunit'];
$this->symbolFirst = $data['symbol_first'];
$this->htmlEntity = $data['html_entity'];
$this->decimalMark = $data['decimal_mark'];
$this->thousandsSeparator = $data['thousands_separator'];
$this->isoNumeric = $data['iso_numeric'];
if (array_key_exists('alternate_symbols', $data)) {
$this->alternateSymbols = $data['alternate_symbols'];
}
if (array_key_exists('disambiguate_symbol', $data)) {
$this->disambiguateSymbol = $data['disambiguate_symbol'];
}
} | [
"protected",
"function",
"fill",
"(",
"array",
"$",
"data",
")",
"{",
"$",
"this",
"->",
"isoCode",
"=",
"$",
"data",
"[",
"'iso_code'",
"]",
";",
"$",
"this",
"->",
"name",
"=",
"$",
"data",
"[",
"'name'",
"]",
";",
"$",
"this",
"->",
"symbol",
"=",
"$",
"data",
"[",
"'symbol'",
"]",
";",
"$",
"this",
"->",
"subunit",
"=",
"$",
"data",
"[",
"'subunit'",
"]",
";",
"$",
"this",
"->",
"symbolFirst",
"=",
"$",
"data",
"[",
"'symbol_first'",
"]",
";",
"$",
"this",
"->",
"htmlEntity",
"=",
"$",
"data",
"[",
"'html_entity'",
"]",
";",
"$",
"this",
"->",
"decimalMark",
"=",
"$",
"data",
"[",
"'decimal_mark'",
"]",
";",
"$",
"this",
"->",
"thousandsSeparator",
"=",
"$",
"data",
"[",
"'thousands_separator'",
"]",
";",
"$",
"this",
"->",
"isoNumeric",
"=",
"$",
"data",
"[",
"'iso_numeric'",
"]",
";",
"if",
"(",
"array_key_exists",
"(",
"'alternate_symbols'",
",",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"alternateSymbols",
"=",
"$",
"data",
"[",
"'alternate_symbols'",
"]",
";",
"}",
"if",
"(",
"array_key_exists",
"(",
"'disambiguate_symbol'",
",",
"$",
"data",
")",
")",
"{",
"$",
"this",
"->",
"disambiguateSymbol",
"=",
"$",
"data",
"[",
"'disambiguate_symbol'",
"]",
";",
"}",
"}"
]
| Protected setter for all fields
@param array $data | [
"Protected",
"setter",
"for",
"all",
"fields"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Currency.php#L142-L161 |
14,930 | keiosweb/moneyright | src/Currency.php | Currency.aggregateData | protected function aggregateData()
{
$data = [
'iso_code' => $this->isoCode,
'name' => $this->name,
'symbol' => $this->symbol,
'subunit' => $this->subunit,
'symbol_first' => $this->symbolFirst,
'html_entity' => $this->htmlEntity,
'decimal_mark' => $this->decimalMark,
'thousands_separator' => $this->thousandsSeparator,
'iso_numeric' => $this->isoNumeric,
];
if (!is_null($this->alternateSymbols)) {
$data['alternate_symbols'] = $this->alternateSymbols;
}
if (!is_null($this->disambiguateSymbol)) {
$data['disambiguate_symbol'] = $this->disambiguateSymbol;
}
return $data;
} | php | protected function aggregateData()
{
$data = [
'iso_code' => $this->isoCode,
'name' => $this->name,
'symbol' => $this->symbol,
'subunit' => $this->subunit,
'symbol_first' => $this->symbolFirst,
'html_entity' => $this->htmlEntity,
'decimal_mark' => $this->decimalMark,
'thousands_separator' => $this->thousandsSeparator,
'iso_numeric' => $this->isoNumeric,
];
if (!is_null($this->alternateSymbols)) {
$data['alternate_symbols'] = $this->alternateSymbols;
}
if (!is_null($this->disambiguateSymbol)) {
$data['disambiguate_symbol'] = $this->disambiguateSymbol;
}
return $data;
} | [
"protected",
"function",
"aggregateData",
"(",
")",
"{",
"$",
"data",
"=",
"[",
"'iso_code'",
"=>",
"$",
"this",
"->",
"isoCode",
",",
"'name'",
"=>",
"$",
"this",
"->",
"name",
",",
"'symbol'",
"=>",
"$",
"this",
"->",
"symbol",
",",
"'subunit'",
"=>",
"$",
"this",
"->",
"subunit",
",",
"'symbol_first'",
"=>",
"$",
"this",
"->",
"symbolFirst",
",",
"'html_entity'",
"=>",
"$",
"this",
"->",
"htmlEntity",
",",
"'decimal_mark'",
"=>",
"$",
"this",
"->",
"decimalMark",
",",
"'thousands_separator'",
"=>",
"$",
"this",
"->",
"thousandsSeparator",
",",
"'iso_numeric'",
"=>",
"$",
"this",
"->",
"isoNumeric",
",",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"alternateSymbols",
")",
")",
"{",
"$",
"data",
"[",
"'alternate_symbols'",
"]",
"=",
"$",
"this",
"->",
"alternateSymbols",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"this",
"->",
"disambiguateSymbol",
")",
")",
"{",
"$",
"data",
"[",
"'disambiguate_symbol'",
"]",
"=",
"$",
"this",
"->",
"disambiguateSymbol",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Prepares data for serialization
@return array | [
"Prepares",
"data",
"for",
"serialization"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Currency.php#L168-L191 |
14,931 | keiosweb/moneyright | src/Currency.php | Currency.unserialize | public function unserialize($serialized)
{
$currentCurrency = $this->getCurrencyFromIsoCode(unserialize($serialized));
$this->fill($currentCurrency);
} | php | public function unserialize($serialized)
{
$currentCurrency = $this->getCurrencyFromIsoCode(unserialize($serialized));
$this->fill($currentCurrency);
} | [
"public",
"function",
"unserialize",
"(",
"$",
"serialized",
")",
"{",
"$",
"currentCurrency",
"=",
"$",
"this",
"->",
"getCurrencyFromIsoCode",
"(",
"unserialize",
"(",
"$",
"serialized",
")",
")",
";",
"$",
"this",
"->",
"fill",
"(",
"$",
"currentCurrency",
")",
";",
"}"
]
| Serialization constructor for \Serializable
@param string $serialized | [
"Serialization",
"constructor",
"for",
"\\",
"Serializable"
]
| 6c6d8ce34e37e42aa1eebbf45a949bbae6b44780 | https://github.com/keiosweb/moneyright/blob/6c6d8ce34e37e42aa1eebbf45a949bbae6b44780/src/Currency.php#L318-L323 |
14,932 | kiwiz/ecl | src/SymbolTable.php | SymbolTable.resolve | public function resolve($sym, $type=Symbol::T_NULL) {
$val = $sym;
if($sym instanceof \ECL\Symbol) {
$val = $this->offsetGet($sym->getName());
if($type == Symbol::T_NULL) {
$type = $sym->getType();
}
}
switch($type) {
case Symbol::T_INT:
$val = (int) $val;
break;
case Symbol::T_FLOAT:
$val = (double) $val;
break;
case Symbol::T_STR:
$val = (string) $val;
break;
case Symbol::T_LIST:
if(!is_array($val)) {
if(!($val instanceof \ECL\ResultSet)) {
throw new WrongTypeException($sym->getName());
}
$val = array_unique(\ECL\Util::pluck($val->getAll(), $sym->getPath()));
}
break;
case Symbol::T_RES:
if(!is_array($val)) {
if(!($val instanceof \ECL\ResultSet)) {
throw new WrongTypeException($sym->getName());
}
} else {
$val = new \ECL\ResultSet(array_map(function($x) { return ['value' => $x]; }, $val), ['value']);
}
break;
}
return $val;
} | php | public function resolve($sym, $type=Symbol::T_NULL) {
$val = $sym;
if($sym instanceof \ECL\Symbol) {
$val = $this->offsetGet($sym->getName());
if($type == Symbol::T_NULL) {
$type = $sym->getType();
}
}
switch($type) {
case Symbol::T_INT:
$val = (int) $val;
break;
case Symbol::T_FLOAT:
$val = (double) $val;
break;
case Symbol::T_STR:
$val = (string) $val;
break;
case Symbol::T_LIST:
if(!is_array($val)) {
if(!($val instanceof \ECL\ResultSet)) {
throw new WrongTypeException($sym->getName());
}
$val = array_unique(\ECL\Util::pluck($val->getAll(), $sym->getPath()));
}
break;
case Symbol::T_RES:
if(!is_array($val)) {
if(!($val instanceof \ECL\ResultSet)) {
throw new WrongTypeException($sym->getName());
}
} else {
$val = new \ECL\ResultSet(array_map(function($x) { return ['value' => $x]; }, $val), ['value']);
}
break;
}
return $val;
} | [
"public",
"function",
"resolve",
"(",
"$",
"sym",
",",
"$",
"type",
"=",
"Symbol",
"::",
"T_NULL",
")",
"{",
"$",
"val",
"=",
"$",
"sym",
";",
"if",
"(",
"$",
"sym",
"instanceof",
"\\",
"ECL",
"\\",
"Symbol",
")",
"{",
"$",
"val",
"=",
"$",
"this",
"->",
"offsetGet",
"(",
"$",
"sym",
"->",
"getName",
"(",
")",
")",
";",
"if",
"(",
"$",
"type",
"==",
"Symbol",
"::",
"T_NULL",
")",
"{",
"$",
"type",
"=",
"$",
"sym",
"->",
"getType",
"(",
")",
";",
"}",
"}",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"Symbol",
"::",
"T_INT",
":",
"$",
"val",
"=",
"(",
"int",
")",
"$",
"val",
";",
"break",
";",
"case",
"Symbol",
"::",
"T_FLOAT",
":",
"$",
"val",
"=",
"(",
"double",
")",
"$",
"val",
";",
"break",
";",
"case",
"Symbol",
"::",
"T_STR",
":",
"$",
"val",
"=",
"(",
"string",
")",
"$",
"val",
";",
"break",
";",
"case",
"Symbol",
"::",
"T_LIST",
":",
"if",
"(",
"!",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"val",
"instanceof",
"\\",
"ECL",
"\\",
"ResultSet",
")",
")",
"{",
"throw",
"new",
"WrongTypeException",
"(",
"$",
"sym",
"->",
"getName",
"(",
")",
")",
";",
"}",
"$",
"val",
"=",
"array_unique",
"(",
"\\",
"ECL",
"\\",
"Util",
"::",
"pluck",
"(",
"$",
"val",
"->",
"getAll",
"(",
")",
",",
"$",
"sym",
"->",
"getPath",
"(",
")",
")",
")",
";",
"}",
"break",
";",
"case",
"Symbol",
"::",
"T_RES",
":",
"if",
"(",
"!",
"is_array",
"(",
"$",
"val",
")",
")",
"{",
"if",
"(",
"!",
"(",
"$",
"val",
"instanceof",
"\\",
"ECL",
"\\",
"ResultSet",
")",
")",
"{",
"throw",
"new",
"WrongTypeException",
"(",
"$",
"sym",
"->",
"getName",
"(",
")",
")",
";",
"}",
"}",
"else",
"{",
"$",
"val",
"=",
"new",
"\\",
"ECL",
"\\",
"ResultSet",
"(",
"array_map",
"(",
"function",
"(",
"$",
"x",
")",
"{",
"return",
"[",
"'value'",
"=>",
"$",
"x",
"]",
";",
"}",
",",
"$",
"val",
")",
",",
"[",
"'value'",
"]",
")",
";",
"}",
"break",
";",
"}",
"return",
"$",
"val",
";",
"}"
]
| Check if the input is a Symbol and resolve it if so.
@param Symbol|mixed $sym A symbol object or builtin type.
@param int $type Data type.
@return mixed A resolved symbol or the passed in data. | [
"Check",
"if",
"the",
"input",
"is",
"a",
"Symbol",
"and",
"resolve",
"it",
"if",
"so",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/SymbolTable.php#L23-L62 |
14,933 | kiwiz/ecl | src/SymbolTable.php | SymbolTable.offsetSet | public function offsetSet($key, $value) {
if(!$this->offsetExists($key)) {
$this->table[$key] = new Value($value);
} else {
$this->table[$key]->setValue($value);
}
} | php | public function offsetSet($key, $value) {
if(!$this->offsetExists($key)) {
$this->table[$key] = new Value($value);
} else {
$this->table[$key]->setValue($value);
}
} | [
"public",
"function",
"offsetSet",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"key",
")",
")",
"{",
"$",
"this",
"->",
"table",
"[",
"$",
"key",
"]",
"=",
"new",
"Value",
"(",
"$",
"value",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"table",
"[",
"$",
"key",
"]",
"->",
"setValue",
"(",
"$",
"value",
")",
";",
"}",
"}"
]
| Set the value for a symbol.
@param string $key Symbol name.
@param Value $value Symbol value. | [
"Set",
"the",
"value",
"for",
"a",
"symbol",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/SymbolTable.php#L80-L86 |
14,934 | tonicospinelli/class-generation | src/ClassGeneration/Method.php | Method.toStringFunction | protected function toStringFunction()
{
$string = ($this->isFinal() ? 'final ' : '')
. ($this->isAbstract() ? 'abstract ' : '')
. $this->getVisibility() . ' '
. ($this->isStatic() ? 'static ' : '')
. 'function ';
return $string;
} | php | protected function toStringFunction()
{
$string = ($this->isFinal() ? 'final ' : '')
. ($this->isAbstract() ? 'abstract ' : '')
. $this->getVisibility() . ' '
. ($this->isStatic() ? 'static ' : '')
. 'function ';
return $string;
} | [
"protected",
"function",
"toStringFunction",
"(",
")",
"{",
"$",
"string",
"=",
"(",
"$",
"this",
"->",
"isFinal",
"(",
")",
"?",
"'final '",
":",
"''",
")",
".",
"(",
"$",
"this",
"->",
"isAbstract",
"(",
")",
"?",
"'abstract '",
":",
"''",
")",
".",
"$",
"this",
"->",
"getVisibility",
"(",
")",
".",
"' '",
".",
"(",
"$",
"this",
"->",
"isStatic",
"(",
")",
"?",
"'static '",
":",
"''",
")",
".",
"'function '",
";",
"return",
"$",
"string",
";",
"}"
]
| Get string with method type.
@return string | [
"Get",
"string",
"with",
"method",
"type",
"."
]
| eee63bdb68c066b25b885b57b23656e809381a76 | https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Method.php#L379-L388 |
14,935 | tonicospinelli/class-generation | src/ClassGeneration/Method.php | Method.toStringCode | public function toStringCode()
{
if (!$this->isInterface() && !$this->isAbstract()) {
$tabulationFormatted = $this->getTabulationFormatted();
$code = PHP_EOL . $tabulationFormatted
. '{'
. $this->codeToString()
. $tabulationFormatted
. '}';
return $code;
}
return ';';
} | php | public function toStringCode()
{
if (!$this->isInterface() && !$this->isAbstract()) {
$tabulationFormatted = $this->getTabulationFormatted();
$code = PHP_EOL . $tabulationFormatted
. '{'
. $this->codeToString()
. $tabulationFormatted
. '}';
return $code;
}
return ';';
} | [
"public",
"function",
"toStringCode",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"isInterface",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"isAbstract",
"(",
")",
")",
"{",
"$",
"tabulationFormatted",
"=",
"$",
"this",
"->",
"getTabulationFormatted",
"(",
")",
";",
"$",
"code",
"=",
"PHP_EOL",
".",
"$",
"tabulationFormatted",
".",
"'{'",
".",
"$",
"this",
"->",
"codeToString",
"(",
")",
".",
"$",
"tabulationFormatted",
".",
"'}'",
";",
"return",
"$",
"code",
";",
"}",
"return",
"';'",
";",
"}"
]
| Get string code.
@return string | [
"Get",
"string",
"code",
"."
]
| eee63bdb68c066b25b885b57b23656e809381a76 | https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Method.php#L394-L408 |
14,936 | tonicospinelli/class-generation | src/ClassGeneration/Method.php | Method.createGetterFromProperty | public static function createGetterFromProperty(PropertyInterface $property)
{
$method = new self();
$method->setName('get_' . $property->getName());
$method->setCode('return $this->' . $property->getName() . ';');
return $method;
} | php | public static function createGetterFromProperty(PropertyInterface $property)
{
$method = new self();
$method->setName('get_' . $property->getName());
$method->setCode('return $this->' . $property->getName() . ';');
return $method;
} | [
"public",
"static",
"function",
"createGetterFromProperty",
"(",
"PropertyInterface",
"$",
"property",
")",
"{",
"$",
"method",
"=",
"new",
"self",
"(",
")",
";",
"$",
"method",
"->",
"setName",
"(",
"'get_'",
".",
"$",
"property",
"->",
"getName",
"(",
")",
")",
";",
"$",
"method",
"->",
"setCode",
"(",
"'return $this->'",
".",
"$",
"property",
"->",
"getName",
"(",
")",
".",
"';'",
")",
";",
"return",
"$",
"method",
";",
"}"
]
| Create a Get Method from Property of Class.
@param PropertyInterface $property
@return Method | [
"Create",
"a",
"Get",
"Method",
"from",
"Property",
"of",
"Class",
"."
]
| eee63bdb68c066b25b885b57b23656e809381a76 | https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Method.php#L417-L424 |
14,937 | tonicospinelli/class-generation | src/ClassGeneration/Method.php | Method.createSetterFromProperty | public static function createSetterFromProperty(PropertyInterface $property)
{
$argument = Argument::createFromProperty($property);
$code = "\$this->{$property->getName()} = {$argument->getNameFormatted()};"
. PHP_EOL
. 'return $this;';
$method = new self;
$method
->setName('set_' . $property->getName())
->setCode($code)
->getArgumentCollection()->add($argument);
return $method;
} | php | public static function createSetterFromProperty(PropertyInterface $property)
{
$argument = Argument::createFromProperty($property);
$code = "\$this->{$property->getName()} = {$argument->getNameFormatted()};"
. PHP_EOL
. 'return $this;';
$method = new self;
$method
->setName('set_' . $property->getName())
->setCode($code)
->getArgumentCollection()->add($argument);
return $method;
} | [
"public",
"static",
"function",
"createSetterFromProperty",
"(",
"PropertyInterface",
"$",
"property",
")",
"{",
"$",
"argument",
"=",
"Argument",
"::",
"createFromProperty",
"(",
"$",
"property",
")",
";",
"$",
"code",
"=",
"\"\\$this->{$property->getName()} = {$argument->getNameFormatted()};\"",
".",
"PHP_EOL",
".",
"'return $this;'",
";",
"$",
"method",
"=",
"new",
"self",
";",
"$",
"method",
"->",
"setName",
"(",
"'set_'",
".",
"$",
"property",
"->",
"getName",
"(",
")",
")",
"->",
"setCode",
"(",
"$",
"code",
")",
"->",
"getArgumentCollection",
"(",
")",
"->",
"add",
"(",
"$",
"argument",
")",
";",
"return",
"$",
"method",
";",
"}"
]
| Generate Set Method from Property.
Add a set method in the class based on Object Property.
@param PropertyInterface $property
@return Method | [
"Generate",
"Set",
"Method",
"from",
"Property",
".",
"Add",
"a",
"set",
"method",
"in",
"the",
"class",
"based",
"on",
"Object",
"Property",
"."
]
| eee63bdb68c066b25b885b57b23656e809381a76 | https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Method.php#L434-L449 |
14,938 | tonicospinelli/class-generation | src/ClassGeneration/Method.php | Method.createFromReflection | public static function createFromReflection(\ReflectionMethod $reflected)
{
$method = new self();
$method->setName($reflected->getName());
foreach ($reflected->getParameters() as $parameterReflected) {
$argument = new Argument();
$argument->setName($parameterReflected->getName());
$method->addArgument($argument);
}
return $method;
} | php | public static function createFromReflection(\ReflectionMethod $reflected)
{
$method = new self();
$method->setName($reflected->getName());
foreach ($reflected->getParameters() as $parameterReflected) {
$argument = new Argument();
$argument->setName($parameterReflected->getName());
$method->addArgument($argument);
}
return $method;
} | [
"public",
"static",
"function",
"createFromReflection",
"(",
"\\",
"ReflectionMethod",
"$",
"reflected",
")",
"{",
"$",
"method",
"=",
"new",
"self",
"(",
")",
";",
"$",
"method",
"->",
"setName",
"(",
"$",
"reflected",
"->",
"getName",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"reflected",
"->",
"getParameters",
"(",
")",
"as",
"$",
"parameterReflected",
")",
"{",
"$",
"argument",
"=",
"new",
"Argument",
"(",
")",
";",
"$",
"argument",
"->",
"setName",
"(",
"$",
"parameterReflected",
"->",
"getName",
"(",
")",
")",
";",
"$",
"method",
"->",
"addArgument",
"(",
"$",
"argument",
")",
";",
"}",
"return",
"$",
"method",
";",
"}"
]
| Creates a method from Reflection Method.
@param \ReflectionMethod $reflected
@return Method | [
"Creates",
"a",
"method",
"from",
"Reflection",
"Method",
"."
]
| eee63bdb68c066b25b885b57b23656e809381a76 | https://github.com/tonicospinelli/class-generation/blob/eee63bdb68c066b25b885b57b23656e809381a76/src/ClassGeneration/Method.php#L458-L470 |
14,939 | discophp/framework | core/classes/Queue.class.php | Queue.push | public function push($job, $delay = 0, $vars = null){
if($vars==null){
$vars='disco-no-variable';
}//if
else {
$vars = base64_encode(serialize($vars));
}//el
$domain = \App::domain();
if($job instanceof \Closure){
$obj = new \Jeremeamia\SuperClosure\SerializableClosure($job);
$method = 'closure';
}//if
else if(stripos($job, '@') !== false){
$obj = explode('@', $job);
$method = $obj[1];
$obj = $obj[0];
}//elif
else {
$obj = $job;
$method = 'work';
}//el
$obj = base64_encode(serialize($obj));
$command = "php %1\$s/public/index.php resolve %2\$s '%3\$s' '%4\$s' %5\$s %6\$s > /dev/null 2>/dev/null &";
$command = sprintf($command,
\App::path(),
$delay,
$obj,
$method,
$vars,
$domain
);
exec($command);
} | php | public function push($job, $delay = 0, $vars = null){
if($vars==null){
$vars='disco-no-variable';
}//if
else {
$vars = base64_encode(serialize($vars));
}//el
$domain = \App::domain();
if($job instanceof \Closure){
$obj = new \Jeremeamia\SuperClosure\SerializableClosure($job);
$method = 'closure';
}//if
else if(stripos($job, '@') !== false){
$obj = explode('@', $job);
$method = $obj[1];
$obj = $obj[0];
}//elif
else {
$obj = $job;
$method = 'work';
}//el
$obj = base64_encode(serialize($obj));
$command = "php %1\$s/public/index.php resolve %2\$s '%3\$s' '%4\$s' %5\$s %6\$s > /dev/null 2>/dev/null &";
$command = sprintf($command,
\App::path(),
$delay,
$obj,
$method,
$vars,
$domain
);
exec($command);
} | [
"public",
"function",
"push",
"(",
"$",
"job",
",",
"$",
"delay",
"=",
"0",
",",
"$",
"vars",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"vars",
"==",
"null",
")",
"{",
"$",
"vars",
"=",
"'disco-no-variable'",
";",
"}",
"//if",
"else",
"{",
"$",
"vars",
"=",
"base64_encode",
"(",
"serialize",
"(",
"$",
"vars",
")",
")",
";",
"}",
"//el",
"$",
"domain",
"=",
"\\",
"App",
"::",
"domain",
"(",
")",
";",
"if",
"(",
"$",
"job",
"instanceof",
"\\",
"Closure",
")",
"{",
"$",
"obj",
"=",
"new",
"\\",
"Jeremeamia",
"\\",
"SuperClosure",
"\\",
"SerializableClosure",
"(",
"$",
"job",
")",
";",
"$",
"method",
"=",
"'closure'",
";",
"}",
"//if",
"else",
"if",
"(",
"stripos",
"(",
"$",
"job",
",",
"'@'",
")",
"!==",
"false",
")",
"{",
"$",
"obj",
"=",
"explode",
"(",
"'@'",
",",
"$",
"job",
")",
";",
"$",
"method",
"=",
"$",
"obj",
"[",
"1",
"]",
";",
"$",
"obj",
"=",
"$",
"obj",
"[",
"0",
"]",
";",
"}",
"//elif",
"else",
"{",
"$",
"obj",
"=",
"$",
"job",
";",
"$",
"method",
"=",
"'work'",
";",
"}",
"//el",
"$",
"obj",
"=",
"base64_encode",
"(",
"serialize",
"(",
"$",
"obj",
")",
")",
";",
"$",
"command",
"=",
"\"php %1\\$s/public/index.php resolve %2\\$s '%3\\$s' '%4\\$s' %5\\$s %6\\$s > /dev/null 2>/dev/null &\"",
";",
"$",
"command",
"=",
"sprintf",
"(",
"$",
"command",
",",
"\\",
"App",
"::",
"path",
"(",
")",
",",
"$",
"delay",
",",
"$",
"obj",
",",
"$",
"method",
",",
"$",
"vars",
",",
"$",
"domain",
")",
";",
"exec",
"(",
"$",
"command",
")",
";",
"}"
]
| Push a job onto the Queue for processing.
@param \Closure|string $job Either a `\Closure` to execute or a Class method pair like `DB@query`.
@param int $delay The delay to wait before beginning execution of the `$job`.
@param null|string|array $vars The variables to pass to the `$job`.
@return void | [
"Push",
"a",
"job",
"onto",
"the",
"Queue",
"for",
"processing",
"."
]
| 40ff3ea5225810534195494dc6c21083da4d1356 | https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Queue.class.php#L26-L66 |
14,940 | discophp/framework | core/classes/Queue.class.php | Queue.killJob | public function killJob($pId){
$j = $this->jobs();
global $argv;
foreach($j as $job){
if($job->pId == $pId){
exec('kill ' . $job->pId);
if($argv[1] == 'kill-job'){
echo 'Killed Job # ' . $job->pId . ' Action:' . $job->object . '@' . $job->method . PHP_EOL;
}//if
return true;
}//if
}//foreach
if($argv[1] == 'kill-job'){
echo 'No Job # ' . $pId . PHP_EOL;
}//if
return false;
} | php | public function killJob($pId){
$j = $this->jobs();
global $argv;
foreach($j as $job){
if($job->pId == $pId){
exec('kill ' . $job->pId);
if($argv[1] == 'kill-job'){
echo 'Killed Job # ' . $job->pId . ' Action:' . $job->object . '@' . $job->method . PHP_EOL;
}//if
return true;
}//if
}//foreach
if($argv[1] == 'kill-job'){
echo 'No Job # ' . $pId . PHP_EOL;
}//if
return false;
} | [
"public",
"function",
"killJob",
"(",
"$",
"pId",
")",
"{",
"$",
"j",
"=",
"$",
"this",
"->",
"jobs",
"(",
")",
";",
"global",
"$",
"argv",
";",
"foreach",
"(",
"$",
"j",
"as",
"$",
"job",
")",
"{",
"if",
"(",
"$",
"job",
"->",
"pId",
"==",
"$",
"pId",
")",
"{",
"exec",
"(",
"'kill '",
".",
"$",
"job",
"->",
"pId",
")",
";",
"if",
"(",
"$",
"argv",
"[",
"1",
"]",
"==",
"'kill-job'",
")",
"{",
"echo",
"'Killed Job # '",
".",
"$",
"job",
"->",
"pId",
".",
"' Action:'",
".",
"$",
"job",
"->",
"object",
".",
"'@'",
".",
"$",
"job",
"->",
"method",
".",
"PHP_EOL",
";",
"}",
"//if",
"return",
"true",
";",
"}",
"//if",
"}",
"//foreach",
"if",
"(",
"$",
"argv",
"[",
"1",
"]",
"==",
"'kill-job'",
")",
"{",
"echo",
"'No Job # '",
".",
"$",
"pId",
".",
"PHP_EOL",
";",
"}",
"//if",
"return",
"false",
";",
"}"
]
| Kill a Queued job by passing its process ID number
@param integer $pId The jobs process ID.
@return boolean Whether or not the job was killed. | [
"Kill",
"a",
"Queued",
"job",
"by",
"passing",
"its",
"process",
"ID",
"number"
]
| 40ff3ea5225810534195494dc6c21083da4d1356 | https://github.com/discophp/framework/blob/40ff3ea5225810534195494dc6c21083da4d1356/core/classes/Queue.class.php#L123-L145 |
14,941 | FrenchFrogs/framework | src/Core/Validator.php | Validator.addValidator | public function addValidator($index, $method = null, array $params = [], $message = null)
{
// set up params
array_unshift($params, $method);
array_unshift($params, $index);
call_user_func_array([$this->getValidator(), 'addRule'], $params);
// Message management
if (!is_null($message)) {
$this->getValidator()->addMessage($index, $message);
}
return $this;
} | php | public function addValidator($index, $method = null, array $params = [], $message = null)
{
// set up params
array_unshift($params, $method);
array_unshift($params, $index);
call_user_func_array([$this->getValidator(), 'addRule'], $params);
// Message management
if (!is_null($message)) {
$this->getValidator()->addMessage($index, $message);
}
return $this;
} | [
"public",
"function",
"addValidator",
"(",
"$",
"index",
",",
"$",
"method",
"=",
"null",
",",
"array",
"$",
"params",
"=",
"[",
"]",
",",
"$",
"message",
"=",
"null",
")",
"{",
"// set up params",
"array_unshift",
"(",
"$",
"params",
",",
"$",
"method",
")",
";",
"array_unshift",
"(",
"$",
"params",
",",
"$",
"index",
")",
";",
"call_user_func_array",
"(",
"[",
"$",
"this",
"->",
"getValidator",
"(",
")",
",",
"'addRule'",
"]",
",",
"$",
"params",
")",
";",
"// Message management",
"if",
"(",
"!",
"is_null",
"(",
"$",
"message",
")",
")",
"{",
"$",
"this",
"->",
"getValidator",
"(",
")",
"->",
"addMessage",
"(",
"$",
"index",
",",
"$",
"message",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Add a single validator with message to the validator container
@param $index
@param null $method
@param array $params
@param null $message
@return $this | [
"Add",
"a",
"single",
"validator",
"with",
"message",
"to",
"the",
"validator",
"container"
]
| a4838c698a5600437e87dac6d35ba8ebe32c4395 | https://github.com/FrenchFrogs/framework/blob/a4838c698a5600437e87dac6d35ba8ebe32c4395/src/Core/Validator.php#L63-L77 |
14,942 | digiaonline/json-helpers | src/JsonDecoder.php | JsonDecoder.decode | public static function decode(string $data, bool $assoc = false, int $depth = 512, int $options = 0)
{
$json = json_decode($data, $assoc, $depth, $options);
$jsonLastError = json_last_error();
if ($jsonLastError !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException('Failed to decode JSON: ' . json_last_error_msg(), $jsonLastError);
}
return $json;
} | php | public static function decode(string $data, bool $assoc = false, int $depth = 512, int $options = 0)
{
$json = json_decode($data, $assoc, $depth, $options);
$jsonLastError = json_last_error();
if ($jsonLastError !== JSON_ERROR_NONE) {
throw new \InvalidArgumentException('Failed to decode JSON: ' . json_last_error_msg(), $jsonLastError);
}
return $json;
} | [
"public",
"static",
"function",
"decode",
"(",
"string",
"$",
"data",
",",
"bool",
"$",
"assoc",
"=",
"false",
",",
"int",
"$",
"depth",
"=",
"512",
",",
"int",
"$",
"options",
"=",
"0",
")",
"{",
"$",
"json",
"=",
"json_decode",
"(",
"$",
"data",
",",
"$",
"assoc",
",",
"$",
"depth",
",",
"$",
"options",
")",
";",
"$",
"jsonLastError",
"=",
"json_last_error",
"(",
")",
";",
"if",
"(",
"$",
"jsonLastError",
"!==",
"JSON_ERROR_NONE",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Failed to decode JSON: '",
".",
"json_last_error_msg",
"(",
")",
",",
"$",
"jsonLastError",
")",
";",
"}",
"return",
"$",
"json",
";",
"}"
]
| Decodes the specified JSON into an object
@param string $data
@param bool $assoc
@param int $depth
@param int $options
@return mixed
@throws \InvalidArgumentException | [
"Decodes",
"the",
"specified",
"JSON",
"into",
"an",
"object"
]
| 596dfca3fb85fba026cc0a498fbcefbda6377a15 | https://github.com/digiaonline/json-helpers/blob/596dfca3fb85fba026cc0a498fbcefbda6377a15/src/JsonDecoder.php#L25-L35 |
14,943 | jasny/router | src/Router.php | Router.add | public function add($path, $middleware = null)
{
if (!isset($middleware)) {
$middleware = $path;
$path = null;
}
if (!empty($path) && !ctype_digit($path) && $path[0] !== '/') {
trigger_error("Middleware path '$path' doesn't start with a '/'", E_USER_NOTICE);
}
if (!is_callable($middleware)) {
throw new \InvalidArgumentException("Middleware should be callable");
}
if (!empty($path)) {
$middleware = $this->wrapMiddleware($path, $middleware);
}
$this->middlewares[] = $middleware;
return $this;
} | php | public function add($path, $middleware = null)
{
if (!isset($middleware)) {
$middleware = $path;
$path = null;
}
if (!empty($path) && !ctype_digit($path) && $path[0] !== '/') {
trigger_error("Middleware path '$path' doesn't start with a '/'", E_USER_NOTICE);
}
if (!is_callable($middleware)) {
throw new \InvalidArgumentException("Middleware should be callable");
}
if (!empty($path)) {
$middleware = $this->wrapMiddleware($path, $middleware);
}
$this->middlewares[] = $middleware;
return $this;
} | [
"public",
"function",
"add",
"(",
"$",
"path",
",",
"$",
"middleware",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"middleware",
")",
")",
"{",
"$",
"middleware",
"=",
"$",
"path",
";",
"$",
"path",
"=",
"null",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
"&&",
"!",
"ctype_digit",
"(",
"$",
"path",
")",
"&&",
"$",
"path",
"[",
"0",
"]",
"!==",
"'/'",
")",
"{",
"trigger_error",
"(",
"\"Middleware path '$path' doesn't start with a '/'\"",
",",
"E_USER_NOTICE",
")",
";",
"}",
"if",
"(",
"!",
"is_callable",
"(",
"$",
"middleware",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Middleware should be callable\"",
")",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"path",
")",
")",
"{",
"$",
"middleware",
"=",
"$",
"this",
"->",
"wrapMiddleware",
"(",
"$",
"path",
",",
"$",
"middleware",
")",
";",
"}",
"$",
"this",
"->",
"middlewares",
"[",
"]",
"=",
"$",
"middleware",
";",
"return",
"$",
"this",
";",
"}"
]
| Add middleware call to router.
@param string $path Middleware is only applied for this path (including subdirectories), may be omitted
@param callable $middleware
@return Router $this | [
"Add",
"middleware",
"call",
"to",
"router",
"."
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router.php#L104-L126 |
14,944 | jasny/router | src/Router.php | Router.wrapMiddleware | protected function wrapMiddleware($path, $middleware)
{
return function(
ServerRequestInterface $request,
ResponseInterface $response,
$next
) use ($middleware, $path) {
$uriPath = $request->getUri()->getPath();
if ($uriPath === $path || strpos($uriPath, rtrim($path, '/') . '/') === 0) {
$ret = $middleware($request, $response, $next);
} else {
$ret = $next($request, $response);
}
return $ret;
};
} | php | protected function wrapMiddleware($path, $middleware)
{
return function(
ServerRequestInterface $request,
ResponseInterface $response,
$next
) use ($middleware, $path) {
$uriPath = $request->getUri()->getPath();
if ($uriPath === $path || strpos($uriPath, rtrim($path, '/') . '/') === 0) {
$ret = $middleware($request, $response, $next);
} else {
$ret = $next($request, $response);
}
return $ret;
};
} | [
"protected",
"function",
"wrapMiddleware",
"(",
"$",
"path",
",",
"$",
"middleware",
")",
"{",
"return",
"function",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"$",
"next",
")",
"use",
"(",
"$",
"middleware",
",",
"$",
"path",
")",
"{",
"$",
"uriPath",
"=",
"$",
"request",
"->",
"getUri",
"(",
")",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"$",
"uriPath",
"===",
"$",
"path",
"||",
"strpos",
"(",
"$",
"uriPath",
",",
"rtrim",
"(",
"$",
"path",
",",
"'/'",
")",
".",
"'/'",
")",
"===",
"0",
")",
"{",
"$",
"ret",
"=",
"$",
"middleware",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"next",
")",
";",
"}",
"else",
"{",
"$",
"ret",
"=",
"$",
"next",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"return",
"$",
"ret",
";",
"}",
";",
"}"
]
| Wrap middleware, so it's only applied to a specified path
@param string $path
@param callable $middleware
@return callable | [
"Wrap",
"middleware",
"so",
"it",
"s",
"only",
"applied",
"to",
"a",
"specified",
"path"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router.php#L135-L152 |
14,945 | jasny/router | src/Router.php | Router.run | public function run(ServerRequestInterface $request, ResponseInterface $response, $next = null)
{
if (!$request->getAttribute('route') instanceof Route) {
$route = $this->routes->getRoute($request);
if (!$route) {
return $this->notFound($request, $response);
}
$request = $request->withAttribute('route', $route);
}
$runner = $this->getRunner();
return $runner($request, $response, $next);
} | php | public function run(ServerRequestInterface $request, ResponseInterface $response, $next = null)
{
if (!$request->getAttribute('route') instanceof Route) {
$route = $this->routes->getRoute($request);
if (!$route) {
return $this->notFound($request, $response);
}
$request = $request->withAttribute('route', $route);
}
$runner = $this->getRunner();
return $runner($request, $response, $next);
} | [
"public",
"function",
"run",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
",",
"$",
"next",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"$",
"request",
"->",
"getAttribute",
"(",
"'route'",
")",
"instanceof",
"Route",
")",
"{",
"$",
"route",
"=",
"$",
"this",
"->",
"routes",
"->",
"getRoute",
"(",
"$",
"request",
")",
";",
"if",
"(",
"!",
"$",
"route",
")",
"{",
"return",
"$",
"this",
"->",
"notFound",
"(",
"$",
"request",
",",
"$",
"response",
")",
";",
"}",
"$",
"request",
"=",
"$",
"request",
"->",
"withAttribute",
"(",
"'route'",
",",
"$",
"route",
")",
";",
"}",
"$",
"runner",
"=",
"$",
"this",
"->",
"getRunner",
"(",
")",
";",
"return",
"$",
"runner",
"(",
"$",
"request",
",",
"$",
"response",
",",
"$",
"next",
")",
";",
"}"
]
| Run the action.
This method doesn't call the middlewares, but only run the action.
@param ServerRequestInterface $request
@param ResponseInterface $response
@param callback $next
@return ResponseInterface | [
"Run",
"the",
"action",
".",
"This",
"method",
"doesn",
"t",
"call",
"the",
"middlewares",
"but",
"only",
"run",
"the",
"action",
"."
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router.php#L202-L217 |
14,946 | jasny/router | src/Router.php | Router.notFound | protected function notFound(ServerRequestInterface $request, ResponseInterface $response)
{
$notFound = $response
->withProtocolVersion($request->getProtocolVersion())
->withStatus(404);
$notFound->getBody()->write('Not Found');
return $notFound;
} | php | protected function notFound(ServerRequestInterface $request, ResponseInterface $response)
{
$notFound = $response
->withProtocolVersion($request->getProtocolVersion())
->withStatus(404);
$notFound->getBody()->write('Not Found');
return $notFound;
} | [
"protected",
"function",
"notFound",
"(",
"ServerRequestInterface",
"$",
"request",
",",
"ResponseInterface",
"$",
"response",
")",
"{",
"$",
"notFound",
"=",
"$",
"response",
"->",
"withProtocolVersion",
"(",
"$",
"request",
"->",
"getProtocolVersion",
"(",
")",
")",
"->",
"withStatus",
"(",
"404",
")",
";",
"$",
"notFound",
"->",
"getBody",
"(",
")",
"->",
"write",
"(",
"'Not Found'",
")",
";",
"return",
"$",
"notFound",
";",
"}"
]
| Return 'Not Found' response
@param ServerRequestInterface $request
@param ResponseInterface $response
@return ResponseInterface | [
"Return",
"Not",
"Found",
"response"
]
| 4c776665ba343150b442c21893946e3d54190896 | https://github.com/jasny/router/blob/4c776665ba343150b442c21893946e3d54190896/src/Router.php#L226-L235 |
14,947 | puli/discovery | src/Api/Type/NoSuchParameterException.php | NoSuchParameterException.forParameterName | public static function forParameterName($parameterName, $typeName, Exception $cause = null)
{
return new static(sprintf(
'The parameter "%s" does not exist for type "%s".',
$parameterName,
$typeName
), 0, $cause);
} | php | public static function forParameterName($parameterName, $typeName, Exception $cause = null)
{
return new static(sprintf(
'The parameter "%s" does not exist for type "%s".',
$parameterName,
$typeName
), 0, $cause);
} | [
"public",
"static",
"function",
"forParameterName",
"(",
"$",
"parameterName",
",",
"$",
"typeName",
",",
"Exception",
"$",
"cause",
"=",
"null",
")",
"{",
"return",
"new",
"static",
"(",
"sprintf",
"(",
"'The parameter \"%s\" does not exist for type \"%s\".'",
",",
"$",
"parameterName",
",",
"$",
"typeName",
")",
",",
"0",
",",
"$",
"cause",
")",
";",
"}"
]
| Creates a new exception for the given parameter name.
@param string $parameterName The name of the parameter that was
not found.
@param string $typeName The name of the type that the
parameter was searched on.
@param Exception|null $cause The exception that caused this
exception.
@return static The created exception. | [
"Creates",
"a",
"new",
"exception",
"for",
"the",
"given",
"parameter",
"name",
"."
]
| 975f5e099563f1096bfabc17fbe4d1816408ad98 | https://github.com/puli/discovery/blob/975f5e099563f1096bfabc17fbe4d1816408ad98/src/Api/Type/NoSuchParameterException.php#L38-L45 |
14,948 | harp-orm/query | src/Compiler/Condition.php | Condition.combine | public static function combine($conditions)
{
return Arr::join(' AND ', Arr::map(function ($condition) {
return "(".Condition::render($condition).")";
}, $conditions));
} | php | public static function combine($conditions)
{
return Arr::join(' AND ', Arr::map(function ($condition) {
return "(".Condition::render($condition).")";
}, $conditions));
} | [
"public",
"static",
"function",
"combine",
"(",
"$",
"conditions",
")",
"{",
"return",
"Arr",
"::",
"join",
"(",
"' AND '",
",",
"Arr",
"::",
"map",
"(",
"function",
"(",
"$",
"condition",
")",
"{",
"return",
"\"(\"",
".",
"Condition",
"::",
"render",
"(",
"$",
"condition",
")",
".",
"\")\"",
";",
"}",
",",
"$",
"conditions",
")",
")",
";",
"}"
]
| Render multiple Condition objects
@param SQL\Condition[]|null $conditions
@return string|null | [
"Render",
"multiple",
"Condition",
"objects"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Condition.php#L21-L26 |
14,949 | harp-orm/query | src/Compiler/Condition.php | Condition.render | public static function render(SQL\Condition $condition)
{
$content = $condition->getContent();
$parameters = $condition->getParameters();
if ($parameters and is_string($content)) {
$content = self::expandParameterArrays($content, $parameters);
}
return Compiler::expression(array(
Compiler::name($condition->getColumn()),
$content
));
} | php | public static function render(SQL\Condition $condition)
{
$content = $condition->getContent();
$parameters = $condition->getParameters();
if ($parameters and is_string($content)) {
$content = self::expandParameterArrays($content, $parameters);
}
return Compiler::expression(array(
Compiler::name($condition->getColumn()),
$content
));
} | [
"public",
"static",
"function",
"render",
"(",
"SQL",
"\\",
"Condition",
"$",
"condition",
")",
"{",
"$",
"content",
"=",
"$",
"condition",
"->",
"getContent",
"(",
")",
";",
"$",
"parameters",
"=",
"$",
"condition",
"->",
"getParameters",
"(",
")",
";",
"if",
"(",
"$",
"parameters",
"and",
"is_string",
"(",
"$",
"content",
")",
")",
"{",
"$",
"content",
"=",
"self",
"::",
"expandParameterArrays",
"(",
"$",
"content",
",",
"$",
"parameters",
")",
";",
"}",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"Compiler",
"::",
"name",
"(",
"$",
"condition",
"->",
"getColumn",
"(",
")",
")",
",",
"$",
"content",
")",
")",
";",
"}"
]
| Render a Condition object
@param SQL\Condition $condition
@return string | [
"Render",
"a",
"Condition",
"object"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Condition.php#L34-L47 |
14,950 | axelitus/php-base | src/BigNum.php | BigNum.toInt | public static function toInt($value)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be numeric (or string representing a big number)."
);
}
if (is_int($value)) {
return $value;
} elseif (is_float($value)) {
return (int)$value;
}
if (($decimal = Str::pos($value, '.')) !== false) {
$value = Str::sub($value, 0, (int)$decimal);
}
return $value;
} | php | public static function toInt($value)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be numeric (or string representing a big number)."
);
}
if (is_int($value)) {
return $value;
} elseif (is_float($value)) {
return (int)$value;
}
if (($decimal = Str::pos($value, '.')) !== false) {
$value = Str::sub($value, 0, (int)$decimal);
}
return $value;
} | [
"public",
"static",
"function",
"toInt",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be numeric (or string representing a big number).\"",
")",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
")",
"{",
"return",
"$",
"value",
";",
"}",
"elseif",
"(",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"int",
")",
"$",
"value",
";",
"}",
"if",
"(",
"(",
"$",
"decimal",
"=",
"Str",
"::",
"pos",
"(",
"$",
"value",
",",
"'.'",
")",
")",
"!==",
"false",
")",
"{",
"$",
"value",
"=",
"Str",
"::",
"sub",
"(",
"$",
"value",
",",
"0",
",",
"(",
"int",
")",
"$",
"decimal",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Gets the integer value of the given value.
@param float|string $value The value to get the integer value from.
@return int|string Returns the integer value of the given value.
@throws \InvalidArgumentException | [
"Gets",
"the",
"integer",
"value",
"of",
"the",
"given",
"value",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigNum.php#L56-L75 |
14,951 | axelitus/php-base | src/BigNum.php | BigNum.toFloat | public static function toFloat($value)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be numeric (or string representing a big number)."
);
}
if (is_int($value) || is_float($value)) {
return (float)$value;
} else {
return ((Str::contains($value, '.')) ? $value : $value . '.0');
}
} | php | public static function toFloat($value)
{
if (!static::is($value)) {
throw new \InvalidArgumentException(
"The \$value parameter must be numeric (or string representing a big number)."
);
}
if (is_int($value) || is_float($value)) {
return (float)$value;
} else {
return ((Str::contains($value, '.')) ? $value : $value . '.0');
}
} | [
"public",
"static",
"function",
"toFloat",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$value parameter must be numeric (or string representing a big number).\"",
")",
";",
"}",
"if",
"(",
"is_int",
"(",
"$",
"value",
")",
"||",
"is_float",
"(",
"$",
"value",
")",
")",
"{",
"return",
"(",
"float",
")",
"$",
"value",
";",
"}",
"else",
"{",
"return",
"(",
"(",
"Str",
"::",
"contains",
"(",
"$",
"value",
",",
"'.'",
")",
")",
"?",
"$",
"value",
":",
"$",
"value",
".",
"'.0'",
")",
";",
"}",
"}"
]
| Converts the given number to float.
@param int|float|string $value The value to convert.
@return float|string Returns the value converted to float.
@throws \InvalidArgumentException | [
"Converts",
"the",
"given",
"number",
"to",
"float",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigNum.php#L85-L98 |
14,952 | axelitus/php-base | src/BigNum.php | BigNum.inside | public static function inside($value, $lower, $upper)
{
return static::inRange($value, $lower, $upper, false, false);
} | php | public static function inside($value, $lower, $upper)
{
return static::inRange($value, $lower, $upper, false, false);
} | [
"public",
"static",
"function",
"inside",
"(",
"$",
"value",
",",
"$",
"lower",
",",
"$",
"upper",
")",
"{",
"return",
"static",
"::",
"inRange",
"(",
"$",
"value",
",",
"$",
"lower",
",",
"$",
"upper",
",",
"false",
",",
"false",
")",
";",
"}"
]
| Tests if a number is inside a range.
It's an alias for BigNum::inRange($value, $lower, $upper, false, false)
@param int|float|string $value The value to test in range.
@param int|float|string $lower The range's lower limit.
@param int|float|string $upper The range's upper limit.
@return bool Whether the value is inside the given range.
@see Num::inRange | [
"Tests",
"if",
"a",
"number",
"is",
"inside",
"a",
"range",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigNum.php#L201-L204 |
14,953 | axelitus/php-base | src/BigNum.php | BigNum.between | public static function between($value, $lower, $upper)
{
return static::inRange($value, $lower, $upper, true, true);
} | php | public static function between($value, $lower, $upper)
{
return static::inRange($value, $lower, $upper, true, true);
} | [
"public",
"static",
"function",
"between",
"(",
"$",
"value",
",",
"$",
"lower",
",",
"$",
"upper",
")",
"{",
"return",
"static",
"::",
"inRange",
"(",
"$",
"value",
",",
"$",
"lower",
",",
"$",
"upper",
",",
"true",
",",
"true",
")",
";",
"}"
]
| Tests if a number is between a range.
It's an alias for BigNum::inRange($value, $lower, $upper, true, true)
@param int|float|string $value The value to test in range.
@param int|float|string $lower The range's lower limit.
@param int|float|string $upper The range's upper limit.
@return bool Whether the value is between the given range.
@see Num::inRange | [
"Tests",
"if",
"a",
"number",
"is",
"between",
"a",
"range",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/BigNum.php#L218-L221 |
14,954 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.addResourceString | protected function addResourceString(string $resource): void
{
$data = json_decode($resource, true);
if (json_last_error() !== \JSON_ERROR_NONE) {
if (function_exists('json_last_error_msg')) {
throw new \InvalidArgumentException(json_last_error_msg(), json_last_error());
}
throw new \InvalidArgumentException("Error parsing JSON.", json_last_error());
}
$this->addResourceArray($data);
} | php | protected function addResourceString(string $resource): void
{
$data = json_decode($resource, true);
if (json_last_error() !== \JSON_ERROR_NONE) {
if (function_exists('json_last_error_msg')) {
throw new \InvalidArgumentException(json_last_error_msg(), json_last_error());
}
throw new \InvalidArgumentException("Error parsing JSON.", json_last_error());
}
$this->addResourceArray($data);
} | [
"protected",
"function",
"addResourceString",
"(",
"string",
"$",
"resource",
")",
":",
"void",
"{",
"$",
"data",
"=",
"json_decode",
"(",
"$",
"resource",
",",
"true",
")",
";",
"if",
"(",
"json_last_error",
"(",
")",
"!==",
"\\",
"JSON_ERROR_NONE",
")",
"{",
"if",
"(",
"function_exists",
"(",
"'json_last_error_msg'",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"json_last_error_msg",
"(",
")",
",",
"json_last_error",
"(",
")",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Error parsing JSON.\"",
",",
"json_last_error",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"addResourceArray",
"(",
"$",
"data",
")",
";",
"}"
]
| Adds a resource represented in a JSON string
@param string $resource The resource as JSON data
@throws \InvalidArgumentException If the resource is not valid JSON | [
"Adds",
"a",
"resource",
"represented",
"in",
"a",
"JSON",
"string"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L72-L83 |
14,955 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.addResourceArray | protected function addResourceArray(array $resource): void
{
foreach ($resource as $locale => $value) {
if ($locale === '@metadata') {
$this->parseMetadata($value);
continue;
}
$this->addSubresource($value, $locale);
}
} | php | protected function addResourceArray(array $resource): void
{
foreach ($resource as $locale => $value) {
if ($locale === '@metadata') {
$this->parseMetadata($value);
continue;
}
$this->addSubresource($value, $locale);
}
} | [
"protected",
"function",
"addResourceArray",
"(",
"array",
"$",
"resource",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"resource",
"as",
"$",
"locale",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"$",
"locale",
"===",
"'@metadata'",
")",
"{",
"$",
"this",
"->",
"parseMetadata",
"(",
"$",
"value",
")",
";",
"continue",
";",
"}",
"$",
"this",
"->",
"addSubresource",
"(",
"$",
"value",
",",
"$",
"locale",
")",
";",
"}",
"}"
]
| Adds a resource array
@param array $resource The resource array | [
"Adds",
"a",
"resource",
"array"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L89-L98 |
14,956 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.addSubresource | public function addSubresource($subresource, string $locale): void
{
if ($subresource instanceof Resource) {
$resource = $subresource;
} elseif (is_string($subresource)) {
$resource = ResourceBuilder::fromFile($subresource, $locale);
} elseif (is_array($subresource)) {
$resource = ResourceBuilder::fromArray($subresource, $locale);
} else {
throw new \InvalidArgumentException('Invalid subresource');
}
if (isset($this->data[$locale])) {
$this->data[$locale]->merge($resource);
} else {
$this->data[$locale] = $resource;
}
} | php | public function addSubresource($subresource, string $locale): void
{
if ($subresource instanceof Resource) {
$resource = $subresource;
} elseif (is_string($subresource)) {
$resource = ResourceBuilder::fromFile($subresource, $locale);
} elseif (is_array($subresource)) {
$resource = ResourceBuilder::fromArray($subresource, $locale);
} else {
throw new \InvalidArgumentException('Invalid subresource');
}
if (isset($this->data[$locale])) {
$this->data[$locale]->merge($resource);
} else {
$this->data[$locale] = $resource;
}
} | [
"public",
"function",
"addSubresource",
"(",
"$",
"subresource",
",",
"string",
"$",
"locale",
")",
":",
"void",
"{",
"if",
"(",
"$",
"subresource",
"instanceof",
"Resource",
")",
"{",
"$",
"resource",
"=",
"$",
"subresource",
";",
"}",
"elseif",
"(",
"is_string",
"(",
"$",
"subresource",
")",
")",
"{",
"$",
"resource",
"=",
"ResourceBuilder",
"::",
"fromFile",
"(",
"$",
"subresource",
",",
"$",
"locale",
")",
";",
"}",
"elseif",
"(",
"is_array",
"(",
"$",
"subresource",
")",
")",
"{",
"$",
"resource",
"=",
"ResourceBuilder",
"::",
"fromArray",
"(",
"$",
"subresource",
",",
"$",
"locale",
")",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Invalid subresource'",
")",
";",
"}",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"locale",
"]",
")",
")",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"locale",
"]",
"->",
"merge",
"(",
"$",
"resource",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"data",
"[",
"$",
"locale",
"]",
"=",
"$",
"resource",
";",
"}",
"}"
]
| Adds a sub-resource
@param mixed $subresource The sub-resource value
@param string $locale | [
"Adds",
"a",
"sub",
"-",
"resource"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L105-L122 |
14,957 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.parseMetadata | protected function parseMetadata(array $metadata): void
{
if (isset($metadata['arrayGroups'])) {
foreach ($metadata['arrayGroups'] as $name => $values) {
if (!isset($this->arrayGroups[$name])) {
$this->arrayGroups[$name] = array();
}
foreach ($values as $locale => $keyName) {
$this->arrayGroups[$name][$locale] = $keyName;
}
}
}
} | php | protected function parseMetadata(array $metadata): void
{
if (isset($metadata['arrayGroups'])) {
foreach ($metadata['arrayGroups'] as $name => $values) {
if (!isset($this->arrayGroups[$name])) {
$this->arrayGroups[$name] = array();
}
foreach ($values as $locale => $keyName) {
$this->arrayGroups[$name][$locale] = $keyName;
}
}
}
} | [
"protected",
"function",
"parseMetadata",
"(",
"array",
"$",
"metadata",
")",
":",
"void",
"{",
"if",
"(",
"isset",
"(",
"$",
"metadata",
"[",
"'arrayGroups'",
"]",
")",
")",
"{",
"foreach",
"(",
"$",
"metadata",
"[",
"'arrayGroups'",
"]",
"as",
"$",
"name",
"=>",
"$",
"values",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"name",
"]",
")",
")",
"{",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"name",
"]",
"=",
"array",
"(",
")",
";",
"}",
"foreach",
"(",
"$",
"values",
"as",
"$",
"locale",
"=>",
"$",
"keyName",
")",
"{",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"name",
"]",
"[",
"$",
"locale",
"]",
"=",
"$",
"keyName",
";",
"}",
"}",
"}",
"}"
]
| Parses resource file metadata
@param array $metadata The metadata | [
"Parses",
"resource",
"file",
"metadata"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L128-L141 |
14,958 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.addResourceFile | protected function addResourceFile(string $file): void
{
if (!is_file($file)) {
throw new \InvalidArgumentException("$file is not a file");
}
$contents = file_get_contents($file);
if ($contents === false) {
throw new \RuntimeException("Error reading file at $file.");
}
$this->addResourceString($contents);
} | php | protected function addResourceFile(string $file): void
{
if (!is_file($file)) {
throw new \InvalidArgumentException("$file is not a file");
}
$contents = file_get_contents($file);
if ($contents === false) {
throw new \RuntimeException("Error reading file at $file.");
}
$this->addResourceString($contents);
} | [
"protected",
"function",
"addResourceFile",
"(",
"string",
"$",
"file",
")",
":",
"void",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"file",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"$file is not a file\"",
")",
";",
"}",
"$",
"contents",
"=",
"file_get_contents",
"(",
"$",
"file",
")",
";",
"if",
"(",
"$",
"contents",
"===",
"false",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"\"Error reading file at $file.\"",
")",
";",
"}",
"$",
"this",
"->",
"addResourceString",
"(",
"$",
"contents",
")",
";",
"}"
]
| Adds a resource file
@param string $file The path to the resource file
@throws \InvalidArgumentException If the filename provided is not a file
@throws \RuntimeException If the file could not be read | [
"Adds",
"a",
"resource",
"file"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L149-L162 |
14,959 | RinkAttendant6/JsonI18n | src/Translate.php | Translate._e | public function _e(string $key, ?string $lang = null): void
{
echo $this->__($key, $lang);
} | php | public function _e(string $key, ?string $lang = null): void
{
echo $this->__($key, $lang);
} | [
"public",
"function",
"_e",
"(",
"string",
"$",
"key",
",",
"?",
"string",
"$",
"lang",
"=",
"null",
")",
":",
"void",
"{",
"echo",
"$",
"this",
"->",
"__",
"(",
"$",
"key",
",",
"$",
"lang",
")",
";",
"}"
]
| Prints localized text
@param string $key The key (description) of the localized text
@param string $lang The output language. Default is default language.
@codeCoverageIgnore | [
"Prints",
"localized",
"text"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L219-L222 |
14,960 | RinkAttendant6/JsonI18n | src/Translate.php | Translate._f | public function _f(string $key, $strings, ?string $lang = null): string
{
if ($lang === null) {
$lang = $this->lang;
}
if (!isset($this->data[$lang])) {
throw new \OutOfBoundsException("Invalid language: $lang");
}
if (!isset($this->data[$lang][$key])) {
throw new \OutOfBoundsException("Invalid key: $key");
}
if ($strings === null) {
$strings = '';
}
if (is_string($strings) || is_float($strings) || is_int($strings)) {
return sprintf($this->data[$lang][$key], $strings);
}
if (is_array($strings)) {
return vsprintf($this->data[$lang][$key], $strings);
}
throw new \InvalidArgumentException('Strings must be a string or array to return a formatted localized string.');
} | php | public function _f(string $key, $strings, ?string $lang = null): string
{
if ($lang === null) {
$lang = $this->lang;
}
if (!isset($this->data[$lang])) {
throw new \OutOfBoundsException("Invalid language: $lang");
}
if (!isset($this->data[$lang][$key])) {
throw new \OutOfBoundsException("Invalid key: $key");
}
if ($strings === null) {
$strings = '';
}
if (is_string($strings) || is_float($strings) || is_int($strings)) {
return sprintf($this->data[$lang][$key], $strings);
}
if (is_array($strings)) {
return vsprintf($this->data[$lang][$key], $strings);
}
throw new \InvalidArgumentException('Strings must be a string or array to return a formatted localized string.');
} | [
"public",
"function",
"_f",
"(",
"string",
"$",
"key",
",",
"$",
"strings",
",",
"?",
"string",
"$",
"lang",
"=",
"null",
")",
":",
"string",
"{",
"if",
"(",
"$",
"lang",
"===",
"null",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"lang",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"lang",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"Invalid language: $lang\"",
")",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"lang",
"]",
"[",
"$",
"key",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"Invalid key: $key\"",
")",
";",
"}",
"if",
"(",
"$",
"strings",
"===",
"null",
")",
"{",
"$",
"strings",
"=",
"''",
";",
"}",
"if",
"(",
"is_string",
"(",
"$",
"strings",
")",
"||",
"is_float",
"(",
"$",
"strings",
")",
"||",
"is_int",
"(",
"$",
"strings",
")",
")",
"{",
"return",
"sprintf",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"lang",
"]",
"[",
"$",
"key",
"]",
",",
"$",
"strings",
")",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"strings",
")",
")",
"{",
"return",
"vsprintf",
"(",
"$",
"this",
"->",
"data",
"[",
"$",
"lang",
"]",
"[",
"$",
"key",
"]",
",",
"$",
"strings",
")",
";",
"}",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"'Strings must be a string or array to return a formatted localized string.'",
")",
";",
"}"
]
| Returns "formatted" localized text
@param string $key The key (description) of the localized text
@param string|array $strings See sprintf (string) and vsprintf (array)
@param string $lang The output language. Default is default language.
@return string The "formatted" localized text
@throws \OutOfBoundsException If the language or key is invalid.
@throws \InvalidArgumentException If the formatter strings is not a string or array. | [
"Returns",
"formatted",
"localized",
"text"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L233-L260 |
14,961 | RinkAttendant6/JsonI18n | src/Translate.php | Translate._ef | public function _ef(string $key, $strings, ?string $lang = null): void
{
echo $this->_f($key, $strings, $lang);
} | php | public function _ef(string $key, $strings, ?string $lang = null): void
{
echo $this->_f($key, $strings, $lang);
} | [
"public",
"function",
"_ef",
"(",
"string",
"$",
"key",
",",
"$",
"strings",
",",
"?",
"string",
"$",
"lang",
"=",
"null",
")",
":",
"void",
"{",
"echo",
"$",
"this",
"->",
"_f",
"(",
"$",
"key",
",",
"$",
"strings",
",",
"$",
"lang",
")",
";",
"}"
]
| Prints "formatted" localized text
@param string $key The key (description) of the localized text
@param string|array $strings See sprintf (string) and vsprintf (array)
@param string $lang The output language. Default is default language.
@codeCoverageIgnore | [
"Prints",
"formatted",
"localized",
"text"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L269-L272 |
14,962 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.localizeDeepArray | public function localizeDeepArray(?array $arr, string $group, int $depth = 1, ?string $lang = null): ?array
{
if ($arr === null) {
return null;
}
if ($depth < 0) {
throw new \InvalidArgumentException("Depth must be a non-negative integer, $depth given");
}
if ($depth) {
foreach ($arr as $key => &$value) {
if (!is_array($value)) {
throw new \LengthException("Exceeded depth when localizing deep array");
}
$value = $this->localizeDeepArray($value, $group, $depth - 1, $lang);
}
unset($value);
return $arr;
}
return $this->flatten($arr, $group, $lang);
} | php | public function localizeDeepArray(?array $arr, string $group, int $depth = 1, ?string $lang = null): ?array
{
if ($arr === null) {
return null;
}
if ($depth < 0) {
throw new \InvalidArgumentException("Depth must be a non-negative integer, $depth given");
}
if ($depth) {
foreach ($arr as $key => &$value) {
if (!is_array($value)) {
throw new \LengthException("Exceeded depth when localizing deep array");
}
$value = $this->localizeDeepArray($value, $group, $depth - 1, $lang);
}
unset($value);
return $arr;
}
return $this->flatten($arr, $group, $lang);
} | [
"public",
"function",
"localizeDeepArray",
"(",
"?",
"array",
"$",
"arr",
",",
"string",
"$",
"group",
",",
"int",
"$",
"depth",
"=",
"1",
",",
"?",
"string",
"$",
"lang",
"=",
"null",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"arr",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"depth",
"<",
"0",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Depth must be a non-negative integer, $depth given\"",
")",
";",
"}",
"if",
"(",
"$",
"depth",
")",
"{",
"foreach",
"(",
"$",
"arr",
"as",
"$",
"key",
"=>",
"&",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"throw",
"new",
"\\",
"LengthException",
"(",
"\"Exceeded depth when localizing deep array\"",
")",
";",
"}",
"$",
"value",
"=",
"$",
"this",
"->",
"localizeDeepArray",
"(",
"$",
"value",
",",
"$",
"group",
",",
"$",
"depth",
"-",
"1",
",",
"$",
"lang",
")",
";",
"}",
"unset",
"(",
"$",
"value",
")",
";",
"return",
"$",
"arr",
";",
"}",
"return",
"$",
"this",
"->",
"flatten",
"(",
"$",
"arr",
",",
"$",
"group",
",",
"$",
"lang",
")",
";",
"}"
]
| Localizes a multidimensional array
@param array $arr The array to localize
@param string $group The name of the group of fields to flatten
@param int $depth The depth of the array
@param string $lang The output language. Default is default language.
@return array | [
"Localizes",
"a",
"multidimensional",
"array"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L282-L304 |
14,963 | RinkAttendant6/JsonI18n | src/Translate.php | Translate.flatten | private function flatten(?array $arr, string $group, ?string $lang = null): ?array
{
if ($arr === null) {
return null;
}
if (!isset($this->arrayGroups[$group])) {
throw new \OutOfBoundsException("Invalid group: $group");
}
if ($lang === null) {
$lang = $this->lang;
}
if (!isset($this->arrayGroups[$group][$lang])) {
throw new \OutOfBoundsException("Invalid language: $lang");
}
$keep = $this->arrayGroups[$group][$lang];
if (!array_key_exists($keep, $arr)) {
throw new \OutOfBoundsException("Invalid array index: $keep");
}
$arr[$group] = $arr[$keep];
foreach ($this->arrayGroups[$group] as $g) {
unset($arr[$g]);
}
return $arr;
} | php | private function flatten(?array $arr, string $group, ?string $lang = null): ?array
{
if ($arr === null) {
return null;
}
if (!isset($this->arrayGroups[$group])) {
throw new \OutOfBoundsException("Invalid group: $group");
}
if ($lang === null) {
$lang = $this->lang;
}
if (!isset($this->arrayGroups[$group][$lang])) {
throw new \OutOfBoundsException("Invalid language: $lang");
}
$keep = $this->arrayGroups[$group][$lang];
if (!array_key_exists($keep, $arr)) {
throw new \OutOfBoundsException("Invalid array index: $keep");
}
$arr[$group] = $arr[$keep];
foreach ($this->arrayGroups[$group] as $g) {
unset($arr[$g]);
}
return $arr;
} | [
"private",
"function",
"flatten",
"(",
"?",
"array",
"$",
"arr",
",",
"string",
"$",
"group",
",",
"?",
"string",
"$",
"lang",
"=",
"null",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"arr",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"group",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"Invalid group: $group\"",
")",
";",
"}",
"if",
"(",
"$",
"lang",
"===",
"null",
")",
"{",
"$",
"lang",
"=",
"$",
"this",
"->",
"lang",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"group",
"]",
"[",
"$",
"lang",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"Invalid language: $lang\"",
")",
";",
"}",
"$",
"keep",
"=",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"group",
"]",
"[",
"$",
"lang",
"]",
";",
"if",
"(",
"!",
"array_key_exists",
"(",
"$",
"keep",
",",
"$",
"arr",
")",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"\"Invalid array index: $keep\"",
")",
";",
"}",
"$",
"arr",
"[",
"$",
"group",
"]",
"=",
"$",
"arr",
"[",
"$",
"keep",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"arrayGroups",
"[",
"$",
"group",
"]",
"as",
"$",
"g",
")",
"{",
"unset",
"(",
"$",
"arr",
"[",
"$",
"g",
"]",
")",
";",
"}",
"return",
"$",
"arr",
";",
"}"
]
| Flattens an array group
@param array $arr The array to localize
@param string $group The name of the group of fields to flatten
@param string $lang The output language. Default is default language.
@return array
@throws \OutOfBoundsException If the group does not exist or if the array values do not contain the key in a given language | [
"Flattens",
"an",
"array",
"group"
]
| 882cbd43d273f771a384eb09d205d327033aaae3 | https://github.com/RinkAttendant6/JsonI18n/blob/882cbd43d273f771a384eb09d205d327033aaae3/src/Translate.php#L314-L344 |
14,964 | wpottier/WizadSettingsBundle | Model/Settings.php | Settings.save | public function save()
{
foreach ($this->data as $key => $value) {
if (!empty($value)) {
$this->parametersStorage->set($key, $value);
} else {
// Remove value to use default
$this->parametersStorage->remove($key);
}
}
} | php | public function save()
{
foreach ($this->data as $key => $value) {
if (!empty($value)) {
$this->parametersStorage->set($key, $value);
} else {
// Remove value to use default
$this->parametersStorage->remove($key);
}
}
} | [
"public",
"function",
"save",
"(",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"data",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"parametersStorage",
"->",
"set",
"(",
"$",
"key",
",",
"$",
"value",
")",
";",
"}",
"else",
"{",
"// Remove value to use default",
"$",
"this",
"->",
"parametersStorage",
"->",
"remove",
"(",
"$",
"key",
")",
";",
"}",
"}",
"}"
]
| Save current model in the storage | [
"Save",
"current",
"model",
"in",
"the",
"storage"
]
| 92738c59d4da28d3a7376de854ce8505898159cb | https://github.com/wpottier/WizadSettingsBundle/blob/92738c59d4da28d3a7376de854ce8505898159cb/Model/Settings.php#L160-L170 |
14,965 | phizzl/deployee | src/Bootstrap/RegisterConfigTrait.php | RegisterConfigTrait.registerConfig | private function registerConfig()
{
/**
* @param Container $di
* @return Config
*/
$this->getContainer()[Config::CONTAINER_ID] = function(Container $di){
/* @var ConfigLoaderInterface $loader */
$loader = $di[ConfigLoaderInterface::CONTAINER_ID];
$params = $loader->load();
$config = new Config();
$config->setParams($params);
return $config;
};
} | php | private function registerConfig()
{
/**
* @param Container $di
* @return Config
*/
$this->getContainer()[Config::CONTAINER_ID] = function(Container $di){
/* @var ConfigLoaderInterface $loader */
$loader = $di[ConfigLoaderInterface::CONTAINER_ID];
$params = $loader->load();
$config = new Config();
$config->setParams($params);
return $config;
};
} | [
"private",
"function",
"registerConfig",
"(",
")",
"{",
"/**\n * @param Container $di\n * @return Config\n */",
"$",
"this",
"->",
"getContainer",
"(",
")",
"[",
"Config",
"::",
"CONTAINER_ID",
"]",
"=",
"function",
"(",
"Container",
"$",
"di",
")",
"{",
"/* @var ConfigLoaderInterface $loader */",
"$",
"loader",
"=",
"$",
"di",
"[",
"ConfigLoaderInterface",
"::",
"CONTAINER_ID",
"]",
";",
"$",
"params",
"=",
"$",
"loader",
"->",
"load",
"(",
")",
";",
"$",
"config",
"=",
"new",
"Config",
"(",
")",
";",
"$",
"config",
"->",
"setParams",
"(",
"$",
"params",
")",
";",
"return",
"$",
"config",
";",
"}",
";",
"}"
]
| Register the config to the DI container | [
"Register",
"the",
"config",
"to",
"the",
"DI",
"container"
]
| def884e49608589d9594b8d538f3ec9aa0e25add | https://github.com/phizzl/deployee/blob/def884e49608589d9594b8d538f3ec9aa0e25add/src/Bootstrap/RegisterConfigTrait.php#L58-L72 |
14,966 | JoffreyPoreeCoding/MongoDB-ODM | src/Factory/RepositoryFactory.php | RepositoryFactory.getRepository | public function getRepository(DocumentManager $documentManager, $modelName, $collectionName, CacheProvider $repositoryCache = null)
{
$repIndex = $modelName . $collectionName;
if (false != ($repository = $this->cache->fetch($repIndex))) {
return $repository;
}
$classMetadata = $this->classMetadataFactory->getMetadataForClass($modelName);
if (!isset($collectionName)) {
$collectionName = $classMetadata->getCollection();
}
$repositoryClass = $classMetadata->getRepositoryClass();
if (is_a($repositoryClass, "JPC\MongoDB\ODM\GridFS\Repository", true) && false === strstr($collectionName, ".files")) {
$bucketName = $collectionName;
$collectionName .= ".files";
} else if (is_a($repositoryClass, "JPC\MongoDB\ODM\GridFS\Repository", true) && false !== strstr($collectionName, ".files")) {
$bucketName = strstr($collectionName, ".files", true);
}
$repIndex = $modelName . $collectionName;
if (false != ($repository = $this->cache->fetch($repIndex))) {
return $repository;
}
$collection = $this->createCollection($documentManager, $classMetadata, $collectionName);
$hydratorClass = $classMetadata->getHydratorClass();
if (!isset($hydratorClass)) {
throw new \Exception($classMetadata->getName() . ' is not a valid model class. Maybe it doesn\'t have a "Document" annotation.');
}
$hydrator = new $hydratorClass($this->classMetadataFactory, $classMetadata, $documentManager, $this);
$queryCaster = new QueryCaster($classMetadata, $this->classMetadataFactory);
if (isset($bucketName)) {
$bucket = $documentManager->getDatabase()->selectGridFSBucket(["bucketName" => $bucketName]);
$repository = new $repositoryClass($documentManager, $collection, $classMetadata, $hydrator, $queryCaster, null, $repositoryCache, $bucket);
} else {
$repository = new $repositoryClass($documentManager, $collection, $classMetadata, $hydrator, $queryCaster, null, $repositoryCache);
}
$this->cache->save($repIndex, $repository, 120);
return $repository;
} | php | public function getRepository(DocumentManager $documentManager, $modelName, $collectionName, CacheProvider $repositoryCache = null)
{
$repIndex = $modelName . $collectionName;
if (false != ($repository = $this->cache->fetch($repIndex))) {
return $repository;
}
$classMetadata = $this->classMetadataFactory->getMetadataForClass($modelName);
if (!isset($collectionName)) {
$collectionName = $classMetadata->getCollection();
}
$repositoryClass = $classMetadata->getRepositoryClass();
if (is_a($repositoryClass, "JPC\MongoDB\ODM\GridFS\Repository", true) && false === strstr($collectionName, ".files")) {
$bucketName = $collectionName;
$collectionName .= ".files";
} else if (is_a($repositoryClass, "JPC\MongoDB\ODM\GridFS\Repository", true) && false !== strstr($collectionName, ".files")) {
$bucketName = strstr($collectionName, ".files", true);
}
$repIndex = $modelName . $collectionName;
if (false != ($repository = $this->cache->fetch($repIndex))) {
return $repository;
}
$collection = $this->createCollection($documentManager, $classMetadata, $collectionName);
$hydratorClass = $classMetadata->getHydratorClass();
if (!isset($hydratorClass)) {
throw new \Exception($classMetadata->getName() . ' is not a valid model class. Maybe it doesn\'t have a "Document" annotation.');
}
$hydrator = new $hydratorClass($this->classMetadataFactory, $classMetadata, $documentManager, $this);
$queryCaster = new QueryCaster($classMetadata, $this->classMetadataFactory);
if (isset($bucketName)) {
$bucket = $documentManager->getDatabase()->selectGridFSBucket(["bucketName" => $bucketName]);
$repository = new $repositoryClass($documentManager, $collection, $classMetadata, $hydrator, $queryCaster, null, $repositoryCache, $bucket);
} else {
$repository = new $repositoryClass($documentManager, $collection, $classMetadata, $hydrator, $queryCaster, null, $repositoryCache);
}
$this->cache->save($repIndex, $repository, 120);
return $repository;
} | [
"public",
"function",
"getRepository",
"(",
"DocumentManager",
"$",
"documentManager",
",",
"$",
"modelName",
",",
"$",
"collectionName",
",",
"CacheProvider",
"$",
"repositoryCache",
"=",
"null",
")",
"{",
"$",
"repIndex",
"=",
"$",
"modelName",
".",
"$",
"collectionName",
";",
"if",
"(",
"false",
"!=",
"(",
"$",
"repository",
"=",
"$",
"this",
"->",
"cache",
"->",
"fetch",
"(",
"$",
"repIndex",
")",
")",
")",
"{",
"return",
"$",
"repository",
";",
"}",
"$",
"classMetadata",
"=",
"$",
"this",
"->",
"classMetadataFactory",
"->",
"getMetadataForClass",
"(",
"$",
"modelName",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"collectionName",
")",
")",
"{",
"$",
"collectionName",
"=",
"$",
"classMetadata",
"->",
"getCollection",
"(",
")",
";",
"}",
"$",
"repositoryClass",
"=",
"$",
"classMetadata",
"->",
"getRepositoryClass",
"(",
")",
";",
"if",
"(",
"is_a",
"(",
"$",
"repositoryClass",
",",
"\"JPC\\MongoDB\\ODM\\GridFS\\Repository\"",
",",
"true",
")",
"&&",
"false",
"===",
"strstr",
"(",
"$",
"collectionName",
",",
"\".files\"",
")",
")",
"{",
"$",
"bucketName",
"=",
"$",
"collectionName",
";",
"$",
"collectionName",
".=",
"\".files\"",
";",
"}",
"else",
"if",
"(",
"is_a",
"(",
"$",
"repositoryClass",
",",
"\"JPC\\MongoDB\\ODM\\GridFS\\Repository\"",
",",
"true",
")",
"&&",
"false",
"!==",
"strstr",
"(",
"$",
"collectionName",
",",
"\".files\"",
")",
")",
"{",
"$",
"bucketName",
"=",
"strstr",
"(",
"$",
"collectionName",
",",
"\".files\"",
",",
"true",
")",
";",
"}",
"$",
"repIndex",
"=",
"$",
"modelName",
".",
"$",
"collectionName",
";",
"if",
"(",
"false",
"!=",
"(",
"$",
"repository",
"=",
"$",
"this",
"->",
"cache",
"->",
"fetch",
"(",
"$",
"repIndex",
")",
")",
")",
"{",
"return",
"$",
"repository",
";",
"}",
"$",
"collection",
"=",
"$",
"this",
"->",
"createCollection",
"(",
"$",
"documentManager",
",",
"$",
"classMetadata",
",",
"$",
"collectionName",
")",
";",
"$",
"hydratorClass",
"=",
"$",
"classMetadata",
"->",
"getHydratorClass",
"(",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"hydratorClass",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"$",
"classMetadata",
"->",
"getName",
"(",
")",
".",
"' is not a valid model class. Maybe it doesn\\'t have a \"Document\" annotation.'",
")",
";",
"}",
"$",
"hydrator",
"=",
"new",
"$",
"hydratorClass",
"(",
"$",
"this",
"->",
"classMetadataFactory",
",",
"$",
"classMetadata",
",",
"$",
"documentManager",
",",
"$",
"this",
")",
";",
"$",
"queryCaster",
"=",
"new",
"QueryCaster",
"(",
"$",
"classMetadata",
",",
"$",
"this",
"->",
"classMetadataFactory",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"bucketName",
")",
")",
"{",
"$",
"bucket",
"=",
"$",
"documentManager",
"->",
"getDatabase",
"(",
")",
"->",
"selectGridFSBucket",
"(",
"[",
"\"bucketName\"",
"=>",
"$",
"bucketName",
"]",
")",
";",
"$",
"repository",
"=",
"new",
"$",
"repositoryClass",
"(",
"$",
"documentManager",
",",
"$",
"collection",
",",
"$",
"classMetadata",
",",
"$",
"hydrator",
",",
"$",
"queryCaster",
",",
"null",
",",
"$",
"repositoryCache",
",",
"$",
"bucket",
")",
";",
"}",
"else",
"{",
"$",
"repository",
"=",
"new",
"$",
"repositoryClass",
"(",
"$",
"documentManager",
",",
"$",
"collection",
",",
"$",
"classMetadata",
",",
"$",
"hydrator",
",",
"$",
"queryCaster",
",",
"null",
",",
"$",
"repositoryCache",
")",
";",
"}",
"$",
"this",
"->",
"cache",
"->",
"save",
"(",
"$",
"repIndex",
",",
"$",
"repository",
",",
"120",
")",
";",
"return",
"$",
"repository",
";",
"}"
]
| Get a repository
@param DocumentManager $documentManager Document manager
@param string $modelName Class of the model
@param string $collectionName Name of MongoDB Collection
@param CacheProvider $repositoryCache Cache for the repository
@return Repository | [
"Get",
"a",
"repository"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Factory/RepositoryFactory.php#L55-L102 |
14,967 | JoffreyPoreeCoding/MongoDB-ODM | src/Factory/RepositoryFactory.php | RepositoryFactory.createCollection | private function createCollection(DocumentManager $documentManager, ClassMetadata $classMetadata, $collectionName)
{
$database = $documentManager->getDatabase();
$exists = false;
foreach ($database->listCollections() as $collection) {
if ($collection->getName() == $collectionName) {
$exists = true;
}
}
$creationOptions = $classMetadata->getCollectionCreationOptions();
if (!empty($creationOptions) && !$exists) {
$database->createCollection($collectionName, $creationOptions);
}
$collectionOptions = $classMetadata->getCollectionOptions();
return $database->selectCollection($collectionName, $collectionOptions);
} | php | private function createCollection(DocumentManager $documentManager, ClassMetadata $classMetadata, $collectionName)
{
$database = $documentManager->getDatabase();
$exists = false;
foreach ($database->listCollections() as $collection) {
if ($collection->getName() == $collectionName) {
$exists = true;
}
}
$creationOptions = $classMetadata->getCollectionCreationOptions();
if (!empty($creationOptions) && !$exists) {
$database->createCollection($collectionName, $creationOptions);
}
$collectionOptions = $classMetadata->getCollectionOptions();
return $database->selectCollection($collectionName, $collectionOptions);
} | [
"private",
"function",
"createCollection",
"(",
"DocumentManager",
"$",
"documentManager",
",",
"ClassMetadata",
"$",
"classMetadata",
",",
"$",
"collectionName",
")",
"{",
"$",
"database",
"=",
"$",
"documentManager",
"->",
"getDatabase",
"(",
")",
";",
"$",
"exists",
"=",
"false",
";",
"foreach",
"(",
"$",
"database",
"->",
"listCollections",
"(",
")",
"as",
"$",
"collection",
")",
"{",
"if",
"(",
"$",
"collection",
"->",
"getName",
"(",
")",
"==",
"$",
"collectionName",
")",
"{",
"$",
"exists",
"=",
"true",
";",
"}",
"}",
"$",
"creationOptions",
"=",
"$",
"classMetadata",
"->",
"getCollectionCreationOptions",
"(",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"creationOptions",
")",
"&&",
"!",
"$",
"exists",
")",
"{",
"$",
"database",
"->",
"createCollection",
"(",
"$",
"collectionName",
",",
"$",
"creationOptions",
")",
";",
"}",
"$",
"collectionOptions",
"=",
"$",
"classMetadata",
"->",
"getCollectionOptions",
"(",
")",
";",
"return",
"$",
"database",
"->",
"selectCollection",
"(",
"$",
"collectionName",
",",
"$",
"collectionOptions",
")",
";",
"}"
]
| Create the collection
@param DocumentManager $documentManager Current document manager
@param ClassMetadata $classMetadata Class metadata
@param string $collectionName Name of collection
@return Collection | [
"Create",
"the",
"collection"
]
| 56fd7ab28c22f276573a89d56bb93c8d74ad7f74 | https://github.com/JoffreyPoreeCoding/MongoDB-ODM/blob/56fd7ab28c22f276573a89d56bb93c8d74ad7f74/src/Factory/RepositoryFactory.php#L112-L132 |
14,968 | crossjoin/Css | src/Crossjoin/Css/Writer/Pretty.php | Pretty.getOptions | protected function getOptions($level)
{
$lineBreak = "\r\n";
$intendChar = "\t";
$intendNum = 1;
$baseIntend = str_repeat($intendChar, $intendNum * $level);
$nextIntend = str_repeat($intendChar, $intendNum * ($level + 1));
$extraLineBreak = ($level === 0 ? $lineBreak : '');
return [
"BaseAddComments" => true,
"BaseLastDeclarationSemicolon" => true,
"BaseIntend" => $baseIntend,
"CommentIntend" => $baseIntend,
"CommentLineBreak" => $lineBreak,
"CharsetLineBreak" => $lineBreak,
"DocumentFilterSeparator" => ", ",
"DocumentRuleSetOpen" => " {" . $lineBreak,
"DocumentRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"FontFaceCommentLineBreak" => $lineBreak,
"FontFaceRuleSetOpen" => " {" . $lineBreak,
"FontFaceRuleSetIntend" => str_repeat($intendChar, $intendNum),
"FontFaceRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"FontFaceDeclarationIntend" => $nextIntend,
"FontFaceDeclarationSeparator" => ": ",
"FontFaceDeclarationLineBreak" => $lineBreak,
"ImportLineBreak" => $lineBreak,
"NamespaceLineBreak" => $lineBreak,
"MediaQuerySeparator" => ", " . $lineBreak,
"MediaRuleSetOpen" => " {" . $lineBreak,
"MediaRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"PageCommentLineBreak" => $lineBreak,
"PageRuleSetOpen" => " {" . $lineBreak,
"PageRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"PageDeclarationIntend" => $nextIntend,
"PageDeclarationSeparator" => ": ",
"PageDeclarationLineBreak" => $lineBreak,
"SupportsRuleSetOpen" => " {" . $lineBreak,
"SupportsRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"StyleCommentLineBreak" => $lineBreak,
"StyleDeclarationsOpen" => " {" . $lineBreak,
"StyleDeclarationsClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"StyleSelectorSeparator" => "," . $lineBreak . $baseIntend,
"StyleDeclarationIntend" => $nextIntend,
"StyleDeclarationSeparator" => ": ",
"StyleDeclarationLineBreak" => $lineBreak,
"KeyframesRuleSetOpen" => " {" . $lineBreak,
"KeyframesRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"KeyframesSelectorSeparator" => "," . $lineBreak . $baseIntend,
"KeyframesDeclarationsOpen" => " {" . $lineBreak,
"KeyframesDeclarationsClose" => $baseIntend . "}" . $lineBreak,
"KeyframesDeclarationIntend" => $nextIntend,
"KeyframesDeclarationSeparator" => ": ",
"KeyframesDeclarationLineBreak" => $lineBreak,
];
} | php | protected function getOptions($level)
{
$lineBreak = "\r\n";
$intendChar = "\t";
$intendNum = 1;
$baseIntend = str_repeat($intendChar, $intendNum * $level);
$nextIntend = str_repeat($intendChar, $intendNum * ($level + 1));
$extraLineBreak = ($level === 0 ? $lineBreak : '');
return [
"BaseAddComments" => true,
"BaseLastDeclarationSemicolon" => true,
"BaseIntend" => $baseIntend,
"CommentIntend" => $baseIntend,
"CommentLineBreak" => $lineBreak,
"CharsetLineBreak" => $lineBreak,
"DocumentFilterSeparator" => ", ",
"DocumentRuleSetOpen" => " {" . $lineBreak,
"DocumentRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"FontFaceCommentLineBreak" => $lineBreak,
"FontFaceRuleSetOpen" => " {" . $lineBreak,
"FontFaceRuleSetIntend" => str_repeat($intendChar, $intendNum),
"FontFaceRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"FontFaceDeclarationIntend" => $nextIntend,
"FontFaceDeclarationSeparator" => ": ",
"FontFaceDeclarationLineBreak" => $lineBreak,
"ImportLineBreak" => $lineBreak,
"NamespaceLineBreak" => $lineBreak,
"MediaQuerySeparator" => ", " . $lineBreak,
"MediaRuleSetOpen" => " {" . $lineBreak,
"MediaRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"PageCommentLineBreak" => $lineBreak,
"PageRuleSetOpen" => " {" . $lineBreak,
"PageRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"PageDeclarationIntend" => $nextIntend,
"PageDeclarationSeparator" => ": ",
"PageDeclarationLineBreak" => $lineBreak,
"SupportsRuleSetOpen" => " {" . $lineBreak,
"SupportsRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"StyleCommentLineBreak" => $lineBreak,
"StyleDeclarationsOpen" => " {" . $lineBreak,
"StyleDeclarationsClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"StyleSelectorSeparator" => "," . $lineBreak . $baseIntend,
"StyleDeclarationIntend" => $nextIntend,
"StyleDeclarationSeparator" => ": ",
"StyleDeclarationLineBreak" => $lineBreak,
"KeyframesRuleSetOpen" => " {" . $lineBreak,
"KeyframesRuleSetClose" => $baseIntend . "}" . $lineBreak . $extraLineBreak,
"KeyframesSelectorSeparator" => "," . $lineBreak . $baseIntend,
"KeyframesDeclarationsOpen" => " {" . $lineBreak,
"KeyframesDeclarationsClose" => $baseIntend . "}" . $lineBreak,
"KeyframesDeclarationIntend" => $nextIntend,
"KeyframesDeclarationSeparator" => ": ",
"KeyframesDeclarationLineBreak" => $lineBreak,
];
} | [
"protected",
"function",
"getOptions",
"(",
"$",
"level",
")",
"{",
"$",
"lineBreak",
"=",
"\"\\r\\n\"",
";",
"$",
"intendChar",
"=",
"\"\\t\"",
";",
"$",
"intendNum",
"=",
"1",
";",
"$",
"baseIntend",
"=",
"str_repeat",
"(",
"$",
"intendChar",
",",
"$",
"intendNum",
"*",
"$",
"level",
")",
";",
"$",
"nextIntend",
"=",
"str_repeat",
"(",
"$",
"intendChar",
",",
"$",
"intendNum",
"*",
"(",
"$",
"level",
"+",
"1",
")",
")",
";",
"$",
"extraLineBreak",
"=",
"(",
"$",
"level",
"===",
"0",
"?",
"$",
"lineBreak",
":",
"''",
")",
";",
"return",
"[",
"\"BaseAddComments\"",
"=>",
"true",
",",
"\"BaseLastDeclarationSemicolon\"",
"=>",
"true",
",",
"\"BaseIntend\"",
"=>",
"$",
"baseIntend",
",",
"\"CommentIntend\"",
"=>",
"$",
"baseIntend",
",",
"\"CommentLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"CharsetLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"DocumentFilterSeparator\"",
"=>",
"\", \"",
",",
"\"DocumentRuleSetOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"DocumentRuleSetClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"FontFaceCommentLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"FontFaceRuleSetOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"FontFaceRuleSetIntend\"",
"=>",
"str_repeat",
"(",
"$",
"intendChar",
",",
"$",
"intendNum",
")",
",",
"\"FontFaceRuleSetClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"FontFaceDeclarationIntend\"",
"=>",
"$",
"nextIntend",
",",
"\"FontFaceDeclarationSeparator\"",
"=>",
"\": \"",
",",
"\"FontFaceDeclarationLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"ImportLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"NamespaceLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"MediaQuerySeparator\"",
"=>",
"\", \"",
".",
"$",
"lineBreak",
",",
"\"MediaRuleSetOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"MediaRuleSetClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"PageCommentLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"PageRuleSetOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"PageRuleSetClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"PageDeclarationIntend\"",
"=>",
"$",
"nextIntend",
",",
"\"PageDeclarationSeparator\"",
"=>",
"\": \"",
",",
"\"PageDeclarationLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"SupportsRuleSetOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"SupportsRuleSetClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"StyleCommentLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"StyleDeclarationsOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"StyleDeclarationsClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"StyleSelectorSeparator\"",
"=>",
"\",\"",
".",
"$",
"lineBreak",
".",
"$",
"baseIntend",
",",
"\"StyleDeclarationIntend\"",
"=>",
"$",
"nextIntend",
",",
"\"StyleDeclarationSeparator\"",
"=>",
"\": \"",
",",
"\"StyleDeclarationLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"\"KeyframesRuleSetOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"KeyframesRuleSetClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
".",
"$",
"extraLineBreak",
",",
"\"KeyframesSelectorSeparator\"",
"=>",
"\",\"",
".",
"$",
"lineBreak",
".",
"$",
"baseIntend",
",",
"\"KeyframesDeclarationsOpen\"",
"=>",
"\" {\"",
".",
"$",
"lineBreak",
",",
"\"KeyframesDeclarationsClose\"",
"=>",
"$",
"baseIntend",
".",
"\"}\"",
".",
"$",
"lineBreak",
",",
"\"KeyframesDeclarationIntend\"",
"=>",
"$",
"nextIntend",
",",
"\"KeyframesDeclarationSeparator\"",
"=>",
"\": \"",
",",
"\"KeyframesDeclarationLineBreak\"",
"=>",
"$",
"lineBreak",
",",
"]",
";",
"}"
]
| Gets the options for the CSS generation.
@param int $level
@return array | [
"Gets",
"the",
"options",
"for",
"the",
"CSS",
"generation",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Writer/Pretty.php#L13-L68 |
14,969 | weavephp/weave | src/Middleware/Middleware.php | Middleware.execute | public function execute($pipelineName = null)
{
$request = $this->requestFactory->newIncomingRequest();
if ($this->adaptor->isDoublePass()) {
$response = $this->responseFactory->newResponse();
} else {
$response = null;
}
return $this->chain($pipelineName, $request, $response);
} | php | public function execute($pipelineName = null)
{
$request = $this->requestFactory->newIncomingRequest();
if ($this->adaptor->isDoublePass()) {
$response = $this->responseFactory->newResponse();
} else {
$response = null;
}
return $this->chain($pipelineName, $request, $response);
} | [
"public",
"function",
"execute",
"(",
"$",
"pipelineName",
"=",
"null",
")",
"{",
"$",
"request",
"=",
"$",
"this",
"->",
"requestFactory",
"->",
"newIncomingRequest",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"adaptor",
"->",
"isDoublePass",
"(",
")",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"responseFactory",
"->",
"newResponse",
"(",
")",
";",
"}",
"else",
"{",
"$",
"response",
"=",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"chain",
"(",
"$",
"pipelineName",
",",
"$",
"request",
",",
"$",
"response",
")",
";",
"}"
]
| Create and execute the named pipeline as an initial entry pipeline.
Similar to chaining but also sets up a Request based on the global data and,
if needed, a Response object.
@param string $pipelineName Optional pipeline name.
@return Response A PSR7 response object. | [
"Create",
"and",
"execute",
"the",
"named",
"pipeline",
"as",
"an",
"initial",
"entry",
"pipeline",
"."
]
| 44183a5bcb9e3ed3754cc76aa9e0724d718caeec | https://github.com/weavephp/weave/blob/44183a5bcb9e3ed3754cc76aa9e0724d718caeec/src/Middleware/Middleware.php#L105-L114 |
14,970 | mnapoli/assembly | src/ObjectDefinition.php | ObjectDefinition.addMethodCall | public function addMethodCall($methodName)
{
$arguments = func_get_args();
array_shift($arguments);
$this->methodCalls[] = new MethodCall($methodName, $arguments);
return $this;
} | php | public function addMethodCall($methodName)
{
$arguments = func_get_args();
array_shift($arguments);
$this->methodCalls[] = new MethodCall($methodName, $arguments);
return $this;
} | [
"public",
"function",
"addMethodCall",
"(",
"$",
"methodName",
")",
"{",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"array_shift",
"(",
"$",
"arguments",
")",
";",
"$",
"this",
"->",
"methodCalls",
"[",
"]",
"=",
"new",
"MethodCall",
"(",
"$",
"methodName",
",",
"$",
"arguments",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set a method to be called after instantiating the class.
After the $methodName parameter, this method take as many parameters as necessary.
@param string $methodName Name of the method to call.
@param string|number|bool|array|ReferenceDefinitionInterface... Can be a scalar value, an array of scalar or
a reference to another entry. See \Assembly\ObjectInitializer\MethodCall::__construct fore more informations.
@return $this | [
"Set",
"a",
"method",
"to",
"be",
"called",
"after",
"instantiating",
"the",
"class",
"."
]
| bdaff7455d34958f2c2a5a3379de3d88b567b9fc | https://github.com/mnapoli/assembly/blob/bdaff7455d34958f2c2a5a3379de3d88b567b9fc/src/ObjectDefinition.php#L97-L105 |
14,971 | ekyna/GlsUniBox | Generator/NumberGenerator.php | NumberGenerator.readNumber | private function readNumber()
{
// Open
if (false === $this->handle = fopen($this->path, 'c+')) {
throw new RuntimeException("Failed to open file {$this->path}.");
}
// Exclusive lock
if (!flock($this->handle, LOCK_EX)) {
throw new RuntimeException("Failed to lock file {$this->path}.");
}
if (false !== $number = fread($this->handle, 10)) {
return intval($number);
}
return 0;
} | php | private function readNumber()
{
// Open
if (false === $this->handle = fopen($this->path, 'c+')) {
throw new RuntimeException("Failed to open file {$this->path}.");
}
// Exclusive lock
if (!flock($this->handle, LOCK_EX)) {
throw new RuntimeException("Failed to lock file {$this->path}.");
}
if (false !== $number = fread($this->handle, 10)) {
return intval($number);
}
return 0;
} | [
"private",
"function",
"readNumber",
"(",
")",
"{",
"// Open",
"if",
"(",
"false",
"===",
"$",
"this",
"->",
"handle",
"=",
"fopen",
"(",
"$",
"this",
"->",
"path",
",",
"'c+'",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to open file {$this->path}.\"",
")",
";",
"}",
"// Exclusive lock",
"if",
"(",
"!",
"flock",
"(",
"$",
"this",
"->",
"handle",
",",
"LOCK_EX",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to lock file {$this->path}.\"",
")",
";",
"}",
"if",
"(",
"false",
"!==",
"$",
"number",
"=",
"fread",
"(",
"$",
"this",
"->",
"handle",
",",
"10",
")",
")",
"{",
"return",
"intval",
"(",
"$",
"number",
")",
";",
"}",
"return",
"0",
";",
"}"
]
| Reads the previous number.
@return int | [
"Reads",
"the",
"previous",
"number",
"."
]
| b474271ba355c3917074422306dc64abf09584d0 | https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Generator/NumberGenerator.php#L54-L70 |
14,972 | ekyna/GlsUniBox | Generator/NumberGenerator.php | NumberGenerator.writeNumber | private function writeNumber($number)
{
// Truncate
if (!ftruncate($this->handle, 0)) {
throw new RuntimeException("Failed to truncate file {$this->path}.");
}
// Reset
if (0 > fseek($this->handle, 0)) {
throw new RuntimeException("Failed to move pointer at the beginning of the file {$this->path}.");
}
// Write
if (!fwrite($this->handle, $number)) {
throw new RuntimeException("Failed to write file {$this->path}.");
}
// Flush
if (!fflush($this->handle)) {
throw new RuntimeException("Failed to flush file {$this->path}.");
}
// Unlock
if (!flock($this->handle, LOCK_UN)) {
throw new RuntimeException("Failed to unlock file {$this->path}.");
}
// Close
fclose($this->handle);
} | php | private function writeNumber($number)
{
// Truncate
if (!ftruncate($this->handle, 0)) {
throw new RuntimeException("Failed to truncate file {$this->path}.");
}
// Reset
if (0 > fseek($this->handle, 0)) {
throw new RuntimeException("Failed to move pointer at the beginning of the file {$this->path}.");
}
// Write
if (!fwrite($this->handle, $number)) {
throw new RuntimeException("Failed to write file {$this->path}.");
}
// Flush
if (!fflush($this->handle)) {
throw new RuntimeException("Failed to flush file {$this->path}.");
}
// Unlock
if (!flock($this->handle, LOCK_UN)) {
throw new RuntimeException("Failed to unlock file {$this->path}.");
}
// Close
fclose($this->handle);
} | [
"private",
"function",
"writeNumber",
"(",
"$",
"number",
")",
"{",
"// Truncate",
"if",
"(",
"!",
"ftruncate",
"(",
"$",
"this",
"->",
"handle",
",",
"0",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to truncate file {$this->path}.\"",
")",
";",
"}",
"// Reset",
"if",
"(",
"0",
">",
"fseek",
"(",
"$",
"this",
"->",
"handle",
",",
"0",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to move pointer at the beginning of the file {$this->path}.\"",
")",
";",
"}",
"// Write",
"if",
"(",
"!",
"fwrite",
"(",
"$",
"this",
"->",
"handle",
",",
"$",
"number",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to write file {$this->path}.\"",
")",
";",
"}",
"// Flush",
"if",
"(",
"!",
"fflush",
"(",
"$",
"this",
"->",
"handle",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to flush file {$this->path}.\"",
")",
";",
"}",
"// Unlock",
"if",
"(",
"!",
"flock",
"(",
"$",
"this",
"->",
"handle",
",",
"LOCK_UN",
")",
")",
"{",
"throw",
"new",
"RuntimeException",
"(",
"\"Failed to unlock file {$this->path}.\"",
")",
";",
"}",
"// Close",
"fclose",
"(",
"$",
"this",
"->",
"handle",
")",
";",
"}"
]
| Writes the new number.
@param string $number | [
"Writes",
"the",
"new",
"number",
"."
]
| b474271ba355c3917074422306dc64abf09584d0 | https://github.com/ekyna/GlsUniBox/blob/b474271ba355c3917074422306dc64abf09584d0/Generator/NumberGenerator.php#L77-L101 |
14,973 | goblindegook/Syllables | src/Cache/Fragment.php | Fragment._output | private function _output() {
$output = \wp_cache_get( $this->key, $this->group );
if ( $output !== false ) {
echo $output;
return true;
}
ob_start();
return false;
} | php | private function _output() {
$output = \wp_cache_get( $this->key, $this->group );
if ( $output !== false ) {
echo $output;
return true;
}
ob_start();
return false;
} | [
"private",
"function",
"_output",
"(",
")",
"{",
"$",
"output",
"=",
"\\",
"wp_cache_get",
"(",
"$",
"this",
"->",
"key",
",",
"$",
"this",
"->",
"group",
")",
";",
"if",
"(",
"$",
"output",
"!==",
"false",
")",
"{",
"echo",
"$",
"output",
";",
"return",
"true",
";",
"}",
"ob_start",
"(",
")",
";",
"return",
"false",
";",
"}"
]
| Outputs cached content, if available, otherwise begins capturing output
for caching.
@return boolean Whether content was found in the cache.
@uses \wp_cache_get()
@codeCoverageIgnore | [
"Outputs",
"cached",
"content",
"if",
"available",
"otherwise",
"begins",
"capturing",
"output",
"for",
"caching",
"."
]
| 1a98cd15e37595a85b242242f88fee38c4e36acc | https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Cache/Fragment.php#L108-L119 |
14,974 | goblindegook/Syllables | src/Cache/Fragment.php | Fragment._store | private function _store() {
// Flushes the buffers
$output = ob_get_flush();
\wp_cache_add( $this->key, $output, $this->group, $this->expires );
} | php | private function _store() {
// Flushes the buffers
$output = ob_get_flush();
\wp_cache_add( $this->key, $output, $this->group, $this->expires );
} | [
"private",
"function",
"_store",
"(",
")",
"{",
"// Flushes the buffers",
"$",
"output",
"=",
"ob_get_flush",
"(",
")",
";",
"\\",
"wp_cache_add",
"(",
"$",
"this",
"->",
"key",
",",
"$",
"output",
",",
"$",
"this",
"->",
"group",
",",
"$",
"this",
"->",
"expires",
")",
";",
"}"
]
| Stores the rendered snippet in the object cache.
@uses \wp_cache_add()
@codeCoverageIgnore | [
"Stores",
"the",
"rendered",
"snippet",
"in",
"the",
"object",
"cache",
"."
]
| 1a98cd15e37595a85b242242f88fee38c4e36acc | https://github.com/goblindegook/Syllables/blob/1a98cd15e37595a85b242242f88fee38c4e36acc/src/Cache/Fragment.php#L128-L133 |
14,975 | axelitus/php-base | src/Int.php | Int.extIs | public static function extIs($value)
{
return static::is($value) || (is_string($value) && (strval(intval($value)) === strval($value)));
} | php | public static function extIs($value)
{
return static::is($value) || (is_string($value) && (strval(intval($value)) === strval($value)));
} | [
"public",
"static",
"function",
"extIs",
"(",
"$",
"value",
")",
"{",
"return",
"static",
"::",
"is",
"(",
"$",
"value",
")",
"||",
"(",
"is_string",
"(",
"$",
"value",
")",
"&&",
"(",
"strval",
"(",
"intval",
"(",
"$",
"value",
")",
")",
"===",
"strval",
"(",
"$",
"value",
")",
")",
")",
";",
"}"
]
| Tests if the given value is an int or a string representation of an int.
@param mixed $value The value to test.
@return bool Returns true if the given value is an int or a representation of an int, false otherwise. | [
"Tests",
"if",
"the",
"given",
"value",
"is",
"an",
"int",
"or",
"a",
"string",
"representation",
"of",
"an",
"int",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Int.php#L59-L62 |
14,976 | axelitus/php-base | src/Int.php | Int.compare | public static function compare($int1, $int2)
{
if (!static::is($int1) || !static::is($int2)) {
throw new \InvalidArgumentException("The \$int1 and \$int2 parameters must be of type int.");
}
return ($int1 - $int2);
} | php | public static function compare($int1, $int2)
{
if (!static::is($int1) || !static::is($int2)) {
throw new \InvalidArgumentException("The \$int1 and \$int2 parameters must be of type int.");
}
return ($int1 - $int2);
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"int1",
",",
"$",
"int2",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"int1",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"int2",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$int1 and \\$int2 parameters must be of type int.\"",
")",
";",
"}",
"return",
"(",
"$",
"int1",
"-",
"$",
"int2",
")",
";",
"}"
]
| Compares two int values.
The returning value contains the actual value difference.
@param int $int1 The left operand.
@param int $int2 The right operand.
@return int Returns <0 if $int1<$int2, =0 if $int1 == $int2, >0 if $int1>$int2
@throws \InvalidArgumentException | [
"Compares",
"two",
"int",
"values",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Int.php#L150-L157 |
14,977 | axelitus/php-base | src/Int.php | Int.random | public static function random($min = 0, $max = 1, $seed = null)
{
if (!static::is($min) || !static::is($max)) {
throw new \InvalidArgumentException("The \$min and \$max parameters must be of type int.");
}
if ($min > $max) {
trigger_error("The \$min value cannot be greater than the \$max value.", E_USER_WARNING);
return false;
}
if (!is_null($seed) && static::is($seed)) {
mt_srand($seed);
}
$rand = mt_rand($min, $max);
// unseed (random reseed) random generator
mt_srand();
return $rand;
} | php | public static function random($min = 0, $max = 1, $seed = null)
{
if (!static::is($min) || !static::is($max)) {
throw new \InvalidArgumentException("The \$min and \$max parameters must be of type int.");
}
if ($min > $max) {
trigger_error("The \$min value cannot be greater than the \$max value.", E_USER_WARNING);
return false;
}
if (!is_null($seed) && static::is($seed)) {
mt_srand($seed);
}
$rand = mt_rand($min, $max);
// unseed (random reseed) random generator
mt_srand();
return $rand;
} | [
"public",
"static",
"function",
"random",
"(",
"$",
"min",
"=",
"0",
",",
"$",
"max",
"=",
"1",
",",
"$",
"seed",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"min",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"max",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$min and \\$max parameters must be of type int.\"",
")",
";",
"}",
"if",
"(",
"$",
"min",
">",
"$",
"max",
")",
"{",
"trigger_error",
"(",
"\"The \\$min value cannot be greater than the \\$max value.\"",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"if",
"(",
"!",
"is_null",
"(",
"$",
"seed",
")",
"&&",
"static",
"::",
"is",
"(",
"$",
"seed",
")",
")",
"{",
"mt_srand",
"(",
"$",
"seed",
")",
";",
"}",
"$",
"rand",
"=",
"mt_rand",
"(",
"$",
"min",
",",
"$",
"max",
")",
";",
"// unseed (random reseed) random generator",
"mt_srand",
"(",
")",
";",
"return",
"$",
"rand",
";",
"}"
]
| Generates a random integer number between min and max.
@param int $min Lower bound (inclusive)
@param int $max Upper bound(inclusive)
@param null|int $seed Random generator seed
@return int|false A random integer value between min (or 0) and max (or 1, inclusive), or FALSE if max
is less than min.
@throws \InvalidArgumentException | [
"Generates",
"a",
"random",
"integer",
"number",
"between",
"min",
"and",
"max",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Int.php#L258-L280 |
14,978 | jenky/laravel-api-helper | src/ApiServiceProvider.php | ApiServiceProvider.registerApiHelper | protected function registerApiHelper(Application $app)
{
$app->singleton(Factory::class, function ($app) {
$request = $app['request'];
$config = $app['config'];
return new Factory($request, $config);
});
$app->alias(Factory::class, 'apihelper');
} | php | protected function registerApiHelper(Application $app)
{
$app->singleton(Factory::class, function ($app) {
$request = $app['request'];
$config = $app['config'];
return new Factory($request, $config);
});
$app->alias(Factory::class, 'apihelper');
} | [
"protected",
"function",
"registerApiHelper",
"(",
"Application",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"singleton",
"(",
"Factory",
"::",
"class",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"request",
"=",
"$",
"app",
"[",
"'request'",
"]",
";",
"$",
"config",
"=",
"$",
"app",
"[",
"'config'",
"]",
";",
"return",
"new",
"Factory",
"(",
"$",
"request",
",",
"$",
"config",
")",
";",
"}",
")",
";",
"$",
"app",
"->",
"alias",
"(",
"Factory",
"::",
"class",
",",
"'apihelper'",
")",
";",
"}"
]
| Register the helper class.
@param \Illuminate\Contracts\Foundation\Application $app
@return void | [
"Register",
"the",
"helper",
"class",
"."
]
| 9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367 | https://github.com/jenky/laravel-api-helper/blob/9af8f4d99d96ed3ea1bee7eabcdb0472f1bfa367/src/ApiServiceProvider.php#L49-L59 |
14,979 | someline/someline-image | src/Someline/Image/SomelineImageService.php | SomelineImageService.autoCreateDirectory | public static function autoCreateDirectory($path_name)
{
// check directory
if (!File::exists(dirname($path_name))) {
$isMadeDir = mkdir(dirname($path_name), 0777, true);
if (!$isMadeDir) {
return false;
}
}
return true;
} | php | public static function autoCreateDirectory($path_name)
{
// check directory
if (!File::exists(dirname($path_name))) {
$isMadeDir = mkdir(dirname($path_name), 0777, true);
if (!$isMadeDir) {
return false;
}
}
return true;
} | [
"public",
"static",
"function",
"autoCreateDirectory",
"(",
"$",
"path_name",
")",
"{",
"// check directory",
"if",
"(",
"!",
"File",
"::",
"exists",
"(",
"dirname",
"(",
"$",
"path_name",
")",
")",
")",
"{",
"$",
"isMadeDir",
"=",
"mkdir",
"(",
"dirname",
"(",
"$",
"path_name",
")",
",",
"0777",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"isMadeDir",
")",
"{",
"return",
"false",
";",
"}",
"}",
"return",
"true",
";",
"}"
]
| auto create directory if not exists
@param $path_name
@return bool | [
"auto",
"create",
"directory",
"if",
"not",
"exists"
]
| a48d760c5292ad24859ff6f4b14b7735fe6f4d42 | https://github.com/someline/someline-image/blob/a48d760c5292ad24859ff6f4b14b7735fe6f4d42/src/Someline/Image/SomelineImageService.php#L638-L648 |
14,980 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/UserRole.php | UserRole.getUser | public function getUser(ConnectionInterface $con = null)
{
if ($this->aUser === null && ($this->user_id !== null)) {
$this->aUser = ChildUserQuery::create()->findPk($this->user_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aUser->addUserRoles($this);
*/
}
return $this->aUser;
} | php | public function getUser(ConnectionInterface $con = null)
{
if ($this->aUser === null && ($this->user_id !== null)) {
$this->aUser = ChildUserQuery::create()->findPk($this->user_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aUser->addUserRoles($this);
*/
}
return $this->aUser;
} | [
"public",
"function",
"getUser",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aUser",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"user_id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"aUser",
"=",
"ChildUserQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"user_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aUser->addUserRoles($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aUser",
";",
"}"
]
| Get the associated ChildUser object
@param ConnectionInterface $con Optional Connection object.
@return ChildUser The associated ChildUser object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildUser",
"object"
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/UserRole.php#L1056-L1070 |
14,981 | phpalchemy/cerberus | src/Alchemy/Component/Cerberus/Model/Base/UserRole.php | UserRole.getRole | public function getRole(ConnectionInterface $con = null)
{
if ($this->aRole === null && ($this->role_id !== null)) {
$this->aRole = ChildRoleQuery::create()->findPk($this->role_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aRole->addUserRoles($this);
*/
}
return $this->aRole;
} | php | public function getRole(ConnectionInterface $con = null)
{
if ($this->aRole === null && ($this->role_id !== null)) {
$this->aRole = ChildRoleQuery::create()->findPk($this->role_id, $con);
/* The following can be used additionally to
guarantee the related object contains a reference
to this object. This level of coupling may, however, be
undesirable since it could result in an only partially populated collection
in the referenced object.
$this->aRole->addUserRoles($this);
*/
}
return $this->aRole;
} | [
"public",
"function",
"getRole",
"(",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"aRole",
"===",
"null",
"&&",
"(",
"$",
"this",
"->",
"role_id",
"!==",
"null",
")",
")",
"{",
"$",
"this",
"->",
"aRole",
"=",
"ChildRoleQuery",
"::",
"create",
"(",
")",
"->",
"findPk",
"(",
"$",
"this",
"->",
"role_id",
",",
"$",
"con",
")",
";",
"/* The following can be used additionally to\n guarantee the related object contains a reference\n to this object. This level of coupling may, however, be\n undesirable since it could result in an only partially populated collection\n in the referenced object.\n $this->aRole->addUserRoles($this);\n */",
"}",
"return",
"$",
"this",
"->",
"aRole",
";",
"}"
]
| Get the associated ChildRole object
@param ConnectionInterface $con Optional Connection object.
@return ChildRole The associated ChildRole object.
@throws PropelException | [
"Get",
"the",
"associated",
"ChildRole",
"object"
]
| 3424a360c9bded71eb5b570bc114a7759cb23ec6 | https://github.com/phpalchemy/cerberus/blob/3424a360c9bded71eb5b570bc114a7759cb23ec6/src/Alchemy/Component/Cerberus/Model/Base/UserRole.php#L1107-L1121 |
14,982 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/OrderParameters.php | OrderParameters.setOrderParameters | public function setOrderParameters($idAttr, $orderAttr, $labelAttr)
{
$this->orderParameters = [
'idAttr' => $idAttr,
'orderAttr' => $orderAttr,
'labelAttr' => $labelAttr
];
return $this;
} | php | public function setOrderParameters($idAttr, $orderAttr, $labelAttr)
{
$this->orderParameters = [
'idAttr' => $idAttr,
'orderAttr' => $orderAttr,
'labelAttr' => $labelAttr
];
return $this;
} | [
"public",
"function",
"setOrderParameters",
"(",
"$",
"idAttr",
",",
"$",
"orderAttr",
",",
"$",
"labelAttr",
")",
"{",
"$",
"this",
"->",
"orderParameters",
"=",
"[",
"'idAttr'",
"=>",
"$",
"idAttr",
",",
"'orderAttr'",
"=>",
"$",
"orderAttr",
",",
"'labelAttr'",
"=>",
"$",
"labelAttr",
"]",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the Ordered list param.
@param array $orderedList the ordered list
@return self | [
"Sets",
"the",
"Ordered",
"list",
"param",
"."
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/OrderParameters.php#L35-L44 |
14,983 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/Actions.php | Actions.setMapAction | private function setMapAction()
{
array_push($this->actions, 'map');
$this->addForm = array_diff($this->addForm, ['map_lat', 'map_lng', 'map_address', 'map_province', 'map_locality', 'map_postal_code']);
$this->editForm = array_diff($this->addForm, ['map_lat', 'map_lng', 'map_address', 'map_province', 'map_locality', 'map_postal_code']);
return $this;
} | php | private function setMapAction()
{
array_push($this->actions, 'map');
$this->addForm = array_diff($this->addForm, ['map_lat', 'map_lng', 'map_address', 'map_province', 'map_locality', 'map_postal_code']);
$this->editForm = array_diff($this->addForm, ['map_lat', 'map_lng', 'map_address', 'map_province', 'map_locality', 'map_postal_code']);
return $this;
} | [
"private",
"function",
"setMapAction",
"(",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"actions",
",",
"'map'",
")",
";",
"$",
"this",
"->",
"addForm",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"addForm",
",",
"[",
"'map_lat'",
",",
"'map_lng'",
",",
"'map_address'",
",",
"'map_province'",
",",
"'map_locality'",
",",
"'map_postal_code'",
"]",
")",
";",
"$",
"this",
"->",
"editForm",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"addForm",
",",
"[",
"'map_lat'",
",",
"'map_lng'",
",",
"'map_address'",
",",
"'map_province'",
",",
"'map_locality'",
",",
"'map_postal_code'",
"]",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set 'map' action | [
"Set",
"map",
"action"
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/Actions.php#L51-L59 |
14,984 | jan-dolata/crude-crud | src/Engine/CrudeSetupTrait/Actions.php | Actions.setFileAction | private function setFileAction()
{
array_push($this->actions, 'file');
$this->addForm = array_diff($this->addForm, ['files']);
$this->editForm = array_diff($this->addForm, ['files']);
$this->setModelDefaults('files', []);
$this->setColumnFormat('files', 'files');
return $this;
} | php | private function setFileAction()
{
array_push($this->actions, 'file');
$this->addForm = array_diff($this->addForm, ['files']);
$this->editForm = array_diff($this->addForm, ['files']);
$this->setModelDefaults('files', []);
$this->setColumnFormat('files', 'files');
return $this;
} | [
"private",
"function",
"setFileAction",
"(",
")",
"{",
"array_push",
"(",
"$",
"this",
"->",
"actions",
",",
"'file'",
")",
";",
"$",
"this",
"->",
"addForm",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"addForm",
",",
"[",
"'files'",
"]",
")",
";",
"$",
"this",
"->",
"editForm",
"=",
"array_diff",
"(",
"$",
"this",
"->",
"addForm",
",",
"[",
"'files'",
"]",
")",
";",
"$",
"this",
"->",
"setModelDefaults",
"(",
"'files'",
",",
"[",
"]",
")",
";",
"$",
"this",
"->",
"setColumnFormat",
"(",
"'files'",
",",
"'files'",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set 'file' action | [
"Set",
"file",
"action"
]
| 9129ea08278835cf5cecfd46a90369226ae6bdd7 | https://github.com/jan-dolata/crude-crud/blob/9129ea08278835cf5cecfd46a90369226ae6bdd7/src/Engine/CrudeSetupTrait/Actions.php#L64-L75 |
14,985 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/PhotosGateway.php | PhotosGateway.getPhoto | public function getPhoto($photoId)
{
$resource = '/photos/' . $photoId;
$response = $this->makeApiRequest($resource);
return $response->photo;
} | php | public function getPhoto($photoId)
{
$resource = '/photos/' . $photoId;
$response = $this->makeApiRequest($resource);
return $response->photo;
} | [
"public",
"function",
"getPhoto",
"(",
"$",
"photoId",
")",
"{",
"$",
"resource",
"=",
"'/photos/'",
".",
"$",
"photoId",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeApiRequest",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"response",
"->",
"photo",
";",
"}"
]
| Check a user to a photo, and maybe to a event too.
@param string $venueId
@return object https://developer.foursquare.com/docs/responses/photo
@see https://developer.foursquare.com/docs/photos/photos | [
"Check",
"a",
"user",
"to",
"a",
"photo",
"and",
"maybe",
"to",
"a",
"event",
"too",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/PhotosGateway.php#L14-L21 |
14,986 | axelitus/php-base | src/Float.php | Float.compare | public static function compare($float1, $float2)
{
if (!static::is($float1) || !static::is($float2)) {
throw new \InvalidArgumentException("The \$float1 and \$float2 parameters must be of type float.");
}
return ($float1 - $float2);
} | php | public static function compare($float1, $float2)
{
if (!static::is($float1) || !static::is($float2)) {
throw new \InvalidArgumentException("The \$float1 and \$float2 parameters must be of type float.");
}
return ($float1 - $float2);
} | [
"public",
"static",
"function",
"compare",
"(",
"$",
"float1",
",",
"$",
"float2",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"float1",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"float2",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$float1 and \\$float2 parameters must be of type float.\"",
")",
";",
"}",
"return",
"(",
"$",
"float1",
"-",
"$",
"float2",
")",
";",
"}"
]
| Compares two float values.
The returning value contains the actual value difference.
@param float $float1 The left operand.
@param float $float2 The right operand.
@return float Returns <0 if $float1<$float2, =0 if $float1 == $float2, >0 if $float1>$float2
@throws \InvalidArgumentException | [
"Compares",
"two",
"float",
"values",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Float.php#L143-L150 |
14,987 | axelitus/php-base | src/Float.php | Float.random | public static function random($min = 0.0, $max = 1.0, $round = null, $seed = null)
{
if (!static::is($min) || !static::is($max)) {
throw new \InvalidArgumentException("The \$min and \$max parameters must be of type float.");
}
if ($min > $max) {
trigger_error("The \$min value cannot be greater than the \$max value.", E_USER_WARNING);
return false;
}
// If a seed was given use that seed
!is_null($seed) && Int::is($seed) && mt_srand($seed);
// Ensure that max is not inclusive
$rand = $min + (((mt_rand() - 1) / mt_getrandmax()) * abs($max - $min));
// Round if needed
(!is_null($round) && Int::is($round) && $round > 0) && ($rand = round($rand, $round));
// unseed (random reseed) random generator
mt_srand();
return $rand;
} | php | public static function random($min = 0.0, $max = 1.0, $round = null, $seed = null)
{
if (!static::is($min) || !static::is($max)) {
throw new \InvalidArgumentException("The \$min and \$max parameters must be of type float.");
}
if ($min > $max) {
trigger_error("The \$min value cannot be greater than the \$max value.", E_USER_WARNING);
return false;
}
// If a seed was given use that seed
!is_null($seed) && Int::is($seed) && mt_srand($seed);
// Ensure that max is not inclusive
$rand = $min + (((mt_rand() - 1) / mt_getrandmax()) * abs($max - $min));
// Round if needed
(!is_null($round) && Int::is($round) && $round > 0) && ($rand = round($rand, $round));
// unseed (random reseed) random generator
mt_srand();
return $rand;
} | [
"public",
"static",
"function",
"random",
"(",
"$",
"min",
"=",
"0.0",
",",
"$",
"max",
"=",
"1.0",
",",
"$",
"round",
"=",
"null",
",",
"$",
"seed",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"static",
"::",
"is",
"(",
"$",
"min",
")",
"||",
"!",
"static",
"::",
"is",
"(",
"$",
"max",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"The \\$min and \\$max parameters must be of type float.\"",
")",
";",
"}",
"if",
"(",
"$",
"min",
">",
"$",
"max",
")",
"{",
"trigger_error",
"(",
"\"The \\$min value cannot be greater than the \\$max value.\"",
",",
"E_USER_WARNING",
")",
";",
"return",
"false",
";",
"}",
"// If a seed was given use that seed",
"!",
"is_null",
"(",
"$",
"seed",
")",
"&&",
"Int",
"::",
"is",
"(",
"$",
"seed",
")",
"&&",
"mt_srand",
"(",
"$",
"seed",
")",
";",
"// Ensure that max is not inclusive",
"$",
"rand",
"=",
"$",
"min",
"+",
"(",
"(",
"(",
"mt_rand",
"(",
")",
"-",
"1",
")",
"/",
"mt_getrandmax",
"(",
")",
")",
"*",
"abs",
"(",
"$",
"max",
"-",
"$",
"min",
")",
")",
";",
"// Round if needed",
"(",
"!",
"is_null",
"(",
"$",
"round",
")",
"&&",
"Int",
"::",
"is",
"(",
"$",
"round",
")",
"&&",
"$",
"round",
">",
"0",
")",
"&&",
"(",
"$",
"rand",
"=",
"round",
"(",
"$",
"rand",
",",
"$",
"round",
")",
")",
";",
"// unseed (random reseed) random generator",
"mt_srand",
"(",
")",
";",
"return",
"$",
"rand",
";",
"}"
]
| Generates a random float number between min and max.
The function will correct the min and max if inverted.
@param float $min Lower bound (inclusive)
@param float $max Upper bound (non-inclusive)
@param null|int $round Decimal places to round the number to (or null for no rounding)
@param null|int $seed Random generator seed
@return float|false A random float value between min (or 0) and max (or 1, exclusive), or FALSE if max
is less than min.
@throws \InvalidArgumentException | [
"Generates",
"a",
"random",
"float",
"number",
"between",
"min",
"and",
"max",
"."
]
| c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075 | https://github.com/axelitus/php-base/blob/c2da680c1f0c3ee93ae6a8be5adaacd0caf7d075/src/Float.php#L254-L279 |
14,988 | pageon/SlackWebhookMonolog | src/Slack/Attachment/Colour.php | Colour.setColour | private function setColour($colour)
{
if (!in_array($colour, $this->getDefaultColours()) &&
!preg_match(
'_^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$_',
$colour
)
) {
throw new InvalidColourException(
sprintf(
'The colour "%s" is not a valid colour. Possible options are "%s" or a valid hex colour',
$colour,
implode('", "', $this->getDefaultColours())
)
);
}
$this->colour = $colour;
} | php | private function setColour($colour)
{
if (!in_array($colour, $this->getDefaultColours()) &&
!preg_match(
'_^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$_',
$colour
)
) {
throw new InvalidColourException(
sprintf(
'The colour "%s" is not a valid colour. Possible options are "%s" or a valid hex colour',
$colour,
implode('", "', $this->getDefaultColours())
)
);
}
$this->colour = $colour;
} | [
"private",
"function",
"setColour",
"(",
"$",
"colour",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"colour",
",",
"$",
"this",
"->",
"getDefaultColours",
"(",
")",
")",
"&&",
"!",
"preg_match",
"(",
"'_^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$_'",
",",
"$",
"colour",
")",
")",
"{",
"throw",
"new",
"InvalidColourException",
"(",
"sprintf",
"(",
"'The colour \"%s\" is not a valid colour. Possible options are \"%s\" or a valid hex colour'",
",",
"$",
"colour",
",",
"implode",
"(",
"'\", \"'",
",",
"$",
"this",
"->",
"getDefaultColours",
"(",
")",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"colour",
"=",
"$",
"colour",
";",
"}"
]
| Set the colour if it is a valid colour.
@param $colour | [
"Set",
"the",
"colour",
"if",
"it",
"is",
"a",
"valid",
"colour",
"."
]
| 6755060ddd6429620fd4c7decbb95f05463fc36b | https://github.com/pageon/SlackWebhookMonolog/blob/6755060ddd6429620fd4c7decbb95f05463fc36b/src/Slack/Attachment/Colour.php#L40-L58 |
14,989 | bfitech/zapcore | dev/RoutingDev.php | RoutingDev.request | public function request(
string $request_uri=null, string $request_method='GET',
array $args=[], array $cookie=[]
) {
self::$core->deinit()->reset();
self::$core->config('home', '/');
$_SERVER['REQUEST_URI'] = $request_uri
? $request_uri : '/';
$_SERVER['REQUEST_METHOD'] = $request_method;
$_COOKIE = $cookie;
if ($args)
self::$core->override_callback_args($args);
return self::$core;
} | php | public function request(
string $request_uri=null, string $request_method='GET',
array $args=[], array $cookie=[]
) {
self::$core->deinit()->reset();
self::$core->config('home', '/');
$_SERVER['REQUEST_URI'] = $request_uri
? $request_uri : '/';
$_SERVER['REQUEST_METHOD'] = $request_method;
$_COOKIE = $cookie;
if ($args)
self::$core->override_callback_args($args);
return self::$core;
} | [
"public",
"function",
"request",
"(",
"string",
"$",
"request_uri",
"=",
"null",
",",
"string",
"$",
"request_method",
"=",
"'GET'",
",",
"array",
"$",
"args",
"=",
"[",
"]",
",",
"array",
"$",
"cookie",
"=",
"[",
"]",
")",
"{",
"self",
"::",
"$",
"core",
"->",
"deinit",
"(",
")",
"->",
"reset",
"(",
")",
";",
"self",
"::",
"$",
"core",
"->",
"config",
"(",
"'home'",
",",
"'/'",
")",
";",
"$",
"_SERVER",
"[",
"'REQUEST_URI'",
"]",
"=",
"$",
"request_uri",
"?",
"$",
"request_uri",
":",
"'/'",
";",
"$",
"_SERVER",
"[",
"'REQUEST_METHOD'",
"]",
"=",
"$",
"request_method",
";",
"$",
"_COOKIE",
"=",
"$",
"cookie",
";",
"if",
"(",
"$",
"args",
")",
"self",
"::",
"$",
"core",
"->",
"override_callback_args",
"(",
"$",
"args",
")",
";",
"return",
"self",
"::",
"$",
"core",
";",
"}"
]
| Fake request.
Use this to simulate HTTP request. To set args to callback
handler without relying on collected HTTP variables, use
$args.
@param string $request_uri Simulated request URI.
@param string $request_method Simulated request method.
@param array $args Simulated callback args.
@param array $cookie Simulated cookies.
@return RouterDev instance, useful for chaining from this method
to $core->route(). | [
"Fake",
"request",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/dev/RoutingDev.php#L45-L58 |
14,990 | ftrrtf/FtrrtfRollbarBundle | DependencyInjection/FtrrtfRollbarExtension.php | FtrrtfRollbarExtension.prepareLogsDir | private function prepareLogsDir($logsDir)
{
if (!is_dir($logsDir)) {
if (false === @mkdir($logsDir, 0777, true) && !is_dir($logsDir)) {
throw new \RuntimeException(sprintf("Unable to create the logs directory (%s)\n", $logsDir));
}
} elseif (!is_writable($logsDir)) {
throw new \RuntimeException(sprintf("Unable to write in the logs directory (%s)\n", $logsDir));
}
} | php | private function prepareLogsDir($logsDir)
{
if (!is_dir($logsDir)) {
if (false === @mkdir($logsDir, 0777, true) && !is_dir($logsDir)) {
throw new \RuntimeException(sprintf("Unable to create the logs directory (%s)\n", $logsDir));
}
} elseif (!is_writable($logsDir)) {
throw new \RuntimeException(sprintf("Unable to write in the logs directory (%s)\n", $logsDir));
}
} | [
"private",
"function",
"prepareLogsDir",
"(",
"$",
"logsDir",
")",
"{",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"logsDir",
")",
")",
"{",
"if",
"(",
"false",
"===",
"@",
"mkdir",
"(",
"$",
"logsDir",
",",
"0777",
",",
"true",
")",
"&&",
"!",
"is_dir",
"(",
"$",
"logsDir",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"\"Unable to create the logs directory (%s)\\n\"",
",",
"$",
"logsDir",
")",
")",
";",
"}",
"}",
"elseif",
"(",
"!",
"is_writable",
"(",
"$",
"logsDir",
")",
")",
"{",
"throw",
"new",
"\\",
"RuntimeException",
"(",
"sprintf",
"(",
"\"Unable to write in the logs directory (%s)\\n\"",
",",
"$",
"logsDir",
")",
")",
";",
"}",
"}"
]
| Create logs dir if does not exist.
@param $logsDir
@throws \RuntimeException | [
"Create",
"logs",
"dir",
"if",
"does",
"not",
"exist",
"."
]
| 64c75862b80a4a1ed9e98c0d217003e84df40dd7 | https://github.com/ftrrtf/FtrrtfRollbarBundle/blob/64c75862b80a4a1ed9e98c0d217003e84df40dd7/DependencyInjection/FtrrtfRollbarExtension.php#L91-L100 |
14,991 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike._before | public function _before(TestInterface $test)
{
if ($this->config['reconnect']) {
$this->connect();
}
$this->removeInserted();
parent::_before($test);
} | php | public function _before(TestInterface $test)
{
if ($this->config['reconnect']) {
$this->connect();
}
$this->removeInserted();
parent::_before($test);
} | [
"public",
"function",
"_before",
"(",
"TestInterface",
"$",
"test",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'reconnect'",
"]",
")",
"{",
"$",
"this",
"->",
"connect",
"(",
")",
";",
"}",
"$",
"this",
"->",
"removeInserted",
"(",
")",
";",
"parent",
"::",
"_before",
"(",
"$",
"test",
")",
";",
"}"
]
| Code to run before each test
@param TestInterface $test | [
"Code",
"to",
"run",
"before",
"each",
"test"
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L86-L95 |
14,992 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike._after | public function _after(TestInterface $test)
{
if ($this->config['reconnect']) {
$this->disconnect();
}
parent::_after($test);
} | php | public function _after(TestInterface $test)
{
if ($this->config['reconnect']) {
$this->disconnect();
}
parent::_after($test);
} | [
"public",
"function",
"_after",
"(",
"TestInterface",
"$",
"test",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"config",
"[",
"'reconnect'",
"]",
")",
"{",
"$",
"this",
"->",
"disconnect",
"(",
")",
";",
"}",
"parent",
"::",
"_after",
"(",
"$",
"test",
")",
";",
"}"
]
| Code to run after each test
@param TestInterface $test | [
"Code",
"to",
"run",
"after",
"each",
"test"
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L102-L109 |
14,993 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike.grabValueFromAerospike | public function grabValueFromAerospike($key)
{
$akey = $this->buildKey($key);
$status = $this->aerospike->get($akey, $data);
if ($status != \Aerospike::OK) {
$this->fail(
strtr(
"[:errno:] Unable to grab ':key:' from the database: :error:",
[
':errno:' => $this->aerospike->errorno(),
':key:' => $key,
':error:' => $this->aerospike->error()
]
)
);
}
$this->debugSection('Value', $data['bins']['value']);
return $data['bins']['value'];
} | php | public function grabValueFromAerospike($key)
{
$akey = $this->buildKey($key);
$status = $this->aerospike->get($akey, $data);
if ($status != \Aerospike::OK) {
$this->fail(
strtr(
"[:errno:] Unable to grab ':key:' from the database: :error:",
[
':errno:' => $this->aerospike->errorno(),
':key:' => $key,
':error:' => $this->aerospike->error()
]
)
);
}
$this->debugSection('Value', $data['bins']['value']);
return $data['bins']['value'];
} | [
"public",
"function",
"grabValueFromAerospike",
"(",
"$",
"key",
")",
"{",
"$",
"akey",
"=",
"$",
"this",
"->",
"buildKey",
"(",
"$",
"key",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"aerospike",
"->",
"get",
"(",
"$",
"akey",
",",
"$",
"data",
")",
";",
"if",
"(",
"$",
"status",
"!=",
"\\",
"Aerospike",
"::",
"OK",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"strtr",
"(",
"\"[:errno:] Unable to grab ':key:' from the database: :error:\"",
",",
"[",
"':errno:'",
"=>",
"$",
"this",
"->",
"aerospike",
"->",
"errorno",
"(",
")",
",",
"':key:'",
"=>",
"$",
"key",
",",
"':error:'",
"=>",
"$",
"this",
"->",
"aerospike",
"->",
"error",
"(",
")",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"debugSection",
"(",
"'Value'",
",",
"$",
"data",
"[",
"'bins'",
"]",
"[",
"'value'",
"]",
")",
";",
"return",
"$",
"data",
"[",
"'bins'",
"]",
"[",
"'value'",
"]",
";",
"}"
]
| Grabs value from Aerospike by key.
Example:
```php
<?php
$users_count = $I->grabValueFromAerospike('users_count');
?>
```
@param $key
@return mixed | [
"Grabs",
"value",
"from",
"Aerospike",
"by",
"key",
"."
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L135-L156 |
14,994 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike.seeInAerospike | public function seeInAerospike($key, $value = false)
{
$akey = $this->buildKey($key);
$status = $this->aerospike->get($akey, $actual);
if ($status != \Aerospike::OK) {
$this->fail(
strtr(
"[:errno:] Unable to get ':key:' from the database: :error:",
[
':errno:' => $this->aerospike->errorno(),
':key:' => $key,
':error:' => $this->aerospike->error()
]
)
);
}
$this->debugSection('Value', $actual['bins']['value']);
$this->assertEquals($value, $actual['bins']['value']);
} | php | public function seeInAerospike($key, $value = false)
{
$akey = $this->buildKey($key);
$status = $this->aerospike->get($akey, $actual);
if ($status != \Aerospike::OK) {
$this->fail(
strtr(
"[:errno:] Unable to get ':key:' from the database: :error:",
[
':errno:' => $this->aerospike->errorno(),
':key:' => $key,
':error:' => $this->aerospike->error()
]
)
);
}
$this->debugSection('Value', $actual['bins']['value']);
$this->assertEquals($value, $actual['bins']['value']);
} | [
"public",
"function",
"seeInAerospike",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"false",
")",
"{",
"$",
"akey",
"=",
"$",
"this",
"->",
"buildKey",
"(",
"$",
"key",
")",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"aerospike",
"->",
"get",
"(",
"$",
"akey",
",",
"$",
"actual",
")",
";",
"if",
"(",
"$",
"status",
"!=",
"\\",
"Aerospike",
"::",
"OK",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"strtr",
"(",
"\"[:errno:] Unable to get ':key:' from the database: :error:\"",
",",
"[",
"':errno:'",
"=>",
"$",
"this",
"->",
"aerospike",
"->",
"errorno",
"(",
")",
",",
"':key:'",
"=>",
"$",
"key",
",",
"':error:'",
"=>",
"$",
"this",
"->",
"aerospike",
"->",
"error",
"(",
")",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"debugSection",
"(",
"'Value'",
",",
"$",
"actual",
"[",
"'bins'",
"]",
"[",
"'value'",
"]",
")",
";",
"$",
"this",
"->",
"assertEquals",
"(",
"$",
"value",
",",
"$",
"actual",
"[",
"'bins'",
"]",
"[",
"'value'",
"]",
")",
";",
"}"
]
| Checks item in Aerospike exists and the same as expected.
Example:
```php
<?php
$I->seeInAerospike('key');
$I->seeInAerospike('key', 'value');
?>
@param $key
@param mixed $value | [
"Checks",
"item",
"in",
"Aerospike",
"exists",
"and",
"the",
"same",
"as",
"expected",
"."
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L172-L192 |
14,995 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike.dontSeeInAerospike | public function dontSeeInAerospike($key, $value = false)
{
$akey = $this->buildKey($key);
if ($value === false) {
$status = $this->aerospike->get($akey, $record);
$this->assertSame(\Aerospike::ERR_RECORD_NOT_FOUND, $status);
return;
}
$this->aerospike->get($akey, $actual);
if (isset($actual['bins']['value'])) {
$actual = $actual['bins']['value'];
}
$this->debugSection('Value', $actual);
$this->assertNotEquals($value, $actual);
} | php | public function dontSeeInAerospike($key, $value = false)
{
$akey = $this->buildKey($key);
if ($value === false) {
$status = $this->aerospike->get($akey, $record);
$this->assertSame(\Aerospike::ERR_RECORD_NOT_FOUND, $status);
return;
}
$this->aerospike->get($akey, $actual);
if (isset($actual['bins']['value'])) {
$actual = $actual['bins']['value'];
}
$this->debugSection('Value', $actual);
$this->assertNotEquals($value, $actual);
} | [
"public",
"function",
"dontSeeInAerospike",
"(",
"$",
"key",
",",
"$",
"value",
"=",
"false",
")",
"{",
"$",
"akey",
"=",
"$",
"this",
"->",
"buildKey",
"(",
"$",
"key",
")",
";",
"if",
"(",
"$",
"value",
"===",
"false",
")",
"{",
"$",
"status",
"=",
"$",
"this",
"->",
"aerospike",
"->",
"get",
"(",
"$",
"akey",
",",
"$",
"record",
")",
";",
"$",
"this",
"->",
"assertSame",
"(",
"\\",
"Aerospike",
"::",
"ERR_RECORD_NOT_FOUND",
",",
"$",
"status",
")",
";",
"return",
";",
"}",
"$",
"this",
"->",
"aerospike",
"->",
"get",
"(",
"$",
"akey",
",",
"$",
"actual",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"actual",
"[",
"'bins'",
"]",
"[",
"'value'",
"]",
")",
")",
"{",
"$",
"actual",
"=",
"$",
"actual",
"[",
"'bins'",
"]",
"[",
"'value'",
"]",
";",
"}",
"$",
"this",
"->",
"debugSection",
"(",
"'Value'",
",",
"$",
"actual",
")",
";",
"$",
"this",
"->",
"assertNotEquals",
"(",
"$",
"value",
",",
"$",
"actual",
")",
";",
"}"
]
| Checks item in Aerospike does not exist or is the same as expected.
Example:
```php
<?php
$I->dontSeeInAerospike('key');
$I->dontSeeInAerospike('key', 'value');
?>
@param string $key Key
@param mixed $value Value | [
"Checks",
"item",
"in",
"Aerospike",
"does",
"not",
"exist",
"or",
"is",
"the",
"same",
"as",
"expected",
"."
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L208-L226 |
14,996 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike.haveInAerospike | public function haveInAerospike($key, $value, $ttl = 0)
{
$akey = $this->buildKey($key);
$bins = ['value' => $value];
$status = $this->aerospike->put(
$akey,
$bins,
$ttl,
[\Aerospike::OPT_POLICY_KEY => \Aerospike::POLICY_KEY_SEND]
);
if ($status != \Aerospike::OK) {
$this->fail(
strtr(
"[:errno:] Unable to store ':key:' to the database: :error:",
[
':errno:' => $this->aerospike->errorno(),
':key:' => $key,
':error:' => $this->aerospike->error()
]
)
);
}
$this->keys[] = $akey;
$this->debugSection('Aerospike', [$key, $value]);
return $akey;
} | php | public function haveInAerospike($key, $value, $ttl = 0)
{
$akey = $this->buildKey($key);
$bins = ['value' => $value];
$status = $this->aerospike->put(
$akey,
$bins,
$ttl,
[\Aerospike::OPT_POLICY_KEY => \Aerospike::POLICY_KEY_SEND]
);
if ($status != \Aerospike::OK) {
$this->fail(
strtr(
"[:errno:] Unable to store ':key:' to the database: :error:",
[
':errno:' => $this->aerospike->errorno(),
':key:' => $key,
':error:' => $this->aerospike->error()
]
)
);
}
$this->keys[] = $akey;
$this->debugSection('Aerospike', [$key, $value]);
return $akey;
} | [
"public",
"function",
"haveInAerospike",
"(",
"$",
"key",
",",
"$",
"value",
",",
"$",
"ttl",
"=",
"0",
")",
"{",
"$",
"akey",
"=",
"$",
"this",
"->",
"buildKey",
"(",
"$",
"key",
")",
";",
"$",
"bins",
"=",
"[",
"'value'",
"=>",
"$",
"value",
"]",
";",
"$",
"status",
"=",
"$",
"this",
"->",
"aerospike",
"->",
"put",
"(",
"$",
"akey",
",",
"$",
"bins",
",",
"$",
"ttl",
",",
"[",
"\\",
"Aerospike",
"::",
"OPT_POLICY_KEY",
"=>",
"\\",
"Aerospike",
"::",
"POLICY_KEY_SEND",
"]",
")",
";",
"if",
"(",
"$",
"status",
"!=",
"\\",
"Aerospike",
"::",
"OK",
")",
"{",
"$",
"this",
"->",
"fail",
"(",
"strtr",
"(",
"\"[:errno:] Unable to store ':key:' to the database: :error:\"",
",",
"[",
"':errno:'",
"=>",
"$",
"this",
"->",
"aerospike",
"->",
"errorno",
"(",
")",
",",
"':key:'",
"=>",
"$",
"key",
",",
"':error:'",
"=>",
"$",
"this",
"->",
"aerospike",
"->",
"error",
"(",
")",
"]",
")",
")",
";",
"}",
"$",
"this",
"->",
"keys",
"[",
"]",
"=",
"$",
"akey",
";",
"$",
"this",
"->",
"debugSection",
"(",
"'Aerospike'",
",",
"[",
"$",
"key",
",",
"$",
"value",
"]",
")",
";",
"return",
"$",
"akey",
";",
"}"
]
| Inserts data into Aerospike database.
This data will be erased after the test.
```php
<?php
$I->haveInAerospike('users', ['name' => 'miles', 'email' => '[email protected]']);
?>
```
@param string $key Key
@param mixed $value Value
@param int $ttl The time-to-live in seconds for the record. [Optional]
@return array | [
"Inserts",
"data",
"into",
"Aerospike",
"database",
"."
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L245-L274 |
14,997 | Codeception/Aerospike-module | src/Module/Aerospike.php | Aerospike.buildKey | protected function buildKey($key)
{
return $this->aerospike->initKey(
$this->config['namespace'],
$this->config['set'],
$this->config['prefix'] . $key
);
} | php | protected function buildKey($key)
{
return $this->aerospike->initKey(
$this->config['namespace'],
$this->config['set'],
$this->config['prefix'] . $key
);
} | [
"protected",
"function",
"buildKey",
"(",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"aerospike",
"->",
"initKey",
"(",
"$",
"this",
"->",
"config",
"[",
"'namespace'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'set'",
"]",
",",
"$",
"this",
"->",
"config",
"[",
"'prefix'",
"]",
".",
"$",
"key",
")",
";",
"}"
]
| Generates a unique key used for storing cache in Aerospike DB.
@param string $key Cache key
@return array | [
"Generates",
"a",
"unique",
"key",
"used",
"for",
"storing",
"cache",
"in",
"Aerospike",
"DB",
"."
]
| bef55ed40280ad18700daf7c93b2e0fa8fe43628 | https://github.com/Codeception/Aerospike-module/blob/bef55ed40280ad18700daf7c93b2e0fa8fe43628/src/Module/Aerospike.php#L359-L366 |
14,998 | rozdol/bi | src/Utils/Utils.php | Utils.file_permissions | public function file_permissions($file)
{
// fileperms returns a numeric value
$numeric_perms = fileperms($file);
// but we are used to seeing the octal value
$octal_perms = sprintf('%o', $numeric_perms);
return substr($octal_perms, -4);
} | php | public function file_permissions($file)
{
// fileperms returns a numeric value
$numeric_perms = fileperms($file);
// but we are used to seeing the octal value
$octal_perms = sprintf('%o', $numeric_perms);
return substr($octal_perms, -4);
} | [
"public",
"function",
"file_permissions",
"(",
"$",
"file",
")",
"{",
"// fileperms returns a numeric value",
"$",
"numeric_perms",
"=",
"fileperms",
"(",
"$",
"file",
")",
";",
"// but we are used to seeing the octal value",
"$",
"octal_perms",
"=",
"sprintf",
"(",
"'%o'",
",",
"$",
"numeric_perms",
")",
";",
"return",
"substr",
"(",
"$",
"octal_perms",
",",
"-",
"4",
")",
";",
"}"
]
| Returns the file permissions in octal format. | [
"Returns",
"the",
"file",
"permissions",
"in",
"octal",
"format",
"."
]
| f63d6b219cc4a7bb25b1865905a2a888ce6ce855 | https://github.com/rozdol/bi/blob/f63d6b219cc4a7bb25b1865905a2a888ce6ce855/src/Utils/Utils.php#L2057-L2064 |
14,999 | chippyash/Math-Type-Calculator | src/Chippyash/Math/Type/Traits/ArbitrateTwoTypes.php | ArbitrateTwoTypes.arbitrate | protected function arbitrate(NumericTypeInterface $a, NumericTypeInterface $b)
{
$pairing = $this->getTypePairing($a, $b);
if ($pairing == 'complex:complex') {
return 'complex';
}
if (strpos($pairing, 'complex') === 0) {
return 'complex:numeric';
}
if (strpos($pairing, 'complex') !== false) {
return 'numeric:complex';
}
if (strstr($pairing, 'rational') !== false) {
return 'rational';
}
if (strstr($pairing, 'float') !== false) {
return 'float';
}
if (strstr($pairing, 'wholeint') !== false) {
return 'whole';
}
if (strstr($pairing, 'naturalint') !== false) {
return 'natural';
}
if ($pairing == 'int:int') {
return 'int';
}
} | php | protected function arbitrate(NumericTypeInterface $a, NumericTypeInterface $b)
{
$pairing = $this->getTypePairing($a, $b);
if ($pairing == 'complex:complex') {
return 'complex';
}
if (strpos($pairing, 'complex') === 0) {
return 'complex:numeric';
}
if (strpos($pairing, 'complex') !== false) {
return 'numeric:complex';
}
if (strstr($pairing, 'rational') !== false) {
return 'rational';
}
if (strstr($pairing, 'float') !== false) {
return 'float';
}
if (strstr($pairing, 'wholeint') !== false) {
return 'whole';
}
if (strstr($pairing, 'naturalint') !== false) {
return 'natural';
}
if ($pairing == 'int:int') {
return 'int';
}
} | [
"protected",
"function",
"arbitrate",
"(",
"NumericTypeInterface",
"$",
"a",
",",
"NumericTypeInterface",
"$",
"b",
")",
"{",
"$",
"pairing",
"=",
"$",
"this",
"->",
"getTypePairing",
"(",
"$",
"a",
",",
"$",
"b",
")",
";",
"if",
"(",
"$",
"pairing",
"==",
"'complex:complex'",
")",
"{",
"return",
"'complex'",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"pairing",
",",
"'complex'",
")",
"===",
"0",
")",
"{",
"return",
"'complex:numeric'",
";",
"}",
"if",
"(",
"strpos",
"(",
"$",
"pairing",
",",
"'complex'",
")",
"!==",
"false",
")",
"{",
"return",
"'numeric:complex'",
";",
"}",
"if",
"(",
"strstr",
"(",
"$",
"pairing",
",",
"'rational'",
")",
"!==",
"false",
")",
"{",
"return",
"'rational'",
";",
"}",
"if",
"(",
"strstr",
"(",
"$",
"pairing",
",",
"'float'",
")",
"!==",
"false",
")",
"{",
"return",
"'float'",
";",
"}",
"if",
"(",
"strstr",
"(",
"$",
"pairing",
",",
"'wholeint'",
")",
"!==",
"false",
")",
"{",
"return",
"'whole'",
";",
"}",
"if",
"(",
"strstr",
"(",
"$",
"pairing",
",",
"'naturalint'",
")",
"!==",
"false",
")",
"{",
"return",
"'natural'",
";",
"}",
"if",
"(",
"$",
"pairing",
"==",
"'int:int'",
")",
"{",
"return",
"'int'",
";",
"}",
"}"
]
| Arbitrate the return type from the operation
@param NumericTypeInterface $a first type
@param NumericTypeInterface $b second type
@return string
@noinspection PhpInconsistentReturnPointsInspection | [
"Arbitrate",
"the",
"return",
"type",
"from",
"the",
"operation"
]
| 2a2fae0ab4d052772d3dd45745efd5a91f88b9e3 | https://github.com/chippyash/Math-Type-Calculator/blob/2a2fae0ab4d052772d3dd45745efd5a91f88b9e3/src/Chippyash/Math/Type/Traits/ArbitrateTwoTypes.php#L29-L56 |
Subsets and Splits