repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1
value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getCategoriesCount | public static function getCategoriesCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/categories/count' . $filter->toQuery());
} | php | public static function getCategoriesCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/categories/count' . $filter->toQuery());
} | [
"public",
"static",
"function",
"getCategoriesCount",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCount",
"(",
"'/categories/count'",
".",
"... | The number of categories in the collection.
@param array $filter
@return int | [
"The",
"number",
"of",
"categories",
"in",
"the",
"collection",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L735-L739 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getBrands | public static function getBrands($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/brands' . $filter->toQuery(), 'Brand');
} | php | public static function getBrands($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/brands' . $filter->toQuery(), 'Brand');
} | [
"public",
"static",
"function",
"getBrands",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/brands'",
".",
"$",
"filter"... | The collection of brands.
@param array $filter
@return array | [
"The",
"collection",
"of",
"brands",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L802-L806 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getBrandsCount | public static function getBrandsCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/brands/count' . $filter->toQuery());
} | php | public static function getBrandsCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/brands/count' . $filter->toQuery());
} | [
"public",
"static",
"function",
"getBrandsCount",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCount",
"(",
"'/brands/count'",
".",
"$",
"f... | The total number of brands in the collection.
@param array $filter
@return int | [
"The",
"total",
"number",
"of",
"brands",
"in",
"the",
"collection",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L814-L818 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOrders | public static function getOrders($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders' . $filter->toQuery(), 'Order');
} | php | public static function getOrders($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders' . $filter->toQuery(), 'Order');
} | [
"public",
"static",
"function",
"getOrders",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/orders'",
".",
"$",
"filter"... | The collection of orders.
@param array $filter
@return array | [
"The",
"collection",
"of",
"orders",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L881-L885 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOrdersCount | public static function getOrdersCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/orders/count' . $filter->toQuery());
} | php | public static function getOrdersCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/orders/count' . $filter->toQuery());
} | [
"public",
"static",
"function",
"getOrdersCount",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCount",
"(",
"'/orders/count'",
".",
"$",
"f... | The number of orders in the collection.
@param array $filter
@return int | [
"The",
"number",
"of",
"orders",
"in",
"the",
"collection",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L893-L897 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOrderStatusesWithCounts | public static function getOrderStatusesWithCounts($filter = array())
{
$filter = Filter::create($filter);
$resource = self::getResource('/orders/count' . $filter->toQuery(), "OrderStatus");
return $resource->statuses;
} | php | public static function getOrderStatusesWithCounts($filter = array())
{
$filter = Filter::create($filter);
$resource = self::getResource('/orders/count' . $filter->toQuery(), "OrderStatus");
return $resource->statuses;
} | [
"public",
"static",
"function",
"getOrderStatusesWithCounts",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"$",
"resource",
"=",
"self",
"::",
"getResource",
"(",
"'/ord... | The order count grouped by order status
@param array $filter
@return Resources\OrderStatus | [
"The",
"order",
"count",
"grouped",
"by",
"order",
"status"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L905-L910 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOrderProductsCount | public static function getOrderProductsCount($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/orders/' . $orderID . '/products/count' . $filter->toQuery());
} | php | public static function getOrderProductsCount($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/orders/' . $orderID . '/products/count' . $filter->toQuery());
} | [
"public",
"static",
"function",
"getOrderProductsCount",
"(",
"$",
"orderID",
",",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCount",
"(",
"'/... | The total number of order products in the collection.
@param $orderID
@param array $filter
@return mixed | [
"The",
"total",
"number",
"of",
"order",
"products",
"in",
"the",
"collection",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L939-L943 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getCustomers | public static function getCustomers($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/customers' . $filter->toQuery(), 'Customer');
} | php | public static function getCustomers($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/customers' . $filter->toQuery(), 'Customer');
} | [
"public",
"static",
"function",
"getCustomers",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/customers'",
".",
"$",
"f... | The list of customers.
@param array $filter
@return array | [
"The",
"list",
"of",
"customers",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L996-L1000 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getCustomersCount | public static function getCustomersCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/customers/count' . $filter->toQuery());
} | php | public static function getCustomersCount($filter = array())
{
$filter = Filter::create($filter);
return self::getCount('/customers/count' . $filter->toQuery());
} | [
"public",
"static",
"function",
"getCustomersCount",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCount",
"(",
"'/customers/count'",
".",
"$"... | The total number of customers in the collection.
@param array $filter
@return int | [
"The",
"total",
"number",
"of",
"customers",
"in",
"the",
"collection",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1008-L1012 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.deleteCustomers | public static function deleteCustomers($filter = array())
{
$filter = Filter::create($filter);
return self::deleteResource('/customers' . $filter->toQuery());
} | php | public static function deleteCustomers($filter = array())
{
$filter = Filter::create($filter);
return self::deleteResource('/customers' . $filter->toQuery());
} | [
"public",
"static",
"function",
"deleteCustomers",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"deleteResource",
"(",
"'/customers'",
".",
"$",
... | Bulk delete customers.
@param array $filter
@return array | [
"Bulk",
"delete",
"customers",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1020-L1024 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOptionSets | public static function getOptionSets($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/optionsets' . $filter->toQuery(), 'OptionSet');
} | php | public static function getOptionSets($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/optionsets' . $filter->toQuery(), 'OptionSet');
} | [
"public",
"static",
"function",
"getOptionSets",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/optionsets'",
".",
"$",
... | Returns the collection of option sets.
@param array $filter
@return array | [
"Returns",
"the",
"collection",
"of",
"option",
"sets",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1088-L1092 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getSkus | public static function getSkus($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/products/skus' . $filter->toQuery(), 'Sku');
} | php | public static function getSkus($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/products/skus' . $filter->toQuery(), 'Sku');
} | [
"public",
"static",
"function",
"getSkus",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/products/skus'",
".",
"$",
"fi... | Get collection of product skus
@param array $filter
@return mixed | [
"Get",
"collection",
"of",
"product",
"skus"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1189-L1193 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getRequestsRemaining | public static function getRequestsRemaining()
{
$limit = self::connection()->getHeader('X-Rate-Limit-Requests-Left');
if (!$limit) {
$result = self::getTime();
if (!$result) {
return false;
}
$limit = self::connection()->getHeader('X-Rate-Limit-Requests-Left');
}
return (int)$limit;
} | php | public static function getRequestsRemaining()
{
$limit = self::connection()->getHeader('X-Rate-Limit-Requests-Left');
if (!$limit) {
$result = self::getTime();
if (!$result) {
return false;
}
$limit = self::connection()->getHeader('X-Rate-Limit-Requests-Left');
}
return (int)$limit;
} | [
"public",
"static",
"function",
"getRequestsRemaining",
"(",
")",
"{",
"$",
"limit",
"=",
"self",
"::",
"connection",
"(",
")",
"->",
"getHeader",
"(",
"'X-Rate-Limit-Requests-Left'",
")",
";",
"if",
"(",
"!",
"$",
"limit",
")",
"{",
"$",
"result",
"=",
... | The number of requests remaining at the current time. Based on the
last request that was fetched within the current script. If no
requests have been made, pings the time endpoint to get the value.
@return int | [
"The",
"number",
"of",
"requests",
"remaining",
"at",
"the",
"current",
"time",
".",
"Based",
"on",
"the",
"last",
"request",
"that",
"was",
"fetched",
"within",
"the",
"current",
"script",
".",
"If",
"no",
"requests",
"have",
"been",
"made",
"pings",
"the... | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1337-L1352 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getShipments | public static function getShipments($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders/' . $orderID . '/shipments' . $filter->toQuery(), 'Shipment');
} | php | public static function getShipments($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders/' . $orderID . '/shipments' . $filter->toQuery(), 'Shipment');
} | [
"public",
"static",
"function",
"getShipments",
"(",
"$",
"orderID",
",",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/orde... | Get shipments for a given order
@param $orderID
@param array $filter
@return mixed | [
"Get",
"shipments",
"for",
"a",
"given",
"order"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1373-L1377 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOrderCoupons | public static function getOrderCoupons($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders/' . $orderID . '/coupons' . $filter->toQuery(), 'OrderCoupons');
} | php | public static function getOrderCoupons($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders/' . $orderID . '/coupons' . $filter->toQuery(), 'OrderCoupons');
} | [
"public",
"static",
"function",
"getOrderCoupons",
"(",
"$",
"orderID",
",",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/o... | Get order coupons for a given order
@param $orderID
@param array $filter
@return mixed | [
"Get",
"order",
"coupons",
"for",
"a",
"given",
"order"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1434-L1438 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getOrderShippingAddresses | public static function getOrderShippingAddresses($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders/' . $orderID . '/shipping_addresses' . $filter->toQuery(), 'Address');
} | php | public static function getOrderShippingAddresses($orderID, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/orders/' . $orderID . '/shipping_addresses' . $filter->toQuery(), 'Address');
} | [
"public",
"static",
"function",
"getOrderShippingAddresses",
"(",
"$",
"orderID",
",",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"... | Get order shipping addresses for a given order
@param $orderID
@param array $filter
@return mixed | [
"Get",
"order",
"shipping",
"addresses",
"for",
"a",
"given",
"order"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1459-L1463 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getCurrencies | public static function getCurrencies($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/currencies' . $filter->toQuery(), 'Currency');
} | php | public static function getCurrencies($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/currencies' . $filter->toQuery(), 'Currency');
} | [
"public",
"static",
"function",
"getCurrencies",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/currencies'",
".",
"$",
... | Returns the default collection of currencies.
@param array $filter
@return mixed array|string list of currencies or XML string if useXml is true | [
"Returns",
"the",
"default",
"collection",
"of",
"currencies",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1516-L1520 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getGiftCertificates | public static function getGiftCertificates($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/gift_certificates' . $filter->toQuery());
} | php | public static function getGiftCertificates($filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/gift_certificates' . $filter->toQuery());
} | [
"public",
"static",
"function",
"getGiftCertificates",
"(",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"'/gift_certificates'",
"... | Return the collection of all gift certificates.
@param array $filter
@return mixed | [
"Return",
"the",
"collection",
"of",
"all",
"gift",
"certificates",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L1654-L1658 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Client.php | Client.getSkusByProduct | public static function getSkusByProduct($productId, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/products/'.$productId.'/skus' . $filter->toQuery(), 'Sku');
} | php | public static function getSkusByProduct($productId, $filter = array())
{
$filter = Filter::create($filter);
return self::getCollection('/products/'.$productId.'/skus' . $filter->toQuery(), 'Sku');
} | [
"public",
"static",
"function",
"getSkusByProduct",
"(",
"$",
"productId",
",",
"$",
"filter",
"=",
"array",
"(",
")",
")",
"{",
"$",
"filter",
"=",
"Filter",
"::",
"create",
"(",
"$",
"filter",
")",
";",
"return",
"self",
"::",
"getCollection",
"(",
"... | Get collection of product skus by Product
@param $productId
@param array $filter
@return mixed | [
"Get",
"collection",
"of",
"product",
"skus",
"by",
"Product"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Client.php#L2051-L2055 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Connection.php | Connection.handleResponse | private function handleResponse()
{
if (curl_errno($this->curl)) {
throw new NetworkError(curl_error($this->curl), curl_errno($this->curl));
}
$body = ($this->rawResponse) ? $this->getBody() : json_decode($this->getBody());
$status = $this->getStatus();
if ($status >= 400 && $status <= 499) {
if ($this->failOnError) {
throw new ClientError($body, $status);
} else {
$this->lastError = $body;
return false;
}
} elseif ($status >= 500 && $status <= 599) {
if ($this->failOnError) {
throw new ServerError($body, $status);
} else {
$this->lastError = $body;
return false;
}
}
if ($this->followLocation) {
$this->followRedirectPath();
}
return $body;
} | php | private function handleResponse()
{
if (curl_errno($this->curl)) {
throw new NetworkError(curl_error($this->curl), curl_errno($this->curl));
}
$body = ($this->rawResponse) ? $this->getBody() : json_decode($this->getBody());
$status = $this->getStatus();
if ($status >= 400 && $status <= 499) {
if ($this->failOnError) {
throw new ClientError($body, $status);
} else {
$this->lastError = $body;
return false;
}
} elseif ($status >= 500 && $status <= 599) {
if ($this->failOnError) {
throw new ServerError($body, $status);
} else {
$this->lastError = $body;
return false;
}
}
if ($this->followLocation) {
$this->followRedirectPath();
}
return $body;
} | [
"private",
"function",
"handleResponse",
"(",
")",
"{",
"if",
"(",
"curl_errno",
"(",
"$",
"this",
"->",
"curl",
")",
")",
"{",
"throw",
"new",
"NetworkError",
"(",
"curl_error",
"(",
"$",
"this",
"->",
"curl",
")",
",",
"curl_errno",
"(",
"$",
"this",... | Check the response for possible errors and handle the response body returned.
If failOnError is true, a client or server error is raised, otherwise returns false
on error. | [
"Check",
"the",
"response",
"for",
"possible",
"errors",
"and",
"handle",
"the",
"response",
"body",
"returned",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Connection.php#L277-L308 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Connection.php | Connection.followRedirectPath | private function followRedirectPath()
{
$this->redirectsFollowed++;
if ($this->getStatus() == 301 || $this->getStatus() == 302) {
if ($this->redirectsFollowed < $this->maxRedirects) {
$location = $this->getHeader('Location');
$forwardTo = parse_url($location);
if (isset($forwardTo['scheme']) && isset($forwardTo['host'])) {
$url = $location;
} else {
$forwardFrom = parse_url(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL));
$url = $forwardFrom['scheme'] . '://' . $forwardFrom['host'] . $location;
}
$this->get($url);
} else {
$errorString = "Too many redirects when trying to follow location.";
throw new NetworkError($errorString, CURLE_TOO_MANY_REDIRECTS);
}
} else {
$this->redirectsFollowed = 0;
}
} | php | private function followRedirectPath()
{
$this->redirectsFollowed++;
if ($this->getStatus() == 301 || $this->getStatus() == 302) {
if ($this->redirectsFollowed < $this->maxRedirects) {
$location = $this->getHeader('Location');
$forwardTo = parse_url($location);
if (isset($forwardTo['scheme']) && isset($forwardTo['host'])) {
$url = $location;
} else {
$forwardFrom = parse_url(curl_getinfo($this->curl, CURLINFO_EFFECTIVE_URL));
$url = $forwardFrom['scheme'] . '://' . $forwardFrom['host'] . $location;
}
$this->get($url);
} else {
$errorString = "Too many redirects when trying to follow location.";
throw new NetworkError($errorString, CURLE_TOO_MANY_REDIRECTS);
}
} else {
$this->redirectsFollowed = 0;
}
} | [
"private",
"function",
"followRedirectPath",
"(",
")",
"{",
"$",
"this",
"->",
"redirectsFollowed",
"++",
";",
"if",
"(",
"$",
"this",
"->",
"getStatus",
"(",
")",
"==",
"301",
"||",
"$",
"this",
"->",
"getStatus",
"(",
")",
"==",
"302",
")",
"{",
"i... | Recursively follow redirect until an OK response is received or
the maximum redirects limit is reached.
Only 301 and 302 redirects are handled. Redirects from POST and PUT requests will
be converted into GET requests, as per the HTTP spec. | [
"Recursively",
"follow",
"redirect",
"until",
"an",
"OK",
"response",
"is",
"received",
"or",
"the",
"maximum",
"redirects",
"limit",
"is",
"reached",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Connection.php#L326-L350 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Connection.php | Connection.parseHeader | private function parseHeader($curl, $headers)
{
if (!$this->responseStatusLine && strpos($headers, 'HTTP/') === 0) {
$this->responseStatusLine = $headers;
} else {
$parts = explode(': ', $headers);
if (isset($parts[1])) {
$this->responseHeaders[$parts[0]] = trim($parts[1]);
}
}
return strlen($headers);
} | php | private function parseHeader($curl, $headers)
{
if (!$this->responseStatusLine && strpos($headers, 'HTTP/') === 0) {
$this->responseStatusLine = $headers;
} else {
$parts = explode(': ', $headers);
if (isset($parts[1])) {
$this->responseHeaders[$parts[0]] = trim($parts[1]);
}
}
return strlen($headers);
} | [
"private",
"function",
"parseHeader",
"(",
"$",
"curl",
",",
"$",
"headers",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"responseStatusLine",
"&&",
"strpos",
"(",
"$",
"headers",
",",
"'HTTP/'",
")",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"respon... | Method that appears unused, but is in fact called by curl
@param resource $curl
@param string $headers
@return int | [
"Method",
"that",
"appears",
"unused",
"but",
"is",
"in",
"fact",
"called",
"by",
"curl"
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Connection.php#L504-L515 | train |
bigcommerce/bigcommerce-api-php | src/Bigcommerce/Api/Connection.php | Connection.getHeader | public function getHeader($header)
{
if (array_key_exists($header, $this->responseHeaders)) {
return $this->responseHeaders[$header];
}
// Do case-insensitive search
foreach ($this->responseHeaders as $k => $v) {
if (strtolower($k) == strtolower($header)) {
return $v;
}
}
} | php | public function getHeader($header)
{
if (array_key_exists($header, $this->responseHeaders)) {
return $this->responseHeaders[$header];
}
// Do case-insensitive search
foreach ($this->responseHeaders as $k => $v) {
if (strtolower($k) == strtolower($header)) {
return $v;
}
}
} | [
"public",
"function",
"getHeader",
"(",
"$",
"header",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"header",
",",
"$",
"this",
"->",
"responseHeaders",
")",
")",
"{",
"return",
"$",
"this",
"->",
"responseHeaders",
"[",
"$",
"header",
"]",
";",
... | Access given header from the response.
@param string $header Header name to retrieve
@return string|void | [
"Access",
"given",
"header",
"from",
"the",
"response",
"."
] | adcafe433271a6b42995ccf364a30856b0934941 | https://github.com/bigcommerce/bigcommerce-api-php/blob/adcafe433271a6b42995ccf364a30856b0934941/src/Bigcommerce/Api/Connection.php#L554-L565 | train |
composer/ca-bundle | src/CaBundle.php | CaBundle.getSystemCaRootBundlePath | public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
{
if (self::$caPath !== null) {
return self::$caPath;
}
// If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$envCertFile = getenv('SSL_CERT_FILE');
if ($envCertFile && is_readable($envCertFile) && static::validateCaFile($envCertFile, $logger)) {
return self::$caPath = $envCertFile;
}
// If SSL_CERT_DIR env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$envCertDir = getenv('SSL_CERT_DIR');
if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) {
return self::$caPath = $envCertDir;
}
$configured = ini_get('openssl.cafile');
if ($configured && strlen($configured) > 0 && is_readable($configured) && static::validateCaFile($configured, $logger)) {
return self::$caPath = $configured;
}
$configured = ini_get('openssl.capath');
if ($configured && is_dir($configured) && is_readable($configured)) {
return self::$caPath = $configured;
}
$caBundlePaths = array(
'/etc/pki/tls/certs/ca-bundle.crt', // Fedora, RHEL, CentOS (ca-certificates package)
'/etc/ssl/certs/ca-certificates.crt', // Debian, Ubuntu, Gentoo, Arch Linux (ca-certificates package)
'/etc/ssl/ca-bundle.pem', // SUSE, openSUSE (ca-certificates package)
'/usr/local/share/certs/ca-root-nss.crt', // FreeBSD (ca_root_nss_package)
'/usr/ssl/certs/ca-bundle.crt', // Cygwin
'/opt/local/share/curl/curl-ca-bundle.crt', // OS X macports, curl-ca-bundle package
'/usr/local/share/curl/curl-ca-bundle.crt', // Default cURL CA bunde path (without --with-ca-bundle option)
'/usr/share/ssl/certs/ca-bundle.crt', // Really old RedHat?
'/etc/ssl/cert.pem', // OpenBSD
'/usr/local/etc/ssl/cert.pem', // FreeBSD 10.x
'/usr/local/etc/openssl/cert.pem', // OS X homebrew, openssl package
);
foreach ($caBundlePaths as $caBundle) {
if (@is_readable($caBundle) && static::validateCaFile($caBundle, $logger)) {
return self::$caPath = $caBundle;
}
}
foreach ($caBundlePaths as $caBundle) {
$caBundle = dirname($caBundle);
if (@is_dir($caBundle) && glob($caBundle.'/*')) {
return self::$caPath = $caBundle;
}
}
return self::$caPath = static::getBundledCaBundlePath(); // Bundled CA file, last resort
} | php | public static function getSystemCaRootBundlePath(LoggerInterface $logger = null)
{
if (self::$caPath !== null) {
return self::$caPath;
}
// If SSL_CERT_FILE env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$envCertFile = getenv('SSL_CERT_FILE');
if ($envCertFile && is_readable($envCertFile) && static::validateCaFile($envCertFile, $logger)) {
return self::$caPath = $envCertFile;
}
// If SSL_CERT_DIR env variable points to a valid certificate/bundle, use that.
// This mimics how OpenSSL uses the SSL_CERT_FILE env variable.
$envCertDir = getenv('SSL_CERT_DIR');
if ($envCertDir && is_dir($envCertDir) && is_readable($envCertDir)) {
return self::$caPath = $envCertDir;
}
$configured = ini_get('openssl.cafile');
if ($configured && strlen($configured) > 0 && is_readable($configured) && static::validateCaFile($configured, $logger)) {
return self::$caPath = $configured;
}
$configured = ini_get('openssl.capath');
if ($configured && is_dir($configured) && is_readable($configured)) {
return self::$caPath = $configured;
}
$caBundlePaths = array(
'/etc/pki/tls/certs/ca-bundle.crt', // Fedora, RHEL, CentOS (ca-certificates package)
'/etc/ssl/certs/ca-certificates.crt', // Debian, Ubuntu, Gentoo, Arch Linux (ca-certificates package)
'/etc/ssl/ca-bundle.pem', // SUSE, openSUSE (ca-certificates package)
'/usr/local/share/certs/ca-root-nss.crt', // FreeBSD (ca_root_nss_package)
'/usr/ssl/certs/ca-bundle.crt', // Cygwin
'/opt/local/share/curl/curl-ca-bundle.crt', // OS X macports, curl-ca-bundle package
'/usr/local/share/curl/curl-ca-bundle.crt', // Default cURL CA bunde path (without --with-ca-bundle option)
'/usr/share/ssl/certs/ca-bundle.crt', // Really old RedHat?
'/etc/ssl/cert.pem', // OpenBSD
'/usr/local/etc/ssl/cert.pem', // FreeBSD 10.x
'/usr/local/etc/openssl/cert.pem', // OS X homebrew, openssl package
);
foreach ($caBundlePaths as $caBundle) {
if (@is_readable($caBundle) && static::validateCaFile($caBundle, $logger)) {
return self::$caPath = $caBundle;
}
}
foreach ($caBundlePaths as $caBundle) {
$caBundle = dirname($caBundle);
if (@is_dir($caBundle) && glob($caBundle.'/*')) {
return self::$caPath = $caBundle;
}
}
return self::$caPath = static::getBundledCaBundlePath(); // Bundled CA file, last resort
} | [
"public",
"static",
"function",
"getSystemCaRootBundlePath",
"(",
"LoggerInterface",
"$",
"logger",
"=",
"null",
")",
"{",
"if",
"(",
"self",
"::",
"$",
"caPath",
"!==",
"null",
")",
"{",
"return",
"self",
"::",
"$",
"caPath",
";",
"}",
"// If SSL_CERT_FILE ... | Returns the system CA bundle path, or a path to the bundled one
This method was adapted from Sslurp.
https://github.com/EvanDotPro/Sslurp
(c) Evan Coury <me@evancoury.com>
For the full copyright and license information, please see below:
Copyright (c) 2013, Evan Coury
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@param LoggerInterface $logger optional logger for information about which CA files were loaded
@return string path to a CA bundle file or directory | [
"Returns",
"the",
"system",
"CA",
"bundle",
"path",
"or",
"a",
"path",
"to",
"the",
"bundled",
"one"
] | 3a41bedd50d032bbff0cd0079c07f454f4a714f3 | https://github.com/composer/ca-bundle/blob/3a41bedd50d032bbff0cd0079c07f454f4a714f3/src/CaBundle.php#L64-L122 | train |
composer/ca-bundle | src/CaBundle.php | CaBundle.getBundledCaBundlePath | public static function getBundledCaBundlePath()
{
$caBundleFile = __DIR__.'/../res/cacert.pem';
// cURL does not understand 'phar://' paths
// see https://github.com/composer/ca-bundle/issues/10
if (0 === strpos($caBundleFile, 'phar://')) {
file_put_contents(
$tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'),
file_get_contents($caBundleFile)
);
register_shutdown_function(function() use ($tempCaBundleFile) {
@unlink($tempCaBundleFile);
});
$caBundleFile = $tempCaBundleFile;
}
return $caBundleFile;
} | php | public static function getBundledCaBundlePath()
{
$caBundleFile = __DIR__.'/../res/cacert.pem';
// cURL does not understand 'phar://' paths
// see https://github.com/composer/ca-bundle/issues/10
if (0 === strpos($caBundleFile, 'phar://')) {
file_put_contents(
$tempCaBundleFile = tempnam(sys_get_temp_dir(), 'openssl-ca-bundle-'),
file_get_contents($caBundleFile)
);
register_shutdown_function(function() use ($tempCaBundleFile) {
@unlink($tempCaBundleFile);
});
$caBundleFile = $tempCaBundleFile;
}
return $caBundleFile;
} | [
"public",
"static",
"function",
"getBundledCaBundlePath",
"(",
")",
"{",
"$",
"caBundleFile",
"=",
"__DIR__",
".",
"'/../res/cacert.pem'",
";",
"// cURL does not understand 'phar://' paths",
"// see https://github.com/composer/ca-bundle/issues/10",
"if",
"(",
"0",
"===",
"str... | Returns the path to the bundled CA file
In case you don't want to trust the user or the system, you can use this directly
@return string path to a CA bundle file | [
"Returns",
"the",
"path",
"to",
"the",
"bundled",
"CA",
"file"
] | 3a41bedd50d032bbff0cd0079c07f454f4a714f3 | https://github.com/composer/ca-bundle/blob/3a41bedd50d032bbff0cd0079c07f454f4a714f3/src/CaBundle.php#L131-L151 | train |
composer/ca-bundle | src/CaBundle.php | CaBundle.validateCaFile | public static function validateCaFile($filename, LoggerInterface $logger = null)
{
static $warned = false;
if (isset(self::$caFileValidity[$filename])) {
return self::$caFileValidity[$filename];
}
$contents = file_get_contents($filename);
// assume the CA is valid if php is vulnerable to
// https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html
if (!static::isOpensslParseSafe()) {
if (!$warned && $logger) {
$logger->warning(sprintf(
'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
PHP_VERSION
));
$warned = true;
}
$isValid = !empty($contents);
} else {
$isValid = (bool) openssl_x509_parse($contents);
}
if ($logger) {
$logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
}
return self::$caFileValidity[$filename] = $isValid;
} | php | public static function validateCaFile($filename, LoggerInterface $logger = null)
{
static $warned = false;
if (isset(self::$caFileValidity[$filename])) {
return self::$caFileValidity[$filename];
}
$contents = file_get_contents($filename);
// assume the CA is valid if php is vulnerable to
// https://www.sektioneins.de/advisories/advisory-012013-php-openssl_x509_parse-memory-corruption-vulnerability.html
if (!static::isOpensslParseSafe()) {
if (!$warned && $logger) {
$logger->warning(sprintf(
'Your version of PHP, %s, is affected by CVE-2013-6420 and cannot safely perform certificate validation, we strongly suggest you upgrade.',
PHP_VERSION
));
$warned = true;
}
$isValid = !empty($contents);
} else {
$isValid = (bool) openssl_x509_parse($contents);
}
if ($logger) {
$logger->debug('Checked CA file '.realpath($filename).': '.($isValid ? 'valid' : 'invalid'));
}
return self::$caFileValidity[$filename] = $isValid;
} | [
"public",
"static",
"function",
"validateCaFile",
"(",
"$",
"filename",
",",
"LoggerInterface",
"$",
"logger",
"=",
"null",
")",
"{",
"static",
"$",
"warned",
"=",
"false",
";",
"if",
"(",
"isset",
"(",
"self",
"::",
"$",
"caFileValidity",
"[",
"$",
"fil... | Validates a CA file using opensl_x509_parse only if it is safe to use
@param string $filename
@param LoggerInterface $logger optional logger for information about which CA files were loaded
@return bool | [
"Validates",
"a",
"CA",
"file",
"using",
"opensl_x509_parse",
"only",
"if",
"it",
"is",
"safe",
"to",
"use"
] | 3a41bedd50d032bbff0cd0079c07f454f4a714f3 | https://github.com/composer/ca-bundle/blob/3a41bedd50d032bbff0cd0079c07f454f4a714f3/src/CaBundle.php#L161-L192 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.getTypes | public function getTypes()
{
$classes = parent::getTypes();
foreach ($classes as $k => &$definition) {
if (empty($definition[$k]['properties'])) {
unset($classes[$k]);
continue;
}
$properties = array_filter(array_map(function ($property) {
if (!empty($property['validation'])) {
foreach ($property['validation'] as &$rule){
foreach ($rule as $type => &$item) {
if ($type === 'Valid') {
continue;
} else {
if (!is_array($item)){
$item = [];
}
$item['groups'] = ['xsd_rules'];
}
}
unset($item);
}
unset($rule);
return $property['validation'];
}
return null;
}, $definition[$k]['properties']));
if (empty($properties)) {
unset($classes[$k]);
continue;
}
$definition[$k] = [
'properties' => $properties
];
}
return $classes;
} | php | public function getTypes()
{
$classes = parent::getTypes();
foreach ($classes as $k => &$definition) {
if (empty($definition[$k]['properties'])) {
unset($classes[$k]);
continue;
}
$properties = array_filter(array_map(function ($property) {
if (!empty($property['validation'])) {
foreach ($property['validation'] as &$rule){
foreach ($rule as $type => &$item) {
if ($type === 'Valid') {
continue;
} else {
if (!is_array($item)){
$item = [];
}
$item['groups'] = ['xsd_rules'];
}
}
unset($item);
}
unset($rule);
return $property['validation'];
}
return null;
}, $definition[$k]['properties']));
if (empty($properties)) {
unset($classes[$k]);
continue;
}
$definition[$k] = [
'properties' => $properties
];
}
return $classes;
} | [
"public",
"function",
"getTypes",
"(",
")",
"{",
"$",
"classes",
"=",
"parent",
"::",
"getTypes",
"(",
")",
";",
"foreach",
"(",
"$",
"classes",
"as",
"$",
"k",
"=>",
"&",
"$",
"definition",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"definition",
"["... | Clean the properties for only remaining valid rules for Symfony Validation Constraints
@return PHPClass[] | [
"Clean",
"the",
"properties",
"for",
"only",
"remaining",
"valid",
"rules",
"for",
"Symfony",
"Validation",
"Constraints"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L23-L74 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.loadValidatorType | private function loadValidatorType(array &$property, Type $type, $arrayized = false)
{
$rules = [];
if (($restrictions = $type->getRestriction()) && $checks = $restrictions->getChecks()) {
foreach ($checks as $key => $check) {
switch ($key) {
case 'enumeration':
$rules[] = [
'Choice' => [
'choices' => array_map(function ($enum) {
return $enum['value'];
}, $check)
]
];
break;
// fractionDigits totalDigits validation makes no sense in object validation
// mainly because they are represented as floats
// case 'fractionDigits':
// foreach ($check as $item) {
// if ($item['value']>0) {
// $rules[] = [
// 'Regex' => "/^\-?(\\d+\\.\\d{{$item['value']}})|\\d*$/"
// ];
// }
// }
// break;
// case 'totalDigits':
// foreach ($check as $item) {
// $rules[] = [
// 'Regex' => "/^([^\d]*\d){{$item['value']}}[^\d]*$/"
// ];
// }
// break;
case 'length':
foreach ($check as $item) {
$rules[] = [
'Length' => [
'min' => $item['value'],
'max' => $item['value']
]
];
}
break;
case 'maxLength':
foreach ($check as $item) {
$rules[] = [
'Length' => [
'max' => $item['value']
]
];
}
break;
case 'minLength':
foreach ($check as $item) {
$rules[] = [
'Length' => [
'min' => $item['value']
]
];
}
break;
case 'pattern':
foreach ($check as $item) {
$rules[] = [
'Regex' => ['pattern' => "/{$item['value']}/"]
];
}
break;
case 'maxExclusive':
foreach ($check as $item) {
$rules[] = [
'LessThan' => ['value' => $item['value']]
];
}
break;
case 'maxInclusive':
foreach ($check as $item) {
$rules[] = [
'LessThanOrEqual' => ['value' => $item['value']]
];
}
break;
case 'minExclusive':
foreach ($check as $item) {
$rules[] = [
'GreaterThan' => ['value' => $item['value']]
];
}
break;
case 'minInclusive':
foreach ($check as $item) {
$rules[] = [
'GreaterThanOrEqual' => ['value' => $item['value']]
];
}
break;
}
}
}
if (!$arrayized) {
$property['validation'] = array_merge(!empty($property['validation']) ? $property['validation'] : [], $rules);
}
return $rules;
} | php | private function loadValidatorType(array &$property, Type $type, $arrayized = false)
{
$rules = [];
if (($restrictions = $type->getRestriction()) && $checks = $restrictions->getChecks()) {
foreach ($checks as $key => $check) {
switch ($key) {
case 'enumeration':
$rules[] = [
'Choice' => [
'choices' => array_map(function ($enum) {
return $enum['value'];
}, $check)
]
];
break;
// fractionDigits totalDigits validation makes no sense in object validation
// mainly because they are represented as floats
// case 'fractionDigits':
// foreach ($check as $item) {
// if ($item['value']>0) {
// $rules[] = [
// 'Regex' => "/^\-?(\\d+\\.\\d{{$item['value']}})|\\d*$/"
// ];
// }
// }
// break;
// case 'totalDigits':
// foreach ($check as $item) {
// $rules[] = [
// 'Regex' => "/^([^\d]*\d){{$item['value']}}[^\d]*$/"
// ];
// }
// break;
case 'length':
foreach ($check as $item) {
$rules[] = [
'Length' => [
'min' => $item['value'],
'max' => $item['value']
]
];
}
break;
case 'maxLength':
foreach ($check as $item) {
$rules[] = [
'Length' => [
'max' => $item['value']
]
];
}
break;
case 'minLength':
foreach ($check as $item) {
$rules[] = [
'Length' => [
'min' => $item['value']
]
];
}
break;
case 'pattern':
foreach ($check as $item) {
$rules[] = [
'Regex' => ['pattern' => "/{$item['value']}/"]
];
}
break;
case 'maxExclusive':
foreach ($check as $item) {
$rules[] = [
'LessThan' => ['value' => $item['value']]
];
}
break;
case 'maxInclusive':
foreach ($check as $item) {
$rules[] = [
'LessThanOrEqual' => ['value' => $item['value']]
];
}
break;
case 'minExclusive':
foreach ($check as $item) {
$rules[] = [
'GreaterThan' => ['value' => $item['value']]
];
}
break;
case 'minInclusive':
foreach ($check as $item) {
$rules[] = [
'GreaterThanOrEqual' => ['value' => $item['value']]
];
}
break;
}
}
}
if (!$arrayized) {
$property['validation'] = array_merge(!empty($property['validation']) ? $property['validation'] : [], $rules);
}
return $rules;
} | [
"private",
"function",
"loadValidatorType",
"(",
"array",
"&",
"$",
"property",
",",
"Type",
"$",
"type",
",",
"$",
"arrayized",
"=",
"false",
")",
"{",
"$",
"rules",
"=",
"[",
"]",
";",
"if",
"(",
"(",
"$",
"restrictions",
"=",
"$",
"type",
"->",
... | Load and convert XSD' restrictions to Symfony Validation Constraints
from a schema type
@param array $property
@param Type $type
@param boolean $arrayized | [
"Load",
"and",
"convert",
"XSD",
"restrictions",
"to",
"Symfony",
"Validation",
"Constraints",
"from",
"a",
"schema",
"type"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L84-L191 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.loadValidatorElement | private function loadValidatorElement(array &$property, ElementItem $element)
{
/* @var $element Element */
$type = $element->getType();
$attrs = [];
$arrayized = strpos($property['type'], 'array<') === 0;
if ($arrayized) {
if ($itemOfArray = $this->isArrayNestedElement($type)) {
$attrs = [
'min' => min($element->getMin(), $itemOfArray->getMin()),
'max' => $itemOfArray->getMax()
];
} elseif ($itemOfArray = $this->isArrayType($type)) {
$attrs = [
'min' => min($element->getMin(), $itemOfArray->getMin()),
'max' => $itemOfArray->getMax()
];
} elseif ($this->isArrayElement($element)) {
// $attrs = [
// 'min' => $element->getMin(),
// 'max' => $element->getMax()
// ];
}
}
if (isset($attrs['min']) && $attrs['min'] === 0) {
unset($attrs['min']);
}
if (isset($attrs['max']) && $attrs['max'] === -1) {
unset($attrs['max']);
}
$rules = $this->loadValidatorType($property, $type, $arrayized );
if ($element->getMin() > 0) {
$property['validation'][] = [
'NotNull' => null
];
}
if ($arrayized && count($attrs) > 0) {
$property['validation'][] = [
'Count' => $attrs
];
}
if ($arrayized && count($rules) > 0) {
// $rules[] = ['Valid' => null];
$property['validation'][] = [
'All' => ['constraints' => $rules]
];
} elseif ($type instanceof ComplexType) {
$property['validation'][] = [
'Valid' => null
];
}
} | php | private function loadValidatorElement(array &$property, ElementItem $element)
{
/* @var $element Element */
$type = $element->getType();
$attrs = [];
$arrayized = strpos($property['type'], 'array<') === 0;
if ($arrayized) {
if ($itemOfArray = $this->isArrayNestedElement($type)) {
$attrs = [
'min' => min($element->getMin(), $itemOfArray->getMin()),
'max' => $itemOfArray->getMax()
];
} elseif ($itemOfArray = $this->isArrayType($type)) {
$attrs = [
'min' => min($element->getMin(), $itemOfArray->getMin()),
'max' => $itemOfArray->getMax()
];
} elseif ($this->isArrayElement($element)) {
// $attrs = [
// 'min' => $element->getMin(),
// 'max' => $element->getMax()
// ];
}
}
if (isset($attrs['min']) && $attrs['min'] === 0) {
unset($attrs['min']);
}
if (isset($attrs['max']) && $attrs['max'] === -1) {
unset($attrs['max']);
}
$rules = $this->loadValidatorType($property, $type, $arrayized );
if ($element->getMin() > 0) {
$property['validation'][] = [
'NotNull' => null
];
}
if ($arrayized && count($attrs) > 0) {
$property['validation'][] = [
'Count' => $attrs
];
}
if ($arrayized && count($rules) > 0) {
// $rules[] = ['Valid' => null];
$property['validation'][] = [
'All' => ['constraints' => $rules]
];
} elseif ($type instanceof ComplexType) {
$property['validation'][] = [
'Valid' => null
];
}
} | [
"private",
"function",
"loadValidatorElement",
"(",
"array",
"&",
"$",
"property",
",",
"ElementItem",
"$",
"element",
")",
"{",
"/* @var $element Element */",
"$",
"type",
"=",
"$",
"element",
"->",
"getType",
"(",
")",
";",
"$",
"attrs",
"=",
"[",
"]",
"... | Load and convert XSD' restrictions to Symfony Validation Constraints
from a schema element including required rule
@param array $property
@param ElementItem $element
@param boolean $arrayize | [
"Load",
"and",
"convert",
"XSD",
"restrictions",
"to",
"Symfony",
"Validation",
"Constraints",
"from",
"a",
"schema",
"element",
"including",
"required",
"rule"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L201-L259 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.loadValidatorAttribute | private function loadValidatorAttribute(array &$property, AttributeItem $attribute)
{
/* @var $element Element */
$type = $attribute->getType();
$this->loadValidatorType($property, $type, false);
// Required properties
if ($attribute instanceof Attribute) {
if ($attribute->getUse() === Attribute::USE_REQUIRED) {
$property['validation'][] = [
'NotNull' => null
];
}
}
} | php | private function loadValidatorAttribute(array &$property, AttributeItem $attribute)
{
/* @var $element Element */
$type = $attribute->getType();
$this->loadValidatorType($property, $type, false);
// Required properties
if ($attribute instanceof Attribute) {
if ($attribute->getUse() === Attribute::USE_REQUIRED) {
$property['validation'][] = [
'NotNull' => null
];
}
}
} | [
"private",
"function",
"loadValidatorAttribute",
"(",
"array",
"&",
"$",
"property",
",",
"AttributeItem",
"$",
"attribute",
")",
"{",
"/* @var $element Element */",
"$",
"type",
"=",
"$",
"attribute",
"->",
"getType",
"(",
")",
";",
"$",
"this",
"->",
"loadVa... | Load and convert XSD' restrictions to Symfony Validation Constraints
from a schema attribute including required rule
@param array $property
@param AttributeItem $element
@param boolean $arrayize | [
"Load",
"and",
"convert",
"XSD",
"restrictions",
"to",
"Symfony",
"Validation",
"Constraints",
"from",
"a",
"schema",
"attribute",
"including",
"required",
"rule"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L269-L284 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.visitSimpleType | protected function visitSimpleType(&$class, &$data, SimpleType $type, $name)
{
parent::visitSimpleType($class, $data, $type, $name);
if ($restriction = $type->getRestriction()) {
$parent = $restriction->getBase();
if ($parent instanceof Type) {
if (!isset($data["properties"]['__value'])) {
$data["properties"]['__value'] = [];
}
$this->loadValidatorType($data["properties"]['__value'], $type);
}
}
} | php | protected function visitSimpleType(&$class, &$data, SimpleType $type, $name)
{
parent::visitSimpleType($class, $data, $type, $name);
if ($restriction = $type->getRestriction()) {
$parent = $restriction->getBase();
if ($parent instanceof Type) {
if (!isset($data["properties"]['__value'])) {
$data["properties"]['__value'] = [];
}
$this->loadValidatorType($data["properties"]['__value'], $type);
}
}
} | [
"protected",
"function",
"visitSimpleType",
"(",
"&",
"$",
"class",
",",
"&",
"$",
"data",
",",
"SimpleType",
"$",
"type",
",",
"$",
"name",
")",
"{",
"parent",
"::",
"visitSimpleType",
"(",
"$",
"class",
",",
"$",
"data",
",",
"$",
"type",
",",
"$",... | Override necessary to improve method to load validations from schema type
@param PHPClass $class
@param array $data
@param SimpleType $type
@param string $name | [
"Override",
"necessary",
"to",
"improve",
"method",
"to",
"load",
"validations",
"from",
"schema",
"type"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L294-L307 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.& | protected function &visitElement(&$class, Schema $schema, ElementItem $element, $arrayize = true)
{
$property = parent::visitElement($class, $schema, $element, $arrayize);
$this->loadValidatorElement($property, $element);
return $property;
} | php | protected function &visitElement(&$class, Schema $schema, ElementItem $element, $arrayize = true)
{
$property = parent::visitElement($class, $schema, $element, $arrayize);
$this->loadValidatorElement($property, $element);
return $property;
} | [
"protected",
"function",
"&",
"visitElement",
"(",
"&",
"$",
"class",
",",
"Schema",
"$",
"schema",
",",
"ElementItem",
"$",
"element",
",",
"$",
"arrayize",
"=",
"true",
")",
"{",
"$",
"property",
"=",
"parent",
"::",
"visitElement",
"(",
"$",
"class",
... | Override necessary to improve method to load validations from schema element
@param PHPClass $class
@param Schema $schema
@param ElementItem $element
@param boolean $arrayize
@return PHPProperty | [
"Override",
"necessary",
"to",
"improve",
"method",
"to",
"load",
"validations",
"from",
"schema",
"element"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L318-L324 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.& | protected function &visitAttribute(&$class, Schema $schema, AttributeItem $attribute)
{
$property = parent::visitAttribute($class, $schema, $attribute);
$this->loadValidatorAttribute($property, $attribute);
return $property;
} | php | protected function &visitAttribute(&$class, Schema $schema, AttributeItem $attribute)
{
$property = parent::visitAttribute($class, $schema, $attribute);
$this->loadValidatorAttribute($property, $attribute);
return $property;
} | [
"protected",
"function",
"&",
"visitAttribute",
"(",
"&",
"$",
"class",
",",
"Schema",
"$",
"schema",
",",
"AttributeItem",
"$",
"attribute",
")",
"{",
"$",
"property",
"=",
"parent",
"::",
"visitAttribute",
"(",
"$",
"class",
",",
"$",
"schema",
",",
"$... | Override necessary to improve method to load validations from schema attribute
@param PHPClass $class
@param Schema $schema
@param AttributeItem $attribute
@return array | [
"Override",
"necessary",
"to",
"improve",
"method",
"to",
"load",
"validations",
"from",
"schema",
"attribute"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L336-L343 | train |
goetas-webservices/xsd2php | src/Jms/YamlValidatorConverter.php | YamlValidatorConverter.& | protected function &handleClassExtension(&$class, &$data, Type $type, $parentName)
{
$property = parent::handleClassExtension($class, $data, $type, $parentName);
$rules = $this->loadValidatorType($property, $type, false );
$property['validation'] = array_merge(!empty($property['validation']) ? $property['validation'] : [], $rules);
return $property;
} | php | protected function &handleClassExtension(&$class, &$data, Type $type, $parentName)
{
$property = parent::handleClassExtension($class, $data, $type, $parentName);
$rules = $this->loadValidatorType($property, $type, false );
$property['validation'] = array_merge(!empty($property['validation']) ? $property['validation'] : [], $rules);
return $property;
} | [
"protected",
"function",
"&",
"handleClassExtension",
"(",
"&",
"$",
"class",
",",
"&",
"$",
"data",
",",
"Type",
"$",
"type",
",",
"$",
"parentName",
")",
"{",
"$",
"property",
"=",
"parent",
"::",
"handleClassExtension",
"(",
"$",
"class",
",",
"$",
... | Responsible for handler all properties from extension types
@param PHPClass $class
@param array $data
@param Type $type
@param string $parentName | [
"Responsible",
"for",
"handler",
"all",
"properties",
"from",
"extension",
"types"
] | 9d6f0425481a45dd017c41e54a7f8a985607dfeb | https://github.com/goetas-webservices/xsd2php/blob/9d6f0425481a45dd017c41e54a7f8a985607dfeb/src/Jms/YamlValidatorConverter.php#L353-L361 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client._call | private function _call($method, $resource, $action, $args)
{
$args = array_merge(
[
'id' => '',
'actionid' => '',
'filters' => [],
'body' => $method == 'GET' ? null : '{}',
], array_change_key_case($args)
);
$url = $this->buildURL($resource, $action, $args['id'], $args['actionid']);
$contentType = ($action == 'csvdata/text:plain' || $action == 'csverror/text:csv') ? 'text/plain' : 'application/json';
$isBasicAuth = $this->isBasicAuthentication($this->apikey, $this->apisecret);
$auth = $isBasicAuth ? [$this->apikey, $this->apisecret] : [$this->apitoken];
$request = new Request(
$auth, $method, $url, $args['filters'], $args['body'], $contentType, $this->requestOptions
);
return $request->call($this->call);
} | php | private function _call($method, $resource, $action, $args)
{
$args = array_merge(
[
'id' => '',
'actionid' => '',
'filters' => [],
'body' => $method == 'GET' ? null : '{}',
], array_change_key_case($args)
);
$url = $this->buildURL($resource, $action, $args['id'], $args['actionid']);
$contentType = ($action == 'csvdata/text:plain' || $action == 'csverror/text:csv') ? 'text/plain' : 'application/json';
$isBasicAuth = $this->isBasicAuthentication($this->apikey, $this->apisecret);
$auth = $isBasicAuth ? [$this->apikey, $this->apisecret] : [$this->apitoken];
$request = new Request(
$auth, $method, $url, $args['filters'], $args['body'], $contentType, $this->requestOptions
);
return $request->call($this->call);
} | [
"private",
"function",
"_call",
"(",
"$",
"method",
",",
"$",
"resource",
",",
"$",
"action",
",",
"$",
"args",
")",
"{",
"$",
"args",
"=",
"array_merge",
"(",
"[",
"'id'",
"=>",
"''",
",",
"'actionid'",
"=>",
"''",
",",
"'filters'",
"=>",
"[",
"]"... | Magic method to call a mailjet resource
@param string $method Http method
@param string $resource mailjet resource
@param string $action mailjet resource action
@param array $args Request arguments
@return Response server response | [
"Magic",
"method",
"to",
"call",
"a",
"mailjet",
"resource"
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L99-L121 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client.getApiUrl | private function getApiUrl()
{
$h = $this->secure === true ? 'https' : 'http';
return sprintf('%s://%s/%s/', $h, $this->url, $this->version);
} | php | private function getApiUrl()
{
$h = $this->secure === true ? 'https' : 'http';
return sprintf('%s://%s/%s/', $h, $this->url, $this->version);
} | [
"private",
"function",
"getApiUrl",
"(",
")",
"{",
"$",
"h",
"=",
"$",
"this",
"->",
"secure",
"===",
"true",
"?",
"'https'",
":",
"'http'",
";",
"return",
"sprintf",
"(",
"'%s://%s/%s/'",
",",
"$",
"h",
",",
"$",
"this",
"->",
"url",
",",
"$",
"th... | Build the base API url depending on wether user need a secure connection
or not
@return string the API url; | [
"Build",
"the",
"base",
"API",
"url",
"depending",
"on",
"wether",
"user",
"need",
"a",
"secure",
"connection",
"or",
"not"
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L128-L132 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client.buildURL | private function buildURL($resource, $action, $id, $actionid)
{
$path = 'REST';
if (in_array($resource, $this->smsResources)) {
$path = '';
} elseif (in_array($action, $this->dataAction)) {
$path = 'DATA';
}
$arrayFilter = [$path, $resource, $id, $action, $actionid];
return $this->getApiUrl() . join('/', array_filter($arrayFilter));
} | php | private function buildURL($resource, $action, $id, $actionid)
{
$path = 'REST';
if (in_array($resource, $this->smsResources)) {
$path = '';
} elseif (in_array($action, $this->dataAction)) {
$path = 'DATA';
}
$arrayFilter = [$path, $resource, $id, $action, $actionid];
return $this->getApiUrl() . join('/', array_filter($arrayFilter));
} | [
"private",
"function",
"buildURL",
"(",
"$",
"resource",
",",
"$",
"action",
",",
"$",
"id",
",",
"$",
"actionid",
")",
"{",
"$",
"path",
"=",
"'REST'",
";",
"if",
"(",
"in_array",
"(",
"$",
"resource",
",",
"$",
"this",
"->",
"smsResources",
")",
... | Build the final call url without query strings
@param string $resource Mailjet resource
@param string $action Mailjet resource action
@param string $id mailjet resource id
@param string $actionid mailjet resource actionid
@return string final call url | [
"Build",
"the",
"final",
"call",
"url",
"without",
"query",
"strings"
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L232-L243 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client.setOptions | private function setOptions($options, $resource)
{
if (!empty($options['version']) && is_string($options['version'])) {
$this->version = $options['version'];
} elseif (!empty($resource[2])) {
$this->version = $resource[2];
}
if (!empty($options['url']) && is_string($options['url'])) {
$this->url = $options['url'];
}
if (isset($options['secured']) && is_bool($options['secured'])) {
$this->secure = $options['secured'];
}
if (isset($options['call']) && is_bool($options['call'])) {
$this->call = $options['call'];
}
$this->changed = true;
} | php | private function setOptions($options, $resource)
{
if (!empty($options['version']) && is_string($options['version'])) {
$this->version = $options['version'];
} elseif (!empty($resource[2])) {
$this->version = $resource[2];
}
if (!empty($options['url']) && is_string($options['url'])) {
$this->url = $options['url'];
}
if (isset($options['secured']) && is_bool($options['secured'])) {
$this->secure = $options['secured'];
}
if (isset($options['call']) && is_bool($options['call'])) {
$this->call = $options['call'];
}
$this->changed = true;
} | [
"private",
"function",
"setOptions",
"(",
"$",
"options",
",",
"$",
"resource",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'version'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"options",
"[",
"'version'",
"]",
")",
")",
"{",
"$",
"... | Temporary set the variables generating the url
@param array $options contain temporary modifications for the client
@param array $resource may contain the version linked to the ressource | [
"Temporary",
"set",
"the",
"variables",
"generating",
"the",
"url"
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L268-L288 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client.setSettings | private function setSettings()
{
if (!empty($this->settings['url']) && is_string($this->settings['url'])) {
$this->url = $this->settings['url'];
} if (!empty($this->settings['version']) && is_string($this->settings['version'])) {
$this->version = $this->settings['version'];
} if (isset($this->settings['call']) && is_bool($this->settings['call'])) {
$this->call = $this->settings['call'];
} if (isset($this->settings['secured']) && is_bool($this->settings['secured'])) {
$this->secure = $this->settings['secured'];
}
$this->changed = false;
} | php | private function setSettings()
{
if (!empty($this->settings['url']) && is_string($this->settings['url'])) {
$this->url = $this->settings['url'];
} if (!empty($this->settings['version']) && is_string($this->settings['version'])) {
$this->version = $this->settings['version'];
} if (isset($this->settings['call']) && is_bool($this->settings['call'])) {
$this->call = $this->settings['call'];
} if (isset($this->settings['secured']) && is_bool($this->settings['secured'])) {
$this->secure = $this->settings['secured'];
}
$this->changed = false;
} | [
"private",
"function",
"setSettings",
"(",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"this",
"->",
"settings",
"[",
"'url'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"this",
"->",
"settings",
"[",
"'url'",
"]",
")",
")",
"{",
"$",
"this",
"->",
... | set back the variables generating the url | [
"set",
"back",
"the",
"variables",
"generating",
"the",
"url"
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L293-L305 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client.initSettings | private function initSettings($call, $settings = [])
{
if (!empty($settings['url']) && is_string($settings['url'])) {
$this->settings['url'] = $settings['url'];
} else {
$this->settings['url'] = $this->url;
}
if (!empty($settings['version']) && is_string($settings['version'])) {
$this->settings['version'] = $settings['version'];
} else {
$this->settings['version'] = $this->version;
}
$settings['call'] = $call;
if (isset($settings['call']) && is_bool($settings['call'])) {
$this->settings['call'] = $settings['call'];
} else {
$this->settings['call'] = $this->call;
}
if (isset($settings['secured']) && is_bool($settings['secured'])) {
$this->settings['secured'] = $settings['secured'];
} else {
$this->settings['secured'] = $this->secure;
}
$this->changed = false;
} | php | private function initSettings($call, $settings = [])
{
if (!empty($settings['url']) && is_string($settings['url'])) {
$this->settings['url'] = $settings['url'];
} else {
$this->settings['url'] = $this->url;
}
if (!empty($settings['version']) && is_string($settings['version'])) {
$this->settings['version'] = $settings['version'];
} else {
$this->settings['version'] = $this->version;
}
$settings['call'] = $call;
if (isset($settings['call']) && is_bool($settings['call'])) {
$this->settings['call'] = $settings['call'];
} else {
$this->settings['call'] = $this->call;
}
if (isset($settings['secured']) && is_bool($settings['secured'])) {
$this->settings['secured'] = $settings['secured'];
} else {
$this->settings['secured'] = $this->secure;
}
$this->changed = false;
} | [
"private",
"function",
"initSettings",
"(",
"$",
"call",
",",
"$",
"settings",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"settings",
"[",
"'url'",
"]",
")",
"&&",
"is_string",
"(",
"$",
"settings",
"[",
"'url'",
"]",
")",
")",
"... | Set a backup if the variables generating the url are change during a call. | [
"Set",
"a",
"backup",
"if",
"the",
"variables",
"generating",
"the",
"url",
"are",
"change",
"during",
"a",
"call",
"."
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L310-L338 | train |
mailjet/mailjet-apiv3-php | src/Mailjet/Client.php | Client.addRequestOption | public function addRequestOption($key, $value)
{
if ((!is_null($key)) && (!is_null($value))) {
$this->requestOptions[$key] = $value;
}
} | php | public function addRequestOption($key, $value)
{
if ((!is_null($key)) && (!is_null($value))) {
$this->requestOptions[$key] = $value;
}
} | [
"public",
"function",
"addRequestOption",
"(",
"$",
"key",
",",
"$",
"value",
")",
"{",
"if",
"(",
"(",
"!",
"is_null",
"(",
"$",
"key",
")",
")",
"&&",
"(",
"!",
"is_null",
"(",
"$",
"value",
")",
")",
")",
"{",
"$",
"this",
"->",
"requestOption... | Add a HTTP request option
@param array $key
@param array $value
[IMPORTANT]Default options will be overwritten
if such option is provided
@see \GuzzleHttp\RequestOptions for a list of available request options. | [
"Add",
"a",
"HTTP",
"request",
"option"
] | 2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947 | https://github.com/mailjet/mailjet-apiv3-php/blob/2c04c9aeb87e0405c9f4aa7e4b14473fee4a9947/src/Mailjet/Client.php#L384-L389 | train |
LaravelDaily/quickadmin | src/Builders/MigrationBuilder.php | MigrationBuilder.buildParts | private function buildParts($template)
{
$camelName = Str::camel($this->name);
$tableName = strtolower($camelName);
$template = str_replace([
'$TABLENAME$',
'$CLASS$',
'$FIELDS$'
], [
$tableName,
$this->className,
$this->buildFields()
], $template);
return $template;
} | php | private function buildParts($template)
{
$camelName = Str::camel($this->name);
$tableName = strtolower($camelName);
$template = str_replace([
'$TABLENAME$',
'$CLASS$',
'$FIELDS$'
], [
$tableName,
$this->className,
$this->buildFields()
], $template);
return $template;
} | [
"private",
"function",
"buildParts",
"(",
"$",
"template",
")",
"{",
"$",
"camelName",
"=",
"Str",
"::",
"camel",
"(",
"$",
"this",
"->",
"name",
")",
";",
"$",
"tableName",
"=",
"strtolower",
"(",
"$",
"camelName",
")",
";",
"$",
"template",
"=",
"s... | Build migration template parts
@param $template
@return mixed | [
"Build",
"migration",
"template",
"parts"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/MigrationBuilder.php#L53-L68 | train |
LaravelDaily/quickadmin | src/Builders/MigrationBuilder.php | MigrationBuilder.buildFields | private function buildFields()
{
$migrationTypes = FieldsDescriber::migration();
$used = [];
$fields = '$table->increments("id");' . "\r\n";
foreach ($this->fields as $field) {
// Check if there is no duplication for radio and checkbox
if (!in_array($field->title, $used)) {
// Generate our migration line
$migrationLine = str_replace([
'$FIELDNAME$',
'$STATE$',
'$RELATIONSHIP$',
], [
$field->title,
$field->default == 'true' ? 1 : 0,
$field->relationship_name
], $migrationTypes[$field->type]);
$fields .= ' '; // Add formatting space to the migration
if ($field->type == 'enum') {
$values = '';
$field->enum = explode(',', $field->enum);
foreach ($field->enum as $val) {
// Remove first whitespace
if (strpos(substr($val, 0, 1), ' ') !== false) {
$len = strlen($val);
$val = substr($val, 1, $len);
}
$values .= '"' . $val . '"';
if ($val != last($field->enum)) {
$values .= ', ';
}
}
$migrationLine = str_replace('$VALUES$', $values, $migrationLine);
}
$fields .= '$table->' . $migrationLine;
if (in_array($field->validation, FieldsDescriber::nullables())) {
$fields .= '->nullable()';
}
$fields .= ";\r\n";
if ($field->type == 'relationship') {
$used[$field->relationship_name] = $field->relationship_name;
} else {
$used[$field->title] = $field->title;
}
}
}
$fields .= ' '; // Add formatting space to the migration
$fields .= '$table->timestamps();';
if ($this->soft == 1) {
$fields .= "\r\n";
$fields .= ' '; // Add formatting space to the migration
$fields .= '$table->softDeletes();';
}
return $fields;
} | php | private function buildFields()
{
$migrationTypes = FieldsDescriber::migration();
$used = [];
$fields = '$table->increments("id");' . "\r\n";
foreach ($this->fields as $field) {
// Check if there is no duplication for radio and checkbox
if (!in_array($field->title, $used)) {
// Generate our migration line
$migrationLine = str_replace([
'$FIELDNAME$',
'$STATE$',
'$RELATIONSHIP$',
], [
$field->title,
$field->default == 'true' ? 1 : 0,
$field->relationship_name
], $migrationTypes[$field->type]);
$fields .= ' '; // Add formatting space to the migration
if ($field->type == 'enum') {
$values = '';
$field->enum = explode(',', $field->enum);
foreach ($field->enum as $val) {
// Remove first whitespace
if (strpos(substr($val, 0, 1), ' ') !== false) {
$len = strlen($val);
$val = substr($val, 1, $len);
}
$values .= '"' . $val . '"';
if ($val != last($field->enum)) {
$values .= ', ';
}
}
$migrationLine = str_replace('$VALUES$', $values, $migrationLine);
}
$fields .= '$table->' . $migrationLine;
if (in_array($field->validation, FieldsDescriber::nullables())) {
$fields .= '->nullable()';
}
$fields .= ";\r\n";
if ($field->type == 'relationship') {
$used[$field->relationship_name] = $field->relationship_name;
} else {
$used[$field->title] = $field->title;
}
}
}
$fields .= ' '; // Add formatting space to the migration
$fields .= '$table->timestamps();';
if ($this->soft == 1) {
$fields .= "\r\n";
$fields .= ' '; // Add formatting space to the migration
$fields .= '$table->softDeletes();';
}
return $fields;
} | [
"private",
"function",
"buildFields",
"(",
")",
"{",
"$",
"migrationTypes",
"=",
"FieldsDescriber",
"::",
"migration",
"(",
")",
";",
"$",
"used",
"=",
"[",
"]",
";",
"$",
"fields",
"=",
"'$table->increments(\"id\");'",
".",
"\"\\r\\n\"",
";",
"foreach",
"("... | Build migration fields
@return string | [
"Build",
"migration",
"fields"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/MigrationBuilder.php#L74-L130 | train |
LaravelDaily/quickadmin | src/Builders/MigrationBuilder.php | MigrationBuilder.names | private function names()
{
$fileName = date("Y_m_d_His") . '_create_';
$fileName .= str_replace(' ', '_', $this->name);
$fileName = strtolower($fileName) . '_table.php';
$this->fileName = $fileName;
$className = 'Create' . ' ' . $this->name . ' Table';
$className = Str::camel($className);
$this->className = ucfirst($className);
} | php | private function names()
{
$fileName = date("Y_m_d_His") . '_create_';
$fileName .= str_replace(' ', '_', $this->name);
$fileName = strtolower($fileName) . '_table.php';
$this->fileName = $fileName;
$className = 'Create' . ' ' . $this->name . ' Table';
$className = Str::camel($className);
$this->className = ucfirst($className);
} | [
"private",
"function",
"names",
"(",
")",
"{",
"$",
"fileName",
"=",
"date",
"(",
"\"Y_m_d_His\"",
")",
".",
"'_create_'",
";",
"$",
"fileName",
".=",
"str_replace",
"(",
"' '",
",",
"'_'",
",",
"$",
"this",
"->",
"name",
")",
";",
"$",
"fileName",
"... | Generate file and class names for the migration | [
"Generate",
"file",
"and",
"class",
"names",
"for",
"the",
"migration"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/MigrationBuilder.php#L135-L145 | train |
LaravelDaily/quickadmin | src/Builders/ControllerBuilder.php | ControllerBuilder.buildParts | private function buildParts($template)
{
$template = str_replace([
'$NAMESPACE$',
'$MODEL$',
'$CREATEREQUESTNAME$',
'$UPDATEREQUESTNAME$',
'$CLASS$',
'$COLLECTION$',
'$RESOURCE$',
'$INDEXGET$',
'$RELATIONSHIPS$',
'$RELATIONSHIP_COMPACT$',
'$RELATIONSHIP_COMPACT_EDIT$',
'$RELATIONSHIP_NAMESPACES$',
'$FILETRAIT$',
'$FILESAVING$',
'$ENUM$',
], [
$this->namespace,
$this->modelName,
$this->createRequestName,
$this->updateRequestName,
$this->className,
strtolower($this->modelName),
strtolower($this->modelName),
$this->indexBuilder(),
$this->relationshipsBuilder(),
$this->compactBuilder(),
$this->compactEditBuilder(),
$this->relationshipsNamespaces(),
$this->files > 0 ? 'use App\Http\Controllers\Traits\FileUploadTrait;' : '',
$this->files > 0 ? '$request = $this->saveFiles($request);' : '',
$this->enum > 0 ? $this->enum() : '',
], $template);
return $template;
} | php | private function buildParts($template)
{
$template = str_replace([
'$NAMESPACE$',
'$MODEL$',
'$CREATEREQUESTNAME$',
'$UPDATEREQUESTNAME$',
'$CLASS$',
'$COLLECTION$',
'$RESOURCE$',
'$INDEXGET$',
'$RELATIONSHIPS$',
'$RELATIONSHIP_COMPACT$',
'$RELATIONSHIP_COMPACT_EDIT$',
'$RELATIONSHIP_NAMESPACES$',
'$FILETRAIT$',
'$FILESAVING$',
'$ENUM$',
], [
$this->namespace,
$this->modelName,
$this->createRequestName,
$this->updateRequestName,
$this->className,
strtolower($this->modelName),
strtolower($this->modelName),
$this->indexBuilder(),
$this->relationshipsBuilder(),
$this->compactBuilder(),
$this->compactEditBuilder(),
$this->relationshipsNamespaces(),
$this->files > 0 ? 'use App\Http\Controllers\Traits\FileUploadTrait;' : '',
$this->files > 0 ? '$request = $this->saveFiles($request);' : '',
$this->enum > 0 ? $this->enum() : '',
], $template);
return $template;
} | [
"private",
"function",
"buildParts",
"(",
"$",
"template",
")",
"{",
"$",
"template",
"=",
"str_replace",
"(",
"[",
"'$NAMESPACE$'",
",",
"'$MODEL$'",
",",
"'$CREATEREQUESTNAME$'",
",",
"'$UPDATEREQUESTNAME$'",
",",
"'$CLASS$'",
",",
"'$COLLECTION$'",
",",
"'$RESO... | Build controller template parts
@param $template
@return mixed | [
"Build",
"controller",
"template",
"parts"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ControllerBuilder.php#L70-L107 | train |
LaravelDaily/quickadmin | src/Builders/ControllerBuilder.php | ControllerBuilder.indexBuilder | public function indexBuilder()
{
if ($this->relationships == 0) {
return '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::all();';
} else {
$relationship = '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::$WITH$get();';
foreach ($this->fields as $field) {
if ($field->type == 'relationship') {
$relationship = str_replace([
'$WITH$'
], [
'with("' . $field->relationship_name . '")->$WITH$'
], $relationship);
}
}
$relationship = str_replace('$WITH$', '', $relationship);
return $relationship;
}
} | php | public function indexBuilder()
{
if ($this->relationships == 0) {
return '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::all();';
} else {
$relationship = '$' . strtolower($this->modelName) . ' = ' . $this->modelName . '::$WITH$get();';
foreach ($this->fields as $field) {
if ($field->type == 'relationship') {
$relationship = str_replace([
'$WITH$'
], [
'with("' . $field->relationship_name . '")->$WITH$'
], $relationship);
}
}
$relationship = str_replace('$WITH$', '', $relationship);
return $relationship;
}
} | [
"public",
"function",
"indexBuilder",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relationships",
"==",
"0",
")",
"{",
"return",
"'$'",
".",
"strtolower",
"(",
"$",
"this",
"->",
"modelName",
")",
".",
"' = '",
".",
"$",
"this",
"->",
"modelName",
... | Build our index template
@return mixed|string | [
"Build",
"our",
"index",
"template"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ControllerBuilder.php#L113-L132 | train |
LaravelDaily/quickadmin | src/Builders/ControllerBuilder.php | ControllerBuilder.compactBuilder | public function compactBuilder()
{
if ($this->relationships == 0 && $this->enum == 0) {
return '';
} else {
$compact = ', compact($RELATIONS$)';
if ($this->relationships > 0) {
$first = true;
foreach ($this->fields as $field) {
if ($field->type == 'relationship') {
$toReplace = '';
if ($first != true) {
$toReplace .= ', ';
} else {
$first = false;
}
$toReplace .= '"' . $field->relationship_name . '"$RELATIONS$';
$compact = str_replace('$RELATIONS$', $toReplace, $compact);
}
}
}
if ($this->enum > 0) {
if (! isset($first)) {
$first = true;
}
foreach ($this->fields as $field) {
if ($field->type == 'enum') {
$toReplace = '';
if ($first != true) {
$toReplace .= ', ';
} else {
$first = false;
}
$toReplace .= '"' . $field->title . '"$RELATIONS$';
$compact = str_replace('$RELATIONS$', $toReplace, $compact);
}
}
}
$compact = str_replace('$RELATIONS$', '', $compact);
return $compact;
}
} | php | public function compactBuilder()
{
if ($this->relationships == 0 && $this->enum == 0) {
return '';
} else {
$compact = ', compact($RELATIONS$)';
if ($this->relationships > 0) {
$first = true;
foreach ($this->fields as $field) {
if ($field->type == 'relationship') {
$toReplace = '';
if ($first != true) {
$toReplace .= ', ';
} else {
$first = false;
}
$toReplace .= '"' . $field->relationship_name . '"$RELATIONS$';
$compact = str_replace('$RELATIONS$', $toReplace, $compact);
}
}
}
if ($this->enum > 0) {
if (! isset($first)) {
$first = true;
}
foreach ($this->fields as $field) {
if ($field->type == 'enum') {
$toReplace = '';
if ($first != true) {
$toReplace .= ', ';
} else {
$first = false;
}
$toReplace .= '"' . $field->title . '"$RELATIONS$';
$compact = str_replace('$RELATIONS$', $toReplace, $compact);
}
}
}
$compact = str_replace('$RELATIONS$', '', $compact);
return $compact;
}
} | [
"public",
"function",
"compactBuilder",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relationships",
"==",
"0",
"&&",
"$",
"this",
"->",
"enum",
"==",
"0",
")",
"{",
"return",
"''",
";",
"}",
"else",
"{",
"$",
"compact",
"=",
"', compact($RELATIONS$)'... | Build compact for create form
@return mixed|string | [
"Build",
"compact",
"for",
"create",
"form"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ControllerBuilder.php#L193-L235 | train |
LaravelDaily/quickadmin | src/Builders/ControllerBuilder.php | ControllerBuilder.compactEditBuilder | public function compactEditBuilder()
{
if ($this->relationships == 0 && $this->enum == 0) {
return '';
} else {
$compact = '';
if ($this->relationships > 0) {
foreach ($this->fields as $field) {
if ($field->type == 'relationship') {
$compact .= ', "' . $field->relationship_name . '"';
}
}
}
if ($this->enum > 0) {
foreach ($this->fields as $field) {
if ($field->type == 'enum') {
$compact .= ', "' . $field->title . '"';
}
}
}
return $compact;
}
} | php | public function compactEditBuilder()
{
if ($this->relationships == 0 && $this->enum == 0) {
return '';
} else {
$compact = '';
if ($this->relationships > 0) {
foreach ($this->fields as $field) {
if ($field->type == 'relationship') {
$compact .= ', "' . $field->relationship_name . '"';
}
}
}
if ($this->enum > 0) {
foreach ($this->fields as $field) {
if ($field->type == 'enum') {
$compact .= ', "' . $field->title . '"';
}
}
}
return $compact;
}
} | [
"public",
"function",
"compactEditBuilder",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"relationships",
"==",
"0",
"&&",
"$",
"this",
"->",
"enum",
"==",
"0",
")",
"{",
"return",
"''",
";",
"}",
"else",
"{",
"$",
"compact",
"=",
"''",
";",
"if",
... | Build compact for edit form
@return string | [
"Build",
"compact",
"for",
"edit",
"form"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ControllerBuilder.php#L241-L264 | train |
LaravelDaily/quickadmin | src/Builders/RequestBuilder.php | RequestBuilder.build | public function build()
{
$cache = new QuickCache();
$cached = $cache->get('fieldsinfo');
$this->template = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'request';
$this->name = $cached['name'];
$this->fields = $cached['fields'];
$this->soft = $cached['soft_delete'];
$this->names();
$template = [
$this->loadTemplate(),
$this->loadTemplate()
];
$template = $this->buildParts($template);
$this->publish($template);
} | php | public function build()
{
$cache = new QuickCache();
$cached = $cache->get('fieldsinfo');
$this->template = __DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'request';
$this->name = $cached['name'];
$this->fields = $cached['fields'];
$this->soft = $cached['soft_delete'];
$this->names();
$template = [
$this->loadTemplate(),
$this->loadTemplate()
];
$template = $this->buildParts($template);
$this->publish($template);
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"cache",
"=",
"new",
"QuickCache",
"(",
")",
";",
"$",
"cached",
"=",
"$",
"cache",
"->",
"get",
"(",
"'fieldsinfo'",
")",
";",
"$",
"this",
"->",
"template",
"=",
"__DIR__",
".",
"DIRECTORY_SEPARATOR"... | Build our request file | [
"Build",
"our",
"request",
"file"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/RequestBuilder.php#L24-L39 | train |
LaravelDaily/quickadmin | src/Builders/RequestBuilder.php | RequestBuilder.buildParts | private function buildParts($template)
{
$template[0] = str_replace([
'$NAMESPACE$',
'$CLASS$',
'$RULES$'
], [
$this->namespace,
'Create' . $this->className,
$this->buildRules(0),
], $template[0]);
$template[1] = str_replace([
'$NAMESPACE$',
'$CLASS$',
'$RULES$'
], [
$this->namespace,
'Update' . $this->className,
$this->buildRules(1),
], $template[1]);
return $template;
} | php | private function buildParts($template)
{
$template[0] = str_replace([
'$NAMESPACE$',
'$CLASS$',
'$RULES$'
], [
$this->namespace,
'Create' . $this->className,
$this->buildRules(0),
], $template[0]);
$template[1] = str_replace([
'$NAMESPACE$',
'$CLASS$',
'$RULES$'
], [
$this->namespace,
'Update' . $this->className,
$this->buildRules(1),
], $template[1]);
return $template;
} | [
"private",
"function",
"buildParts",
"(",
"$",
"template",
")",
"{",
"$",
"template",
"[",
"0",
"]",
"=",
"str_replace",
"(",
"[",
"'$NAMESPACE$'",
",",
"'$CLASS$'",
",",
"'$RULES$'",
"]",
",",
"[",
"$",
"this",
"->",
"namespace",
",",
"'Create'",
".",
... | Build request template parts
@param $template
@return mixed | [
"Build",
"request",
"template",
"parts"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/RequestBuilder.php#L56-L79 | train |
LaravelDaily/quickadmin | src/Controllers/QuickadminMenuController.php | QuickadminMenuController.index | public function index()
{
$menusList = Menu::with(['children'])
->where('menu_type', '!=', 0)
->where('parent_id', null)
->orderBy('position')->get();
return view('qa::menus.index', compact('menusList'));
} | php | public function index()
{
$menusList = Menu::with(['children'])
->where('menu_type', '!=', 0)
->where('parent_id', null)
->orderBy('position')->get();
return view('qa::menus.index', compact('menusList'));
} | [
"public",
"function",
"index",
"(",
")",
"{",
"$",
"menusList",
"=",
"Menu",
"::",
"with",
"(",
"[",
"'children'",
"]",
")",
"->",
"where",
"(",
"'menu_type'",
",",
"'!='",
",",
"0",
")",
"->",
"where",
"(",
"'parent_id'",
",",
"null",
")",
"->",
"... | Quickadmin menu list page
@return \BladeView|bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"Quickadmin",
"menu",
"list",
"page"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Controllers/QuickadminMenuController.php#L26-L34 | train |
LaravelDaily/quickadmin | src/Controllers/QuickadminMenuController.php | QuickadminMenuController.rearrange | public function rearrange(Request $request)
{
$menusList = Menu::with(['children'])
->where('menu_type', '!=', 0)
->where('parent_id', null)
->orderBy('position')->get();
foreach ($menusList as $menu) {
if ($menu->children()->first() == null) {
$menu->position = $request->{'menu-' . $menu->id};
$menu->save();
} else {
$menu->position = $request->{'menu-' . $menu->id};
$menu->save();
foreach ($menu->children as $child) {
$child->position = $request->{'child-' . $child->id};
$child->parent_id = $request->{'child-parent-' . $child->id};
$child->save();
}
}
}
return redirect()->back();
} | php | public function rearrange(Request $request)
{
$menusList = Menu::with(['children'])
->where('menu_type', '!=', 0)
->where('parent_id', null)
->orderBy('position')->get();
foreach ($menusList as $menu) {
if ($menu->children()->first() == null) {
$menu->position = $request->{'menu-' . $menu->id};
$menu->save();
} else {
$menu->position = $request->{'menu-' . $menu->id};
$menu->save();
foreach ($menu->children as $child) {
$child->position = $request->{'child-' . $child->id};
$child->parent_id = $request->{'child-parent-' . $child->id};
$child->save();
}
}
}
return redirect()->back();
} | [
"public",
"function",
"rearrange",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"menusList",
"=",
"Menu",
"::",
"with",
"(",
"[",
"'children'",
"]",
")",
"->",
"where",
"(",
"'menu_type'",
",",
"'!='",
",",
"0",
")",
"->",
"where",
"(",
"'parent_id'"... | Rearrange quickadmin menu items
@param Request $request
@return \Illuminate\Http\RedirectResponse | [
"Rearrange",
"quickadmin",
"menu",
"items"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Controllers/QuickadminMenuController.php#L43-L65 | train |
LaravelDaily/quickadmin | src/Controllers/QuickadminMenuController.php | QuickadminMenuController.createCrud | public function createCrud()
{
$fieldTypes = FieldsDescriber::types();
$fieldValidation = FieldsDescriber::validation();
$defaultValuesCbox = FieldsDescriber::default_cbox();
$menusSelect = Menu::whereNotIn('menu_type', [2, 3])->pluck('title', 'id');
$roles = Role::all();
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
// Get columns for relationship
$models = [];
foreach (Menu::whereNotIn('menu_type', [2, 3])->get() as $menu) {
// We are having a default User model
if ($menu->title == 'User' && $menu->is_menu == 0) {
$tableName = 'users';
} else {
$tableName = strtolower($menu->name);
}
$models[$menu->id] = Schema::getColumnListing($tableName);
}
return view("qa::menus.createCrud",
compact('fieldTypes', 'fieldValidation', 'defaultValuesCbox', 'menusSelect', 'models', 'parentsSelect',
'roles'));
} | php | public function createCrud()
{
$fieldTypes = FieldsDescriber::types();
$fieldValidation = FieldsDescriber::validation();
$defaultValuesCbox = FieldsDescriber::default_cbox();
$menusSelect = Menu::whereNotIn('menu_type', [2, 3])->pluck('title', 'id');
$roles = Role::all();
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
// Get columns for relationship
$models = [];
foreach (Menu::whereNotIn('menu_type', [2, 3])->get() as $menu) {
// We are having a default User model
if ($menu->title == 'User' && $menu->is_menu == 0) {
$tableName = 'users';
} else {
$tableName = strtolower($menu->name);
}
$models[$menu->id] = Schema::getColumnListing($tableName);
}
return view("qa::menus.createCrud",
compact('fieldTypes', 'fieldValidation', 'defaultValuesCbox', 'menusSelect', 'models', 'parentsSelect',
'roles'));
} | [
"public",
"function",
"createCrud",
"(",
")",
"{",
"$",
"fieldTypes",
"=",
"FieldsDescriber",
"::",
"types",
"(",
")",
";",
"$",
"fieldValidation",
"=",
"FieldsDescriber",
"::",
"validation",
"(",
")",
";",
"$",
"defaultValuesCbox",
"=",
"FieldsDescriber",
"::... | Show new menu creation page
@return \Illuminate\View\View | [
"Show",
"new",
"menu",
"creation",
"page"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Controllers/QuickadminMenuController.php#L71-L94 | train |
LaravelDaily/quickadmin | src/Controllers/QuickadminMenuController.php | QuickadminMenuController.insertParent | public function insertParent(Request $request)
{
$validation = Validator::make($request->all(), [
'title' => 'required',
]);
if ($validation->fails()) {
return redirect()->back()->withInput()->withErrors($validation);
}
$menu = Menu::create([
'position' => 0,
'menu_type' => 2,
'icon' => $request->icon != '' ? $request->icon : 'fa-database',
'name' => ucfirst(camel_case($request->title)),
'title' => $request->title,
'parent_id' => null,
]);
$menu->roles()->sync($request->input('roles', []));
return redirect()->route('menu');
} | php | public function insertParent(Request $request)
{
$validation = Validator::make($request->all(), [
'title' => 'required',
]);
if ($validation->fails()) {
return redirect()->back()->withInput()->withErrors($validation);
}
$menu = Menu::create([
'position' => 0,
'menu_type' => 2,
'icon' => $request->icon != '' ? $request->icon : 'fa-database',
'name' => ucfirst(camel_case($request->title)),
'title' => $request->title,
'parent_id' => null,
]);
$menu->roles()->sync($request->input('roles', []));
return redirect()->route('menu');
} | [
"public",
"function",
"insertParent",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"validation",
"=",
"Validator",
"::",
"make",
"(",
"$",
"request",
"->",
"all",
"(",
")",
",",
"[",
"'title'",
"=>",
"'required'",
",",
"]",
")",
";",
"if",
"(",
"$"... | Insert our fresh parent page
@param Request $request
@return \Illuminate\Http\RedirectResponse | [
"Insert",
"our",
"fresh",
"parent",
"page"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Controllers/QuickadminMenuController.php#L221-L240 | train |
LaravelDaily/quickadmin | src/Controllers/QuickadminMenuController.php | QuickadminMenuController.createCustom | public function createCustom()
{
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
$roles = Role::all();
return view('qa::menus.createCustom', compact('parentsSelect', 'roles'));
} | php | public function createCustom()
{
$parentsSelect = Menu::where('menu_type', 2)->pluck('title', 'id')->prepend('-- no parent --', '');
$roles = Role::all();
return view('qa::menus.createCustom', compact('parentsSelect', 'roles'));
} | [
"public",
"function",
"createCustom",
"(",
")",
"{",
"$",
"parentsSelect",
"=",
"Menu",
"::",
"where",
"(",
"'menu_type'",
",",
"2",
")",
"->",
"pluck",
"(",
"'title'",
",",
"'id'",
")",
"->",
"prepend",
"(",
"'-- no parent --'",
",",
"''",
")",
";",
"... | Create custom controller page
@return \BladeView|bool|\Illuminate\Contracts\View\Factory|\Illuminate\View\View | [
"Create",
"custom",
"controller",
"page"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Controllers/QuickadminMenuController.php#L246-L252 | train |
LaravelDaily/quickadmin | src/Controllers/QuickadminMenuController.php | QuickadminMenuController.insertCustom | public function insertCustom(Request $request)
{
$validation = Validator::make($request->all(), [
'name' => 'required|unique:menus,name',
'title' => 'required'
]);
if ($validation->fails()) {
return redirect()->back()->withInput()->withErrors($validation);
}
// Create controller
$controllerBuilder = new ControllerBuilder();
$controllerBuilder->buildCustom($request->name);
// Create views
$viewsBuilder = new ViewsBuilder();
$viewsBuilder->buildCustom($request->name);
$menu = Menu::create([
'position' => 0,
'menu_type' => 3,
'icon' => $request->icon != '' ? $request->icon : 'fa-database',
'name' => $request->name,
'title' => $request->title,
'parent_id' => $request->parent_id ?: null,
]);
$menu->roles()->sync($request->input('roles', []));
return redirect()->route('menu');
} | php | public function insertCustom(Request $request)
{
$validation = Validator::make($request->all(), [
'name' => 'required|unique:menus,name',
'title' => 'required'
]);
if ($validation->fails()) {
return redirect()->back()->withInput()->withErrors($validation);
}
// Create controller
$controllerBuilder = new ControllerBuilder();
$controllerBuilder->buildCustom($request->name);
// Create views
$viewsBuilder = new ViewsBuilder();
$viewsBuilder->buildCustom($request->name);
$menu = Menu::create([
'position' => 0,
'menu_type' => 3,
'icon' => $request->icon != '' ? $request->icon : 'fa-database',
'name' => $request->name,
'title' => $request->title,
'parent_id' => $request->parent_id ?: null,
]);
$menu->roles()->sync($request->input('roles', []));
return redirect()->route('menu');
} | [
"public",
"function",
"insertCustom",
"(",
"Request",
"$",
"request",
")",
"{",
"$",
"validation",
"=",
"Validator",
"::",
"make",
"(",
"$",
"request",
"->",
"all",
"(",
")",
",",
"[",
"'name'",
"=>",
"'required|unique:menus,name'",
",",
"'title'",
"=>",
"... | Insert custom controller
@param Request $request
@return \Illuminate\Http\RedirectResponse | [
"Insert",
"custom",
"controller"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Controllers/QuickadminMenuController.php#L261-L289 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.loadTemplate | private function loadTemplate()
{
return [
0 => $this->template[0] != '' ? file_get_contents($this->template[0]) : '',
1 => $this->template[1] != '' ? file_get_contents($this->template[1]) : '',
2 => $this->template[2] != '' ? file_get_contents($this->template[2]) : '',
];
} | php | private function loadTemplate()
{
return [
0 => $this->template[0] != '' ? file_get_contents($this->template[0]) : '',
1 => $this->template[1] != '' ? file_get_contents($this->template[1]) : '',
2 => $this->template[2] != '' ? file_get_contents($this->template[2]) : '',
];
} | [
"private",
"function",
"loadTemplate",
"(",
")",
"{",
"return",
"[",
"0",
"=>",
"$",
"this",
"->",
"template",
"[",
"0",
"]",
"!=",
"''",
"?",
"file_get_contents",
"(",
"$",
"this",
"->",
"template",
"[",
"0",
"]",
")",
":",
"''",
",",
"1",
"=>",
... | Load views templates | [
"Load",
"views",
"templates"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L67-L74 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.buildParts | private function buildParts($template)
{
$this->buildTable();
$this->buildCreateForm();
$this->buildEditForm();
// Index template
$template[0] = str_replace([
'$ROUTE$',
'$RESOURCE$',
'$HEADINGS$',
'$FIELDS$',
], [
$this->route,
$this->resource,
$this->headings,
$this->columns
], $template[0]);
// Edit template
$template[1] = str_replace([
'$ROUTE$',
'$RESOURCE$',
'$FORMFIELDS$',
'$MODEL$',
'$FILES$'
], [
$this->route,
$this->resource,
$this->formFieldsEdit,
$this->model,
$this->files != 0 ? "'files' => true, " : ''
], $template[1]);
// Create template
$template[2] = str_replace([
'$ROUTE$',
'$RESOURCE$',
'$FORMFIELDS$',
'$FILES$'
], [
$this->route,
$this->resource,
$this->formFieldsCreate,
$this->files != 0 ? "'files' => true, " : ''
], $template[2]);
return $template;
} | php | private function buildParts($template)
{
$this->buildTable();
$this->buildCreateForm();
$this->buildEditForm();
// Index template
$template[0] = str_replace([
'$ROUTE$',
'$RESOURCE$',
'$HEADINGS$',
'$FIELDS$',
], [
$this->route,
$this->resource,
$this->headings,
$this->columns
], $template[0]);
// Edit template
$template[1] = str_replace([
'$ROUTE$',
'$RESOURCE$',
'$FORMFIELDS$',
'$MODEL$',
'$FILES$'
], [
$this->route,
$this->resource,
$this->formFieldsEdit,
$this->model,
$this->files != 0 ? "'files' => true, " : ''
], $template[1]);
// Create template
$template[2] = str_replace([
'$ROUTE$',
'$RESOURCE$',
'$FORMFIELDS$',
'$FILES$'
], [
$this->route,
$this->resource,
$this->formFieldsCreate,
$this->files != 0 ? "'files' => true, " : ''
], $template[2]);
return $template;
} | [
"private",
"function",
"buildParts",
"(",
"$",
"template",
")",
"{",
"$",
"this",
"->",
"buildTable",
"(",
")",
";",
"$",
"this",
"->",
"buildCreateForm",
"(",
")",
";",
"$",
"this",
"->",
"buildEditForm",
"(",
")",
";",
"// Index template",
"$",
"templa... | Build views templates parts
@param $template
@return mixed | [
"Build",
"views",
"templates",
"parts"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L83-L131 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.buildTable | private function buildTable()
{
$used = [];
$headings = '';
$columns = '';
foreach ($this->fields as $field) {
// Check if there is no duplication for radio and checkbox.
// Password fields are excluded from the table too.
if (! in_array($field->title, $used)
&& $field->type != 'password'
&& $field->type != 'textarea'
&& $field->show == 1
) {
$headings .= "<th>$field->label</th>\r\n";
// Format our table column by field type
if ($field->type == 'relationship') {
$columns .= '<td>{{ isset($row->' . $field->relationship_name . '->' . $field->relationship_field . ') ? $row->' . $field->relationship_name . '->' . $field->relationship_field . " : '' }}</td>\r\n";
$used[$field->relationship_field] = $field->relationship_field;
} elseif ($field->type == 'photo') {
$columns .= '<td>@if($row->' . $field->title . ' != \'\')<img src="{{ asset(\'uploads/thumb\') . \'/\'. $row->' . $field->title . " }}\">@endif</td>\r\n";
$used[$field->title] = $field->title;
} else {
$columns .= '<td>{{ $row->' . $field->title . " }}</td>\r\n";
$used[$field->title] = $field->title;
}
}
}
$this->headings = $headings;
$this->columns = $columns;
} | php | private function buildTable()
{
$used = [];
$headings = '';
$columns = '';
foreach ($this->fields as $field) {
// Check if there is no duplication for radio and checkbox.
// Password fields are excluded from the table too.
if (! in_array($field->title, $used)
&& $field->type != 'password'
&& $field->type != 'textarea'
&& $field->show == 1
) {
$headings .= "<th>$field->label</th>\r\n";
// Format our table column by field type
if ($field->type == 'relationship') {
$columns .= '<td>{{ isset($row->' . $field->relationship_name . '->' . $field->relationship_field . ') ? $row->' . $field->relationship_name . '->' . $field->relationship_field . " : '' }}</td>\r\n";
$used[$field->relationship_field] = $field->relationship_field;
} elseif ($field->type == 'photo') {
$columns .= '<td>@if($row->' . $field->title . ' != \'\')<img src="{{ asset(\'uploads/thumb\') . \'/\'. $row->' . $field->title . " }}\">@endif</td>\r\n";
$used[$field->title] = $field->title;
} else {
$columns .= '<td>{{ $row->' . $field->title . " }}</td>\r\n";
$used[$field->title] = $field->title;
}
}
}
$this->headings = $headings;
$this->columns = $columns;
} | [
"private",
"function",
"buildTable",
"(",
")",
"{",
"$",
"used",
"=",
"[",
"]",
";",
"$",
"headings",
"=",
"''",
";",
"$",
"columns",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"// Check if there is no ... | Build index table | [
"Build",
"index",
"table"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L136-L165 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.buildEditForm | private function buildEditForm()
{
$form = '';
foreach ($this->fields as $field) {
$title = addslashes($field->label);
$label = $field->title;
if (in_array($field->validation,
$this->starred) && $field->type != 'password' && $field->type != 'file' && $field->type != 'photo'
) {
$title .= '*';
}
if ($field->type == 'relationship') {
$label = $field->relationship_name . '_id';
}
if ($field->type == 'checkbox') {
$field->default = '$' . $this->model . '->' . $label . ' == 1';
}
$temp = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR . $field->type);
$temp = str_replace([
'old(\'$LABEL$\')',
'$LABEL$',
'$TITLE$',
'$VALUE$',
'$STATE$',
'$SELECT$',
'$TEXTEDITOR$',
'$HELPER$',
'$WIDTH$',
'$HEIGHT$',
], [
'old(\'$LABEL$\',$' . $this->resource . '->' . $label . ')',
$label,
$title,
$field->type != 'radio' ?
$field->value != '' ? ', "' . $field->value . '"' : ''
: "'$field->value'",
$field->default,
'$' . $field->relationship_name,
$field->texteditor == 1 ? ' ckeditor' : '',
$this->helper($field->helper),
$field->dimension_w,
$field->dimension_h,
], $temp);
$form .= $temp;
}
$this->formFieldsEdit = $form;
} | php | private function buildEditForm()
{
$form = '';
foreach ($this->fields as $field) {
$title = addslashes($field->label);
$label = $field->title;
if (in_array($field->validation,
$this->starred) && $field->type != 'password' && $field->type != 'file' && $field->type != 'photo'
) {
$title .= '*';
}
if ($field->type == 'relationship') {
$label = $field->relationship_name . '_id';
}
if ($field->type == 'checkbox') {
$field->default = '$' . $this->model . '->' . $label . ' == 1';
}
$temp = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR . $field->type);
$temp = str_replace([
'old(\'$LABEL$\')',
'$LABEL$',
'$TITLE$',
'$VALUE$',
'$STATE$',
'$SELECT$',
'$TEXTEDITOR$',
'$HELPER$',
'$WIDTH$',
'$HEIGHT$',
], [
'old(\'$LABEL$\',$' . $this->resource . '->' . $label . ')',
$label,
$title,
$field->type != 'radio' ?
$field->value != '' ? ', "' . $field->value . '"' : ''
: "'$field->value'",
$field->default,
'$' . $field->relationship_name,
$field->texteditor == 1 ? ' ckeditor' : '',
$this->helper($field->helper),
$field->dimension_w,
$field->dimension_h,
], $temp);
$form .= $temp;
}
$this->formFieldsEdit = $form;
} | [
"private",
"function",
"buildEditForm",
"(",
")",
"{",
"$",
"form",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"title",
"=",
"addslashes",
"(",
"$",
"field",
"->",
"label",
")",
";",
"$",
"label"... | Build edit.blade.php form | [
"Build",
"edit",
".",
"blade",
".",
"php",
"form"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L170-L216 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.buildCreateForm | private function buildCreateForm()
{
$form = '';
foreach ($this->fields as $field) {
$title = addslashes($field->label);
$key = $field->title;
if (in_array($field->validation, $this->starred)) {
$title .= '*';
}
if ($field->type == 'relationship') {
$key = $field->relationship_name . '_id';
}
$temp = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR . $field->type);
$temp = str_replace([
'$LABEL$',
'$TITLE$',
'$VALUE$',
'$STATE$',
'$SELECT$',
'$TEXTEDITOR$',
'$HELPER$',
'$WIDTH$',
'$HEIGHT$',
], [
$key,
$title,
$field->type != 'radio' ?
$field->value != '' ? ', ' . $field->value : ''
: "'$field->value'",
$field->default,
'$' . $field->relationship_name,
$field->texteditor == 1 ? ' ckeditor' : '',
$this->helper($field->helper),
$field->dimension_w,
$field->dimension_h,
], $temp);
$form .= $temp;
}
$this->formFieldsCreate = $form;
} | php | private function buildCreateForm()
{
$form = '';
foreach ($this->fields as $field) {
$title = addslashes($field->label);
$key = $field->title;
if (in_array($field->validation, $this->starred)) {
$title .= '*';
}
if ($field->type == 'relationship') {
$key = $field->relationship_name . '_id';
}
$temp = file_get_contents(__DIR__ . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'Templates' . DIRECTORY_SEPARATOR . 'fields' . DIRECTORY_SEPARATOR . $field->type);
$temp = str_replace([
'$LABEL$',
'$TITLE$',
'$VALUE$',
'$STATE$',
'$SELECT$',
'$TEXTEDITOR$',
'$HELPER$',
'$WIDTH$',
'$HEIGHT$',
], [
$key,
$title,
$field->type != 'radio' ?
$field->value != '' ? ', ' . $field->value : ''
: "'$field->value'",
$field->default,
'$' . $field->relationship_name,
$field->texteditor == 1 ? ' ckeditor' : '',
$this->helper($field->helper),
$field->dimension_w,
$field->dimension_h,
], $temp);
$form .= $temp;
}
$this->formFieldsCreate = $form;
} | [
"private",
"function",
"buildCreateForm",
"(",
")",
"{",
"$",
"form",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"$",
"title",
"=",
"addslashes",
"(",
"$",
"field",
"->",
"label",
")",
";",
"$",
"key"... | Build create.blade.php form | [
"Build",
"create",
".",
"blade",
".",
"php",
"form"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L221-L260 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.names | private function names()
{
$camelCase = ucfirst(Str::camel($this->name));
$this->route = strtolower($camelCase);
$this->path = strtolower($camelCase);
$this->resource = strtolower($camelCase);
$this->model = strtolower($camelCase);
} | php | private function names()
{
$camelCase = ucfirst(Str::camel($this->name));
$this->route = strtolower($camelCase);
$this->path = strtolower($camelCase);
$this->resource = strtolower($camelCase);
$this->model = strtolower($camelCase);
} | [
"private",
"function",
"names",
"(",
")",
"{",
"$",
"camelCase",
"=",
"ucfirst",
"(",
"Str",
"::",
"camel",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"$",
"this",
"->",
"route",
"=",
"strtolower",
"(",
"$",
"camelCase",
")",
";",
"$",
"this",
... | Generate names for the views | [
"Generate",
"names",
"for",
"the",
"views"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L265-L272 | train |
LaravelDaily/quickadmin | src/Builders/ViewsBuilder.php | ViewsBuilder.publish | private function publish($template)
{
if (! file_exists(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path))) {
mkdir(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path));
chmod(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin'), 0777);
}
file_put_contents(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . 'index.blade.php'),
$template[0]);
file_put_contents(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . 'edit.blade.php'),
$template[1]);
file_put_contents(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . 'create.blade.php'),
$template[2]);
} | php | private function publish($template)
{
if (! file_exists(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path))) {
mkdir(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path));
chmod(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin'), 0777);
}
file_put_contents(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . 'index.blade.php'),
$template[0]);
file_put_contents(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . 'edit.blade.php'),
$template[1]);
file_put_contents(base_path('resources' . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'admin' . DIRECTORY_SEPARATOR . $this->path . DIRECTORY_SEPARATOR . 'create.blade.php'),
$template[2]);
} | [
"private",
"function",
"publish",
"(",
"$",
"template",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"base_path",
"(",
"'resources'",
".",
"DIRECTORY_SEPARATOR",
".",
"'views'",
".",
"DIRECTORY_SEPARATOR",
".",
"'admin'",
".",
"DIRECTORY_SEPARATOR",
".",
"$",
... | Publish files into their places | [
"Publish",
"files",
"into",
"their",
"places"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ViewsBuilder.php#L293-L305 | train |
LaravelDaily/quickadmin | src/Commands/QuickAdminInstall.php | QuickAdminInstall.createUser | public function createUser()
{
$data['name'] = $this->ask('Administrator name');
$data['email'] = $this->ask('Administrator email');
$data['password'] = bcrypt($this->secret('Administrator password'));
$data['role_id'] = 1;
User::create($data);
$this->info('User has been created');
} | php | public function createUser()
{
$data['name'] = $this->ask('Administrator name');
$data['email'] = $this->ask('Administrator email');
$data['password'] = bcrypt($this->secret('Administrator password'));
$data['role_id'] = 1;
User::create($data);
$this->info('User has been created');
} | [
"public",
"function",
"createUser",
"(",
")",
"{",
"$",
"data",
"[",
"'name'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Administrator name'",
")",
";",
"$",
"data",
"[",
"'email'",
"]",
"=",
"$",
"this",
"->",
"ask",
"(",
"'Administrator email'",
")"... | Create first user | [
"Create",
"first",
"user"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Commands/QuickAdminInstall.php#L89-L97 | train |
LaravelDaily/quickadmin | src/Builders/ModelBuilder.php | ModelBuilder.buildParts | private function buildParts($template)
{
$camelName = Str::camel($this->name);
// Insert table names
$tableName = strtolower($camelName);
if ($this->soft == 1) {
$soft_call = 'use Illuminate\Database\Eloquent\SoftDeletes;';
$soft_use = 'use SoftDeletes;';
$soft_date = '/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [\'deleted_at\'];';
} else {
$soft_call = '';
$soft_use = '';
$soft_date = '';
}
$template = str_replace([
'$NAMESPACE$',
'$SOFT_DELETE_CALL$',
'$SOFT_DELETE_USE$',
'$SOFT_DELETE_DATES$',
'$TABLENAME$',
'$CLASS$',
'$FILLABLE$',
'$RELATIONSHIPS$',
'$PASSWORDHASH_CALL$',
'$PASSWORDHASH$',
'$DATEPICKERS_CALL$',
'$DATEPICKERS$',
'$DATETIMEPICKERS$',
'$ENUMS$',
], [
$this->namespace,
$soft_call,
$soft_use,
$soft_date,
$tableName,
$this->className,
$this->buildFillables(),
$this->buildRelationships(),
$this->password > 0 ? "use Illuminate\Support\Facades\Hash; \n\r" : '',
$this->password > 0 ? $this->passwordHash() : '',
$this->date > 0 || $this->datetime > 0 ? "use Carbon\Carbon; \n\r" : '',
$this->date > 0 ? $this->datepickers() : '',
$this->datetime > 0 ? $this->datetimepickers() : '',
$this->enum > 0 ? $this->enum() : '',
], $template);
return $template;
} | php | private function buildParts($template)
{
$camelName = Str::camel($this->name);
// Insert table names
$tableName = strtolower($camelName);
if ($this->soft == 1) {
$soft_call = 'use Illuminate\Database\Eloquent\SoftDeletes;';
$soft_use = 'use SoftDeletes;';
$soft_date = '/**
* The attributes that should be mutated to dates.
*
* @var array
*/
protected $dates = [\'deleted_at\'];';
} else {
$soft_call = '';
$soft_use = '';
$soft_date = '';
}
$template = str_replace([
'$NAMESPACE$',
'$SOFT_DELETE_CALL$',
'$SOFT_DELETE_USE$',
'$SOFT_DELETE_DATES$',
'$TABLENAME$',
'$CLASS$',
'$FILLABLE$',
'$RELATIONSHIPS$',
'$PASSWORDHASH_CALL$',
'$PASSWORDHASH$',
'$DATEPICKERS_CALL$',
'$DATEPICKERS$',
'$DATETIMEPICKERS$',
'$ENUMS$',
], [
$this->namespace,
$soft_call,
$soft_use,
$soft_date,
$tableName,
$this->className,
$this->buildFillables(),
$this->buildRelationships(),
$this->password > 0 ? "use Illuminate\Support\Facades\Hash; \n\r" : '',
$this->password > 0 ? $this->passwordHash() : '',
$this->date > 0 || $this->datetime > 0 ? "use Carbon\Carbon; \n\r" : '',
$this->date > 0 ? $this->datepickers() : '',
$this->datetime > 0 ? $this->datetimepickers() : '',
$this->enum > 0 ? $this->enum() : '',
], $template);
return $template;
} | [
"private",
"function",
"buildParts",
"(",
"$",
"template",
")",
"{",
"$",
"camelName",
"=",
"Str",
"::",
"camel",
"(",
"$",
"this",
"->",
"name",
")",
";",
"// Insert table names",
"$",
"tableName",
"=",
"strtolower",
"(",
"$",
"camelName",
")",
";",
"if... | Build model template parts
@param $template
@return mixed | [
"Build",
"model",
"template",
"parts"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ModelBuilder.php#L67-L119 | train |
LaravelDaily/quickadmin | src/Builders/ModelBuilder.php | ModelBuilder.buildFillables | private function buildFillables()
{
$used = [];
$fillables = '';
$count = count($this->fields);
// Move to the new line if we have more than one field
if ($count > 1) {
$fillables .= "\r\n";
}
foreach ($this->fields as $key => $field) {
// Check if there is no duplication for radio and checkbox
if (! in_array($field->title, $used)) {
if ($count > 1) {
$fillables .= ' '; // Add formatting space to the model
}
if ($field->type == 'relationship') {
$fillables .= "'" . $field->relationship_name . "_id'";
$used[$field->relationship_name] = $field->relationship_name;
} else {
$fillables .= "'" . $field->title . "'";
$used[$field->title] = $field->title;
}
// Formatting lines
if ($count != 1) {
if ($key != $count - 1) {
$fillables .= ",\r\n";
} else {
if ($key == $count - 1) {
$fillables .= "\r\n ";
} else {
$fillables .= "\r\n";
}
}
}
}
}
return $fillables;
} | php | private function buildFillables()
{
$used = [];
$fillables = '';
$count = count($this->fields);
// Move to the new line if we have more than one field
if ($count > 1) {
$fillables .= "\r\n";
}
foreach ($this->fields as $key => $field) {
// Check if there is no duplication for radio and checkbox
if (! in_array($field->title, $used)) {
if ($count > 1) {
$fillables .= ' '; // Add formatting space to the model
}
if ($field->type == 'relationship') {
$fillables .= "'" . $field->relationship_name . "_id'";
$used[$field->relationship_name] = $field->relationship_name;
} else {
$fillables .= "'" . $field->title . "'";
$used[$field->title] = $field->title;
}
// Formatting lines
if ($count != 1) {
if ($key != $count - 1) {
$fillables .= ",\r\n";
} else {
if ($key == $count - 1) {
$fillables .= "\r\n ";
} else {
$fillables .= "\r\n";
}
}
}
}
}
return $fillables;
} | [
"private",
"function",
"buildFillables",
"(",
")",
"{",
"$",
"used",
"=",
"[",
"]",
";",
"$",
"fillables",
"=",
"''",
";",
"$",
"count",
"=",
"count",
"(",
"$",
"this",
"->",
"fields",
")",
";",
"// Move to the new line if we have more than one field",
"if",... | Build model fillables
@return string | [
"Build",
"model",
"fillables"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ModelBuilder.php#L125-L163 | train |
LaravelDaily/quickadmin | src/Builders/ModelBuilder.php | ModelBuilder.buildRelationships | private function buildRelationships()
{
$menus = Menu::all()->keyBy('id');
$used = [];
$relationships = '';
foreach ($this->fields as $key => $field) {
if (! in_array($field->title, $used) && $field->type == 'relationship') {
$menu = $menus[$field->relationship_id];
$relLine = '
public function $RELATIONSHIP$()
{
return $this->hasOne(\'App\$RELATIONSHIP_MODEL$\', \'id\', \'$RELATIONSHIP$_id\');
}' . "\r\n\r\n";
$relLine = str_replace([
'$RELATIONSHIP$',
'$RELATIONSHIP_MODEL$'
], [
strtolower($menu->name),
ucfirst(Str::camel($menu->name))
], $relLine);
$relationships .= $relLine;
}
}
return $relationships;
} | php | private function buildRelationships()
{
$menus = Menu::all()->keyBy('id');
$used = [];
$relationships = '';
foreach ($this->fields as $key => $field) {
if (! in_array($field->title, $used) && $field->type == 'relationship') {
$menu = $menus[$field->relationship_id];
$relLine = '
public function $RELATIONSHIP$()
{
return $this->hasOne(\'App\$RELATIONSHIP_MODEL$\', \'id\', \'$RELATIONSHIP$_id\');
}' . "\r\n\r\n";
$relLine = str_replace([
'$RELATIONSHIP$',
'$RELATIONSHIP_MODEL$'
], [
strtolower($menu->name),
ucfirst(Str::camel($menu->name))
], $relLine);
$relationships .= $relLine;
}
}
return $relationships;
} | [
"private",
"function",
"buildRelationships",
"(",
")",
"{",
"$",
"menus",
"=",
"Menu",
"::",
"all",
"(",
")",
"->",
"keyBy",
"(",
"'id'",
")",
";",
"$",
"used",
"=",
"[",
"]",
";",
"$",
"relationships",
"=",
"''",
";",
"foreach",
"(",
"$",
"this",
... | Build model relationships
@return string | [
"Build",
"model",
"relationships"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ModelBuilder.php#L169-L194 | train |
LaravelDaily/quickadmin | src/Builders/ModelBuilder.php | ModelBuilder.names | private function names()
{
$this->className = ucfirst(Str::camel($this->name));
$fileName = $this->className . '.php';
$this->fileName = $fileName;
} | php | private function names()
{
$this->className = ucfirst(Str::camel($this->name));
$fileName = $this->className . '.php';
$this->fileName = $fileName;
} | [
"private",
"function",
"names",
"(",
")",
"{",
"$",
"this",
"->",
"className",
"=",
"ucfirst",
"(",
"Str",
"::",
"camel",
"(",
"$",
"this",
"->",
"name",
")",
")",
";",
"$",
"fileName",
"=",
"$",
"this",
"->",
"className",
".",
"'.php'",
";",
"$",
... | Generate file and class names for the model | [
"Generate",
"file",
"and",
"class",
"names",
"for",
"the",
"model"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ModelBuilder.php#L199-L205 | train |
LaravelDaily/quickadmin | src/Builders/ModelBuilder.php | ModelBuilder.enum | public function enum()
{
$return = "\r\n";
foreach ($this->fields as $field) {
if ($field->type == 'enum') {
$values = '';
$field->enum = explode(',', $field->enum);
foreach ($field->enum as $val) {
// Remove first whitespace
if (strpos(substr($val, 0, 1), ' ') !== false) {
$len = strlen($val);
$val = substr($val, 1, $len);
}
$values .= '"' . $val . '" => "' . $val . '"';
if ($val != last($field->enum)) {
$values .= ', ';
}
}
$return .= ' public static $' . $field->title . ' = [' . $values . '];' . "\r\n";
}
}
return $return;
} | php | public function enum()
{
$return = "\r\n";
foreach ($this->fields as $field) {
if ($field->type == 'enum') {
$values = '';
$field->enum = explode(',', $field->enum);
foreach ($field->enum as $val) {
// Remove first whitespace
if (strpos(substr($val, 0, 1), ' ') !== false) {
$len = strlen($val);
$val = substr($val, 1, $len);
}
$values .= '"' . $val . '" => "' . $val . '"';
if ($val != last($field->enum)) {
$values .= ', ';
}
}
$return .= ' public static $' . $field->title . ' = [' . $values . '];' . "\r\n";
}
}
return $return;
} | [
"public",
"function",
"enum",
"(",
")",
"{",
"$",
"return",
"=",
"\"\\r\\n\"",
";",
"foreach",
"(",
"$",
"this",
"->",
"fields",
"as",
"$",
"field",
")",
"{",
"if",
"(",
"$",
"field",
"->",
"type",
"==",
"'enum'",
")",
"{",
"$",
"values",
"=",
"'... | Generate enum model
@return string | [
"Generate",
"enum",
"model"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Builders/ModelBuilder.php#L317-L340 | train |
LaravelDaily/quickadmin | src/Cache/QuickCache.php | QuickCache.put | public function put($filename, $content)
{
// Merge existing content to new content
if (file_exists($this->cacheDir . $filename) && file_get_contents($this->cacheDir . $filename) != '') {
$cachedContent = $this->get($filename);
$content = array_merge($content, $cachedContent);
}
$this->files->put($this->cacheDir . $filename, json_encode($content));
} | php | public function put($filename, $content)
{
// Merge existing content to new content
if (file_exists($this->cacheDir . $filename) && file_get_contents($this->cacheDir . $filename) != '') {
$cachedContent = $this->get($filename);
$content = array_merge($content, $cachedContent);
}
$this->files->put($this->cacheDir . $filename, json_encode($content));
} | [
"public",
"function",
"put",
"(",
"$",
"filename",
",",
"$",
"content",
")",
"{",
"// Merge existing content to new content",
"if",
"(",
"file_exists",
"(",
"$",
"this",
"->",
"cacheDir",
".",
"$",
"filename",
")",
"&&",
"file_get_contents",
"(",
"$",
"this",
... | Put information into cache file
@param $filename
@param $content | [
"Put",
"information",
"into",
"cache",
"file"
] | 94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95 | https://github.com/LaravelDaily/quickadmin/blob/94d5b009d7d5d8b30985c14d6fd64e4cd1e10b95/src/Cache/QuickCache.php#L27-L35 | train |
beyondcode/laravel-dump-server | src/RequestContextProvider.php | RequestContextProvider.getContext | public function getContext(): ?array
{
if ($this->currentRequest === null) {
return null;
}
$controller = null;
if ($route = $this->currentRequest->route()) {
$controller = $route->controller;
if (! $controller && ! is_string($route->action['uses'])) {
$controller = $route->action['uses'];
}
}
return [
'uri' => $this->currentRequest->getUri(),
'method' => $this->currentRequest->getMethod(),
'controller' => $controller ? $this->cloner->cloneVar(class_basename($controller)) : $controller,
'identifier' => spl_object_hash($this->currentRequest),
];
} | php | public function getContext(): ?array
{
if ($this->currentRequest === null) {
return null;
}
$controller = null;
if ($route = $this->currentRequest->route()) {
$controller = $route->controller;
if (! $controller && ! is_string($route->action['uses'])) {
$controller = $route->action['uses'];
}
}
return [
'uri' => $this->currentRequest->getUri(),
'method' => $this->currentRequest->getMethod(),
'controller' => $controller ? $this->cloner->cloneVar(class_basename($controller)) : $controller,
'identifier' => spl_object_hash($this->currentRequest),
];
} | [
"public",
"function",
"getContext",
"(",
")",
":",
"?",
"array",
"{",
"if",
"(",
"$",
"this",
"->",
"currentRequest",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"$",
"controller",
"=",
"null",
";",
"if",
"(",
"$",
"route",
"=",
"$",
"this... | Get the context.
@return array|null | [
"Get",
"the",
"context",
"."
] | 561ecb6a5ccc3bc77df1ff865b14e3dbe3f053e5 | https://github.com/beyondcode/laravel-dump-server/blob/561ecb6a5ccc3bc77df1ff865b14e3dbe3f053e5/src/RequestContextProvider.php#L43-L65 | train |
paratestphp/paratest | src/Coverage/CoverageReporter.php | CoverageReporter.clover | public function clover(string $target)
{
$clover = new Clover();
$clover->process($this->coverage, $target);
} | php | public function clover(string $target)
{
$clover = new Clover();
$clover->process($this->coverage, $target);
} | [
"public",
"function",
"clover",
"(",
"string",
"$",
"target",
")",
"{",
"$",
"clover",
"=",
"new",
"Clover",
"(",
")",
";",
"$",
"clover",
"->",
"process",
"(",
"$",
"this",
"->",
"coverage",
",",
"$",
"target",
")",
";",
"}"
] | Generate clover coverage report.
@param string $target Report filename | [
"Generate",
"clover",
"coverage",
"report",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Coverage/CoverageReporter.php#L35-L39 | train |
paratestphp/paratest | src/Coverage/CoverageReporter.php | CoverageReporter.html | public function html(string $target)
{
$html = new Html\Facade();
$html->process($this->coverage, $target);
} | php | public function html(string $target)
{
$html = new Html\Facade();
$html->process($this->coverage, $target);
} | [
"public",
"function",
"html",
"(",
"string",
"$",
"target",
")",
"{",
"$",
"html",
"=",
"new",
"Html",
"\\",
"Facade",
"(",
")",
";",
"$",
"html",
"->",
"process",
"(",
"$",
"this",
"->",
"coverage",
",",
"$",
"target",
")",
";",
"}"
] | Generate html coverage report.
@param string $target Report filename | [
"Generate",
"html",
"coverage",
"report",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Coverage/CoverageReporter.php#L46-L50 | train |
paratestphp/paratest | src/Coverage/CoverageReporter.php | CoverageReporter.php | public function php(string $target)
{
$php = new PHP();
$php->process($this->coverage, $target);
} | php | public function php(string $target)
{
$php = new PHP();
$php->process($this->coverage, $target);
} | [
"public",
"function",
"php",
"(",
"string",
"$",
"target",
")",
"{",
"$",
"php",
"=",
"new",
"PHP",
"(",
")",
";",
"$",
"php",
"->",
"process",
"(",
"$",
"this",
"->",
"coverage",
",",
"$",
"target",
")",
";",
"}"
] | Generate php coverage report.
@param string $target Report filename | [
"Generate",
"php",
"coverage",
"report",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Coverage/CoverageReporter.php#L57-L61 | train |
paratestphp/paratest | src/Coverage/CoverageReporter.php | CoverageReporter.xml | public function xml(string $target)
{
$xml = new XmlReport(Version::id());
$xml->process($this->coverage, $target);
} | php | public function xml(string $target)
{
$xml = new XmlReport(Version::id());
$xml->process($this->coverage, $target);
} | [
"public",
"function",
"xml",
"(",
"string",
"$",
"target",
")",
"{",
"$",
"xml",
"=",
"new",
"XmlReport",
"(",
"Version",
"::",
"id",
"(",
")",
")",
";",
"$",
"xml",
"->",
"process",
"(",
"$",
"this",
"->",
"coverage",
",",
"$",
"target",
")",
";... | Generate PHPUnit XML coverage report.
@param string $target Report filename | [
"Generate",
"PHPUnit",
"XML",
"coverage",
"report",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Coverage/CoverageReporter.php#L77-L81 | train |
paratestphp/paratest | src/Logging/JUnit/Writer.php | Writer.getXml | public function getXml(): string
{
$suites = $this->interpreter->flattenCases();
$root = $this->getSuiteRoot($suites);
foreach ($suites as $suite) {
$snode = $this->appendSuite($root, $suite);
foreach ($suite->cases as $case) {
$cnode = $this->appendCase($snode, $case);
}
}
return $this->document->saveXML();
} | php | public function getXml(): string
{
$suites = $this->interpreter->flattenCases();
$root = $this->getSuiteRoot($suites);
foreach ($suites as $suite) {
$snode = $this->appendSuite($root, $suite);
foreach ($suite->cases as $case) {
$cnode = $this->appendCase($snode, $case);
}
}
return $this->document->saveXML();
} | [
"public",
"function",
"getXml",
"(",
")",
":",
"string",
"{",
"$",
"suites",
"=",
"$",
"this",
"->",
"interpreter",
"->",
"flattenCases",
"(",
")",
";",
"$",
"root",
"=",
"$",
"this",
"->",
"getSuiteRoot",
"(",
"$",
"suites",
")",
";",
"foreach",
"("... | Returns the xml structure the writer
will use.
@return string | [
"Returns",
"the",
"xml",
"structure",
"the",
"writer",
"will",
"use",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Writer.php#L82-L94 | train |
paratestphp/paratest | src/Logging/JUnit/Writer.php | Writer.appendSuite | protected function appendSuite(\DOMElement $root, TestSuite $suite): \DOMElement
{
$suiteNode = $this->document->createElement('testsuite');
$vars = get_object_vars($suite);
foreach ($vars as $name => $value) {
if (preg_match(static::$suiteAttrs, $name)) {
$suiteNode->setAttribute($name, (string) $value);
}
}
$root->appendChild($suiteNode);
return $suiteNode;
} | php | protected function appendSuite(\DOMElement $root, TestSuite $suite): \DOMElement
{
$suiteNode = $this->document->createElement('testsuite');
$vars = get_object_vars($suite);
foreach ($vars as $name => $value) {
if (preg_match(static::$suiteAttrs, $name)) {
$suiteNode->setAttribute($name, (string) $value);
}
}
$root->appendChild($suiteNode);
return $suiteNode;
} | [
"protected",
"function",
"appendSuite",
"(",
"\\",
"DOMElement",
"$",
"root",
",",
"TestSuite",
"$",
"suite",
")",
":",
"\\",
"DOMElement",
"{",
"$",
"suiteNode",
"=",
"$",
"this",
"->",
"document",
"->",
"createElement",
"(",
"'testsuite'",
")",
";",
"$",... | Append a testsuite node to the given
root element.
@param $root
@param TestSuite $suite
@return \DOMElement | [
"Append",
"a",
"testsuite",
"node",
"to",
"the",
"given",
"root",
"element",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Writer.php#L115-L127 | train |
paratestphp/paratest | src/Logging/JUnit/Writer.php | Writer.appendCase | protected function appendCase(\DOMElement $suiteNode, TestCase $case): \DOMElement
{
$caseNode = $this->document->createElement('testcase');
$vars = get_object_vars($case);
foreach ($vars as $name => $value) {
if (preg_match(static::$caseAttrs, $name)) {
if ($this->isEmptyLineAttribute($name, $value)) {
continue;
}
$caseNode->setAttribute($name, (string) $value);
}
}
$suiteNode->appendChild($caseNode);
$this->appendDefects($caseNode, $case->failures, 'failure');
$this->appendDefects($caseNode, $case->errors, 'error');
return $caseNode;
} | php | protected function appendCase(\DOMElement $suiteNode, TestCase $case): \DOMElement
{
$caseNode = $this->document->createElement('testcase');
$vars = get_object_vars($case);
foreach ($vars as $name => $value) {
if (preg_match(static::$caseAttrs, $name)) {
if ($this->isEmptyLineAttribute($name, $value)) {
continue;
}
$caseNode->setAttribute($name, (string) $value);
}
}
$suiteNode->appendChild($caseNode);
$this->appendDefects($caseNode, $case->failures, 'failure');
$this->appendDefects($caseNode, $case->errors, 'error');
return $caseNode;
} | [
"protected",
"function",
"appendCase",
"(",
"\\",
"DOMElement",
"$",
"suiteNode",
",",
"TestCase",
"$",
"case",
")",
":",
"\\",
"DOMElement",
"{",
"$",
"caseNode",
"=",
"$",
"this",
"->",
"document",
"->",
"createElement",
"(",
"'testcase'",
")",
";",
"$",... | Append a testcase node to the given testsuite
node.
@param $suiteNode
@param TestCase $case
@return \DOMElement | [
"Append",
"a",
"testcase",
"node",
"to",
"the",
"given",
"testsuite",
"node",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Writer.php#L138-L155 | train |
paratestphp/paratest | src/Logging/JUnit/Writer.php | Writer.appendDefects | protected function appendDefects(\DOMElement $caseNode, array $defects, string $type)
{
foreach ($defects as $defect) {
$defectNode = $this->document->createElement($type, htmlspecialchars($defect['text'], ENT_XML1) . "\n");
$defectNode->setAttribute('type', $defect['type']);
$caseNode->appendChild($defectNode);
}
} | php | protected function appendDefects(\DOMElement $caseNode, array $defects, string $type)
{
foreach ($defects as $defect) {
$defectNode = $this->document->createElement($type, htmlspecialchars($defect['text'], ENT_XML1) . "\n");
$defectNode->setAttribute('type', $defect['type']);
$caseNode->appendChild($defectNode);
}
} | [
"protected",
"function",
"appendDefects",
"(",
"\\",
"DOMElement",
"$",
"caseNode",
",",
"array",
"$",
"defects",
",",
"string",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"defects",
"as",
"$",
"defect",
")",
"{",
"$",
"defectNode",
"=",
"$",
"this",
... | Append error or failure nodes to the given testcase node.
@param $caseNode
@param $defects
@param $type | [
"Append",
"error",
"or",
"failure",
"nodes",
"to",
"the",
"given",
"testcase",
"node",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Writer.php#L164-L171 | train |
paratestphp/paratest | src/Logging/JUnit/Writer.php | Writer.getSuiteRoot | protected function getSuiteRoot(array $suites): \DOMElement
{
$testsuites = $this->document->createElement('testsuites');
$this->document->appendChild($testsuites);
if (\count($suites) === 1) {
return $testsuites;
}
$rootSuite = $this->document->createElement('testsuite');
$attrs = $this->getSuiteRootAttributes($suites);
foreach ($attrs as $attr => $value) {
$rootSuite->setAttribute($attr, (string) $value);
}
$testsuites->appendChild($rootSuite);
return $rootSuite;
} | php | protected function getSuiteRoot(array $suites): \DOMElement
{
$testsuites = $this->document->createElement('testsuites');
$this->document->appendChild($testsuites);
if (\count($suites) === 1) {
return $testsuites;
}
$rootSuite = $this->document->createElement('testsuite');
$attrs = $this->getSuiteRootAttributes($suites);
foreach ($attrs as $attr => $value) {
$rootSuite->setAttribute($attr, (string) $value);
}
$testsuites->appendChild($rootSuite);
return $rootSuite;
} | [
"protected",
"function",
"getSuiteRoot",
"(",
"array",
"$",
"suites",
")",
":",
"\\",
"DOMElement",
"{",
"$",
"testsuites",
"=",
"$",
"this",
"->",
"document",
"->",
"createElement",
"(",
"'testsuites'",
")",
";",
"$",
"this",
"->",
"document",
"->",
"appe... | Get the root level testsuite node.
@param $suites
@return \DOMElement | [
"Get",
"the",
"root",
"level",
"testsuite",
"node",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Writer.php#L180-L195 | train |
paratestphp/paratest | src/Logging/JUnit/Writer.php | Writer.getSuiteRootAttributes | protected function getSuiteRootAttributes(array $suites)
{
return array_reduce($suites, function (array $result, TestSuite $suite): array {
$result['tests'] += $suite->tests;
$result['assertions'] += $suite->assertions;
$result['failures'] += $suite->failures;
$result['skipped'] += $suite->skipped;
$result['errors'] += $suite->errors;
$result['time'] += $suite->time;
return $result;
}, array_merge(['name' => $this->name], self::$defaultSuite));
} | php | protected function getSuiteRootAttributes(array $suites)
{
return array_reduce($suites, function (array $result, TestSuite $suite): array {
$result['tests'] += $suite->tests;
$result['assertions'] += $suite->assertions;
$result['failures'] += $suite->failures;
$result['skipped'] += $suite->skipped;
$result['errors'] += $suite->errors;
$result['time'] += $suite->time;
return $result;
}, array_merge(['name' => $this->name], self::$defaultSuite));
} | [
"protected",
"function",
"getSuiteRootAttributes",
"(",
"array",
"$",
"suites",
")",
"{",
"return",
"array_reduce",
"(",
"$",
"suites",
",",
"function",
"(",
"array",
"$",
"result",
",",
"TestSuite",
"$",
"suite",
")",
":",
"array",
"{",
"$",
"result",
"["... | Get the attributes used on the root testsuite
node.
@param $suites
@return mixed | [
"Get",
"the",
"attributes",
"used",
"on",
"the",
"root",
"testsuite",
"node",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Writer.php#L205-L217 | train |
paratestphp/paratest | src/Runners/PHPUnit/SuiteLoader.php | SuiteLoader.load | public function load(string $path = '')
{
if ($path) {
$testFileLoader = new TestFileLoader($this->options);
$this->files = array_merge(
$this->files,
$testFileLoader->loadPath($path)
);
} elseif (
isset($this->options->parallelSuite)
&& $this->options->parallelSuite
) {
$this->suitesName = $this->configuration->getSuitesName();
} elseif ($this->configuration->hasSuites()) {
if (!empty($this->options->testsuite)) {
$suites = [];
foreach ($this->options->testsuite as $testsuite) {
$suites = array_merge($suites, $this->configuration->getSuiteByName($testsuite));
}
} else {
$suites = $this->configuration->getSuites();
}
foreach ($suites as $suite) {
foreach ($suite as $suitePath) {
$testFileLoader = new TestFileLoader($this->options);
$this->files = array_merge(
$this->files,
$testFileLoader->loadSuitePath($suitePath)
);
}
}
}
if (!$this->files && !\is_array($this->suitesName)) {
throw new \RuntimeException('No path or configuration provided (tests must end with Test.php)');
}
$this->files = array_unique($this->files); // remove duplicates
$this->initSuites();
} | php | public function load(string $path = '')
{
if ($path) {
$testFileLoader = new TestFileLoader($this->options);
$this->files = array_merge(
$this->files,
$testFileLoader->loadPath($path)
);
} elseif (
isset($this->options->parallelSuite)
&& $this->options->parallelSuite
) {
$this->suitesName = $this->configuration->getSuitesName();
} elseif ($this->configuration->hasSuites()) {
if (!empty($this->options->testsuite)) {
$suites = [];
foreach ($this->options->testsuite as $testsuite) {
$suites = array_merge($suites, $this->configuration->getSuiteByName($testsuite));
}
} else {
$suites = $this->configuration->getSuites();
}
foreach ($suites as $suite) {
foreach ($suite as $suitePath) {
$testFileLoader = new TestFileLoader($this->options);
$this->files = array_merge(
$this->files,
$testFileLoader->loadSuitePath($suitePath)
);
}
}
}
if (!$this->files && !\is_array($this->suitesName)) {
throw new \RuntimeException('No path or configuration provided (tests must end with Test.php)');
}
$this->files = array_unique($this->files); // remove duplicates
$this->initSuites();
} | [
"public",
"function",
"load",
"(",
"string",
"$",
"path",
"=",
"''",
")",
"{",
"if",
"(",
"$",
"path",
")",
"{",
"$",
"testFileLoader",
"=",
"new",
"TestFileLoader",
"(",
"$",
"this",
"->",
"options",
")",
";",
"$",
"this",
"->",
"files",
"=",
"arr... | Populates the loaded suite collection. Will load suites
based off a phpunit xml configuration or a specified path.
@param string $path
@throws \RuntimeException | [
"Populates",
"the",
"loaded",
"suite",
"collection",
".",
"Will",
"load",
"suites",
"based",
"off",
"a",
"phpunit",
"xml",
"configuration",
"or",
"a",
"specified",
"path",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SuiteLoader.php#L90-L131 | train |
paratestphp/paratest | src/Runners/PHPUnit/SuiteLoader.php | SuiteLoader.initSuites | protected function initSuites()
{
if (\is_array($this->suitesName)) {
foreach ($this->suitesName as $suiteName) {
$this->loadedSuites[$suiteName] = $this->createFullSuite($suiteName, $this->configuration->getPath());
}
} else {
foreach ($this->files as $path) {
try {
$parser = new Parser($path);
if ($class = $parser->getClass()) {
$this->loadedSuites[$path] = $this->createSuite($path, $class);
}
} catch (NoClassInFileException $e) {
continue;
}
}
}
} | php | protected function initSuites()
{
if (\is_array($this->suitesName)) {
foreach ($this->suitesName as $suiteName) {
$this->loadedSuites[$suiteName] = $this->createFullSuite($suiteName, $this->configuration->getPath());
}
} else {
foreach ($this->files as $path) {
try {
$parser = new Parser($path);
if ($class = $parser->getClass()) {
$this->loadedSuites[$path] = $this->createSuite($path, $class);
}
} catch (NoClassInFileException $e) {
continue;
}
}
}
} | [
"protected",
"function",
"initSuites",
"(",
")",
"{",
"if",
"(",
"\\",
"is_array",
"(",
"$",
"this",
"->",
"suitesName",
")",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"suitesName",
"as",
"$",
"suiteName",
")",
"{",
"$",
"this",
"->",
"loadedSuites"... | Called after all files are loaded. Parses loaded files into
ExecutableTest objects - either Suite or TestMethod or FullSuite. | [
"Called",
"after",
"all",
"files",
"are",
"loaded",
".",
"Parses",
"loaded",
"files",
"into",
"ExecutableTest",
"objects",
"-",
"either",
"Suite",
"or",
"TestMethod",
"or",
"FullSuite",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SuiteLoader.php#L137-L155 | train |
paratestphp/paratest | src/Runners/PHPUnit/SuiteLoader.php | SuiteLoader.getMethodBatches | protected function getMethodBatches(ParsedClass $class): array
{
$classMethods = $class->getMethods($this->options ? $this->options->annotations : []);
$maxBatchSize = $this->options && $this->options->functional ? $this->options->maxBatchSize : 0;
$batches = [];
foreach ($classMethods as $method) {
$tests = $this->getMethodTests($class, $method, $maxBatchSize !== 0);
// if filter passed to paratest then method tests can be blank if not match to filter
if (!$tests) {
continue;
}
if (($dependsOn = $this->methodDependency($method)) !== null) {
$this->addDependentTestsToBatchSet($batches, $dependsOn, $tests);
} else {
$this->addTestsToBatchSet($batches, $tests, $maxBatchSize);
}
}
return $batches;
} | php | protected function getMethodBatches(ParsedClass $class): array
{
$classMethods = $class->getMethods($this->options ? $this->options->annotations : []);
$maxBatchSize = $this->options && $this->options->functional ? $this->options->maxBatchSize : 0;
$batches = [];
foreach ($classMethods as $method) {
$tests = $this->getMethodTests($class, $method, $maxBatchSize !== 0);
// if filter passed to paratest then method tests can be blank if not match to filter
if (!$tests) {
continue;
}
if (($dependsOn = $this->methodDependency($method)) !== null) {
$this->addDependentTestsToBatchSet($batches, $dependsOn, $tests);
} else {
$this->addTestsToBatchSet($batches, $tests, $maxBatchSize);
}
}
return $batches;
} | [
"protected",
"function",
"getMethodBatches",
"(",
"ParsedClass",
"$",
"class",
")",
":",
"array",
"{",
"$",
"classMethods",
"=",
"$",
"class",
"->",
"getMethods",
"(",
"$",
"this",
"->",
"options",
"?",
"$",
"this",
"->",
"options",
"->",
"annotations",
":... | Get method batches.
Identify method dependencies, and group dependents and dependees on a single methodBatch.
Use max batch size to fill batches.
@param ParsedClass $class
@return array of MethodBatches. Each MethodBatch has an array of method names | [
"Get",
"method",
"batches",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/SuiteLoader.php#L179-L199 | train |
paratestphp/paratest | src/Runners/PHPUnit/Configuration.php | Configuration.getSuitePaths | public function getSuitePaths(string $path)
{
$real = realpath($this->getConfigDir() . $path);
if ($real !== false) {
return [$real];
}
if ($this->isGlobRequired($path)) {
$paths = [];
foreach (glob($this->getConfigDir() . $path, GLOB_ONLYDIR) as $path) {
if (($path = realpath($path)) !== false) {
$paths[] = $path;
}
}
return $paths;
}
throw new \RuntimeException("Suite path $path could not be found");
} | php | public function getSuitePaths(string $path)
{
$real = realpath($this->getConfigDir() . $path);
if ($real !== false) {
return [$real];
}
if ($this->isGlobRequired($path)) {
$paths = [];
foreach (glob($this->getConfigDir() . $path, GLOB_ONLYDIR) as $path) {
if (($path = realpath($path)) !== false) {
$paths[] = $path;
}
}
return $paths;
}
throw new \RuntimeException("Suite path $path could not be found");
} | [
"public",
"function",
"getSuitePaths",
"(",
"string",
"$",
"path",
")",
"{",
"$",
"real",
"=",
"realpath",
"(",
"$",
"this",
"->",
"getConfigDir",
"(",
")",
".",
"$",
"path",
")",
";",
"if",
"(",
"$",
"real",
"!==",
"false",
")",
"{",
"return",
"["... | Returns a suite paths relative to the config file.
@param $path
@return array|string[] | [
"Returns",
"a",
"suite",
"paths",
"relative",
"to",
"the",
"config",
"file",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Configuration.php#L198-L218 | train |
paratestphp/paratest | src/Runners/PHPUnit/Configuration.php | Configuration.getEnvironmentVariables | public function getEnvironmentVariables(): array
{
if (!isset($this->xml->php->env)) {
return [];
}
$variables = [];
foreach ($this->xml->php->env as $env) {
$variables[(string) $env['name']] = (string) $env['value'];
}
return $variables;
} | php | public function getEnvironmentVariables(): array
{
if (!isset($this->xml->php->env)) {
return [];
}
$variables = [];
foreach ($this->xml->php->env as $env) {
$variables[(string) $env['name']] = (string) $env['value'];
}
return $variables;
} | [
"public",
"function",
"getEnvironmentVariables",
"(",
")",
":",
"array",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"xml",
"->",
"php",
"->",
"env",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"variables",
"=",
"[",
"]",
";",
"fo... | Get override environment variables from phpunit config file.
@return array | [
"Get",
"override",
"environment",
"variables",
"from",
"phpunit",
"config",
"file",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Configuration.php#L225-L238 | train |
paratestphp/paratest | src/Coverage/CoverageMerger.php | CoverageMerger.getCoverageObject | private function getCoverageObject(\SplFileObject $coverageFile): CodeCoverage
{
if ('<?php' === $coverageFile->fread(5)) {
return include $coverageFile->getRealPath();
}
$coverageFile->fseek(0);
// the PHPUnit 3.x and below
return unserialize($coverageFile->fread($coverageFile->getSize()));
} | php | private function getCoverageObject(\SplFileObject $coverageFile): CodeCoverage
{
if ('<?php' === $coverageFile->fread(5)) {
return include $coverageFile->getRealPath();
}
$coverageFile->fseek(0);
// the PHPUnit 3.x and below
return unserialize($coverageFile->fread($coverageFile->getSize()));
} | [
"private",
"function",
"getCoverageObject",
"(",
"\\",
"SplFileObject",
"$",
"coverageFile",
")",
":",
"CodeCoverage",
"{",
"if",
"(",
"'<?php'",
"===",
"$",
"coverageFile",
"->",
"fread",
"(",
"5",
")",
")",
"{",
"return",
"include",
"$",
"coverageFile",
"-... | Returns coverage object from file.
@param \SplFileObject $coverageFile coverage file
@return CodeCoverage | [
"Returns",
"coverage",
"object",
"from",
"file",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Coverage/CoverageMerger.php#L35-L44 | train |
paratestphp/paratest | src/Parser/ParsedObject.php | ParsedObject.hasAnnotation | public function hasAnnotation(string $annotation, string $value = null): bool
{
$pattern = sprintf(
'/@%s%s/',
$annotation,
null !== $value ? "[\s]+$value" : '\b'
);
return 1 === preg_match($pattern, $this->docBlock);
} | php | public function hasAnnotation(string $annotation, string $value = null): bool
{
$pattern = sprintf(
'/@%s%s/',
$annotation,
null !== $value ? "[\s]+$value" : '\b'
);
return 1 === preg_match($pattern, $this->docBlock);
} | [
"public",
"function",
"hasAnnotation",
"(",
"string",
"$",
"annotation",
",",
"string",
"$",
"value",
"=",
"null",
")",
":",
"bool",
"{",
"$",
"pattern",
"=",
"sprintf",
"(",
"'/@%s%s/'",
",",
"$",
"annotation",
",",
"null",
"!==",
"$",
"value",
"?",
"... | Returns whether or not the parsed object
has an annotation matching the name and value
if provided.
@param string $anno
@param mixed $value
@return bool | [
"Returns",
"whether",
"or",
"not",
"the",
"parsed",
"object",
"has",
"an",
"annotation",
"matching",
"the",
"name",
"and",
"value",
"if",
"provided",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Parser/ParsedObject.php#L55-L64 | train |
paratestphp/paratest | src/Logging/JUnit/Reader.php | Reader.init | protected function init()
{
$this->initSuite();
$cases = $this->getCaseNodes();
foreach ($cases as $file => $nodeArray) {
$this->initSuiteFromCases($nodeArray);
}
} | php | protected function init()
{
$this->initSuite();
$cases = $this->getCaseNodes();
foreach ($cases as $file => $nodeArray) {
$this->initSuiteFromCases($nodeArray);
}
} | [
"protected",
"function",
"init",
"(",
")",
"{",
"$",
"this",
"->",
"initSuite",
"(",
")",
";",
"$",
"cases",
"=",
"$",
"this",
"->",
"getCaseNodes",
"(",
")",
";",
"foreach",
"(",
"$",
"cases",
"as",
"$",
"file",
"=>",
"$",
"nodeArray",
")",
"{",
... | Initialize the suite collection
from the JUnit xml document. | [
"Initialize",
"the",
"suite",
"collection",
"from",
"the",
"JUnit",
"xml",
"document",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Reader.php#L125-L132 | train |
paratestphp/paratest | src/Logging/JUnit/Reader.php | Reader.initSuiteFromCases | protected function initSuiteFromCases(array $nodeArray)
{
$testCases = [];
$properties = $this->caseNodesToSuiteProperties($nodeArray, $testCases);
if (!$this->isSingle) {
$this->addSuite($properties, $testCases);
} else {
$this->suites[0]->cases = $testCases;
}
} | php | protected function initSuiteFromCases(array $nodeArray)
{
$testCases = [];
$properties = $this->caseNodesToSuiteProperties($nodeArray, $testCases);
if (!$this->isSingle) {
$this->addSuite($properties, $testCases);
} else {
$this->suites[0]->cases = $testCases;
}
} | [
"protected",
"function",
"initSuiteFromCases",
"(",
"array",
"$",
"nodeArray",
")",
"{",
"$",
"testCases",
"=",
"[",
"]",
";",
"$",
"properties",
"=",
"$",
"this",
"->",
"caseNodesToSuiteProperties",
"(",
"$",
"nodeArray",
",",
"$",
"testCases",
")",
";",
... | Uses an array of testcase nodes to build a suite.
@param array $nodeArray an array of SimpleXMLElement nodes representing testcase elements | [
"Uses",
"an",
"array",
"of",
"testcase",
"nodes",
"to",
"build",
"a",
"suite",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Reader.php#L139-L148 | train |
paratestphp/paratest | src/Logging/JUnit/Reader.php | Reader.addSuite | protected function addSuite($properties, array $testCases)
{
$suite = TestSuite::suiteFromArray($properties);
$suite->cases = $testCases;
$this->suites[0]->suites[] = $suite;
} | php | protected function addSuite($properties, array $testCases)
{
$suite = TestSuite::suiteFromArray($properties);
$suite->cases = $testCases;
$this->suites[0]->suites[] = $suite;
} | [
"protected",
"function",
"addSuite",
"(",
"$",
"properties",
",",
"array",
"$",
"testCases",
")",
"{",
"$",
"suite",
"=",
"TestSuite",
"::",
"suiteFromArray",
"(",
"$",
"properties",
")",
";",
"$",
"suite",
"->",
"cases",
"=",
"$",
"testCases",
";",
"$",... | Creates and adds a TestSuite based on the given
suite properties and collection of test cases.
@param $properties
@param $testCases | [
"Creates",
"and",
"adds",
"a",
"TestSuite",
"based",
"on",
"the",
"given",
"suite",
"properties",
"and",
"collection",
"of",
"test",
"cases",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Reader.php#L157-L162 | train |
paratestphp/paratest | src/Logging/JUnit/Reader.php | Reader.caseNodesToSuiteProperties | protected function caseNodesToSuiteProperties(array $nodeArray, array &$testCases = [])
{
$cb = [TestCase::class, 'caseFromNode'];
return array_reduce($nodeArray, function ($result, $c) use (&$testCases, $cb) {
$testCases[] = \call_user_func_array($cb, [$c]);
$result['name'] = (string) $c['class'];
$result['file'] = (string) $c['file'];
++$result['tests'];
$result['assertions'] += (int) $c['assertions'];
$result['failures'] += \count($c->xpath('failure'));
$result['errors'] += \count($c->xpath('error'));
$result['skipped'] += \count($c->xpath('skipped'));
$result['time'] += (float) $c['time'];
return $result;
}, static::$defaultSuite);
} | php | protected function caseNodesToSuiteProperties(array $nodeArray, array &$testCases = [])
{
$cb = [TestCase::class, 'caseFromNode'];
return array_reduce($nodeArray, function ($result, $c) use (&$testCases, $cb) {
$testCases[] = \call_user_func_array($cb, [$c]);
$result['name'] = (string) $c['class'];
$result['file'] = (string) $c['file'];
++$result['tests'];
$result['assertions'] += (int) $c['assertions'];
$result['failures'] += \count($c->xpath('failure'));
$result['errors'] += \count($c->xpath('error'));
$result['skipped'] += \count($c->xpath('skipped'));
$result['time'] += (float) $c['time'];
return $result;
}, static::$defaultSuite);
} | [
"protected",
"function",
"caseNodesToSuiteProperties",
"(",
"array",
"$",
"nodeArray",
",",
"array",
"&",
"$",
"testCases",
"=",
"[",
"]",
")",
"{",
"$",
"cb",
"=",
"[",
"TestCase",
"::",
"class",
",",
"'caseFromNode'",
"]",
";",
"return",
"array_reduce",
... | Fold an array of testcase nodes into a suite array.
@param array $nodeArray an array of testcase nodes
@param array $testCases an array reference. Individual testcases will be placed here.
@return mixed | [
"Fold",
"an",
"array",
"of",
"testcase",
"nodes",
"into",
"a",
"suite",
"array",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Reader.php#L172-L189 | train |
paratestphp/paratest | src/Logging/JUnit/Reader.php | Reader.getCaseNodes | protected function getCaseNodes(): array
{
$caseNodes = $this->xml->xpath('//testcase');
$cases = [];
foreach ($caseNodes as $node) {
$case = $node;
if (!isset($cases[(string) $node['file']])) {
$cases[(string) $node['file']] = [];
}
$cases[(string) $node['file']][] = $node;
}
return $cases;
} | php | protected function getCaseNodes(): array
{
$caseNodes = $this->xml->xpath('//testcase');
$cases = [];
foreach ($caseNodes as $node) {
$case = $node;
if (!isset($cases[(string) $node['file']])) {
$cases[(string) $node['file']] = [];
}
$cases[(string) $node['file']][] = $node;
}
return $cases;
} | [
"protected",
"function",
"getCaseNodes",
"(",
")",
":",
"array",
"{",
"$",
"caseNodes",
"=",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'//testcase'",
")",
";",
"$",
"cases",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"caseNodes",
"as",
"$",
"node"... | Return a collection of testcase nodes
from the xml document.
@return array | [
"Return",
"a",
"collection",
"of",
"testcase",
"nodes",
"from",
"the",
"xml",
"document",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Reader.php#L197-L210 | train |
paratestphp/paratest | src/Logging/JUnit/Reader.php | Reader.initSuite | protected function initSuite()
{
$suiteNodes = $this->xml->xpath('/testsuites/testsuite/testsuite');
$this->isSingle = \count($suiteNodes) === 0;
$node = current($this->xml->xpath('/testsuites/testsuite'));
if ($node !== false) {
$this->suites[] = TestSuite::suiteFromNode($node);
} else {
$this->suites[] = TestSuite::suiteFromArray(self::$defaultSuite);
}
} | php | protected function initSuite()
{
$suiteNodes = $this->xml->xpath('/testsuites/testsuite/testsuite');
$this->isSingle = \count($suiteNodes) === 0;
$node = current($this->xml->xpath('/testsuites/testsuite'));
if ($node !== false) {
$this->suites[] = TestSuite::suiteFromNode($node);
} else {
$this->suites[] = TestSuite::suiteFromArray(self::$defaultSuite);
}
} | [
"protected",
"function",
"initSuite",
"(",
")",
"{",
"$",
"suiteNodes",
"=",
"$",
"this",
"->",
"xml",
"->",
"xpath",
"(",
"'/testsuites/testsuite/testsuite'",
")",
";",
"$",
"this",
"->",
"isSingle",
"=",
"\\",
"count",
"(",
"$",
"suiteNodes",
")",
"===",... | Determine if this reader is a single suite
and initialize the suite collection with the first
suite. | [
"Determine",
"if",
"this",
"reader",
"is",
"a",
"single",
"suite",
"and",
"initialize",
"the",
"suite",
"collection",
"with",
"the",
"first",
"suite",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Logging/JUnit/Reader.php#L217-L228 | train |
paratestphp/paratest | src/Runners/PHPUnit/Worker/WrapperWorker.php | WrapperWorker.waitForFinishedJob | public function waitForFinishedJob()
{
if ($this->inExecution === 0) {
return;
}
$tellsUsItHasFinished = false;
stream_set_blocking($this->pipes[1], true);
while ($line = fgets($this->pipes[1])) {
if (strstr($line, "FINISHED\n")) {
$tellsUsItHasFinished = true;
--$this->inExecution;
break;
}
}
if (!$tellsUsItHasFinished) {
throw new \RuntimeException('The Worker terminated without finishing the job.');
}
} | php | public function waitForFinishedJob()
{
if ($this->inExecution === 0) {
return;
}
$tellsUsItHasFinished = false;
stream_set_blocking($this->pipes[1], true);
while ($line = fgets($this->pipes[1])) {
if (strstr($line, "FINISHED\n")) {
$tellsUsItHasFinished = true;
--$this->inExecution;
break;
}
}
if (!$tellsUsItHasFinished) {
throw new \RuntimeException('The Worker terminated without finishing the job.');
}
} | [
"public",
"function",
"waitForFinishedJob",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"inExecution",
"===",
"0",
")",
"{",
"return",
";",
"}",
"$",
"tellsUsItHasFinished",
"=",
"false",
";",
"stream_set_blocking",
"(",
"$",
"this",
"->",
"pipes",
"[",
... | This is an utility function for tests.
Refactor or write it only in the test case. | [
"This",
"is",
"an",
"utility",
"function",
"for",
"tests",
".",
"Refactor",
"or",
"write",
"it",
"only",
"in",
"the",
"test",
"case",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/Worker/WrapperWorker.php#L80-L97 | train |
paratestphp/paratest | src/Parser/Parser.php | Parser.getClass | public function getClass()
{
return $this->refl->isAbstract()
? null
: new ParsedClass(
(string) $this->refl->getDocComment(),
$this->getCleanReflectionName(),
$this->refl->getNamespaceName(),
$this->getMethods()
);
} | php | public function getClass()
{
return $this->refl->isAbstract()
? null
: new ParsedClass(
(string) $this->refl->getDocComment(),
$this->getCleanReflectionName(),
$this->refl->getNamespaceName(),
$this->getMethods()
);
} | [
"public",
"function",
"getClass",
"(",
")",
"{",
"return",
"$",
"this",
"->",
"refl",
"->",
"isAbstract",
"(",
")",
"?",
"null",
":",
"new",
"ParsedClass",
"(",
"(",
"string",
")",
"$",
"this",
"->",
"refl",
"->",
"getDocComment",
"(",
")",
",",
"$",... | Returns the fully constructed class
with methods or null if the class is abstract.
@return ParsedClass|null | [
"Returns",
"the",
"fully",
"constructed",
"class",
"with",
"methods",
"or",
"null",
"if",
"the",
"class",
"is",
"abstract",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Parser/Parser.php#L62-L72 | train |
paratestphp/paratest | src/Parser/Parser.php | Parser.getMethods | private function getMethods(): array
{
$tests = [];
$methods = $this->refl->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
$hasTestName = preg_match(self::$testName, $method->getName());
$docComment = $method->getDocComment();
$hasTestAnnotation = false !== $docComment && preg_match(self::$testAnnotation, $docComment);
$isTestMethod = $hasTestName || $hasTestAnnotation;
if ($isTestMethod) {
$tests[] = new ParsedFunction((string) $method->getDocComment(), 'public', $method->getName());
}
}
return $tests;
} | php | private function getMethods(): array
{
$tests = [];
$methods = $this->refl->getMethods(\ReflectionMethod::IS_PUBLIC);
foreach ($methods as $method) {
$hasTestName = preg_match(self::$testName, $method->getName());
$docComment = $method->getDocComment();
$hasTestAnnotation = false !== $docComment && preg_match(self::$testAnnotation, $docComment);
$isTestMethod = $hasTestName || $hasTestAnnotation;
if ($isTestMethod) {
$tests[] = new ParsedFunction((string) $method->getDocComment(), 'public', $method->getName());
}
}
return $tests;
} | [
"private",
"function",
"getMethods",
"(",
")",
":",
"array",
"{",
"$",
"tests",
"=",
"[",
"]",
";",
"$",
"methods",
"=",
"$",
"this",
"->",
"refl",
"->",
"getMethods",
"(",
"\\",
"ReflectionMethod",
"::",
"IS_PUBLIC",
")",
";",
"foreach",
"(",
"$",
"... | Return all test methods present in the file.
@return array | [
"Return",
"all",
"test",
"methods",
"present",
"in",
"the",
"file",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Parser/Parser.php#L89-L104 | train |
paratestphp/paratest | src/Parser/Parser.php | Parser.getClassName | private function getClassName(string $filename, array $previousDeclaredClasses)
{
$filename = realpath($filename);
$classes = get_declared_classes();
$newClasses = array_values(array_diff($classes, $previousDeclaredClasses));
$className = $this->_searchForUnitTestClass($newClasses, $filename);
if (isset($className)) {
return $className;
}
$className = $this->_searchForUnitTestClass($classes, $filename);
if (isset($className)) {
return $className;
}
} | php | private function getClassName(string $filename, array $previousDeclaredClasses)
{
$filename = realpath($filename);
$classes = get_declared_classes();
$newClasses = array_values(array_diff($classes, $previousDeclaredClasses));
$className = $this->_searchForUnitTestClass($newClasses, $filename);
if (isset($className)) {
return $className;
}
$className = $this->_searchForUnitTestClass($classes, $filename);
if (isset($className)) {
return $className;
}
} | [
"private",
"function",
"getClassName",
"(",
"string",
"$",
"filename",
",",
"array",
"$",
"previousDeclaredClasses",
")",
"{",
"$",
"filename",
"=",
"realpath",
"(",
"$",
"filename",
")",
";",
"$",
"classes",
"=",
"get_declared_classes",
"(",
")",
";",
"$",
... | Return the class name of the class contained
in the file.
@param mixed $filename
@param mixed $previousDeclaredClasses
@return string | [
"Return",
"the",
"class",
"name",
"of",
"the",
"class",
"contained",
"in",
"the",
"file",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Parser/Parser.php#L115-L130 | train |
paratestphp/paratest | src/Runners/PHPUnit/WrapperRunner.php | WrapperRunner.waitForStreamsToChange | private function waitForStreamsToChange(array $modified)
{
$write = [];
$except = [];
$result = stream_select($modified, $write, $except, 1);
if ($result === false) {
throw new \RuntimeException('stream_select() returned an error while waiting for all workers to finish.');
}
$this->modified = $modified;
return $result;
} | php | private function waitForStreamsToChange(array $modified)
{
$write = [];
$except = [];
$result = stream_select($modified, $write, $except, 1);
if ($result === false) {
throw new \RuntimeException('stream_select() returned an error while waiting for all workers to finish.');
}
$this->modified = $modified;
return $result;
} | [
"private",
"function",
"waitForStreamsToChange",
"(",
"array",
"$",
"modified",
")",
"{",
"$",
"write",
"=",
"[",
"]",
";",
"$",
"except",
"=",
"[",
"]",
";",
"$",
"result",
"=",
"stream_select",
"(",
"$",
"modified",
",",
"$",
"write",
",",
"$",
"ex... | put on WorkersPool | [
"put",
"on",
"WorkersPool"
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/WrapperRunner.php#L127-L138 | train |
paratestphp/paratest | src/Runners/PHPUnit/WrapperRunner.php | WrapperRunner.progressedWorkers | private function progressedWorkers(): array
{
$result = [];
foreach ($this->modified as $modifiedStream) {
$found = null;
foreach ($this->streams as $index => $stream) {
if ($modifiedStream === $stream) {
$found = $index;
break;
}
}
$result[$found] = $this->workers[$found];
}
$this->modified = [];
return $result;
} | php | private function progressedWorkers(): array
{
$result = [];
foreach ($this->modified as $modifiedStream) {
$found = null;
foreach ($this->streams as $index => $stream) {
if ($modifiedStream === $stream) {
$found = $index;
break;
}
}
$result[$found] = $this->workers[$found];
}
$this->modified = [];
return $result;
} | [
"private",
"function",
"progressedWorkers",
"(",
")",
":",
"array",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"modified",
"as",
"$",
"modifiedStream",
")",
"{",
"$",
"found",
"=",
"null",
";",
"foreach",
"(",
"$",
"th... | put on WorkersPool.
@return WrapperWorker[] | [
"put",
"on",
"WorkersPool",
"."
] | 34094d805bcabb6d9c2e20554c702c436c8a50d3 | https://github.com/paratestphp/paratest/blob/34094d805bcabb6d9c2e20554c702c436c8a50d3/src/Runners/PHPUnit/WrapperRunner.php#L145-L161 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.