id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
5,800
sellerlabs/nucleus
src/SellerLabs/Nucleus/Support/Str.php
Str.contains
public static function contains($subject, $inner, $encoding = null) { return Rope::of($subject, $encoding)->contains($inner); }
php
public static function contains($subject, $inner, $encoding = null) { return Rope::of($subject, $encoding)->contains($inner); }
[ "public", "static", "function", "contains", "(", "$", "subject", ",", "$", "inner", ",", "$", "encoding", "=", "null", ")", "{", "return", "Rope", "::", "of", "(", "$", "subject", ",", "$", "encoding", ")", "->", "contains", "(", "$", "inner", ")", ";", "}" ]
Return whether or not the subject contains the inner string. @param string $subject @param string $inner @param null|string $encoding @return bool
[ "Return", "whether", "or", "not", "the", "subject", "contains", "the", "inner", "string", "." ]
c05d9c23d424a6bd5ab2e29140805cc6e37e4623
https://github.com/sellerlabs/nucleus/blob/c05d9c23d424a6bd5ab2e29140805cc6e37e4623/src/SellerLabs/Nucleus/Support/Str.php#L152-L155
5,801
phlexible/phlexible
src/Phlexible/Bundle/MessageBundle/Controller/SubscriptionsController.php
SubscriptionsController.listAction
public function listAction() { $subscriptionManager = $this->get('phlexible_message.subscription_manager'); $subscriptions = []; foreach ($subscriptionManager->findAll() as $subscription) { $subscriptions[] = [ 'id' => $subscription->getId(), 'filterId' => $subscription->getFilter()->getId(), 'filter' => $subscription->getFilter()->getTitle(), 'handler' => $subscription->getHandler(), ]; } return new JsonResponse($subscriptions); }
php
public function listAction() { $subscriptionManager = $this->get('phlexible_message.subscription_manager'); $subscriptions = []; foreach ($subscriptionManager->findAll() as $subscription) { $subscriptions[] = [ 'id' => $subscription->getId(), 'filterId' => $subscription->getFilter()->getId(), 'filter' => $subscription->getFilter()->getTitle(), 'handler' => $subscription->getHandler(), ]; } return new JsonResponse($subscriptions); }
[ "public", "function", "listAction", "(", ")", "{", "$", "subscriptionManager", "=", "$", "this", "->", "get", "(", "'phlexible_message.subscription_manager'", ")", ";", "$", "subscriptions", "=", "[", "]", ";", "foreach", "(", "$", "subscriptionManager", "->", "findAll", "(", ")", "as", "$", "subscription", ")", "{", "$", "subscriptions", "[", "]", "=", "[", "'id'", "=>", "$", "subscription", "->", "getId", "(", ")", ",", "'filterId'", "=>", "$", "subscription", "->", "getFilter", "(", ")", "->", "getId", "(", ")", ",", "'filter'", "=>", "$", "subscription", "->", "getFilter", "(", ")", "->", "getTitle", "(", ")", ",", "'handler'", "=>", "$", "subscription", "->", "getHandler", "(", ")", ",", "]", ";", "}", "return", "new", "JsonResponse", "(", "$", "subscriptions", ")", ";", "}" ]
List subscriptions. @return JsonResponse @Route("", name="messages_subscriptions")
[ "List", "subscriptions", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MessageBundle/Controller/SubscriptionsController.php#L34-L50
5,802
phlexible/phlexible
src/Phlexible/Bundle/MessageBundle/Controller/SubscriptionsController.php
SubscriptionsController.createAction
public function createAction(Request $request) { $filterId = $request->get('filter'); $handler = $request->get('handler'); $subscriptionManager = $this->get('phlexible_message.subscription_manager'); $filterManager = $this->get('phlexible_message.filter_manager'); $filter = $filterManager->find($filterId); $subscription = $subscriptionManager->create() ->setUserId($this->getUser()->getId()) ->setFilter($filter) ->setHandler($handler); $subscriptionManager->updateSubscription($subscription); return new ResultResponse(true, 'Subscription created.'); }
php
public function createAction(Request $request) { $filterId = $request->get('filter'); $handler = $request->get('handler'); $subscriptionManager = $this->get('phlexible_message.subscription_manager'); $filterManager = $this->get('phlexible_message.filter_manager'); $filter = $filterManager->find($filterId); $subscription = $subscriptionManager->create() ->setUserId($this->getUser()->getId()) ->setFilter($filter) ->setHandler($handler); $subscriptionManager->updateSubscription($subscription); return new ResultResponse(true, 'Subscription created.'); }
[ "public", "function", "createAction", "(", "Request", "$", "request", ")", "{", "$", "filterId", "=", "$", "request", "->", "get", "(", "'filter'", ")", ";", "$", "handler", "=", "$", "request", "->", "get", "(", "'handler'", ")", ";", "$", "subscriptionManager", "=", "$", "this", "->", "get", "(", "'phlexible_message.subscription_manager'", ")", ";", "$", "filterManager", "=", "$", "this", "->", "get", "(", "'phlexible_message.filter_manager'", ")", ";", "$", "filter", "=", "$", "filterManager", "->", "find", "(", "$", "filterId", ")", ";", "$", "subscription", "=", "$", "subscriptionManager", "->", "create", "(", ")", "->", "setUserId", "(", "$", "this", "->", "getUser", "(", ")", "->", "getId", "(", ")", ")", "->", "setFilter", "(", "$", "filter", ")", "->", "setHandler", "(", "$", "handler", ")", ";", "$", "subscriptionManager", "->", "updateSubscription", "(", "$", "subscription", ")", ";", "return", "new", "ResultResponse", "(", "true", ",", "'Subscription created.'", ")", ";", "}" ]
Create subscription. @param Request $request @return ResultResponse @Route("/create", name="messages_subscription_create")
[ "Create", "subscription", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MessageBundle/Controller/SubscriptionsController.php#L60-L78
5,803
phlexible/phlexible
src/Phlexible/Bundle/MessageBundle/Controller/SubscriptionsController.php
SubscriptionsController.deleteAction
public function deleteAction($id) { $subscriptionManager = $this->get('phlexible_message.subscription_manager'); $subscription = $subscriptionManager->find($id); $subscriptionManager->deleteSubscription($subscription); return new ResultResponse(true, 'Subscription deleted.'); }
php
public function deleteAction($id) { $subscriptionManager = $this->get('phlexible_message.subscription_manager'); $subscription = $subscriptionManager->find($id); $subscriptionManager->deleteSubscription($subscription); return new ResultResponse(true, 'Subscription deleted.'); }
[ "public", "function", "deleteAction", "(", "$", "id", ")", "{", "$", "subscriptionManager", "=", "$", "this", "->", "get", "(", "'phlexible_message.subscription_manager'", ")", ";", "$", "subscription", "=", "$", "subscriptionManager", "->", "find", "(", "$", "id", ")", ";", "$", "subscriptionManager", "->", "deleteSubscription", "(", "$", "subscription", ")", ";", "return", "new", "ResultResponse", "(", "true", ",", "'Subscription deleted.'", ")", ";", "}" ]
Delete subscription. @param string $id @return ResultResponse @Route("/delete/{id}", name="messages_subscription_delete")
[ "Delete", "subscription", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/MessageBundle/Controller/SubscriptionsController.php#L88-L96
5,804
gossi/trixionary
src/model/Base/StructureNodeParentQuery.php
StructureNodeParentQuery.filterByStructureNodeId
public function filterByStructureNodeId($structureNodeId = null, $comparison = null) { if (is_array($structureNodeId)) { $useMinMax = false; if (isset($structureNodeId['min'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $structureNodeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($structureNodeId['max'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $structureNodeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $structureNodeId, $comparison); }
php
public function filterByStructureNodeId($structureNodeId = null, $comparison = null) { if (is_array($structureNodeId)) { $useMinMax = false; if (isset($structureNodeId['min'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $structureNodeId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($structureNodeId['max'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $structureNodeId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(StructureNodeParentTableMap::COL_STRUCTURE_NODE_ID, $structureNodeId, $comparison); }
[ "public", "function", "filterByStructureNodeId", "(", "$", "structureNodeId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "structureNodeId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "structureNodeId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "StructureNodeParentTableMap", "::", "COL_STRUCTURE_NODE_ID", ",", "$", "structureNodeId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "structureNodeId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "StructureNodeParentTableMap", "::", "COL_STRUCTURE_NODE_ID", ",", "$", "structureNodeId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "StructureNodeParentTableMap", "::", "COL_STRUCTURE_NODE_ID", ",", "$", "structureNodeId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the structure_node_id column Example usage: <code> $query->filterByStructureNodeId(1234); // WHERE structure_node_id = 1234 $query->filterByStructureNodeId(array(12, 34)); // WHERE structure_node_id IN (12, 34) $query->filterByStructureNodeId(array('min' => 12)); // WHERE structure_node_id > 12 </code> @see filterByStructureNodeRelatedByStructureNodeId() @param mixed $structureNodeId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildStructureNodeParentQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "structure_node_id", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeParentQuery.php#L272-L293
5,805
gossi/trixionary
src/model/Base/StructureNodeParentQuery.php
StructureNodeParentQuery.filterByParentId
public function filterByParentId($parentId = null, $comparison = null) { if (is_array($parentId)) { $useMinMax = false; if (isset($parentId['min'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $parentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parentId['max'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $parentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $parentId, $comparison); }
php
public function filterByParentId($parentId = null, $comparison = null) { if (is_array($parentId)) { $useMinMax = false; if (isset($parentId['min'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $parentId['min'], Criteria::GREATER_EQUAL); $useMinMax = true; } if (isset($parentId['max'])) { $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $parentId['max'], Criteria::LESS_EQUAL); $useMinMax = true; } if ($useMinMax) { return $this; } if (null === $comparison) { $comparison = Criteria::IN; } } return $this->addUsingAlias(StructureNodeParentTableMap::COL_PARENT_ID, $parentId, $comparison); }
[ "public", "function", "filterByParentId", "(", "$", "parentId", "=", "null", ",", "$", "comparison", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "parentId", ")", ")", "{", "$", "useMinMax", "=", "false", ";", "if", "(", "isset", "(", "$", "parentId", "[", "'min'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "StructureNodeParentTableMap", "::", "COL_PARENT_ID", ",", "$", "parentId", "[", "'min'", "]", ",", "Criteria", "::", "GREATER_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "isset", "(", "$", "parentId", "[", "'max'", "]", ")", ")", "{", "$", "this", "->", "addUsingAlias", "(", "StructureNodeParentTableMap", "::", "COL_PARENT_ID", ",", "$", "parentId", "[", "'max'", "]", ",", "Criteria", "::", "LESS_EQUAL", ")", ";", "$", "useMinMax", "=", "true", ";", "}", "if", "(", "$", "useMinMax", ")", "{", "return", "$", "this", ";", "}", "if", "(", "null", "===", "$", "comparison", ")", "{", "$", "comparison", "=", "Criteria", "::", "IN", ";", "}", "}", "return", "$", "this", "->", "addUsingAlias", "(", "StructureNodeParentTableMap", "::", "COL_PARENT_ID", ",", "$", "parentId", ",", "$", "comparison", ")", ";", "}" ]
Filter the query on the parent_id column Example usage: <code> $query->filterByParentId(1234); // WHERE parent_id = 1234 $query->filterByParentId(array(12, 34)); // WHERE parent_id IN (12, 34) $query->filterByParentId(array('min' => 12)); // WHERE parent_id > 12 </code> @see filterByStructureNodeRelatedByParentId() @param mixed $parentId The value to use as filter. Use scalar values for equality. Use array values for in_array() equivalent. Use associative array('min' => $minValue, 'max' => $maxValue) for intervals. @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL @return $this|ChildStructureNodeParentQuery The current query, for fluid interface
[ "Filter", "the", "query", "on", "the", "parent_id", "column" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeParentQuery.php#L315-L336
5,806
gossi/trixionary
src/model/Base/StructureNodeParentQuery.php
StructureNodeParentQuery.useStructureNodeRelatedByStructureNodeIdQuery
public function useStructureNodeRelatedByStructureNodeIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeRelatedByStructureNodeId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeRelatedByStructureNodeId', '\gossi\trixionary\model\StructureNodeQuery'); }
php
public function useStructureNodeRelatedByStructureNodeIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeRelatedByStructureNodeId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeRelatedByStructureNodeId', '\gossi\trixionary\model\StructureNodeQuery'); }
[ "public", "function", "useStructureNodeRelatedByStructureNodeIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinStructureNodeRelatedByStructureNodeId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'StructureNodeRelatedByStructureNodeId'", ",", "'\\gossi\\trixionary\\model\\StructureNodeQuery'", ")", ";", "}" ]
Use the StructureNodeRelatedByStructureNodeId relation StructureNode object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\StructureNodeQuery A secondary query class using the current class as primary query
[ "Use", "the", "StructureNodeRelatedByStructureNodeId", "relation", "StructureNode", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeParentQuery.php#L408-L413
5,807
gossi/trixionary
src/model/Base/StructureNodeParentQuery.php
StructureNodeParentQuery.useStructureNodeRelatedByParentIdQuery
public function useStructureNodeRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeRelatedByParentId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeRelatedByParentId', '\gossi\trixionary\model\StructureNodeQuery'); }
php
public function useStructureNodeRelatedByParentIdQuery($relationAlias = null, $joinType = Criteria::INNER_JOIN) { return $this ->joinStructureNodeRelatedByParentId($relationAlias, $joinType) ->useQuery($relationAlias ? $relationAlias : 'StructureNodeRelatedByParentId', '\gossi\trixionary\model\StructureNodeQuery'); }
[ "public", "function", "useStructureNodeRelatedByParentIdQuery", "(", "$", "relationAlias", "=", "null", ",", "$", "joinType", "=", "Criteria", "::", "INNER_JOIN", ")", "{", "return", "$", "this", "->", "joinStructureNodeRelatedByParentId", "(", "$", "relationAlias", ",", "$", "joinType", ")", "->", "useQuery", "(", "$", "relationAlias", "?", "$", "relationAlias", ":", "'StructureNodeRelatedByParentId'", ",", "'\\gossi\\trixionary\\model\\StructureNodeQuery'", ")", ";", "}" ]
Use the StructureNodeRelatedByParentId relation StructureNode object @see useQuery() @param string $relationAlias optional alias for the relation, to be used as main alias in the secondary query @param string $joinType Accepted values are null, 'left join', 'right join', 'inner join' @return \gossi\trixionary\model\StructureNodeQuery A secondary query class using the current class as primary query
[ "Use", "the", "StructureNodeRelatedByParentId", "relation", "StructureNode", "object" ]
221a6c5322473d7d7f8e322958a3ee46d87da150
https://github.com/gossi/trixionary/blob/221a6c5322473d7d7f8e322958a3ee46d87da150/src/model/Base/StructureNodeParentQuery.php#L485-L490
5,808
franckysolo/octopush-sdk
src/Octopush/Message.php
Message.setParams
public function setParams(array $params = []) { if (empty($params) || count($params) < 4) { throw new \InvalidArgumentException( 'Missing required params for Octopush message' ); } foreach ($params as $key => $param) { if (!in_array($key, array_merge($this->requiredKeys, $this->optionalKeys))) { throw new \InvalidArgumentException( 'Missing required params for Octopush message' ); } } foreach ($params as $key => $value) { $method = 'set' . $this->setMethod($key); $this->$method($value); } // set default params $this->params['sending_time'] = (new \DateTime())->getTimestamp(); if (isset($this->params['sending_date'])) { $this->params['sms_mode'] = static::WITH_DELAY; } if (isset($this->params['request_keys'])) { $this->params['request_sha1'] = $this->encrypt($this->params); } if ($this->params['sms_type'] === 'FR') { $this->params['sms_text'] .= PHP_EOL . 'STOP au XXXXX'; } return $this; }
php
public function setParams(array $params = []) { if (empty($params) || count($params) < 4) { throw new \InvalidArgumentException( 'Missing required params for Octopush message' ); } foreach ($params as $key => $param) { if (!in_array($key, array_merge($this->requiredKeys, $this->optionalKeys))) { throw new \InvalidArgumentException( 'Missing required params for Octopush message' ); } } foreach ($params as $key => $value) { $method = 'set' . $this->setMethod($key); $this->$method($value); } // set default params $this->params['sending_time'] = (new \DateTime())->getTimestamp(); if (isset($this->params['sending_date'])) { $this->params['sms_mode'] = static::WITH_DELAY; } if (isset($this->params['request_keys'])) { $this->params['request_sha1'] = $this->encrypt($this->params); } if ($this->params['sms_type'] === 'FR') { $this->params['sms_text'] .= PHP_EOL . 'STOP au XXXXX'; } return $this; }
[ "public", "function", "setParams", "(", "array", "$", "params", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "params", ")", "||", "count", "(", "$", "params", ")", "<", "4", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Missing required params for Octopush message'", ")", ";", "}", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "param", ")", "{", "if", "(", "!", "in_array", "(", "$", "key", ",", "array_merge", "(", "$", "this", "->", "requiredKeys", ",", "$", "this", "->", "optionalKeys", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Missing required params for Octopush message'", ")", ";", "}", "}", "foreach", "(", "$", "params", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "method", "=", "'set'", ".", "$", "this", "->", "setMethod", "(", "$", "key", ")", ";", "$", "this", "->", "$", "method", "(", "$", "value", ")", ";", "}", "// set default params", "$", "this", "->", "params", "[", "'sending_time'", "]", "=", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "getTimestamp", "(", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "params", "[", "'sending_date'", "]", ")", ")", "{", "$", "this", "->", "params", "[", "'sms_mode'", "]", "=", "static", "::", "WITH_DELAY", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "params", "[", "'request_keys'", "]", ")", ")", "{", "$", "this", "->", "params", "[", "'request_sha1'", "]", "=", "$", "this", "->", "encrypt", "(", "$", "this", "->", "params", ")", ";", "}", "if", "(", "$", "this", "->", "params", "[", "'sms_type'", "]", "===", "'FR'", ")", "{", "$", "this", "->", "params", "[", "'sms_text'", "]", ".=", "PHP_EOL", ".", "'STOP au XXXXX'", ";", "}", "return", "$", "this", ";", "}" ]
Set the parameters message @param array $params The parameters message required and optionnals @return \Octopush\Message @throws \InvalidArgumentException
[ "Set", "the", "parameters", "message" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Message.php#L154-L191
5,809
franckysolo/octopush-sdk
src/Octopush/Message.php
Message.encrypt
public function encrypt(array $params = []) { $requestString = ''; $requestKey = $this->params['request_keys']; for ($i = 0, $n = strlen($requestKey); $i < $n; ++$i) { $char = $requestKey[$i]; if (!isset($this->encryptData[$char]) || !isset($params[$this->encryptData[$char]])) { continue; } $requestString .= $params[$this->encryptData[$char]]; } return sha1($requestString); }
php
public function encrypt(array $params = []) { $requestString = ''; $requestKey = $this->params['request_keys']; for ($i = 0, $n = strlen($requestKey); $i < $n; ++$i) { $char = $requestKey[$i]; if (!isset($this->encryptData[$char]) || !isset($params[$this->encryptData[$char]])) { continue; } $requestString .= $params[$this->encryptData[$char]]; } return sha1($requestString); }
[ "public", "function", "encrypt", "(", "array", "$", "params", "=", "[", "]", ")", "{", "$", "requestString", "=", "''", ";", "$", "requestKey", "=", "$", "this", "->", "params", "[", "'request_keys'", "]", ";", "for", "(", "$", "i", "=", "0", ",", "$", "n", "=", "strlen", "(", "$", "requestKey", ")", ";", "$", "i", "<", "$", "n", ";", "++", "$", "i", ")", "{", "$", "char", "=", "$", "requestKey", "[", "$", "i", "]", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "encryptData", "[", "$", "char", "]", ")", "||", "!", "isset", "(", "$", "params", "[", "$", "this", "->", "encryptData", "[", "$", "char", "]", "]", ")", ")", "{", "continue", ";", "}", "$", "requestString", ".=", "$", "params", "[", "$", "this", "->", "encryptData", "[", "$", "char", "]", "]", ";", "}", "return", "sha1", "(", "$", "requestString", ")", ";", "}" ]
Encoding request_sha1 Optionnel Cette valeur contient le sha1 de la concaténation des valeurs des champs choisis dans la variable request_keys et concaténés dans le même ordre que les clés. @param array $params the params @return string the encrypt string code
[ "Encoding", "request_sha1", "Optionnel" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Message.php#L214-L228
5,810
franckysolo/octopush-sdk
src/Octopush/Message.php
Message.setRequestMode
public function setRequestMode($mode) { if (!in_array($mode, ['real', 'simu'])) { $message = sprintf( 'The request mode %s is not supported, real or simu expected!', $mode ); throw new \InvalidArgumentException($message, 500); } $this->params['request_mode'] = $mode; return $this; }
php
public function setRequestMode($mode) { if (!in_array($mode, ['real', 'simu'])) { $message = sprintf( 'The request mode %s is not supported, real or simu expected!', $mode ); throw new \InvalidArgumentException($message, 500); } $this->params['request_mode'] = $mode; return $this; }
[ "public", "function", "setRequestMode", "(", "$", "mode", ")", "{", "if", "(", "!", "in_array", "(", "$", "mode", ",", "[", "'real'", ",", "'simu'", "]", ")", ")", "{", "$", "message", "=", "sprintf", "(", "'The request mode %s is not supported, real or simu expected!'", ",", "$", "mode", ")", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "message", ",", "500", ")", ";", "}", "$", "this", "->", "params", "[", "'request_mode'", "]", "=", "$", "mode", ";", "return", "$", "this", ";", "}" ]
The request_mode param Optionnel Allows you to choose simulation mode with the value 'simu'. * Default: real Permet de choisir le mode simulation avec la valeur 'simu'. * défaut : real @param string $mode @return \Octopush\Message
[ "The", "request_mode", "param", "Optionnel" ]
3797e53d51474a64b65fbf437e5dd46e288f2ef8
https://github.com/franckysolo/octopush-sdk/blob/3797e53d51474a64b65fbf437e5dd46e288f2ef8/src/Octopush/Message.php#L334-L345
5,811
fortrabbit/datafilter
src/DataFilter/Rule.php
Rule.parseDefinition
protected function parseDefinition($definition = null) { if (is_null($definition)) { if (!is_null($this->definition)) { throw new \InvalidArgumentException( 'Cannot parse rule definitions for rule "'. $this->name. '", attrib "' . $this->attrib->getName(). '" without definition!' ); } $definition = $this->definition; $this->definition = null; } // required, simple if (is_string($definition) || is_callable($definition)) { $definition = array('constraint' => $definition); } // init empty to reduce isset checks.. $definition = array_merge(self::$DEFAULT_ATTRIBS, $definition); // set attribs $this->sufficient = $definition['sufficient']; $this->skipEmpty = $definition['skipEmpty']; $this->error = $definition['error']; // having old style callable constraint if (is_callable($definition['constraint']) && is_array($definition['constraint'])) { // !($definition['constraint'] instanceof \Closure)) { $cb = $definition['constraint']; $definition['constraint'] = function () use ($cb) { $args = func_get_args(); return call_user_func_array($cb, $args); }; } // from string -> check predefined elseif (is_string($definition['constraint'])) { $args = preg_split('/:/', $definition['constraint']); $method = 'rule'. array_shift($args); $found = false; foreach ($this->dataFilter->getPredefinedRuleClasses() as $className) { if (is_callable(array($className, $method)) && method_exists($className, $method)) { $definition['constraint'] = call_user_func_array(array($className, $method), $args); $found = true; break; } } if (!$found) { throw new \InvalidArgumentException( 'Could not use constraint "'. $definition['constraint']. '" for rule "' . $this->name. '", attrib "'. $this->attrib->getName(). '" because no ' . 'predefined rule class found implementing "'. $method. '()"' ); } } // determine class $constraintClass = is_object($definition['constraint']) ? get_class($definition['constraint']) : '(Scalar)'; // at this point: it has to be a closure! if ($constraintClass !== 'Closure') { throw new \InvalidArgumentException( 'Definition for rule "'. $this->name. '", attrib "'. $this->attrib->getName(). '"' . ' has an invalid constraint of class '. $constraintClass ); } $this->constraint = $definition['constraint']; }
php
protected function parseDefinition($definition = null) { if (is_null($definition)) { if (!is_null($this->definition)) { throw new \InvalidArgumentException( 'Cannot parse rule definitions for rule "'. $this->name. '", attrib "' . $this->attrib->getName(). '" without definition!' ); } $definition = $this->definition; $this->definition = null; } // required, simple if (is_string($definition) || is_callable($definition)) { $definition = array('constraint' => $definition); } // init empty to reduce isset checks.. $definition = array_merge(self::$DEFAULT_ATTRIBS, $definition); // set attribs $this->sufficient = $definition['sufficient']; $this->skipEmpty = $definition['skipEmpty']; $this->error = $definition['error']; // having old style callable constraint if (is_callable($definition['constraint']) && is_array($definition['constraint'])) { // !($definition['constraint'] instanceof \Closure)) { $cb = $definition['constraint']; $definition['constraint'] = function () use ($cb) { $args = func_get_args(); return call_user_func_array($cb, $args); }; } // from string -> check predefined elseif (is_string($definition['constraint'])) { $args = preg_split('/:/', $definition['constraint']); $method = 'rule'. array_shift($args); $found = false; foreach ($this->dataFilter->getPredefinedRuleClasses() as $className) { if (is_callable(array($className, $method)) && method_exists($className, $method)) { $definition['constraint'] = call_user_func_array(array($className, $method), $args); $found = true; break; } } if (!$found) { throw new \InvalidArgumentException( 'Could not use constraint "'. $definition['constraint']. '" for rule "' . $this->name. '", attrib "'. $this->attrib->getName(). '" because no ' . 'predefined rule class found implementing "'. $method. '()"' ); } } // determine class $constraintClass = is_object($definition['constraint']) ? get_class($definition['constraint']) : '(Scalar)'; // at this point: it has to be a closure! if ($constraintClass !== 'Closure') { throw new \InvalidArgumentException( 'Definition for rule "'. $this->name. '", attrib "'. $this->attrib->getName(). '"' . ' has an invalid constraint of class '. $constraintClass ); } $this->constraint = $definition['constraint']; }
[ "protected", "function", "parseDefinition", "(", "$", "definition", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "definition", ")", ")", "{", "if", "(", "!", "is_null", "(", "$", "this", "->", "definition", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Cannot parse rule definitions for rule \"'", ".", "$", "this", "->", "name", ".", "'\", attrib \"'", ".", "$", "this", "->", "attrib", "->", "getName", "(", ")", ".", "'\" without definition!'", ")", ";", "}", "$", "definition", "=", "$", "this", "->", "definition", ";", "$", "this", "->", "definition", "=", "null", ";", "}", "// required, simple", "if", "(", "is_string", "(", "$", "definition", ")", "||", "is_callable", "(", "$", "definition", ")", ")", "{", "$", "definition", "=", "array", "(", "'constraint'", "=>", "$", "definition", ")", ";", "}", "// init empty to reduce isset checks..", "$", "definition", "=", "array_merge", "(", "self", "::", "$", "DEFAULT_ATTRIBS", ",", "$", "definition", ")", ";", "// set attribs", "$", "this", "->", "sufficient", "=", "$", "definition", "[", "'sufficient'", "]", ";", "$", "this", "->", "skipEmpty", "=", "$", "definition", "[", "'skipEmpty'", "]", ";", "$", "this", "->", "error", "=", "$", "definition", "[", "'error'", "]", ";", "// having old style callable constraint", "if", "(", "is_callable", "(", "$", "definition", "[", "'constraint'", "]", ")", "&&", "is_array", "(", "$", "definition", "[", "'constraint'", "]", ")", ")", "{", "// !($definition['constraint'] instanceof \\Closure)) {", "$", "cb", "=", "$", "definition", "[", "'constraint'", "]", ";", "$", "definition", "[", "'constraint'", "]", "=", "function", "(", ")", "use", "(", "$", "cb", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "return", "call_user_func_array", "(", "$", "cb", ",", "$", "args", ")", ";", "}", ";", "}", "// from string -> check predefined", "elseif", "(", "is_string", "(", "$", "definition", "[", "'constraint'", "]", ")", ")", "{", "$", "args", "=", "preg_split", "(", "'/:/'", ",", "$", "definition", "[", "'constraint'", "]", ")", ";", "$", "method", "=", "'rule'", ".", "array_shift", "(", "$", "args", ")", ";", "$", "found", "=", "false", ";", "foreach", "(", "$", "this", "->", "dataFilter", "->", "getPredefinedRuleClasses", "(", ")", "as", "$", "className", ")", "{", "if", "(", "is_callable", "(", "array", "(", "$", "className", ",", "$", "method", ")", ")", "&&", "method_exists", "(", "$", "className", ",", "$", "method", ")", ")", "{", "$", "definition", "[", "'constraint'", "]", "=", "call_user_func_array", "(", "array", "(", "$", "className", ",", "$", "method", ")", ",", "$", "args", ")", ";", "$", "found", "=", "true", ";", "break", ";", "}", "}", "if", "(", "!", "$", "found", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Could not use constraint \"'", ".", "$", "definition", "[", "'constraint'", "]", ".", "'\" for rule \"'", ".", "$", "this", "->", "name", ".", "'\", attrib \"'", ".", "$", "this", "->", "attrib", "->", "getName", "(", ")", ".", "'\" because no '", ".", "'predefined rule class found implementing \"'", ".", "$", "method", ".", "'()\"'", ")", ";", "}", "}", "// determine class", "$", "constraintClass", "=", "is_object", "(", "$", "definition", "[", "'constraint'", "]", ")", "?", "get_class", "(", "$", "definition", "[", "'constraint'", "]", ")", ":", "'(Scalar)'", ";", "// at this point: it has to be a closure!", "if", "(", "$", "constraintClass", "!==", "'Closure'", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Definition for rule \"'", ".", "$", "this", "->", "name", ".", "'\", attrib \"'", ".", "$", "this", "->", "attrib", "->", "getName", "(", ")", ".", "'\"'", ".", "' has an invalid constraint of class '", ".", "$", "constraintClass", ")", ";", "}", "$", "this", "->", "constraint", "=", "$", "definition", "[", "'constraint'", "]", ";", "}" ]
The long description @param mixed $definition The rule definition @throws \InvalidArgumentException
[ "The", "long", "description" ]
fca1c2cbd299f3762b251134d8a62038fb7defe3
https://github.com/fortrabbit/datafilter/blob/fca1c2cbd299f3762b251134d8a62038fb7defe3/src/DataFilter/Rule.php#L118-L187
5,812
fortrabbit/datafilter
src/DataFilter/Rule.php
Rule.getError
public function getError(\DataFilter\Attribute $attrib = null) { if ($this->error === false) { return null; } if (!$attrib) { $attrib = $this->attrib; } $formatData = array('rule' => $this->name); if ($attrib) { $formatData['attrib'] = $attrib->getName(); } $error = $this->error; if (!$error && $attrib) { $error = $attrib->getDefaultErrorStr(); } if (!$error) { $error = $this->dataFilter->getErrorTemplate(); } return U::formatString($error, $formatData); }
php
public function getError(\DataFilter\Attribute $attrib = null) { if ($this->error === false) { return null; } if (!$attrib) { $attrib = $this->attrib; } $formatData = array('rule' => $this->name); if ($attrib) { $formatData['attrib'] = $attrib->getName(); } $error = $this->error; if (!$error && $attrib) { $error = $attrib->getDefaultErrorStr(); } if (!$error) { $error = $this->dataFilter->getErrorTemplate(); } return U::formatString($error, $formatData); }
[ "public", "function", "getError", "(", "\\", "DataFilter", "\\", "Attribute", "$", "attrib", "=", "null", ")", "{", "if", "(", "$", "this", "->", "error", "===", "false", ")", "{", "return", "null", ";", "}", "if", "(", "!", "$", "attrib", ")", "{", "$", "attrib", "=", "$", "this", "->", "attrib", ";", "}", "$", "formatData", "=", "array", "(", "'rule'", "=>", "$", "this", "->", "name", ")", ";", "if", "(", "$", "attrib", ")", "{", "$", "formatData", "[", "'attrib'", "]", "=", "$", "attrib", "->", "getName", "(", ")", ";", "}", "$", "error", "=", "$", "this", "->", "error", ";", "if", "(", "!", "$", "error", "&&", "$", "attrib", ")", "{", "$", "error", "=", "$", "attrib", "->", "getDefaultErrorStr", "(", ")", ";", "}", "if", "(", "!", "$", "error", ")", "{", "$", "error", "=", "$", "this", "->", "dataFilter", "->", "getErrorTemplate", "(", ")", ";", "}", "return", "U", "::", "formatString", "(", "$", "error", ",", "$", "formatData", ")", ";", "}" ]
Returns error string or null @return string
[ "Returns", "error", "string", "or", "null" ]
fca1c2cbd299f3762b251134d8a62038fb7defe3
https://github.com/fortrabbit/datafilter/blob/fca1c2cbd299f3762b251134d8a62038fb7defe3/src/DataFilter/Rule.php#L235-L255
5,813
hediet/php-type-reflection
src/Hediet/Types/ArrayType.php
ArrayType.isAssignableFrom
public function isAssignableFrom(Type $type) { if (!$type instanceof ArrayType) return false; if (!$type->itemType->equals($this->itemType)) return false; if (!$type->keyType->equals($this->keyType)) return false; return true; }
php
public function isAssignableFrom(Type $type) { if (!$type instanceof ArrayType) return false; if (!$type->itemType->equals($this->itemType)) return false; if (!$type->keyType->equals($this->keyType)) return false; return true; }
[ "public", "function", "isAssignableFrom", "(", "Type", "$", "type", ")", "{", "if", "(", "!", "$", "type", "instanceof", "ArrayType", ")", "return", "false", ";", "if", "(", "!", "$", "type", "->", "itemType", "->", "equals", "(", "$", "this", "->", "itemType", ")", ")", "return", "false", ";", "if", "(", "!", "$", "type", "->", "keyType", "->", "equals", "(", "$", "this", "->", "keyType", ")", ")", "return", "false", ";", "return", "true", ";", "}" ]
Checks whether the provided type represents an array whose key and value type are equal to the key and value type of this instance. @param Type $type The provided type. @return boolean
[ "Checks", "whether", "the", "provided", "type", "represents", "an", "array", "whose", "key", "and", "value", "type", "are", "equal", "to", "the", "key", "and", "value", "type", "of", "this", "instance", "." ]
4a049c0e35f35cf95769f3823c915a3c41d6a292
https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ArrayType.php#L61-L71
5,814
hediet/php-type-reflection
src/Hediet/Types/ArrayType.php
ArrayType.isAssignableFromValue
public function isAssignableFromValue($value) { if (!is_array($value)) return false; foreach ($value as $key => $item) { if (!$this->itemType->isAssignableFromValue($item)) return false; if (!$this->keyType->isAssignableFromValue($key)) return false; } return true; }
php
public function isAssignableFromValue($value) { if (!is_array($value)) return false; foreach ($value as $key => $item) { if (!$this->itemType->isAssignableFromValue($item)) return false; if (!$this->keyType->isAssignableFromValue($key)) return false; } return true; }
[ "public", "function", "isAssignableFromValue", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "return", "false", ";", "foreach", "(", "$", "value", "as", "$", "key", "=>", "$", "item", ")", "{", "if", "(", "!", "$", "this", "->", "itemType", "->", "isAssignableFromValue", "(", "$", "item", ")", ")", "return", "false", ";", "if", "(", "!", "$", "this", "->", "keyType", "->", "isAssignableFromValue", "(", "$", "key", ")", ")", "return", "false", ";", "}", "return", "true", ";", "}" ]
Checks whether the provided value is an array and all keys and values are assignable to the key and value type of this instance. @param mixed $value The provided value. @return boolean
[ "Checks", "whether", "the", "provided", "value", "is", "an", "array", "and", "all", "keys", "and", "values", "are", "assignable", "to", "the", "key", "and", "value", "type", "of", "this", "instance", "." ]
4a049c0e35f35cf95769f3823c915a3c41d6a292
https://github.com/hediet/php-type-reflection/blob/4a049c0e35f35cf95769f3823c915a3c41d6a292/src/Hediet/Types/ArrayType.php#L80-L92
5,815
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/StatusController.php
StatusController.indexAction
public function indexAction() { $output = ''; $output .= '<a href="'.$this->generateUrl('gui_status_listeners').'">listeners</a><br/>'; $output .= '<a href="'.$this->generateUrl('gui_status_php').'">php</a><br/>'; $output .= '<a href="'.$this->generateUrl('gui_status_load').'">load</a><br/>'; return new Response($output); }
php
public function indexAction() { $output = ''; $output .= '<a href="'.$this->generateUrl('gui_status_listeners').'">listeners</a><br/>'; $output .= '<a href="'.$this->generateUrl('gui_status_php').'">php</a><br/>'; $output .= '<a href="'.$this->generateUrl('gui_status_load').'">load</a><br/>'; return new Response($output); }
[ "public", "function", "indexAction", "(", ")", "{", "$", "output", "=", "''", ";", "$", "output", ".=", "'<a href=\"'", ".", "$", "this", "->", "generateUrl", "(", "'gui_status_listeners'", ")", ".", "'\">listeners</a><br/>'", ";", "$", "output", ".=", "'<a href=\"'", ".", "$", "this", "->", "generateUrl", "(", "'gui_status_php'", ")", ".", "'\">php</a><br/>'", ";", "$", "output", ".=", "'<a href=\"'", ".", "$", "this", "->", "generateUrl", "(", "'gui_status_load'", ")", ".", "'\">load</a><br/>'", ";", "return", "new", "Response", "(", "$", "output", ")", ";", "}" ]
List status actions. @return Response @Route("", name="gui_status")
[ "List", "status", "actions", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/StatusController.php#L35-L43
5,816
phlexible/phlexible
src/Phlexible/Bundle/GuiBundle/Controller/StatusController.php
StatusController.listenersAction
public function listenersAction() { $dispatcher = $this->get('event_dispatcher'); $listenerNames = array_keys($dispatcher->getListeners()); sort($listenerNames); $output = '<pre>'; $output .= str_repeat('=', 3).str_pad(' Events / Listeners ', 80, '=').PHP_EOL.PHP_EOL; foreach ($listenerNames as $listenerName) { $listeners = $dispatcher->getListeners($listenerName); $output .= $listenerName.' (<a href="#'.$listenerName.'">'.count($listeners).' listeners</a>)'.PHP_EOL; } foreach ($listenerNames as $listenerName) { $listeners = $dispatcher->getListeners($listenerName); if (!$listenerName) { $listenerName = '(global)'; } $output .= PHP_EOL.PHP_EOL.str_repeat('-', 3).'<a name="'.$listenerName.'"></a>'.str_pad(' '.$listenerName.' ', 80, '-').PHP_EOL.PHP_EOL; foreach ($listeners as $listener) { if (is_array($listener)) { if (is_object($listener[0])) { $listener = get_class($listener[0]).'->'.$listener[1].'()'; } else { $listener = implode('::', $listener).'()'; } } $output .= '* '.$listener.PHP_EOL; } } return new Response($output); }
php
public function listenersAction() { $dispatcher = $this->get('event_dispatcher'); $listenerNames = array_keys($dispatcher->getListeners()); sort($listenerNames); $output = '<pre>'; $output .= str_repeat('=', 3).str_pad(' Events / Listeners ', 80, '=').PHP_EOL.PHP_EOL; foreach ($listenerNames as $listenerName) { $listeners = $dispatcher->getListeners($listenerName); $output .= $listenerName.' (<a href="#'.$listenerName.'">'.count($listeners).' listeners</a>)'.PHP_EOL; } foreach ($listenerNames as $listenerName) { $listeners = $dispatcher->getListeners($listenerName); if (!$listenerName) { $listenerName = '(global)'; } $output .= PHP_EOL.PHP_EOL.str_repeat('-', 3).'<a name="'.$listenerName.'"></a>'.str_pad(' '.$listenerName.' ', 80, '-').PHP_EOL.PHP_EOL; foreach ($listeners as $listener) { if (is_array($listener)) { if (is_object($listener[0])) { $listener = get_class($listener[0]).'->'.$listener[1].'()'; } else { $listener = implode('::', $listener).'()'; } } $output .= '* '.$listener.PHP_EOL; } } return new Response($output); }
[ "public", "function", "listenersAction", "(", ")", "{", "$", "dispatcher", "=", "$", "this", "->", "get", "(", "'event_dispatcher'", ")", ";", "$", "listenerNames", "=", "array_keys", "(", "$", "dispatcher", "->", "getListeners", "(", ")", ")", ";", "sort", "(", "$", "listenerNames", ")", ";", "$", "output", "=", "'<pre>'", ";", "$", "output", ".=", "str_repeat", "(", "'='", ",", "3", ")", ".", "str_pad", "(", "' Events / Listeners '", ",", "80", ",", "'='", ")", ".", "PHP_EOL", ".", "PHP_EOL", ";", "foreach", "(", "$", "listenerNames", "as", "$", "listenerName", ")", "{", "$", "listeners", "=", "$", "dispatcher", "->", "getListeners", "(", "$", "listenerName", ")", ";", "$", "output", ".=", "$", "listenerName", ".", "' (<a href=\"#'", ".", "$", "listenerName", ".", "'\">'", ".", "count", "(", "$", "listeners", ")", ".", "' listeners</a>)'", ".", "PHP_EOL", ";", "}", "foreach", "(", "$", "listenerNames", "as", "$", "listenerName", ")", "{", "$", "listeners", "=", "$", "dispatcher", "->", "getListeners", "(", "$", "listenerName", ")", ";", "if", "(", "!", "$", "listenerName", ")", "{", "$", "listenerName", "=", "'(global)'", ";", "}", "$", "output", ".=", "PHP_EOL", ".", "PHP_EOL", ".", "str_repeat", "(", "'-'", ",", "3", ")", ".", "'<a name=\"'", ".", "$", "listenerName", ".", "'\"></a>'", ".", "str_pad", "(", "' '", ".", "$", "listenerName", ".", "' '", ",", "80", ",", "'-'", ")", ".", "PHP_EOL", ".", "PHP_EOL", ";", "foreach", "(", "$", "listeners", "as", "$", "listener", ")", "{", "if", "(", "is_array", "(", "$", "listener", ")", ")", "{", "if", "(", "is_object", "(", "$", "listener", "[", "0", "]", ")", ")", "{", "$", "listener", "=", "get_class", "(", "$", "listener", "[", "0", "]", ")", ".", "'->'", ".", "$", "listener", "[", "1", "]", ".", "'()'", ";", "}", "else", "{", "$", "listener", "=", "implode", "(", "'::'", ",", "$", "listener", ")", ".", "'()'", ";", "}", "}", "$", "output", ".=", "'* '", ".", "$", "listener", ".", "PHP_EOL", ";", "}", "}", "return", "new", "Response", "(", "$", "output", ")", ";", "}" ]
Show events. @return Response @Route("/listeners", name="gui_status_listeners")
[ "Show", "events", "." ]
132f24924c9bb0dbb6c1ea84db0a463f97fa3893
https://github.com/phlexible/phlexible/blob/132f24924c9bb0dbb6c1ea84db0a463f97fa3893/src/Phlexible/Bundle/GuiBundle/Controller/StatusController.php#L51-L89
5,817
harvestcloud/CoreBundle
Entity/Profile.php
Profile.addBuyerHubRefAsBuyer
public function addBuyerHubRefAsBuyer(BuyerHubRef $buyerHubRef) { if (!count($this->buyerHubRefsAsBuyer)) { $buyerHubRef->setIsDefault(true); } $this->buyerHubRefsAsBuyer[] = $buyerHubRef; $buyerHubRef->setBuyer($this); }
php
public function addBuyerHubRefAsBuyer(BuyerHubRef $buyerHubRef) { if (!count($this->buyerHubRefsAsBuyer)) { $buyerHubRef->setIsDefault(true); } $this->buyerHubRefsAsBuyer[] = $buyerHubRef; $buyerHubRef->setBuyer($this); }
[ "public", "function", "addBuyerHubRefAsBuyer", "(", "BuyerHubRef", "$", "buyerHubRef", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "buyerHubRefsAsBuyer", ")", ")", "{", "$", "buyerHubRef", "->", "setIsDefault", "(", "true", ")", ";", "}", "$", "this", "->", "buyerHubRefsAsBuyer", "[", "]", "=", "$", "buyerHubRef", ";", "$", "buyerHubRef", "->", "setBuyer", "(", "$", "this", ")", ";", "}" ]
Add BuyerHubRef as Buyer @author Tom Haskins-Vaughan <[email protected]> @since 2012-04-26 @param BuyerHubRef $buyerHubRef
[ "Add", "BuyerHubRef", "as", "Buyer" ]
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Profile.php#L812-L821
5,818
harvestcloud/CoreBundle
Entity/Profile.php
Profile.addSellerHubRefAsSeller
public function addSellerHubRefAsSeller(SellerHubRef $sellerHubRef) { if (!count($this->sellerHubRefsAsSeller)) { $sellerHubRef->setIsDefault(true); } $this->sellerHubRefsAsSeller[] = $sellerHubRef; $sellerHubRef->setSeller($this); }
php
public function addSellerHubRefAsSeller(SellerHubRef $sellerHubRef) { if (!count($this->sellerHubRefsAsSeller)) { $sellerHubRef->setIsDefault(true); } $this->sellerHubRefsAsSeller[] = $sellerHubRef; $sellerHubRef->setSeller($this); }
[ "public", "function", "addSellerHubRefAsSeller", "(", "SellerHubRef", "$", "sellerHubRef", ")", "{", "if", "(", "!", "count", "(", "$", "this", "->", "sellerHubRefsAsSeller", ")", ")", "{", "$", "sellerHubRef", "->", "setIsDefault", "(", "true", ")", ";", "}", "$", "this", "->", "sellerHubRefsAsSeller", "[", "]", "=", "$", "sellerHubRef", ";", "$", "sellerHubRef", "->", "setSeller", "(", "$", "this", ")", ";", "}" ]
Add SellerHubRef as Seller @author Tom Haskins-Vaughan <[email protected]> @since 2012-04-26 @param SellerHubRef $sellerHubRef
[ "Add", "SellerHubRef", "as", "Seller" ]
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Profile.php#L879-L888
5,819
harvestcloud/CoreBundle
Entity/Profile.php
Profile.getAccountByCode
public function getAccountByCode($type_code) { switch ($type_code) { case Account::TYPE_ACCOUNTS_RECEIVABLE: case Account::TYPE_ACCOUNTS_PAYABLE: case Account::TYPE_SALES: case Account::TYPE_BANK: foreach ($this->getAccounts() as $account) { if ($account->getTypeCode() == $type_code) { return $account; } } // We couldn't find an account, so let's create one $account = new Account(); $account->setBalance(0); $account->setProfile($this); $account->setTypeCode($type_code); $account->setName($this->getName().Account::getAccountNameSuffix($type_code)); return $account; default: throw new \Exception('Invalid account code: '.$account_code); } }
php
public function getAccountByCode($type_code) { switch ($type_code) { case Account::TYPE_ACCOUNTS_RECEIVABLE: case Account::TYPE_ACCOUNTS_PAYABLE: case Account::TYPE_SALES: case Account::TYPE_BANK: foreach ($this->getAccounts() as $account) { if ($account->getTypeCode() == $type_code) { return $account; } } // We couldn't find an account, so let's create one $account = new Account(); $account->setBalance(0); $account->setProfile($this); $account->setTypeCode($type_code); $account->setName($this->getName().Account::getAccountNameSuffix($type_code)); return $account; default: throw new \Exception('Invalid account code: '.$account_code); } }
[ "public", "function", "getAccountByCode", "(", "$", "type_code", ")", "{", "switch", "(", "$", "type_code", ")", "{", "case", "Account", "::", "TYPE_ACCOUNTS_RECEIVABLE", ":", "case", "Account", "::", "TYPE_ACCOUNTS_PAYABLE", ":", "case", "Account", "::", "TYPE_SALES", ":", "case", "Account", "::", "TYPE_BANK", ":", "foreach", "(", "$", "this", "->", "getAccounts", "(", ")", "as", "$", "account", ")", "{", "if", "(", "$", "account", "->", "getTypeCode", "(", ")", "==", "$", "type_code", ")", "{", "return", "$", "account", ";", "}", "}", "// We couldn't find an account, so let's create one", "$", "account", "=", "new", "Account", "(", ")", ";", "$", "account", "->", "setBalance", "(", "0", ")", ";", "$", "account", "->", "setProfile", "(", "$", "this", ")", ";", "$", "account", "->", "setTypeCode", "(", "$", "type_code", ")", ";", "$", "account", "->", "setName", "(", "$", "this", "->", "getName", "(", ")", ".", "Account", "::", "getAccountNameSuffix", "(", "$", "type_code", ")", ")", ";", "return", "$", "account", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'Invalid account code: '", ".", "$", "account_code", ")", ";", "}", "}" ]
Get Profile's account by code e.g. AP => Accounts Payable @author Tom Haskins-Vaughan <[email protected]> @since 2012-05-21 @param string $type_code @return \HarvestCloud\CoreBundle\Entity\Account
[ "Get", "Profile", "s", "account", "by", "code" ]
f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc
https://github.com/harvestcloud/CoreBundle/blob/f33e079c4a6191cf674aa2678f2fb2e6f0dd89cc/Entity/Profile.php#L1232-L1263
5,820
SocietyCMS/User
Entities/Entrust/EloquentUser.php
EloquentUser.can
public function can($permission, $requireAll = false) { if ($this->cachedRoles()->where('name', 'admin')->count()) { return true; } return $this->entrustCan($permission, $requireAll = false); }
php
public function can($permission, $requireAll = false) { if ($this->cachedRoles()->where('name', 'admin')->count()) { return true; } return $this->entrustCan($permission, $requireAll = false); }
[ "public", "function", "can", "(", "$", "permission", ",", "$", "requireAll", "=", "false", ")", "{", "if", "(", "$", "this", "->", "cachedRoles", "(", ")", "->", "where", "(", "'name'", ",", "'admin'", ")", "->", "count", "(", ")", ")", "{", "return", "true", ";", "}", "return", "$", "this", "->", "entrustCan", "(", "$", "permission", ",", "$", "requireAll", "=", "false", ")", ";", "}" ]
Check if user has a permission by its name. return rearly if the user is in the admin group. @param string|array $permission Permission string or array of permissions. @param bool $requireAll All permissions in the array are required. @return bool
[ "Check", "if", "user", "has", "a", "permission", "by", "its", "name", ".", "return", "rearly", "if", "the", "user", "is", "in", "the", "admin", "group", "." ]
76f7b52b27e8a9740f8d5a9c3b86181e1c231634
https://github.com/SocietyCMS/User/blob/76f7b52b27e8a9740f8d5a9c3b86181e1c231634/Entities/Entrust/EloquentUser.php#L135-L142
5,821
park-manager/security
Token/SplitToken.php
SplitToken.fromString
final public static function fromString(string $token): self { if (Binary::safeStrlen($token) < self::TOKEN_CHAR_LENGTH) { // Don't zero memory as the value is invalid. throw new \RuntimeException('Invalid token provided.'); } $instance = new static(); $instance->token = new HiddenString($token); $instance->selector = Binary::safeSubstr($token, 0, 32); $instance->verifier = Binary::safeSubstr($token, 32); // Don't (re)generate as this needs the salt of the stored hash. $instance->verifierHash = null; \sodium_memzero($token); return $instance; }
php
final public static function fromString(string $token): self { if (Binary::safeStrlen($token) < self::TOKEN_CHAR_LENGTH) { // Don't zero memory as the value is invalid. throw new \RuntimeException('Invalid token provided.'); } $instance = new static(); $instance->token = new HiddenString($token); $instance->selector = Binary::safeSubstr($token, 0, 32); $instance->verifier = Binary::safeSubstr($token, 32); // Don't (re)generate as this needs the salt of the stored hash. $instance->verifierHash = null; \sodium_memzero($token); return $instance; }
[ "final", "public", "static", "function", "fromString", "(", "string", "$", "token", ")", ":", "self", "{", "if", "(", "Binary", "::", "safeStrlen", "(", "$", "token", ")", "<", "self", "::", "TOKEN_CHAR_LENGTH", ")", "{", "// Don't zero memory as the value is invalid.", "throw", "new", "\\", "RuntimeException", "(", "'Invalid token provided.'", ")", ";", "}", "$", "instance", "=", "new", "static", "(", ")", ";", "$", "instance", "->", "token", "=", "new", "HiddenString", "(", "$", "token", ")", ";", "$", "instance", "->", "selector", "=", "Binary", "::", "safeSubstr", "(", "$", "token", ",", "0", ",", "32", ")", ";", "$", "instance", "->", "verifier", "=", "Binary", "::", "safeSubstr", "(", "$", "token", ",", "32", ")", ";", "// Don't (re)generate as this needs the salt of the stored hash.", "$", "instance", "->", "verifierHash", "=", "null", ";", "\\", "sodium_memzero", "(", "$", "token", ")", ";", "return", "$", "instance", ";", "}" ]
Recreates a SplitToken object from a string. Note: The $token is zeroed from memory when valid. @param string $token @return static
[ "Recreates", "a", "SplitToken", "object", "from", "a", "string", "." ]
14faa70daa7559a2ccbd256f7168ab782463feab
https://github.com/park-manager/security/blob/14faa70daa7559a2ccbd256f7168ab782463feab/Token/SplitToken.php#L157-L175
5,822
park-manager/security
Token/SplitToken.php
SplitToken.toValueHolder
public function toValueHolder(array $metadata = []): SplitTokenValueHolder { if (null === $this->verifierHash) { throw new \RuntimeException('toValueHolder() does not work SplitToken object created with fromString().'); } return new SplitTokenValueHolder($this->selector, $this->verifierHash, $this->expiresAt, $metadata, $this); }
php
public function toValueHolder(array $metadata = []): SplitTokenValueHolder { if (null === $this->verifierHash) { throw new \RuntimeException('toValueHolder() does not work SplitToken object created with fromString().'); } return new SplitTokenValueHolder($this->selector, $this->verifierHash, $this->expiresAt, $metadata, $this); }
[ "public", "function", "toValueHolder", "(", "array", "$", "metadata", "=", "[", "]", ")", ":", "SplitTokenValueHolder", "{", "if", "(", "null", "===", "$", "this", "->", "verifierHash", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'toValueHolder() does not work SplitToken object created with fromString().'", ")", ";", "}", "return", "new", "SplitTokenValueHolder", "(", "$", "this", "->", "selector", ",", "$", "this", "->", "verifierHash", ",", "$", "this", "->", "expiresAt", ",", "$", "metadata", ",", "$", "this", ")", ";", "}" ]
Produce a new SplitTokenValue instance. Note: This method doesn't work when reconstructed from a string. @param array $metadata @return SplitTokenValueHolder
[ "Produce", "a", "new", "SplitTokenValue", "instance", "." ]
14faa70daa7559a2ccbd256f7168ab782463feab
https://github.com/park-manager/security/blob/14faa70daa7559a2ccbd256f7168ab782463feab/Token/SplitToken.php#L226-L233
5,823
fkooman/php-lib-rest
src/fkooman/Rest/Route.php
Route.findAvailableParameterValue
private function findAvailableParameterValue(ReflectionParameter $p, array $availableParameters) { // determine the name, in case of a class this is the type hint, in // case of a non-class parameter it is the actual name $isClass = null !== $p->getClass(); if ($isClass) { $parameterName = $p->getClass()->getName(); } else { $parameterName = $p->getName(); } if (array_key_exists($parameterName, $availableParameters)) { // we found the parameter! return $availableParameters[$parameterName]; } if ($p->isDefaultValueAvailable()) { // we have a default value! return $p->getDefaultValue(); } throw new BadFunctionCallException( sprintf( 'parameter "%s" expected by callback not available', $parameterName ) ); }
php
private function findAvailableParameterValue(ReflectionParameter $p, array $availableParameters) { // determine the name, in case of a class this is the type hint, in // case of a non-class parameter it is the actual name $isClass = null !== $p->getClass(); if ($isClass) { $parameterName = $p->getClass()->getName(); } else { $parameterName = $p->getName(); } if (array_key_exists($parameterName, $availableParameters)) { // we found the parameter! return $availableParameters[$parameterName]; } if ($p->isDefaultValueAvailable()) { // we have a default value! return $p->getDefaultValue(); } throw new BadFunctionCallException( sprintf( 'parameter "%s" expected by callback not available', $parameterName ) ); }
[ "private", "function", "findAvailableParameterValue", "(", "ReflectionParameter", "$", "p", ",", "array", "$", "availableParameters", ")", "{", "// determine the name, in case of a class this is the type hint, in", "// case of a non-class parameter it is the actual name", "$", "isClass", "=", "null", "!==", "$", "p", "->", "getClass", "(", ")", ";", "if", "(", "$", "isClass", ")", "{", "$", "parameterName", "=", "$", "p", "->", "getClass", "(", ")", "->", "getName", "(", ")", ";", "}", "else", "{", "$", "parameterName", "=", "$", "p", "->", "getName", "(", ")", ";", "}", "if", "(", "array_key_exists", "(", "$", "parameterName", ",", "$", "availableParameters", ")", ")", "{", "// we found the parameter!", "return", "$", "availableParameters", "[", "$", "parameterName", "]", ";", "}", "if", "(", "$", "p", "->", "isDefaultValueAvailable", "(", ")", ")", "{", "// we have a default value!", "return", "$", "p", "->", "getDefaultValue", "(", ")", ";", "}", "throw", "new", "BadFunctionCallException", "(", "sprintf", "(", "'parameter \"%s\" expected by callback not available'", ",", "$", "parameterName", ")", ")", ";", "}" ]
Find the parameter required by the callback. @param ReflectionParameter $p a parameter belonging to the callback @param array $availableParameters contains a list of parameters available to the callback, where the key contains either the type hinted name of the class, or the name of the parameter if the parameter is no class, e.g.: array('foo' => 5, 'stdClass' => new StdClass()) @return string the value of the parameter from $availableParameters, or an (optional) provided default value by the callback
[ "Find", "the", "parameter", "required", "by", "the", "callback", "." ]
27bfd12e267b2ce866c2855c8a094db9682906af
https://github.com/fkooman/php-lib-rest/blob/27bfd12e267b2ce866c2855c8a094db9682906af/src/fkooman/Rest/Route.php#L108-L133
5,824
ddehart/dilmun
src/Anshar/Http/UriParts/Port.php
Port.isValid
public static function isValid($port) { $port_valid = false; if (is_int($port)) { $port_valid = self::portIsInValidRange($port); } elseif (is_null($port)) { $port_valid = true; } return $port_valid; }
php
public static function isValid($port) { $port_valid = false; if (is_int($port)) { $port_valid = self::portIsInValidRange($port); } elseif (is_null($port)) { $port_valid = true; } return $port_valid; }
[ "public", "static", "function", "isValid", "(", "$", "port", ")", "{", "$", "port_valid", "=", "false", ";", "if", "(", "is_int", "(", "$", "port", ")", ")", "{", "$", "port_valid", "=", "self", "::", "portIsInValidRange", "(", "$", "port", ")", ";", "}", "elseif", "(", "is_null", "(", "$", "port", ")", ")", "{", "$", "port_valid", "=", "true", ";", "}", "return", "$", "port_valid", ";", "}" ]
Validates a given port. A port is valid if it is either null or an integer between 1 and 65535 inclusive. @param mixed $port The port to be validated @return bool Returns true if the given port is valid Returns false otherwise
[ "Validates", "a", "given", "port", ".", "A", "port", "is", "valid", "if", "it", "is", "either", "null", "or", "an", "integer", "between", "1", "and", "65535", "inclusive", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/UriParts/Port.php#L82-L93
5,825
ddehart/dilmun
src/Anshar/Http/UriParts/Port.php
Port.toUriString
public function toUriString(Scheme $scheme = null) { $normalized_port = $this->normalizePortAgainstScheme($scheme); $uri_string = (string) $normalized_port; if (!is_null($normalized_port)) { $uri_string = ":" . $uri_string; } return $uri_string; }
php
public function toUriString(Scheme $scheme = null) { $normalized_port = $this->normalizePortAgainstScheme($scheme); $uri_string = (string) $normalized_port; if (!is_null($normalized_port)) { $uri_string = ":" . $uri_string; } return $uri_string; }
[ "public", "function", "toUriString", "(", "Scheme", "$", "scheme", "=", "null", ")", "{", "$", "normalized_port", "=", "$", "this", "->", "normalizePortAgainstScheme", "(", "$", "scheme", ")", ";", "$", "uri_string", "=", "(", "string", ")", "$", "normalized_port", ";", "if", "(", "!", "is_null", "(", "$", "normalized_port", ")", ")", "{", "$", "uri_string", "=", "\":\"", ".", "$", "uri_string", ";", "}", "return", "$", "uri_string", ";", "}" ]
Returns a string representation of the port formatted so that it can be compiled into a complete URI string per the Uri object's string specification. If the port is empty, toUriString returns an empty string; if the port is not empty, toUriString returns the port prefixed with a colon. toUriString will also check the port against an optionally-provided scheme; if the port is standard for the given scheme, toUriString returns an empty string. @see Uri::__toString @param Scheme|null $scheme [optional] A scheme against which to check if the port is the standard @return string A string representation of the port formatted for a complete URI string
[ "Returns", "a", "string", "representation", "of", "the", "port", "formatted", "so", "that", "it", "can", "be", "compiled", "into", "a", "complete", "URI", "string", "per", "the", "Uri", "object", "s", "string", "specification", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/UriParts/Port.php#L111-L122
5,826
ddehart/dilmun
src/Anshar/Http/UriParts/Port.php
Port.normalizePortAgainstScheme
public function normalizePortAgainstScheme(Scheme $scheme = null) { $scheme_port_array = new ArrayHelper($this->scheme_ports); $scheme_string = (string) $scheme; $standard_port = $scheme_port_array->valueLookup($scheme_string); if ($this->port == $standard_port) { $normalized_port = null; } else { $normalized_port = $this->port; } return $normalized_port; }
php
public function normalizePortAgainstScheme(Scheme $scheme = null) { $scheme_port_array = new ArrayHelper($this->scheme_ports); $scheme_string = (string) $scheme; $standard_port = $scheme_port_array->valueLookup($scheme_string); if ($this->port == $standard_port) { $normalized_port = null; } else { $normalized_port = $this->port; } return $normalized_port; }
[ "public", "function", "normalizePortAgainstScheme", "(", "Scheme", "$", "scheme", "=", "null", ")", "{", "$", "scheme_port_array", "=", "new", "ArrayHelper", "(", "$", "this", "->", "scheme_ports", ")", ";", "$", "scheme_string", "=", "(", "string", ")", "$", "scheme", ";", "$", "standard_port", "=", "$", "scheme_port_array", "->", "valueLookup", "(", "$", "scheme_string", ")", ";", "if", "(", "$", "this", "->", "port", "==", "$", "standard_port", ")", "{", "$", "normalized_port", "=", "null", ";", "}", "else", "{", "$", "normalized_port", "=", "$", "this", "->", "port", ";", "}", "return", "$", "normalized_port", ";", "}" ]
Normalizes the port against a given scheme so that the scheme is reported as null if the port is standard for the scheme. For example, given a http scheme and a port of 80, the normalized port will be reported as null; given a https scheme and a port of 80, the normalized port will be reported as 80. @see Port::toUriString() @see SchemePortsTrait @param Scheme|null $scheme @return int|null
[ "Normalizes", "the", "port", "against", "a", "given", "scheme", "so", "that", "the", "scheme", "is", "reported", "as", "null", "if", "the", "port", "is", "standard", "for", "the", "scheme", "." ]
e2a294dbcd4c6754063c247be64930c5ee91378f
https://github.com/ddehart/dilmun/blob/e2a294dbcd4c6754063c247be64930c5ee91378f/src/Anshar/Http/UriParts/Port.php#L137-L151
5,827
SocietyCMS/Menu
Repositories/Menu/MenuRepository.php
MenuRepository.menu
public function menu($name) { if (array_key_exists($name, $this->menus)) { return $this->menus[$name]; } return $this->menus[$name] = new MenuBuilder($name, $this->config); }
php
public function menu($name) { if (array_key_exists($name, $this->menus)) { return $this->menus[$name]; } return $this->menus[$name] = new MenuBuilder($name, $this->config); }
[ "public", "function", "menu", "(", "$", "name", ")", "{", "if", "(", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "menus", ")", ")", "{", "return", "$", "this", "->", "menus", "[", "$", "name", "]", ";", "}", "return", "$", "this", "->", "menus", "[", "$", "name", "]", "=", "new", "MenuBuilder", "(", "$", "name", ",", "$", "this", "->", "config", ")", ";", "}" ]
Create MenuItem for specified menu. @param $name @return MenuItem
[ "Create", "MenuItem", "for", "specified", "menu", "." ]
417468edaa2be0051ae041ee614ab609f0ac8b49
https://github.com/SocietyCMS/Menu/blob/417468edaa2be0051ae041ee614ab609f0ac8b49/Repositories/Menu/MenuRepository.php#L40-L47
5,828
SocietyCMS/Menu
Repositories/Menu/MenuRepository.php
MenuRepository.getItemUuiD
public function getItemUuiD($menuItem) { $itemID = ''; if (is_a($menuItem, MenuItem::class)) { $itemID = 'MenuItem'.$menuItem->getURL(); } if (is_a($menuItem, MenuBuilder::class)) { $itemID = 'MenuBuilder'.$menuItem->getName(); } return Str::limit(md5(Str::slug($itemID)), 12, null); }
php
public function getItemUuiD($menuItem) { $itemID = ''; if (is_a($menuItem, MenuItem::class)) { $itemID = 'MenuItem'.$menuItem->getURL(); } if (is_a($menuItem, MenuBuilder::class)) { $itemID = 'MenuBuilder'.$menuItem->getName(); } return Str::limit(md5(Str::slug($itemID)), 12, null); }
[ "public", "function", "getItemUuiD", "(", "$", "menuItem", ")", "{", "$", "itemID", "=", "''", ";", "if", "(", "is_a", "(", "$", "menuItem", ",", "MenuItem", "::", "class", ")", ")", "{", "$", "itemID", "=", "'MenuItem'", ".", "$", "menuItem", "->", "getURL", "(", ")", ";", "}", "if", "(", "is_a", "(", "$", "menuItem", ",", "MenuBuilder", "::", "class", ")", ")", "{", "$", "itemID", "=", "'MenuBuilder'", ".", "$", "menuItem", "->", "getName", "(", ")", ";", "}", "return", "Str", "::", "limit", "(", "md5", "(", "Str", "::", "slug", "(", "$", "itemID", ")", ")", ",", "12", ",", "null", ")", ";", "}" ]
Generate Item uuid. @param $menuName @param $itemURL @return string
[ "Generate", "Item", "uuid", "." ]
417468edaa2be0051ae041ee614ab609f0ac8b49
https://github.com/SocietyCMS/Menu/blob/417468edaa2be0051ae041ee614ab609f0ac8b49/Repositories/Menu/MenuRepository.php#L77-L89
5,829
DripsPHP/DataStructures
src/DataCollection.php
DataCollection.delete
public function delete($key) { if ($this->has($key)) { unset($this->collection[$key]); return true; } return false; }
php
public function delete($key) { if ($this->has($key)) { unset($this->collection[$key]); return true; } return false; }
[ "public", "function", "delete", "(", "$", "key", ")", "{", "if", "(", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "unset", "(", "$", "this", "->", "collection", "[", "$", "key", "]", ")", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Entfernt ein Element aus der Collection. @param $key @return bool
[ "Entfernt", "ein", "Element", "aus", "der", "Collection", "." ]
1daa5a654afe63f7bafa7c5104288d293e2e5aa0
https://github.com/DripsPHP/DataStructures/blob/1daa5a654afe63f7bafa7c5104288d293e2e5aa0/src/DataCollection.php#L88-L95
5,830
jumilla/laravel-source-generator
sources/OneFileGeneratorCommand.php
OneFileGeneratorCommand.generate
protected function generate(FileGenerator $generator) { $fqcn = $this->convertToFullQualifyClassName($this->getNameInput()); $path = $this->getRelativePath($fqcn).'.php'; if ($generator->exists($path)) { $this->error($this->type.' already exists!'); return false; } return $this->generateFile($generator, $path, $fqcn); }
php
protected function generate(FileGenerator $generator) { $fqcn = $this->convertToFullQualifyClassName($this->getNameInput()); $path = $this->getRelativePath($fqcn).'.php'; if ($generator->exists($path)) { $this->error($this->type.' already exists!'); return false; } return $this->generateFile($generator, $path, $fqcn); }
[ "protected", "function", "generate", "(", "FileGenerator", "$", "generator", ")", "{", "$", "fqcn", "=", "$", "this", "->", "convertToFullQualifyClassName", "(", "$", "this", "->", "getNameInput", "(", ")", ")", ";", "$", "path", "=", "$", "this", "->", "getRelativePath", "(", "$", "fqcn", ")", ".", "'.php'", ";", "if", "(", "$", "generator", "->", "exists", "(", "$", "path", ")", ")", "{", "$", "this", "->", "error", "(", "$", "this", "->", "type", ".", "' already exists!'", ")", ";", "return", "false", ";", "}", "return", "$", "this", "->", "generateFile", "(", "$", "generator", ",", "$", "path", ",", "$", "fqcn", ")", ";", "}" ]
Generate files. @return bool
[ "Generate", "files", "." ]
cb4757f636d68643a8ba2644527ffb9f6390750e
https://github.com/jumilla/laravel-source-generator/blob/cb4757f636d68643a8ba2644527ffb9f6390750e/sources/OneFileGeneratorCommand.php#L14-L27
5,831
onesimus-systems/oslogger
src/ErrorHandler.php
ErrorHandler.PHPErrorHandler
public function PHPErrorHandler($error_level, $error_message, $error_file, $error_line, $error_context) { $message = $error_message . ' | File: {file} | Ln: {line}'; $context = array( 'file' => $error_file, 'line' => $error_line ); switch ($error_level) { case E_USER_ERROR: // no break case E_RECOVERABLE_ERROR: $this->logger->error($message, $context); break; case E_WARNING: // no break case E_USER_WARNING: $this->logger->warning($message, $context); break; case E_NOTICE: // no break case E_USER_NOTICE: $this->logger->notice($message, $context); break; case E_STRICT: $this->logger->debug($message, $context); break; default: $this->logger->warning($message, $context); } return; }
php
public function PHPErrorHandler($error_level, $error_message, $error_file, $error_line, $error_context) { $message = $error_message . ' | File: {file} | Ln: {line}'; $context = array( 'file' => $error_file, 'line' => $error_line ); switch ($error_level) { case E_USER_ERROR: // no break case E_RECOVERABLE_ERROR: $this->logger->error($message, $context); break; case E_WARNING: // no break case E_USER_WARNING: $this->logger->warning($message, $context); break; case E_NOTICE: // no break case E_USER_NOTICE: $this->logger->notice($message, $context); break; case E_STRICT: $this->logger->debug($message, $context); break; default: $this->logger->warning($message, $context); } return; }
[ "public", "function", "PHPErrorHandler", "(", "$", "error_level", ",", "$", "error_message", ",", "$", "error_file", ",", "$", "error_line", ",", "$", "error_context", ")", "{", "$", "message", "=", "$", "error_message", ".", "' | File: {file} | Ln: {line}'", ";", "$", "context", "=", "array", "(", "'file'", "=>", "$", "error_file", ",", "'line'", "=>", "$", "error_line", ")", ";", "switch", "(", "$", "error_level", ")", "{", "case", "E_USER_ERROR", ":", "// no break", "case", "E_RECOVERABLE_ERROR", ":", "$", "this", "->", "logger", "->", "error", "(", "$", "message", ",", "$", "context", ")", ";", "break", ";", "case", "E_WARNING", ":", "// no break", "case", "E_USER_WARNING", ":", "$", "this", "->", "logger", "->", "warning", "(", "$", "message", ",", "$", "context", ")", ";", "break", ";", "case", "E_NOTICE", ":", "// no break", "case", "E_USER_NOTICE", ":", "$", "this", "->", "logger", "->", "notice", "(", "$", "message", ",", "$", "context", ")", ";", "break", ";", "case", "E_STRICT", ":", "$", "this", "->", "logger", "->", "debug", "(", "$", "message", ",", "$", "context", ")", ";", "break", ";", "default", ":", "$", "this", "->", "logger", "->", "warning", "(", "$", "message", ",", "$", "context", ")", ";", "}", "return", ";", "}" ]
Logger provided error handler
[ "Logger", "provided", "error", "handler" ]
98138d4fbcae83b9cedac13ab173a3f8273de3e0
https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/ErrorHandler.php#L56-L87
5,832
onesimus-systems/oslogger
src/ErrorHandler.php
ErrorHandler.PHPShutdownHandler
public function PHPShutdownHandler() { session_write_close(); if ($lasterror = error_get_last()) { $message = $lasterror['message'] . ' | File: {file} | Ln: {line}'; $context = array( 'file' => $lasterror['file'], 'line' => $lasterror['line'] ); $this->logger->log($this->shutdownLogLevel, $message, $context); } }
php
public function PHPShutdownHandler() { session_write_close(); if ($lasterror = error_get_last()) { $message = $lasterror['message'] . ' | File: {file} | Ln: {line}'; $context = array( 'file' => $lasterror['file'], 'line' => $lasterror['line'] ); $this->logger->log($this->shutdownLogLevel, $message, $context); } }
[ "public", "function", "PHPShutdownHandler", "(", ")", "{", "session_write_close", "(", ")", ";", "if", "(", "$", "lasterror", "=", "error_get_last", "(", ")", ")", "{", "$", "message", "=", "$", "lasterror", "[", "'message'", "]", ".", "' | File: {file} | Ln: {line}'", ";", "$", "context", "=", "array", "(", "'file'", "=>", "$", "lasterror", "[", "'file'", "]", ",", "'line'", "=>", "$", "lasterror", "[", "'line'", "]", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "$", "this", "->", "shutdownLogLevel", ",", "$", "message", ",", "$", "context", ")", ";", "}", "}" ]
Logger provided shutdown handler
[ "Logger", "provided", "shutdown", "handler" ]
98138d4fbcae83b9cedac13ab173a3f8273de3e0
https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/ErrorHandler.php#L92-L103
5,833
onesimus-systems/oslogger
src/ErrorHandler.php
ErrorHandler.PHPExceptionHandler
public function PHPExceptionHandler($exception) { session_write_close(); $message = $exception->getMessage() . ' | File: {file} | Ln: {line} | ST: {stacktrace}'; $context = array( 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'stacktrace' => $exception->getTraceAsString() ); $this->logger->log($this->exceptionLogLevel, $message, $context); }
php
public function PHPExceptionHandler($exception) { session_write_close(); $message = $exception->getMessage() . ' | File: {file} | Ln: {line} | ST: {stacktrace}'; $context = array( 'file' => $exception->getFile(), 'line' => $exception->getLine(), 'stacktrace' => $exception->getTraceAsString() ); $this->logger->log($this->exceptionLogLevel, $message, $context); }
[ "public", "function", "PHPExceptionHandler", "(", "$", "exception", ")", "{", "session_write_close", "(", ")", ";", "$", "message", "=", "$", "exception", "->", "getMessage", "(", ")", ".", "' | File: {file} | Ln: {line} | ST: {stacktrace}'", ";", "$", "context", "=", "array", "(", "'file'", "=>", "$", "exception", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "exception", "->", "getLine", "(", ")", ",", "'stacktrace'", "=>", "$", "exception", "->", "getTraceAsString", "(", ")", ")", ";", "$", "this", "->", "logger", "->", "log", "(", "$", "this", "->", "exceptionLogLevel", ",", "$", "message", ",", "$", "context", ")", ";", "}" ]
Logger provided uncaught Exception handler
[ "Logger", "provided", "uncaught", "Exception", "handler" ]
98138d4fbcae83b9cedac13ab173a3f8273de3e0
https://github.com/onesimus-systems/oslogger/blob/98138d4fbcae83b9cedac13ab173a3f8273de3e0/src/ErrorHandler.php#L108-L118
5,834
strident/Trident
src/Trident/Module/FrameworkModule/Console/Command/AssetsInstallCommand.php
AssetsInstallCommand.installAssets
private function installAssets(\TridentKernel $kernel, $name, $from, OutputInterface $output) { $output->write(sprintf('Installing assets for "%s"', $name)); $filesystem = new FileSystem(); if ( ! $filesystem->exists($from)) { // If there were no assets to install $output->writeln('... <comment>N/A</comment>'); return; } try { $filesystem->symlink($from, $kernel->getAssetDir().'/'.strtolower($name)); // If assets were found, and successfully installed: $output->writeln('... <info>Done</info>'); } catch(IOExceptionInterface $e) { // If there were any problems installing assets: $output->writeln('... <error>Error</error>'); } }
php
private function installAssets(\TridentKernel $kernel, $name, $from, OutputInterface $output) { $output->write(sprintf('Installing assets for "%s"', $name)); $filesystem = new FileSystem(); if ( ! $filesystem->exists($from)) { // If there were no assets to install $output->writeln('... <comment>N/A</comment>'); return; } try { $filesystem->symlink($from, $kernel->getAssetDir().'/'.strtolower($name)); // If assets were found, and successfully installed: $output->writeln('... <info>Done</info>'); } catch(IOExceptionInterface $e) { // If there were any problems installing assets: $output->writeln('... <error>Error</error>'); } }
[ "private", "function", "installAssets", "(", "\\", "TridentKernel", "$", "kernel", ",", "$", "name", ",", "$", "from", ",", "OutputInterface", "$", "output", ")", "{", "$", "output", "->", "write", "(", "sprintf", "(", "'Installing assets for \"%s\"'", ",", "$", "name", ")", ")", ";", "$", "filesystem", "=", "new", "FileSystem", "(", ")", ";", "if", "(", "!", "$", "filesystem", "->", "exists", "(", "$", "from", ")", ")", "{", "// If there were no assets to install", "$", "output", "->", "writeln", "(", "'... <comment>N/A</comment>'", ")", ";", "return", ";", "}", "try", "{", "$", "filesystem", "->", "symlink", "(", "$", "from", ",", "$", "kernel", "->", "getAssetDir", "(", ")", ".", "'/'", ".", "strtolower", "(", "$", "name", ")", ")", ";", "// If assets were found, and successfully installed:", "$", "output", "->", "writeln", "(", "'... <info>Done</info>'", ")", ";", "}", "catch", "(", "IOExceptionInterface", "$", "e", ")", "{", "// If there were any problems installing assets:", "$", "output", "->", "writeln", "(", "'... <error>Error</error>'", ")", ";", "}", "}" ]
Install assets from on directory to another. @param \TridentKernel $kernel @param string $name @param string $from @param OutputInterface $output
[ "Install", "assets", "from", "on", "directory", "to", "another", "." ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Module/FrameworkModule/Console/Command/AssetsInstallCommand.php#L83-L104
5,835
strident/Trident
src/Trident/Module/FrameworkModule/Console/Command/AssetsInstallCommand.php
AssetsInstallCommand.flushAssets
private function flushAssets(\TridentKernel $kernel, OutputInterface $output) { $filesystem = new FileSystem(); $output->write('Clearing existing assets'); try { if ($filesystem->exists($kernel->getAssetDir())) { $filesystem->remove($kernel->getAssetDir()); } $output->writeln('... <info>Done</info>'); $output->writeln(''); return true; } catch (\Exception $e) { $output->writeln('... <error>Error</error>'); $output->writeln(''); return false; } }
php
private function flushAssets(\TridentKernel $kernel, OutputInterface $output) { $filesystem = new FileSystem(); $output->write('Clearing existing assets'); try { if ($filesystem->exists($kernel->getAssetDir())) { $filesystem->remove($kernel->getAssetDir()); } $output->writeln('... <info>Done</info>'); $output->writeln(''); return true; } catch (\Exception $e) { $output->writeln('... <error>Error</error>'); $output->writeln(''); return false; } }
[ "private", "function", "flushAssets", "(", "\\", "TridentKernel", "$", "kernel", ",", "OutputInterface", "$", "output", ")", "{", "$", "filesystem", "=", "new", "FileSystem", "(", ")", ";", "$", "output", "->", "write", "(", "'Clearing existing assets'", ")", ";", "try", "{", "if", "(", "$", "filesystem", "->", "exists", "(", "$", "kernel", "->", "getAssetDir", "(", ")", ")", ")", "{", "$", "filesystem", "->", "remove", "(", "$", "kernel", "->", "getAssetDir", "(", ")", ")", ";", "}", "$", "output", "->", "writeln", "(", "'... <info>Done</info>'", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "return", "true", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "output", "->", "writeln", "(", "'... <error>Error</error>'", ")", ";", "$", "output", "->", "writeln", "(", "''", ")", ";", "return", "false", ";", "}", "}" ]
Flush all existing assets @param TridentKernel $kernel @param OutputInterface $output @return boolean
[ "Flush", "all", "existing", "assets" ]
a112f0b75601b897c470a49d85791dc386c29952
https://github.com/strident/Trident/blob/a112f0b75601b897c470a49d85791dc386c29952/src/Trident/Module/FrameworkModule/Console/Command/AssetsInstallCommand.php#L114-L135
5,836
joomla-framework/mediawiki-api
src/Users.php
Users.login
public function login($lgname, $lgpassword, $lgdomain = null) { // Build the request path. $path = '?action=login&lgname=' . $lgname . '&lgpassword=' . $lgpassword; if (isset($lgdomain)) { $path .= '&lgdomain=' . $lgdomain; } // Send the request. $response = $this->client->post($this->fetchUrl($path), null); // Request path with login token. $path = '?action=login&lgname=' . $lgname . '&lgpassword=' . $lgpassword . '&lgtoken=' . $this->validateResponse($response)->login['token']; if (isset($lgdomain)) { $path .= '&lgdomain=' . $lgdomain; } // Set the session cookies returned. $headers = (array) $this->options->get('headers'); $headers['Cookie'] = !empty($headers['Cookie']) ? empty($headers['Cookie']) : ''; $headers['Cookie'] = $headers['Cookie'] . $response->headers['Set-Cookie']; $this->options->set('headers', $headers); // Send the request again with the token. $response = $this->client->post($this->fetchUrl($path), null); $responseBody = $this->validateResponse($response); $headers = (array) $this->options->get('headers'); $cookiePrefix = $responseBody->login['cookieprefix']; $cookie = $cookiePrefix . 'UserID=' . $responseBody->login['lguserid'] . '; ' . $cookiePrefix . 'UserName=' . $responseBody->login['lgusername']; $headers['Cookie'] = $headers['Cookie'] . '; ' . $response->headers['Set-Cookie'] . '; ' . $cookie; $this->options->set('headers', $headers); return $this->validateResponse($response); }
php
public function login($lgname, $lgpassword, $lgdomain = null) { // Build the request path. $path = '?action=login&lgname=' . $lgname . '&lgpassword=' . $lgpassword; if (isset($lgdomain)) { $path .= '&lgdomain=' . $lgdomain; } // Send the request. $response = $this->client->post($this->fetchUrl($path), null); // Request path with login token. $path = '?action=login&lgname=' . $lgname . '&lgpassword=' . $lgpassword . '&lgtoken=' . $this->validateResponse($response)->login['token']; if (isset($lgdomain)) { $path .= '&lgdomain=' . $lgdomain; } // Set the session cookies returned. $headers = (array) $this->options->get('headers'); $headers['Cookie'] = !empty($headers['Cookie']) ? empty($headers['Cookie']) : ''; $headers['Cookie'] = $headers['Cookie'] . $response->headers['Set-Cookie']; $this->options->set('headers', $headers); // Send the request again with the token. $response = $this->client->post($this->fetchUrl($path), null); $responseBody = $this->validateResponse($response); $headers = (array) $this->options->get('headers'); $cookiePrefix = $responseBody->login['cookieprefix']; $cookie = $cookiePrefix . 'UserID=' . $responseBody->login['lguserid'] . '; ' . $cookiePrefix . 'UserName=' . $responseBody->login['lgusername']; $headers['Cookie'] = $headers['Cookie'] . '; ' . $response->headers['Set-Cookie'] . '; ' . $cookie; $this->options->set('headers', $headers); return $this->validateResponse($response); }
[ "public", "function", "login", "(", "$", "lgname", ",", "$", "lgpassword", ",", "$", "lgdomain", "=", "null", ")", "{", "// Build the request path.", "$", "path", "=", "'?action=login&lgname='", ".", "$", "lgname", ".", "'&lgpassword='", ".", "$", "lgpassword", ";", "if", "(", "isset", "(", "$", "lgdomain", ")", ")", "{", "$", "path", ".=", "'&lgdomain='", ".", "$", "lgdomain", ";", "}", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "null", ")", ";", "// Request path with login token.", "$", "path", "=", "'?action=login&lgname='", ".", "$", "lgname", ".", "'&lgpassword='", ".", "$", "lgpassword", ".", "'&lgtoken='", ".", "$", "this", "->", "validateResponse", "(", "$", "response", ")", "->", "login", "[", "'token'", "]", ";", "if", "(", "isset", "(", "$", "lgdomain", ")", ")", "{", "$", "path", ".=", "'&lgdomain='", ".", "$", "lgdomain", ";", "}", "// Set the session cookies returned.", "$", "headers", "=", "(", "array", ")", "$", "this", "->", "options", "->", "get", "(", "'headers'", ")", ";", "$", "headers", "[", "'Cookie'", "]", "=", "!", "empty", "(", "$", "headers", "[", "'Cookie'", "]", ")", "?", "empty", "(", "$", "headers", "[", "'Cookie'", "]", ")", ":", "''", ";", "$", "headers", "[", "'Cookie'", "]", "=", "$", "headers", "[", "'Cookie'", "]", ".", "$", "response", "->", "headers", "[", "'Set-Cookie'", "]", ";", "$", "this", "->", "options", "->", "set", "(", "'headers'", ",", "$", "headers", ")", ";", "// Send the request again with the token.", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "null", ")", ";", "$", "responseBody", "=", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "$", "headers", "=", "(", "array", ")", "$", "this", "->", "options", "->", "get", "(", "'headers'", ")", ";", "$", "cookiePrefix", "=", "$", "responseBody", "->", "login", "[", "'cookieprefix'", "]", ";", "$", "cookie", "=", "$", "cookiePrefix", ".", "'UserID='", ".", "$", "responseBody", "->", "login", "[", "'lguserid'", "]", ".", "'; '", ".", "$", "cookiePrefix", ".", "'UserName='", ".", "$", "responseBody", "->", "login", "[", "'lgusername'", "]", ";", "$", "headers", "[", "'Cookie'", "]", "=", "$", "headers", "[", "'Cookie'", "]", ".", "'; '", ".", "$", "response", "->", "headers", "[", "'Set-Cookie'", "]", ".", "'; '", ".", "$", "cookie", ";", "$", "this", "->", "options", "->", "set", "(", "'headers'", ",", "$", "headers", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to login and get authentication tokens. @param string $lgname User Name. @param string $lgpassword Password. @param string $lgdomain Domain (optional). @return object @since 1.0
[ "Method", "to", "login", "and", "get", "authentication", "tokens", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L29-L68
5,837
joomla-framework/mediawiki-api
src/Users.php
Users.logout
public function logout() { // Build the request path. $path = '?action=login'; // @todo clear internal data as well // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
php
public function logout() { // Build the request path. $path = '?action=login'; // @todo clear internal data as well // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
[ "public", "function", "logout", "(", ")", "{", "// Build the request path.", "$", "path", "=", "'?action=login'", ";", "// @todo clear internal data as well", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to logout and clear session data. @return object @since 1.0
[ "Method", "to", "logout", "and", "clear", "session", "data", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L77-L88
5,838
joomla-framework/mediawiki-api
src/Users.php
Users.getUserInfo
public function getUserInfo(array $ususers, array $usprop = null) { // Build the request path. $path = '?action=query&list=users'; // Append users to the request. $path .= '&ususers=' . $this->buildParameter($ususers); if (isset($usprop)) { $path .= '&usprop' . $this->buildParameter($usprop); } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
php
public function getUserInfo(array $ususers, array $usprop = null) { // Build the request path. $path = '?action=query&list=users'; // Append users to the request. $path .= '&ususers=' . $this->buildParameter($ususers); if (isset($usprop)) { $path .= '&usprop' . $this->buildParameter($usprop); } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
[ "public", "function", "getUserInfo", "(", "array", "$", "ususers", ",", "array", "$", "usprop", "=", "null", ")", "{", "// Build the request path.", "$", "path", "=", "'?action=query&list=users'", ";", "// Append users to the request.", "$", "path", ".=", "'&ususers='", ".", "$", "this", "->", "buildParameter", "(", "$", "ususers", ")", ";", "if", "(", "isset", "(", "$", "usprop", ")", ")", "{", "$", "path", ".=", "'&usprop'", ".", "$", "this", "->", "buildParameter", "(", "$", "usprop", ")", ";", "}", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to get user information. @param array $ususers A list of users to obtain the same information for. @param array $usprop What pieces of information to include. @return object @since 1.0
[ "Method", "to", "get", "user", "information", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L100-L117
5,839
joomla-framework/mediawiki-api
src/Users.php
Users.getCurrentUserInfo
public function getCurrentUserInfo(array $uiprop = null) { // Build the request path. $path = '?action=query&meta=userinfo'; if (isset($uiprop)) { $path .= '&uiprop' . $this->buildParameter($uiprop); } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
php
public function getCurrentUserInfo(array $uiprop = null) { // Build the request path. $path = '?action=query&meta=userinfo'; if (isset($uiprop)) { $path .= '&uiprop' . $this->buildParameter($uiprop); } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
[ "public", "function", "getCurrentUserInfo", "(", "array", "$", "uiprop", "=", "null", ")", "{", "// Build the request path.", "$", "path", "=", "'?action=query&meta=userinfo'", ";", "if", "(", "isset", "(", "$", "uiprop", ")", ")", "{", "$", "path", ".=", "'&uiprop'", ".", "$", "this", "->", "buildParameter", "(", "$", "uiprop", ")", ";", "}", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to get current user information. @param array $uiprop What pieces of information to include. @return object @since 1.0
[ "Method", "to", "get", "current", "user", "information", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L128-L142
5,840
joomla-framework/mediawiki-api
src/Users.php
Users.getUserContribs
public function getUserContribs($ucuser = null, $ucuserprefix = null, $uclimit = null, $ucstart = null, $ucend = null, $uccontinue = null, $ucdir = null, array $ucnamespace = null, array $ucprop = null, array $ucshow = null, $uctag = null, $uctoponly = null ) { // Build the request path. $path = '?action=query&list=usercontribs'; if (isset($ucuser)) { $path .= '&ucuser=' . $ucuser; } if (isset($ucuserprefix)) { $path .= '&ucuserprefix=' . $ucuserprefix; } if (isset($uclimit)) { $path .= '&uclimit=' . $uclimit; } if (isset($ucstart)) { $path .= '&ucstart=' . $ucstart; } if (isset($ucend)) { $path .= '&ucend=' . $ucend; } if ($uccontinue) { $path .= '&uccontinue='; } if (isset($ucdir)) { $path .= '&ucdir=' . $ucdir; } if (isset($ucnamespace)) { $path .= '&ucnamespace=' . $this->buildParameter($ucnamespace); } if (isset($ucprop)) { $path .= '&ucprop=' . $this->buildParameter($ucprop); } if (isset($ucshow)) { $path .= '&ucshow=' . $this->buildParameter($ucshow); } if (isset($uctag)) { $path .= '&uctag=' . $uctag; } if (isset($uctoponly)) { $path .= '&uctoponly=' . $uctoponly; } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
php
public function getUserContribs($ucuser = null, $ucuserprefix = null, $uclimit = null, $ucstart = null, $ucend = null, $uccontinue = null, $ucdir = null, array $ucnamespace = null, array $ucprop = null, array $ucshow = null, $uctag = null, $uctoponly = null ) { // Build the request path. $path = '?action=query&list=usercontribs'; if (isset($ucuser)) { $path .= '&ucuser=' . $ucuser; } if (isset($ucuserprefix)) { $path .= '&ucuserprefix=' . $ucuserprefix; } if (isset($uclimit)) { $path .= '&uclimit=' . $uclimit; } if (isset($ucstart)) { $path .= '&ucstart=' . $ucstart; } if (isset($ucend)) { $path .= '&ucend=' . $ucend; } if ($uccontinue) { $path .= '&uccontinue='; } if (isset($ucdir)) { $path .= '&ucdir=' . $ucdir; } if (isset($ucnamespace)) { $path .= '&ucnamespace=' . $this->buildParameter($ucnamespace); } if (isset($ucprop)) { $path .= '&ucprop=' . $this->buildParameter($ucprop); } if (isset($ucshow)) { $path .= '&ucshow=' . $this->buildParameter($ucshow); } if (isset($uctag)) { $path .= '&uctag=' . $uctag; } if (isset($uctoponly)) { $path .= '&uctoponly=' . $uctoponly; } // Send the request. $response = $this->client->get($this->fetchUrl($path)); return $this->validateResponse($response); }
[ "public", "function", "getUserContribs", "(", "$", "ucuser", "=", "null", ",", "$", "ucuserprefix", "=", "null", ",", "$", "uclimit", "=", "null", ",", "$", "ucstart", "=", "null", ",", "$", "ucend", "=", "null", ",", "$", "uccontinue", "=", "null", ",", "$", "ucdir", "=", "null", ",", "array", "$", "ucnamespace", "=", "null", ",", "array", "$", "ucprop", "=", "null", ",", "array", "$", "ucshow", "=", "null", ",", "$", "uctag", "=", "null", ",", "$", "uctoponly", "=", "null", ")", "{", "// Build the request path.", "$", "path", "=", "'?action=query&list=usercontribs'", ";", "if", "(", "isset", "(", "$", "ucuser", ")", ")", "{", "$", "path", ".=", "'&ucuser='", ".", "$", "ucuser", ";", "}", "if", "(", "isset", "(", "$", "ucuserprefix", ")", ")", "{", "$", "path", ".=", "'&ucuserprefix='", ".", "$", "ucuserprefix", ";", "}", "if", "(", "isset", "(", "$", "uclimit", ")", ")", "{", "$", "path", ".=", "'&uclimit='", ".", "$", "uclimit", ";", "}", "if", "(", "isset", "(", "$", "ucstart", ")", ")", "{", "$", "path", ".=", "'&ucstart='", ".", "$", "ucstart", ";", "}", "if", "(", "isset", "(", "$", "ucend", ")", ")", "{", "$", "path", ".=", "'&ucend='", ".", "$", "ucend", ";", "}", "if", "(", "$", "uccontinue", ")", "{", "$", "path", ".=", "'&uccontinue='", ";", "}", "if", "(", "isset", "(", "$", "ucdir", ")", ")", "{", "$", "path", ".=", "'&ucdir='", ".", "$", "ucdir", ";", "}", "if", "(", "isset", "(", "$", "ucnamespace", ")", ")", "{", "$", "path", ".=", "'&ucnamespace='", ".", "$", "this", "->", "buildParameter", "(", "$", "ucnamespace", ")", ";", "}", "if", "(", "isset", "(", "$", "ucprop", ")", ")", "{", "$", "path", ".=", "'&ucprop='", ".", "$", "this", "->", "buildParameter", "(", "$", "ucprop", ")", ";", "}", "if", "(", "isset", "(", "$", "ucshow", ")", ")", "{", "$", "path", ".=", "'&ucshow='", ".", "$", "this", "->", "buildParameter", "(", "$", "ucshow", ")", ";", "}", "if", "(", "isset", "(", "$", "uctag", ")", ")", "{", "$", "path", ".=", "'&uctag='", ".", "$", "uctag", ";", "}", "if", "(", "isset", "(", "$", "uctoponly", ")", ")", "{", "$", "path", ".=", "'&uctoponly='", ".", "$", "uctoponly", ";", "}", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "get", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to get user contributions. @param string $ucuser The users to retrieve contributions for. @param string $ucuserprefix Retrieve contibutions for all users whose names begin with this value. @param integer $uclimit The users to retrieve contributions for. @param string $ucstart The start timestamp to return from. @param string $ucend The end timestamp to return to. @param boolean $uccontinue When more results are available, use this to continue. @param string $ucdir In which direction to enumerate. @param array $ucnamespace Only list contributions in these namespaces. @param array $ucprop Include additional pieces of information. @param array $ucshow Show only items that meet this criteria. @param string $uctag Only list revisions tagged with this tag. @param string $uctoponly Only list changes which are the latest revision @return object @since 1.0
[ "Method", "to", "get", "user", "contributions", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L164-L235
5,841
joomla-framework/mediawiki-api
src/Users.php
Users.blockUser
public function blockUser($user, $expiry = null, $reason = null, $anononly = null, $nocreate = null, $autoblock = null, $noemail = null, $hidename = null, $allowusertalk = null, $reblock = null, $watchuser = null ) { // Get the token. $token = $this->getToken($user, 'block'); // Build the request path. $path = '?action=unblock'; // Build the request data. $data = array( 'user' => $user, 'token' => $token, 'expiry' => $expiry, 'reason' => $reason, 'anononly' => $anononly, 'nocreate' => $nocreate, 'autoblock' => $autoblock, 'noemail' => $noemail, 'hidename' => $hidename, 'allowusetalk' => $allowusertalk, 'reblock' => $reblock, 'watchuser' => $watchuser, ); // Send the request. $response = $this->client->post($this->fetchUrl($path), $data); return $this->validateResponse($response); }
php
public function blockUser($user, $expiry = null, $reason = null, $anononly = null, $nocreate = null, $autoblock = null, $noemail = null, $hidename = null, $allowusertalk = null, $reblock = null, $watchuser = null ) { // Get the token. $token = $this->getToken($user, 'block'); // Build the request path. $path = '?action=unblock'; // Build the request data. $data = array( 'user' => $user, 'token' => $token, 'expiry' => $expiry, 'reason' => $reason, 'anononly' => $anononly, 'nocreate' => $nocreate, 'autoblock' => $autoblock, 'noemail' => $noemail, 'hidename' => $hidename, 'allowusetalk' => $allowusertalk, 'reblock' => $reblock, 'watchuser' => $watchuser, ); // Send the request. $response = $this->client->post($this->fetchUrl($path), $data); return $this->validateResponse($response); }
[ "public", "function", "blockUser", "(", "$", "user", ",", "$", "expiry", "=", "null", ",", "$", "reason", "=", "null", ",", "$", "anononly", "=", "null", ",", "$", "nocreate", "=", "null", ",", "$", "autoblock", "=", "null", ",", "$", "noemail", "=", "null", ",", "$", "hidename", "=", "null", ",", "$", "allowusertalk", "=", "null", ",", "$", "reblock", "=", "null", ",", "$", "watchuser", "=", "null", ")", "{", "// Get the token.", "$", "token", "=", "$", "this", "->", "getToken", "(", "$", "user", ",", "'block'", ")", ";", "// Build the request path.", "$", "path", "=", "'?action=unblock'", ";", "// Build the request data.", "$", "data", "=", "array", "(", "'user'", "=>", "$", "user", ",", "'token'", "=>", "$", "token", ",", "'expiry'", "=>", "$", "expiry", ",", "'reason'", "=>", "$", "reason", ",", "'anononly'", "=>", "$", "anononly", ",", "'nocreate'", "=>", "$", "nocreate", ",", "'autoblock'", "=>", "$", "autoblock", ",", "'noemail'", "=>", "$", "noemail", ",", "'hidename'", "=>", "$", "hidename", ",", "'allowusetalk'", "=>", "$", "allowusertalk", ",", "'reblock'", "=>", "$", "reblock", ",", "'watchuser'", "=>", "$", "watchuser", ",", ")", ";", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "$", "data", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to block a user. @param string $user Username, IP address or IP range you want to block. @param string $expiry Relative expiry time, Default: never. @param string $reason Reason for block (optional). @param boolean $anononly Block anonymous users only. @param boolean $nocreate Prevent account creation. @param boolean $autoblock Automatically block the last used IP address, and any subsequent IP addresses they try to login from. @param boolean $noemail Prevent user from sending e-mail through the wiki. @param boolean $hidename Hide the username from the block log. @param boolean $allowusertalk Allow the user to edit their own talk page. @param boolean $reblock If the user is already blocked, overwrite the existing block. @param boolean $watchuser Watch the user/IP's user and talk pages. @return object @since 1.0
[ "Method", "to", "block", "a", "user", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L256-L286
5,842
joomla-framework/mediawiki-api
src/Users.php
Users.assignGroup
public function assignGroup($username, $add = null, $remove = null, $reason = null) { // Get the token. $token = $this->getToken($username, 'unblock'); // Build the request path. $path = '?action=userrights'; // Build the request data. $data = array( 'username' => $username, 'token' => $token, 'add' => $add, 'remove' => $remove, 'reason' => $reason, ); // Send the request. $response = $this->client->post($this->fetchUrl($path), $data); return $this->validateResponse($response); }
php
public function assignGroup($username, $add = null, $remove = null, $reason = null) { // Get the token. $token = $this->getToken($username, 'unblock'); // Build the request path. $path = '?action=userrights'; // Build the request data. $data = array( 'username' => $username, 'token' => $token, 'add' => $add, 'remove' => $remove, 'reason' => $reason, ); // Send the request. $response = $this->client->post($this->fetchUrl($path), $data); return $this->validateResponse($response); }
[ "public", "function", "assignGroup", "(", "$", "username", ",", "$", "add", "=", "null", ",", "$", "remove", "=", "null", ",", "$", "reason", "=", "null", ")", "{", "// Get the token.", "$", "token", "=", "$", "this", "->", "getToken", "(", "$", "username", ",", "'unblock'", ")", ";", "// Build the request path.", "$", "path", "=", "'?action=userrights'", ";", "// Build the request data.", "$", "data", "=", "array", "(", "'username'", "=>", "$", "username", ",", "'token'", "=>", "$", "token", ",", "'add'", "=>", "$", "add", ",", "'remove'", "=>", "$", "remove", ",", "'reason'", "=>", "$", "reason", ",", ")", ";", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "$", "data", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to assign a user to a group. @param string $username User name. @param array $add Add the user to these groups. @param array $remove Remove the user from these groups. @param string $reason Reason for the change. @return object @since 1.0
[ "Method", "to", "assign", "a", "user", "to", "a", "group", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L363-L384
5,843
joomla-framework/mediawiki-api
src/Users.php
Users.emailUser
public function emailUser($target, $subject = null, $text = null, $ccme = null) { // Get the token. $token = $this->getToken($target, 'emailuser'); // Build the request path. $path = '?action=emailuser'; // Build the request data. $data = array( 'target' => $target, 'token' => $token, 'subject' => $subject, 'text' => $text, 'ccme' => $ccme, ); // Send the request. $response = $this->client->post($this->fetchUrl($path), $data); return $this->validateResponse($response); }
php
public function emailUser($target, $subject = null, $text = null, $ccme = null) { // Get the token. $token = $this->getToken($target, 'emailuser'); // Build the request path. $path = '?action=emailuser'; // Build the request data. $data = array( 'target' => $target, 'token' => $token, 'subject' => $subject, 'text' => $text, 'ccme' => $ccme, ); // Send the request. $response = $this->client->post($this->fetchUrl($path), $data); return $this->validateResponse($response); }
[ "public", "function", "emailUser", "(", "$", "target", ",", "$", "subject", "=", "null", ",", "$", "text", "=", "null", ",", "$", "ccme", "=", "null", ")", "{", "// Get the token.", "$", "token", "=", "$", "this", "->", "getToken", "(", "$", "target", ",", "'emailuser'", ")", ";", "// Build the request path.", "$", "path", "=", "'?action=emailuser'", ";", "// Build the request data.", "$", "data", "=", "array", "(", "'target'", "=>", "$", "target", ",", "'token'", "=>", "$", "token", ",", "'subject'", "=>", "$", "subject", ",", "'text'", "=>", "$", "text", ",", "'ccme'", "=>", "$", "ccme", ",", ")", ";", "// Send the request.", "$", "response", "=", "$", "this", "->", "client", "->", "post", "(", "$", "this", "->", "fetchUrl", "(", "$", "path", ")", ",", "$", "data", ")", ";", "return", "$", "this", "->", "validateResponse", "(", "$", "response", ")", ";", "}" ]
Method to email a user. @param string $target User to send email to. @param string $subject Subject header. @param string $text Mail body. @param boolean $ccme Send a copy of this mail to me. @return object @since 1.0
[ "Method", "to", "email", "a", "user", "." ]
8855d51b61d5518bd92a0806fbd3098f4e063619
https://github.com/joomla-framework/mediawiki-api/blob/8855d51b61d5518bd92a0806fbd3098f4e063619/src/Users.php#L398-L419
5,844
nourdine/regular
src/regular/Match.php
Match.getCaptured
public function getCaptured($i) { if ($this->success) { if ($i >= 0) { $i++; // Captured groups starts from index 1. Index 0 is the whole match! if (array_key_exists($i, $this->matches)) { return new Group($this->matches[$i]); } else { throw new RuntimeException("The index " . $i . " does not identify any captured subpattern"); } } else { throw new RuntimeException("Negative indexes are not allowed"); } } else { throw new RuntimeException("The matching was not succesfull"); } }
php
public function getCaptured($i) { if ($this->success) { if ($i >= 0) { $i++; // Captured groups starts from index 1. Index 0 is the whole match! if (array_key_exists($i, $this->matches)) { return new Group($this->matches[$i]); } else { throw new RuntimeException("The index " . $i . " does not identify any captured subpattern"); } } else { throw new RuntimeException("Negative indexes are not allowed"); } } else { throw new RuntimeException("The matching was not succesfull"); } }
[ "public", "function", "getCaptured", "(", "$", "i", ")", "{", "if", "(", "$", "this", "->", "success", ")", "{", "if", "(", "$", "i", ">=", "0", ")", "{", "$", "i", "++", ";", "// Captured groups starts from index 1. Index 0 is the whole match! ", "if", "(", "array_key_exists", "(", "$", "i", ",", "$", "this", "->", "matches", ")", ")", "{", "return", "new", "Group", "(", "$", "this", "->", "matches", "[", "$", "i", "]", ")", ";", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"The index \"", ".", "$", "i", ".", "\" does not identify any captured subpattern\"", ")", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"Negative indexes are not allowed\"", ")", ";", "}", "}", "else", "{", "throw", "new", "RuntimeException", "(", "\"The matching was not succesfull\"", ")", ";", "}", "}" ]
Return a captured group. @param integer $i Index of the wanted captured subgroup @return Group @throws RuntimeException
[ "Return", "a", "captured", "group", "." ]
4bf599fb8dceb7ce259f1f5b0003f5f550e2e3f3
https://github.com/nourdine/regular/blob/4bf599fb8dceb7ce259f1f5b0003f5f550e2e3f3/src/regular/Match.php#L61-L76
5,845
bishopb/vanilla
applications/dashboard/models/class.exportmodel.php
ExportModel.BeginExport
public function BeginExport($Path, $Source = '') { $this->BeginTime = microtime(TRUE); $TimeStart = list($sm, $ss) = explode(' ', microtime()); if($this->UseCompression && function_exists('gzopen')) $fp = gzopen($Path, 'wb'); else $fp = fopen($Path, 'wb'); $this->_File = $fp; fwrite($fp, 'Vanilla Export: '.$this->Version()); if($Source) fwrite($fp, self::DELIM.' Source: '.$Source); fwrite($fp, self::NEWLINE.self::NEWLINE); $this->Comment('Exported Started: '.date('Y-m-d H:i:s')); }
php
public function BeginExport($Path, $Source = '') { $this->BeginTime = microtime(TRUE); $TimeStart = list($sm, $ss) = explode(' ', microtime()); if($this->UseCompression && function_exists('gzopen')) $fp = gzopen($Path, 'wb'); else $fp = fopen($Path, 'wb'); $this->_File = $fp; fwrite($fp, 'Vanilla Export: '.$this->Version()); if($Source) fwrite($fp, self::DELIM.' Source: '.$Source); fwrite($fp, self::NEWLINE.self::NEWLINE); $this->Comment('Exported Started: '.date('Y-m-d H:i:s')); }
[ "public", "function", "BeginExport", "(", "$", "Path", ",", "$", "Source", "=", "''", ")", "{", "$", "this", "->", "BeginTime", "=", "microtime", "(", "TRUE", ")", ";", "$", "TimeStart", "=", "list", "(", "$", "sm", ",", "$", "ss", ")", "=", "explode", "(", "' '", ",", "microtime", "(", ")", ")", ";", "if", "(", "$", "this", "->", "UseCompression", "&&", "function_exists", "(", "'gzopen'", ")", ")", "$", "fp", "=", "gzopen", "(", "$", "Path", ",", "'wb'", ")", ";", "else", "$", "fp", "=", "fopen", "(", "$", "Path", ",", "'wb'", ")", ";", "$", "this", "->", "_File", "=", "$", "fp", ";", "fwrite", "(", "$", "fp", ",", "'Vanilla Export: '", ".", "$", "this", "->", "Version", "(", ")", ")", ";", "if", "(", "$", "Source", ")", "fwrite", "(", "$", "fp", ",", "self", "::", "DELIM", ".", "' Source: '", ".", "$", "Source", ")", ";", "fwrite", "(", "$", "fp", ",", "self", "::", "NEWLINE", ".", "self", "::", "NEWLINE", ")", ";", "$", "this", "->", "Comment", "(", "'Exported Started: '", ".", "date", "(", "'Y-m-d H:i:s'", ")", ")", ";", "}" ]
Create the export file and begin the export. @param string $Path The path to the export file. @param string $Source The source program that created the export. This may be used by the import routine to do additional processing.
[ "Create", "the", "export", "file", "and", "begin", "the", "export", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.exportmodel.php#L28-L43
5,846
bishopb/vanilla
applications/dashboard/models/class.exportmodel.php
ExportModel.Comment
public function Comment($Message, $Echo = TRUE) { fwrite($this->_File, self::COMMENT.' '.str_replace(self::NEWLINE, self::NEWLINE.self::COMMENT.' ', $Message).self::NEWLINE); if($Echo) echo $Message, "\n"; }
php
public function Comment($Message, $Echo = TRUE) { fwrite($this->_File, self::COMMENT.' '.str_replace(self::NEWLINE, self::NEWLINE.self::COMMENT.' ', $Message).self::NEWLINE); if($Echo) echo $Message, "\n"; }
[ "public", "function", "Comment", "(", "$", "Message", ",", "$", "Echo", "=", "TRUE", ")", "{", "fwrite", "(", "$", "this", "->", "_File", ",", "self", "::", "COMMENT", ".", "' '", ".", "str_replace", "(", "self", "::", "NEWLINE", ",", "self", "::", "NEWLINE", ".", "self", "::", "COMMENT", ".", "' '", ",", "$", "Message", ")", ".", "self", "::", "NEWLINE", ")", ";", "if", "(", "$", "Echo", ")", "echo", "$", "Message", ",", "\"\\n\"", ";", "}" ]
Write a comment to the export file. @param string $Message The message to write. @param bool $Echo Whether or not to echo the message in addition to writing it to the file.
[ "Write", "a", "comment", "to", "the", "export", "file", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.exportmodel.php#L50-L54
5,847
bishopb/vanilla
applications/dashboard/models/class.exportmodel.php
ExportModel.PDO
public function PDO($DsnOrPDO = NULL, $Username = NULL, $Password = NULL) { if(!is_null($DsnOrPDO)) { if($DsnOrPDO instanceof PDO) $this->_PDO = $DsnOrPDO; else { $this->_PDO = new PDO($DsnOrPDO, $Username, $Password); if(strncasecmp($DsnOrPDO, 'mysql', 5) == 0) $this->_PDO->exec('set names utf8'); } } return $this->_PDO; }
php
public function PDO($DsnOrPDO = NULL, $Username = NULL, $Password = NULL) { if(!is_null($DsnOrPDO)) { if($DsnOrPDO instanceof PDO) $this->_PDO = $DsnOrPDO; else { $this->_PDO = new PDO($DsnOrPDO, $Username, $Password); if(strncasecmp($DsnOrPDO, 'mysql', 5) == 0) $this->_PDO->exec('set names utf8'); } } return $this->_PDO; }
[ "public", "function", "PDO", "(", "$", "DsnOrPDO", "=", "NULL", ",", "$", "Username", "=", "NULL", ",", "$", "Password", "=", "NULL", ")", "{", "if", "(", "!", "is_null", "(", "$", "DsnOrPDO", ")", ")", "{", "if", "(", "$", "DsnOrPDO", "instanceof", "PDO", ")", "$", "this", "->", "_PDO", "=", "$", "DsnOrPDO", ";", "else", "{", "$", "this", "->", "_PDO", "=", "new", "PDO", "(", "$", "DsnOrPDO", ",", "$", "Username", ",", "$", "Password", ")", ";", "if", "(", "strncasecmp", "(", "$", "DsnOrPDO", ",", "'mysql'", ",", "5", ")", "==", "0", ")", "$", "this", "->", "_PDO", "->", "exec", "(", "'set names utf8'", ")", ";", "}", "}", "return", "$", "this", "->", "_PDO", ";", "}" ]
Gets or sets the PDO connection to the database. @param mixed $DsnOrPDO One of the following: - <b>String</b>: The dsn to the database. - <b>PDO</b>: An existing connection to the database. - <b>Null</b>: The PDO connection will not be set. @param string $Username The username for the database if a dsn is specified. @param string $Password The password for the database if a dsn is specified. @return PDO The current database connection.
[ "Gets", "or", "sets", "the", "PDO", "connection", "to", "the", "database", "." ]
8494eb4a4ad61603479015a8054d23ff488364e8
https://github.com/bishopb/vanilla/blob/8494eb4a4ad61603479015a8054d23ff488364e8/applications/dashboard/models/class.exportmodel.php#L86-L97
5,848
matryoshka-model/mongo-wrapper
library/Criteria/Isolated/DocumentStore.php
DocumentStore.has
public function has(MongoCollection $dataGateway, $id) { $id = (string) $id; if (!$this->splObjectStorage->contains($dataGateway)) { return false; } if (isset($this->splObjectStorage[$dataGateway][$id])) { return true; } return false; }
php
public function has(MongoCollection $dataGateway, $id) { $id = (string) $id; if (!$this->splObjectStorage->contains($dataGateway)) { return false; } if (isset($this->splObjectStorage[$dataGateway][$id])) { return true; } return false; }
[ "public", "function", "has", "(", "MongoCollection", "$", "dataGateway", ",", "$", "id", ")", "{", "$", "id", "=", "(", "string", ")", "$", "id", ";", "if", "(", "!", "$", "this", "->", "splObjectStorage", "->", "contains", "(", "$", "dataGateway", ")", ")", "{", "return", "false", ";", "}", "if", "(", "isset", "(", "$", "this", "->", "splObjectStorage", "[", "$", "dataGateway", "]", "[", "$", "id", "]", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
Check whether the given data gateway exists in the current store @param MongoCollection $dataGateway @param $id @return bool
[ "Check", "whether", "the", "given", "data", "gateway", "exists", "in", "the", "current", "store" ]
d69511d7f7fc58e708c771ea0cd3c8ba7e8a155a
https://github.com/matryoshka-model/mongo-wrapper/blob/d69511d7f7fc58e708c771ea0cd3c8ba7e8a155a/library/Criteria/Isolated/DocumentStore.php#L109-L122
5,849
matryoshka-model/mongo-wrapper
library/Criteria/Isolated/DocumentStore.php
DocumentStore.get
public function get(MongoCollection $dataGateway, $id) { $id = (string) $id; if ($this->has($dataGateway, $id)) { return $this->splObjectStorage[$dataGateway][$id]; } }
php
public function get(MongoCollection $dataGateway, $id) { $id = (string) $id; if ($this->has($dataGateway, $id)) { return $this->splObjectStorage[$dataGateway][$id]; } }
[ "public", "function", "get", "(", "MongoCollection", "$", "dataGateway", ",", "$", "id", ")", "{", "$", "id", "=", "(", "string", ")", "$", "id", ";", "if", "(", "$", "this", "->", "has", "(", "$", "dataGateway", ",", "$", "id", ")", ")", "{", "return", "$", "this", "->", "splObjectStorage", "[", "$", "dataGateway", "]", "[", "$", "id", "]", ";", "}", "}" ]
Retrieve the given data gateway from the store @param MongoCollection $dataGateway @param $id @return mixed|null
[ "Retrieve", "the", "given", "data", "gateway", "from", "the", "store" ]
d69511d7f7fc58e708c771ea0cd3c8ba7e8a155a
https://github.com/matryoshka-model/mongo-wrapper/blob/d69511d7f7fc58e708c771ea0cd3c8ba7e8a155a/library/Criteria/Isolated/DocumentStore.php#L131-L138
5,850
awjudd/l4-revisable
src/Awjudd/Revisable/Revisable.php
Revisable.getRevisionNumber
public function getRevisionNumber($revisionNumber, $columnList = array('*')) { $query = $this->deriveRevisions(); if($revisionNumber > 1) { // Skip ahead to where we need to be $query->skip($revisionNumber - 1)->take(1); } return $query->get($columnList)->first(); }
php
public function getRevisionNumber($revisionNumber, $columnList = array('*')) { $query = $this->deriveRevisions(); if($revisionNumber > 1) { // Skip ahead to where we need to be $query->skip($revisionNumber - 1)->take(1); } return $query->get($columnList)->first(); }
[ "public", "function", "getRevisionNumber", "(", "$", "revisionNumber", ",", "$", "columnList", "=", "array", "(", "'*'", ")", ")", "{", "$", "query", "=", "$", "this", "->", "deriveRevisions", "(", ")", ";", "if", "(", "$", "revisionNumber", ">", "1", ")", "{", "// Skip ahead to where we need to be", "$", "query", "->", "skip", "(", "$", "revisionNumber", "-", "1", ")", "->", "take", "(", "1", ")", ";", "}", "return", "$", "query", "->", "get", "(", "$", "columnList", ")", "->", "first", "(", ")", ";", "}" ]
Gets a single revision from the list. @param int $revisionNumber The revision number to retrieve @param array $columnList The list of columns to retrieve @return array
[ "Gets", "a", "single", "revision", "from", "the", "list", "." ]
15954fa1d4bf97453514f4be1f56382ba40279fc
https://github.com/awjudd/l4-revisable/blob/15954fa1d4bf97453514f4be1f56382ba40279fc/src/Awjudd/Revisable/Revisable.php#L121-L132
5,851
awjudd/l4-revisable
src/Awjudd/Revisable/Revisable.php
Revisable.removeExpired
public static function removeExpired(array $where = array()) { // Check if we either have no revisions enabled, or it is set to infinite if(static::$revisionCount <= 0) { // Remove nothing return TRUE; } // Otherwise look for the expired revisions if( static::hasAlternateRevisionTable()) { $query = \DB::table(static::$revisionTable); } else { $query = self::onlyTrashed(); } // Were there any where clause filters? if(count($where)>0) { // There were, so add them in foreach($where as $key => $value) { $query->where($key, '=', $value); } } // Were there any columns that were defined as a "key column" if(count(static::$keyColumns) > 0) { // There were, so add in the group bys foreach(static::$keyColumns as $column) { $query->groupBy($column); } // Send back all of the key columns where we have more than the allowed $query->having(\DB::raw('count(1)'), '>', static::$revisionCount) ->addSelect(static::$keyColumns); } else { $query->where(\DB::raw('count(1)'), '>', static::$revisionCount); } // List of all of the ids affected by the revision count $ids = array(); // Cycle through the list foreach($query->get() as $row) { // Otherwise look for the expired revisions if(static::hasAlternateRevisionTable()) { $filter = \DB::table(static::$revisionTable); } else { $filter = self::onlyTrashed(); } // foreach(static::$keyColumns as $column) { $filter->where($column, '=', $row->$column); } $filter->skip(static::$revisionCount) // Take as many as we need ->take(PHP_INT_MAX) // Grab anything that was soft deleted after the number we keep ->orderBy('created_at', 'desc') // Grab the ID column ->addSelect('id'); // Cycle through all of the records foreach($filter->get() as $id) { $ids[] = $id->id; } } // Were there any records that fit the criteria if(count($ids) > 0) { // There were, so if(static::hasAlternateRevisionTable()) { $delete = \DB::table(static::$revisionTable); } else { $delete = self::onlyTrashed(); } // Filter all of the selected $delete->whereIn('id', $ids); // Figure out how we should delete if(static::hasAlternateRevisionTable()) { // Alternate table, so just delete it $delete->delete(); } else { // Otherwise delete it $delete->forceDelete(); } } return TRUE; }
php
public static function removeExpired(array $where = array()) { // Check if we either have no revisions enabled, or it is set to infinite if(static::$revisionCount <= 0) { // Remove nothing return TRUE; } // Otherwise look for the expired revisions if( static::hasAlternateRevisionTable()) { $query = \DB::table(static::$revisionTable); } else { $query = self::onlyTrashed(); } // Were there any where clause filters? if(count($where)>0) { // There were, so add them in foreach($where as $key => $value) { $query->where($key, '=', $value); } } // Were there any columns that were defined as a "key column" if(count(static::$keyColumns) > 0) { // There were, so add in the group bys foreach(static::$keyColumns as $column) { $query->groupBy($column); } // Send back all of the key columns where we have more than the allowed $query->having(\DB::raw('count(1)'), '>', static::$revisionCount) ->addSelect(static::$keyColumns); } else { $query->where(\DB::raw('count(1)'), '>', static::$revisionCount); } // List of all of the ids affected by the revision count $ids = array(); // Cycle through the list foreach($query->get() as $row) { // Otherwise look for the expired revisions if(static::hasAlternateRevisionTable()) { $filter = \DB::table(static::$revisionTable); } else { $filter = self::onlyTrashed(); } // foreach(static::$keyColumns as $column) { $filter->where($column, '=', $row->$column); } $filter->skip(static::$revisionCount) // Take as many as we need ->take(PHP_INT_MAX) // Grab anything that was soft deleted after the number we keep ->orderBy('created_at', 'desc') // Grab the ID column ->addSelect('id'); // Cycle through all of the records foreach($filter->get() as $id) { $ids[] = $id->id; } } // Were there any records that fit the criteria if(count($ids) > 0) { // There were, so if(static::hasAlternateRevisionTable()) { $delete = \DB::table(static::$revisionTable); } else { $delete = self::onlyTrashed(); } // Filter all of the selected $delete->whereIn('id', $ids); // Figure out how we should delete if(static::hasAlternateRevisionTable()) { // Alternate table, so just delete it $delete->delete(); } else { // Otherwise delete it $delete->forceDelete(); } } return TRUE; }
[ "public", "static", "function", "removeExpired", "(", "array", "$", "where", "=", "array", "(", ")", ")", "{", "// Check if we either have no revisions enabled, or it is set to infinite", "if", "(", "static", "::", "$", "revisionCount", "<=", "0", ")", "{", "// Remove nothing", "return", "TRUE", ";", "}", "// Otherwise look for the expired revisions", "if", "(", "static", "::", "hasAlternateRevisionTable", "(", ")", ")", "{", "$", "query", "=", "\\", "DB", "::", "table", "(", "static", "::", "$", "revisionTable", ")", ";", "}", "else", "{", "$", "query", "=", "self", "::", "onlyTrashed", "(", ")", ";", "}", "// Were there any where clause filters?", "if", "(", "count", "(", "$", "where", ")", ">", "0", ")", "{", "// There were, so add them in", "foreach", "(", "$", "where", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "query", "->", "where", "(", "$", "key", ",", "'='", ",", "$", "value", ")", ";", "}", "}", "// Were there any columns that were defined as a \"key column\"", "if", "(", "count", "(", "static", "::", "$", "keyColumns", ")", ">", "0", ")", "{", "// There were, so add in the group bys", "foreach", "(", "static", "::", "$", "keyColumns", "as", "$", "column", ")", "{", "$", "query", "->", "groupBy", "(", "$", "column", ")", ";", "}", "// Send back all of the key columns where we have more than the allowed", "$", "query", "->", "having", "(", "\\", "DB", "::", "raw", "(", "'count(1)'", ")", ",", "'>'", ",", "static", "::", "$", "revisionCount", ")", "->", "addSelect", "(", "static", "::", "$", "keyColumns", ")", ";", "}", "else", "{", "$", "query", "->", "where", "(", "\\", "DB", "::", "raw", "(", "'count(1)'", ")", ",", "'>'", ",", "static", "::", "$", "revisionCount", ")", ";", "}", "// List of all of the ids affected by the revision count", "$", "ids", "=", "array", "(", ")", ";", "// Cycle through the list", "foreach", "(", "$", "query", "->", "get", "(", ")", "as", "$", "row", ")", "{", "// Otherwise look for the expired revisions", "if", "(", "static", "::", "hasAlternateRevisionTable", "(", ")", ")", "{", "$", "filter", "=", "\\", "DB", "::", "table", "(", "static", "::", "$", "revisionTable", ")", ";", "}", "else", "{", "$", "filter", "=", "self", "::", "onlyTrashed", "(", ")", ";", "}", "//", "foreach", "(", "static", "::", "$", "keyColumns", "as", "$", "column", ")", "{", "$", "filter", "->", "where", "(", "$", "column", ",", "'='", ",", "$", "row", "->", "$", "column", ")", ";", "}", "$", "filter", "->", "skip", "(", "static", "::", "$", "revisionCount", ")", "// Take as many as we need", "->", "take", "(", "PHP_INT_MAX", ")", "// Grab anything that was soft deleted after the number we keep", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", "// Grab the ID column", "->", "addSelect", "(", "'id'", ")", ";", "// Cycle through all of the records", "foreach", "(", "$", "filter", "->", "get", "(", ")", "as", "$", "id", ")", "{", "$", "ids", "[", "]", "=", "$", "id", "->", "id", ";", "}", "}", "// Were there any records that fit the criteria", "if", "(", "count", "(", "$", "ids", ")", ">", "0", ")", "{", "// There were, so ", "if", "(", "static", "::", "hasAlternateRevisionTable", "(", ")", ")", "{", "$", "delete", "=", "\\", "DB", "::", "table", "(", "static", "::", "$", "revisionTable", ")", ";", "}", "else", "{", "$", "delete", "=", "self", "::", "onlyTrashed", "(", ")", ";", "}", "// Filter all of the selected", "$", "delete", "->", "whereIn", "(", "'id'", ",", "$", "ids", ")", ";", "// Figure out how we should delete", "if", "(", "static", "::", "hasAlternateRevisionTable", "(", ")", ")", "{", "// Alternate table, so just delete it", "$", "delete", "->", "delete", "(", ")", ";", "}", "else", "{", "// Otherwise delete it", "$", "delete", "->", "forceDelete", "(", ")", ";", "}", "}", "return", "TRUE", ";", "}" ]
Used in order to get rid of any expired revisions. @param array $where Any filters to apply to the filters @return boolean
[ "Used", "in", "order", "to", "get", "rid", "of", "any", "expired", "revisions", "." ]
15954fa1d4bf97453514f4be1f56382ba40279fc
https://github.com/awjudd/l4-revisable/blob/15954fa1d4bf97453514f4be1f56382ba40279fc/src/Awjudd/Revisable/Revisable.php#L248-L365
5,852
awjudd/l4-revisable
src/Awjudd/Revisable/Revisable.php
Revisable.deriveRevisions
private function deriveRevisions() { $query = NULL; // There are, so look for any revisions if($this->hasAlternateRevisionTable()) { $query = \DB::table(static::$revisionTable); } else { // Only grab the instances that were trashed $query = self::onlyTrashed(); } // Cycle through all of the other respective columns foreach(static::$keyColumns as $column) { // Filter on the key values $query->where($column, '=', $this->$column); } // Check if we only want to keep a certain number of revisions if(static::$revisionCount > 0) { // Only grab the ones that fit $query->take($this->revisionCount); } // Return the query return $query->orderBy('created_at', 'desc'); }
php
private function deriveRevisions() { $query = NULL; // There are, so look for any revisions if($this->hasAlternateRevisionTable()) { $query = \DB::table(static::$revisionTable); } else { // Only grab the instances that were trashed $query = self::onlyTrashed(); } // Cycle through all of the other respective columns foreach(static::$keyColumns as $column) { // Filter on the key values $query->where($column, '=', $this->$column); } // Check if we only want to keep a certain number of revisions if(static::$revisionCount > 0) { // Only grab the ones that fit $query->take($this->revisionCount); } // Return the query return $query->orderBy('created_at', 'desc'); }
[ "private", "function", "deriveRevisions", "(", ")", "{", "$", "query", "=", "NULL", ";", "// There are, so look for any revisions", "if", "(", "$", "this", "->", "hasAlternateRevisionTable", "(", ")", ")", "{", "$", "query", "=", "\\", "DB", "::", "table", "(", "static", "::", "$", "revisionTable", ")", ";", "}", "else", "{", "// Only grab the instances that were trashed", "$", "query", "=", "self", "::", "onlyTrashed", "(", ")", ";", "}", "// Cycle through all of the other respective columns", "foreach", "(", "static", "::", "$", "keyColumns", "as", "$", "column", ")", "{", "// Filter on the key values", "$", "query", "->", "where", "(", "$", "column", ",", "'='", ",", "$", "this", "->", "$", "column", ")", ";", "}", "// Check if we only want to keep a certain number of revisions", "if", "(", "static", "::", "$", "revisionCount", ">", "0", ")", "{", "// Only grab the ones that fit", "$", "query", "->", "take", "(", "$", "this", "->", "revisionCount", ")", ";", "}", "// Return the query", "return", "$", "query", "->", "orderBy", "(", "'created_at'", ",", "'desc'", ")", ";", "}" ]
Used in order to derive the actual query that is used to grab the revisions. @return Illuminate\Database\Query\Builder
[ "Used", "in", "order", "to", "derive", "the", "actual", "query", "that", "is", "used", "to", "grab", "the", "revisions", "." ]
15954fa1d4bf97453514f4be1f56382ba40279fc
https://github.com/awjudd/l4-revisable/blob/15954fa1d4bf97453514f4be1f56382ba40279fc/src/Awjudd/Revisable/Revisable.php#L372-L403
5,853
coolms/common
src/Stdlib/ArrayUtils.php
ArrayUtils.filterRecursive
public static function filterRecursive(array $array, $callback = null, $removeEmptyArrays = false) { if (null !== $callback && !is_callable($callback)) { throw new Exception\InvalidArgumentException(sprintf( 'Second parameter of %s must be callable', __METHOD__ )); } foreach ($array as $key => &$value) { // mind the reference if (is_array($value)) { $value = static::filterRecursive($value, $callback, $removeEmptyArrays); if ($removeEmptyArrays && ! (bool) $value) { unset($array[$key]); } } else { if (null !== $callback && !$callback($value)) { unset($array[$key]); } elseif (! (bool) $value) { unset($array[$key]); } } } unset($value); // kill the reference return $array; }
php
public static function filterRecursive(array $array, $callback = null, $removeEmptyArrays = false) { if (null !== $callback && !is_callable($callback)) { throw new Exception\InvalidArgumentException(sprintf( 'Second parameter of %s must be callable', __METHOD__ )); } foreach ($array as $key => &$value) { // mind the reference if (is_array($value)) { $value = static::filterRecursive($value, $callback, $removeEmptyArrays); if ($removeEmptyArrays && ! (bool) $value) { unset($array[$key]); } } else { if (null !== $callback && !$callback($value)) { unset($array[$key]); } elseif (! (bool) $value) { unset($array[$key]); } } } unset($value); // kill the reference return $array; }
[ "public", "static", "function", "filterRecursive", "(", "array", "$", "array", ",", "$", "callback", "=", "null", ",", "$", "removeEmptyArrays", "=", "false", ")", "{", "if", "(", "null", "!==", "$", "callback", "&&", "!", "is_callable", "(", "$", "callback", ")", ")", "{", "throw", "new", "Exception", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'Second parameter of %s must be callable'", ",", "__METHOD__", ")", ")", ";", "}", "foreach", "(", "$", "array", "as", "$", "key", "=>", "&", "$", "value", ")", "{", "// mind the reference", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "static", "::", "filterRecursive", "(", "$", "value", ",", "$", "callback", ",", "$", "removeEmptyArrays", ")", ";", "if", "(", "$", "removeEmptyArrays", "&&", "!", "(", "bool", ")", "$", "value", ")", "{", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "}", "}", "else", "{", "if", "(", "null", "!==", "$", "callback", "&&", "!", "$", "callback", "(", "$", "value", ")", ")", "{", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "}", "elseif", "(", "!", "(", "bool", ")", "$", "value", ")", "{", "unset", "(", "$", "array", "[", "$", "key", "]", ")", ";", "}", "}", "}", "unset", "(", "$", "value", ")", ";", "// kill the reference", "return", "$", "array", ";", "}" ]
Exactly the same as array_filter except this function filters within multi-dimensional arrays @param array $array @param callable $callback optional callback function name @param bool $removeEmptyArrays optional flag removal of empty arrays after filtering @return array
[ "Exactly", "the", "same", "as", "array_filter", "except", "this", "function", "filters", "within", "multi", "-", "dimensional", "arrays" ]
3572993cdcdb2898cdde396a2f1de9864b193660
https://github.com/coolms/common/blob/3572993cdcdb2898cdde396a2f1de9864b193660/src/Stdlib/ArrayUtils.php#L32-L60
5,854
ItinerisLtd/preflight-command
src/Validators/AbstractValidator.php
AbstractValidator.report
public function report(string ...$messages): ResultInterface { if (! empty($messages)) { return ResultFactory::makeFailure( $this->checker, array_merge([$this->failureMessage], $messages) ); } return ResultFactory::makeSuccess($this->checker); }
php
public function report(string ...$messages): ResultInterface { if (! empty($messages)) { return ResultFactory::makeFailure( $this->checker, array_merge([$this->failureMessage], $messages) ); } return ResultFactory::makeSuccess($this->checker); }
[ "public", "function", "report", "(", "string", "...", "$", "messages", ")", ":", "ResultInterface", "{", "if", "(", "!", "empty", "(", "$", "messages", ")", ")", "{", "return", "ResultFactory", "::", "makeFailure", "(", "$", "this", "->", "checker", ",", "array_merge", "(", "[", "$", "this", "->", "failureMessage", "]", ",", "$", "messages", ")", ")", ";", "}", "return", "ResultFactory", "::", "makeSuccess", "(", "$", "this", "->", "checker", ")", ";", "}" ]
Returns result instance. TODO: Should I be protected? @param string|string[] ...$messages Failure message. If empty, assume success. @return Failure|Success
[ "Returns", "result", "instance", "." ]
d1c1360ea8d7de0312b5c0c09c9c486949594049
https://github.com/ItinerisLtd/preflight-command/blob/d1c1360ea8d7de0312b5c0c09c9c486949594049/src/Validators/AbstractValidator.php#L52-L62
5,855
Webiny/Hrc
src/Webiny/Hrc/CacheStorage/FileSystem.php
FileSystem.save
public function save($key, $content, $ttl) { $cacheFile = $this->getCachePath($key); $cache = json_encode(['ttl' => (time() + $ttl), 'content' => $content]); file_put_contents($cacheFile, $cache); return true; }
php
public function save($key, $content, $ttl) { $cacheFile = $this->getCachePath($key); $cache = json_encode(['ttl' => (time() + $ttl), 'content' => $content]); file_put_contents($cacheFile, $cache); return true; }
[ "public", "function", "save", "(", "$", "key", ",", "$", "content", ",", "$", "ttl", ")", "{", "$", "cacheFile", "=", "$", "this", "->", "getCachePath", "(", "$", "key", ")", ";", "$", "cache", "=", "json_encode", "(", "[", "'ttl'", "=>", "(", "time", "(", ")", "+", "$", "ttl", ")", ",", "'content'", "=>", "$", "content", "]", ")", ";", "file_put_contents", "(", "$", "cacheFile", ",", "$", "cache", ")", ";", "return", "true", ";", "}" ]
Save the given content into cache. @param string $key Cache key. @param string $content Content that should be saved. @param string $ttl Cache time-to-live @return bool
[ "Save", "the", "given", "content", "into", "cache", "." ]
2594d645dd79a579916d90ec93ce815bd413558f
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/CacheStorage/FileSystem.php#L74-L82
5,856
Webiny/Hrc
src/Webiny/Hrc/CacheStorage/FileSystem.php
FileSystem.getCachePath
private function getCachePath($cacheKey) { $folder = $this->cacheDir . substr($cacheKey, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheKey, 2, 2) . DIRECTORY_SEPARATOR . substr($cacheKey, 4, 2) . DIRECTORY_SEPARATOR; if (!is_dir($folder)) { mkdir($folder, 0755, true); } return $folder . $cacheKey; }
php
private function getCachePath($cacheKey) { $folder = $this->cacheDir . substr($cacheKey, 0, 2) . DIRECTORY_SEPARATOR . substr($cacheKey, 2, 2) . DIRECTORY_SEPARATOR . substr($cacheKey, 4, 2) . DIRECTORY_SEPARATOR; if (!is_dir($folder)) { mkdir($folder, 0755, true); } return $folder . $cacheKey; }
[ "private", "function", "getCachePath", "(", "$", "cacheKey", ")", "{", "$", "folder", "=", "$", "this", "->", "cacheDir", ".", "substr", "(", "$", "cacheKey", ",", "0", ",", "2", ")", ".", "DIRECTORY_SEPARATOR", ".", "substr", "(", "$", "cacheKey", ",", "2", ",", "2", ")", ".", "DIRECTORY_SEPARATOR", ".", "substr", "(", "$", "cacheKey", ",", "4", ",", "2", ")", ".", "DIRECTORY_SEPARATOR", ";", "if", "(", "!", "is_dir", "(", "$", "folder", ")", ")", "{", "mkdir", "(", "$", "folder", ",", "0755", ",", "true", ")", ";", "}", "return", "$", "folder", ".", "$", "cacheKey", ";", "}" ]
Creates the cache folder hierarchy and returns the full path to the given cache file. @param string $cacheKey @return string
[ "Creates", "the", "cache", "folder", "hierarchy", "and", "returns", "the", "full", "path", "to", "the", "given", "cache", "file", "." ]
2594d645dd79a579916d90ec93ce815bd413558f
https://github.com/Webiny/Hrc/blob/2594d645dd79a579916d90ec93ce815bd413558f/src/Webiny/Hrc/CacheStorage/FileSystem.php#L112-L121
5,857
nirix/radium
src/Database/Model/Relatable.php
Relatable.getRelationInfo
public static function getRelationInfo($name, $info = array()) { // Get current models namespace $class = new \ReflectionClass(get_called_class()); $namespace = $class->getNamespaceName(); // Name $info['name'] = $name; // Model and class if (!isset($info['model'])) { // Model $info['model'] = Inflector::modelise($name); } // Set model namespace if (strpos($info['model'], '\\') === false) { $info['model'] = "\\{$namespace}\\{$info['model']}"; } // Class $model = new \ReflectionClass($info['model']); $info['class'] = $model->getShortName(); return $info; }
php
public static function getRelationInfo($name, $info = array()) { // Get current models namespace $class = new \ReflectionClass(get_called_class()); $namespace = $class->getNamespaceName(); // Name $info['name'] = $name; // Model and class if (!isset($info['model'])) { // Model $info['model'] = Inflector::modelise($name); } // Set model namespace if (strpos($info['model'], '\\') === false) { $info['model'] = "\\{$namespace}\\{$info['model']}"; } // Class $model = new \ReflectionClass($info['model']); $info['class'] = $model->getShortName(); return $info; }
[ "public", "static", "function", "getRelationInfo", "(", "$", "name", ",", "$", "info", "=", "array", "(", ")", ")", "{", "// Get current models namespace", "$", "class", "=", "new", "\\", "ReflectionClass", "(", "get_called_class", "(", ")", ")", ";", "$", "namespace", "=", "$", "class", "->", "getNamespaceName", "(", ")", ";", "// Name", "$", "info", "[", "'name'", "]", "=", "$", "name", ";", "// Model and class", "if", "(", "!", "isset", "(", "$", "info", "[", "'model'", "]", ")", ")", "{", "// Model", "$", "info", "[", "'model'", "]", "=", "Inflector", "::", "modelise", "(", "$", "name", ")", ";", "}", "// Set model namespace", "if", "(", "strpos", "(", "$", "info", "[", "'model'", "]", ",", "'\\\\'", ")", "===", "false", ")", "{", "$", "info", "[", "'model'", "]", "=", "\"\\\\{$namespace}\\\\{$info['model']}\"", ";", "}", "// Class", "$", "model", "=", "new", "\\", "ReflectionClass", "(", "$", "info", "[", "'model'", "]", ")", ";", "$", "info", "[", "'class'", "]", "=", "$", "model", "->", "getShortName", "(", ")", ";", "return", "$", "info", ";", "}" ]
Returns an array containing information about the relation. @param string $name Relation name @param array $info Relation info @return array
[ "Returns", "an", "array", "containing", "information", "about", "the", "relation", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/Relatable.php#L41-L66
5,858
nirix/radium
src/Database/Model/Relatable.php
Relatable.belongsTo
public function belongsTo($model, $options = array()) { if (isset($this->_relationsCache[$model])) { return $this->_relationsCache[$model]; } $options = static::getRelationInfo($model, $options); if (!isset($options['localKey'])) { $options['localKey'] = Inflector::foreignKey($model); } if (!isset($options['foreignKey'])) { $options['foreignKey'] = $options['model']::primaryKey(); } return $this->_relationsCache[$model] = $options['model']::select() ->where("{$options['foreignKey']} = ?", $this->{$options['localKey']}) ->fetch(); }
php
public function belongsTo($model, $options = array()) { if (isset($this->_relationsCache[$model])) { return $this->_relationsCache[$model]; } $options = static::getRelationInfo($model, $options); if (!isset($options['localKey'])) { $options['localKey'] = Inflector::foreignKey($model); } if (!isset($options['foreignKey'])) { $options['foreignKey'] = $options['model']::primaryKey(); } return $this->_relationsCache[$model] = $options['model']::select() ->where("{$options['foreignKey']} = ?", $this->{$options['localKey']}) ->fetch(); }
[ "public", "function", "belongsTo", "(", "$", "model", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_relationsCache", "[", "$", "model", "]", ")", ")", "{", "return", "$", "this", "->", "_relationsCache", "[", "$", "model", "]", ";", "}", "$", "options", "=", "static", "::", "getRelationInfo", "(", "$", "model", ",", "$", "options", ")", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'localKey'", "]", ")", ")", "{", "$", "options", "[", "'localKey'", "]", "=", "Inflector", "::", "foreignKey", "(", "$", "model", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'foreignKey'", "]", ")", ")", "{", "$", "options", "[", "'foreignKey'", "]", "=", "$", "options", "[", "'model'", "]", "::", "primaryKey", "(", ")", ";", "}", "return", "$", "this", "->", "_relationsCache", "[", "$", "model", "]", "=", "$", "options", "[", "'model'", "]", "::", "select", "(", ")", "->", "where", "(", "\"{$options['foreignKey']} = ?\"", ",", "$", "this", "->", "{", "$", "options", "[", "'localKey'", "]", "}", ")", "->", "fetch", "(", ")", ";", "}" ]
Returns the owning object. @param string $model Name of the model. @param aray $options Optional relation options. @return object
[ "Returns", "the", "owning", "object", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/Relatable.php#L110-L129
5,859
nirix/radium
src/Database/Model/Relatable.php
Relatable.hasMany
public function hasMany($model, $options = array()) { $options = static::getRelationInfo($model, $options); if (!isset($options['localKey'])) { $options['localKey'] = static::primaryKey(); } if (!isset($options['foreignKey'])) { $options['foreignKey'] = Inflector::foreignKey(static::table()); } return $options['model']::select() ->where("{$options['foreignKey']} = ?", $this->{$options['localKey']}) ->mergeNextWhere(); }
php
public function hasMany($model, $options = array()) { $options = static::getRelationInfo($model, $options); if (!isset($options['localKey'])) { $options['localKey'] = static::primaryKey(); } if (!isset($options['foreignKey'])) { $options['foreignKey'] = Inflector::foreignKey(static::table()); } return $options['model']::select() ->where("{$options['foreignKey']} = ?", $this->{$options['localKey']}) ->mergeNextWhere(); }
[ "public", "function", "hasMany", "(", "$", "model", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "options", "=", "static", "::", "getRelationInfo", "(", "$", "model", ",", "$", "options", ")", ";", "if", "(", "!", "isset", "(", "$", "options", "[", "'localKey'", "]", ")", ")", "{", "$", "options", "[", "'localKey'", "]", "=", "static", "::", "primaryKey", "(", ")", ";", "}", "if", "(", "!", "isset", "(", "$", "options", "[", "'foreignKey'", "]", ")", ")", "{", "$", "options", "[", "'foreignKey'", "]", "=", "Inflector", "::", "foreignKey", "(", "static", "::", "table", "(", ")", ")", ";", "}", "return", "$", "options", "[", "'model'", "]", "::", "select", "(", ")", "->", "where", "(", "\"{$options['foreignKey']} = ?\"", ",", "$", "this", "->", "{", "$", "options", "[", "'localKey'", "]", "}", ")", "->", "mergeNextWhere", "(", ")", ";", "}" ]
Returns an array of owned objects. @param string $model Name of the model. @param aray $options Optional relation options. @return array
[ "Returns", "an", "array", "of", "owned", "objects", "." ]
cc6907bfee296b64a7630b0b188e233d7cdb86fd
https://github.com/nirix/radium/blob/cc6907bfee296b64a7630b0b188e233d7cdb86fd/src/Database/Model/Relatable.php#L139-L154
5,860
mszewcz/php-json-schema-validator
src/Validators/ObjectValidators/AdditionalPropertiesValidator.php
AdditionalPropertiesValidator.validate
public function validate($subject): bool { // Validation with "additionalProperties" applies only to the child values of instance names that do // not match any names in "properties", and do not match any regular expression in "patternProperties". $subject = $this->removePropertiesFromSubject($subject, $this->schema); $subject = $this->removePatternPropertiesFromSubject($subject, $this->schema); // The value of "additionalProperties" MUST be a valid JSON Schema (including boolean false) if (\is_bool($this->schema['additionalProperties']) && $this->schema['additionalProperties'] === false) { if (count($subject) > 0) { return false; } } elseif (\is_array($this->schema['additionalProperties'])) { foreach ($subject as $propertyValue) { $nodeValidator = new NodeValidator($this->schema['additionalProperties'], $this->rootSchema); if (!$nodeValidator->validate($propertyValue)) { return false; } } } return true; }
php
public function validate($subject): bool { // Validation with "additionalProperties" applies only to the child values of instance names that do // not match any names in "properties", and do not match any regular expression in "patternProperties". $subject = $this->removePropertiesFromSubject($subject, $this->schema); $subject = $this->removePatternPropertiesFromSubject($subject, $this->schema); // The value of "additionalProperties" MUST be a valid JSON Schema (including boolean false) if (\is_bool($this->schema['additionalProperties']) && $this->schema['additionalProperties'] === false) { if (count($subject) > 0) { return false; } } elseif (\is_array($this->schema['additionalProperties'])) { foreach ($subject as $propertyValue) { $nodeValidator = new NodeValidator($this->schema['additionalProperties'], $this->rootSchema); if (!$nodeValidator->validate($propertyValue)) { return false; } } } return true; }
[ "public", "function", "validate", "(", "$", "subject", ")", ":", "bool", "{", "// Validation with \"additionalProperties\" applies only to the child values of instance names that do", "// not match any names in \"properties\", and do not match any regular expression in \"patternProperties\".", "$", "subject", "=", "$", "this", "->", "removePropertiesFromSubject", "(", "$", "subject", ",", "$", "this", "->", "schema", ")", ";", "$", "subject", "=", "$", "this", "->", "removePatternPropertiesFromSubject", "(", "$", "subject", ",", "$", "this", "->", "schema", ")", ";", "// The value of \"additionalProperties\" MUST be a valid JSON Schema (including boolean false)", "if", "(", "\\", "is_bool", "(", "$", "this", "->", "schema", "[", "'additionalProperties'", "]", ")", "&&", "$", "this", "->", "schema", "[", "'additionalProperties'", "]", "===", "false", ")", "{", "if", "(", "count", "(", "$", "subject", ")", ">", "0", ")", "{", "return", "false", ";", "}", "}", "elseif", "(", "\\", "is_array", "(", "$", "this", "->", "schema", "[", "'additionalProperties'", "]", ")", ")", "{", "foreach", "(", "$", "subject", "as", "$", "propertyValue", ")", "{", "$", "nodeValidator", "=", "new", "NodeValidator", "(", "$", "this", "->", "schema", "[", "'additionalProperties'", "]", ",", "$", "this", "->", "rootSchema", ")", ";", "if", "(", "!", "$", "nodeValidator", "->", "validate", "(", "$", "propertyValue", ")", ")", "{", "return", "false", ";", "}", "}", "}", "return", "true", ";", "}" ]
Validates subject against additionalProperties @param array $subject @return bool
[ "Validates", "subject", "against", "additionalProperties" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ObjectValidators/AdditionalPropertiesValidator.php#L48-L68
5,861
mszewcz/php-json-schema-validator
src/Validators/ObjectValidators/AdditionalPropertiesValidator.php
AdditionalPropertiesValidator.removePropertiesFromSubject
private function removePropertiesFromSubject(array $subject, array $schema): array { if (isset($schema['properties']) && \is_array($schema['properties'])) { $propertyNames = \array_keys($schema['properties']); foreach ($propertyNames as $propertyName) { if (isset($subject[$propertyName])) { unset($subject[$propertyName]); } } } return $subject; }
php
private function removePropertiesFromSubject(array $subject, array $schema): array { if (isset($schema['properties']) && \is_array($schema['properties'])) { $propertyNames = \array_keys($schema['properties']); foreach ($propertyNames as $propertyName) { if (isset($subject[$propertyName])) { unset($subject[$propertyName]); } } } return $subject; }
[ "private", "function", "removePropertiesFromSubject", "(", "array", "$", "subject", ",", "array", "$", "schema", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "schema", "[", "'properties'", "]", ")", "&&", "\\", "is_array", "(", "$", "schema", "[", "'properties'", "]", ")", ")", "{", "$", "propertyNames", "=", "\\", "array_keys", "(", "$", "schema", "[", "'properties'", "]", ")", ";", "foreach", "(", "$", "propertyNames", "as", "$", "propertyName", ")", "{", "if", "(", "isset", "(", "$", "subject", "[", "$", "propertyName", "]", ")", ")", "{", "unset", "(", "$", "subject", "[", "$", "propertyName", "]", ")", ";", "}", "}", "}", "return", "$", "subject", ";", "}" ]
Removes properties defined in 'properties' from subject @param array $subject @param array $schema @return array
[ "Removes", "properties", "defined", "in", "properties", "from", "subject" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ObjectValidators/AdditionalPropertiesValidator.php#L77-L88
5,862
mszewcz/php-json-schema-validator
src/Validators/ObjectValidators/AdditionalPropertiesValidator.php
AdditionalPropertiesValidator.removePatternPropertiesFromSubject
private function removePatternPropertiesFromSubject(array $subject, array $schema): array { if (isset($schema['patternProperties']) && \is_array($schema['patternProperties'])) { $patterns = \array_keys($schema['patternProperties']); $propertyNames = \array_keys($subject); foreach ($patterns as $pattern) { foreach ($propertyNames as $propertyName) { if (\preg_match(sprintf('/%s/', $pattern), $propertyName)) { unset($subject[$propertyName]); } } } } return $subject; }
php
private function removePatternPropertiesFromSubject(array $subject, array $schema): array { if (isset($schema['patternProperties']) && \is_array($schema['patternProperties'])) { $patterns = \array_keys($schema['patternProperties']); $propertyNames = \array_keys($subject); foreach ($patterns as $pattern) { foreach ($propertyNames as $propertyName) { if (\preg_match(sprintf('/%s/', $pattern), $propertyName)) { unset($subject[$propertyName]); } } } } return $subject; }
[ "private", "function", "removePatternPropertiesFromSubject", "(", "array", "$", "subject", ",", "array", "$", "schema", ")", ":", "array", "{", "if", "(", "isset", "(", "$", "schema", "[", "'patternProperties'", "]", ")", "&&", "\\", "is_array", "(", "$", "schema", "[", "'patternProperties'", "]", ")", ")", "{", "$", "patterns", "=", "\\", "array_keys", "(", "$", "schema", "[", "'patternProperties'", "]", ")", ";", "$", "propertyNames", "=", "\\", "array_keys", "(", "$", "subject", ")", ";", "foreach", "(", "$", "patterns", "as", "$", "pattern", ")", "{", "foreach", "(", "$", "propertyNames", "as", "$", "propertyName", ")", "{", "if", "(", "\\", "preg_match", "(", "sprintf", "(", "'/%s/'", ",", "$", "pattern", ")", ",", "$", "propertyName", ")", ")", "{", "unset", "(", "$", "subject", "[", "$", "propertyName", "]", ")", ";", "}", "}", "}", "}", "return", "$", "subject", ";", "}" ]
Removes properties defined in 'patternProperties' from subject @param array $subject @param array $schema @return array
[ "Removes", "properties", "defined", "in", "patternProperties", "from", "subject" ]
f7768bfe07ce6508bb1ff36163560a5e5791de7d
https://github.com/mszewcz/php-json-schema-validator/blob/f7768bfe07ce6508bb1ff36163560a5e5791de7d/src/Validators/ObjectValidators/AdditionalPropertiesValidator.php#L97-L112
5,863
iwyg/template
View.php
View.setListeners
public function setListeners(array $listeners) { $this->listeners = []; foreach ($listeners as $name => $listener) { $this->addListener($name, $listener); } }
php
public function setListeners(array $listeners) { $this->listeners = []; foreach ($listeners as $name => $listener) { $this->addListener($name, $listener); } }
[ "public", "function", "setListeners", "(", "array", "$", "listeners", ")", "{", "$", "this", "->", "listeners", "=", "[", "]", ";", "foreach", "(", "$", "listeners", "as", "$", "name", "=>", "$", "listener", ")", "{", "$", "this", "->", "addListener", "(", "$", "name", ",", "$", "listener", ")", ";", "}", "}" ]
Set render listeners. @param array $listeners @return void
[ "Set", "render", "listeners", "." ]
ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e
https://github.com/iwyg/template/blob/ad7c8e79ce3b8fc7fcf82bc3e53737a4d7ecc16e/View.php#L77-L84
5,864
bugotech/phar
src/Commands/CompilerCommand.php
CompilerCommand.runScripts
protected function runScripts($keyList) { $this->info('Run scripts'); $this->laravel->configure('phar'); $scripts = $this->laravel['config']->get($keyList, []); foreach ($scripts as $item) { try { $this->info('..' . $item); $out = []; exec($item, $out); $this->info(' ' . trim(implode("\r\n", $out))); } catch (\Exception $e) { $this->error(sprintf("Error build: %s\r\nMessage: %s", $item, $e->getMessage())); } } }
php
protected function runScripts($keyList) { $this->info('Run scripts'); $this->laravel->configure('phar'); $scripts = $this->laravel['config']->get($keyList, []); foreach ($scripts as $item) { try { $this->info('..' . $item); $out = []; exec($item, $out); $this->info(' ' . trim(implode("\r\n", $out))); } catch (\Exception $e) { $this->error(sprintf("Error build: %s\r\nMessage: %s", $item, $e->getMessage())); } } }
[ "protected", "function", "runScripts", "(", "$", "keyList", ")", "{", "$", "this", "->", "info", "(", "'Run scripts'", ")", ";", "$", "this", "->", "laravel", "->", "configure", "(", "'phar'", ")", ";", "$", "scripts", "=", "$", "this", "->", "laravel", "[", "'config'", "]", "->", "get", "(", "$", "keyList", ",", "[", "]", ")", ";", "foreach", "(", "$", "scripts", "as", "$", "item", ")", "{", "try", "{", "$", "this", "->", "info", "(", "'..'", ".", "$", "item", ")", ";", "$", "out", "=", "[", "]", ";", "exec", "(", "$", "item", ",", "$", "out", ")", ";", "$", "this", "->", "info", "(", "' '", ".", "trim", "(", "implode", "(", "\"\\r\\n\"", ",", "$", "out", ")", ")", ")", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "error", "(", "sprintf", "(", "\"Error build: %s\\r\\nMessage: %s\"", ",", "$", "item", ",", "$", "e", "->", "getMessage", "(", ")", ")", ")", ";", "}", "}", "}" ]
Executar scripts. @param $keyList
[ "Executar", "scripts", "." ]
96f226d2c4bb1787fd41a3c67fe64b10de22b7af
https://github.com/bugotech/phar/blob/96f226d2c4bb1787fd41a3c67fe64b10de22b7af/src/Commands/CompilerCommand.php#L78-L93
5,865
PublisherHub/Publisher
src/Publisher/Mode/ContentTransformer.php
ContentTransformer.transform
public function transform(string $mode, array $modeData) { $return = array(); foreach($modeData as $data) { $modeClass = $this->entryHelper->getModeClass($mode, $data['entry']); $entity = new $modeClass($data['content']); $entryData = array(); $entryData['entry'] = $data['entry']; $entryData['content'] = $entity->generateBody(); /* Since the publisher manager ask for the parameter data * sooner or later we'll provide the key here * if its still missing. */ $entryData['parameters'] = isset($data['parameters']) ? $data['parameters'] : array(); $return[] = $entryData; } return $return; }
php
public function transform(string $mode, array $modeData) { $return = array(); foreach($modeData as $data) { $modeClass = $this->entryHelper->getModeClass($mode, $data['entry']); $entity = new $modeClass($data['content']); $entryData = array(); $entryData['entry'] = $data['entry']; $entryData['content'] = $entity->generateBody(); /* Since the publisher manager ask for the parameter data * sooner or later we'll provide the key here * if its still missing. */ $entryData['parameters'] = isset($data['parameters']) ? $data['parameters'] : array(); $return[] = $entryData; } return $return; }
[ "public", "function", "transform", "(", "string", "$", "mode", ",", "array", "$", "modeData", ")", "{", "$", "return", "=", "array", "(", ")", ";", "foreach", "(", "$", "modeData", "as", "$", "data", ")", "{", "$", "modeClass", "=", "$", "this", "->", "entryHelper", "->", "getModeClass", "(", "$", "mode", ",", "$", "data", "[", "'entry'", "]", ")", ";", "$", "entity", "=", "new", "$", "modeClass", "(", "$", "data", "[", "'content'", "]", ")", ";", "$", "entryData", "=", "array", "(", ")", ";", "$", "entryData", "[", "'entry'", "]", "=", "$", "data", "[", "'entry'", "]", ";", "$", "entryData", "[", "'content'", "]", "=", "$", "entity", "->", "generateBody", "(", ")", ";", "/* Since the publisher manager ask for the parameter data\n * sooner or later we'll provide the key here\n * if its still missing.\n */", "$", "entryData", "[", "'parameters'", "]", "=", "isset", "(", "$", "data", "[", "'parameters'", "]", ")", "?", "$", "data", "[", "'parameters'", "]", ":", "array", "(", ")", ";", "$", "return", "[", "]", "=", "$", "entryData", ";", "}", "return", "$", "return", ";", "}" ]
Transforms the mode specific data for each entry to the mapped entry data. @param string $mode @param array $modeData @return array
[ "Transforms", "the", "mode", "specific", "data", "for", "each", "entry", "to", "the", "mapped", "entry", "data", "." ]
954e05118be9956e0c8631e44958af4ba42606b3
https://github.com/PublisherHub/Publisher/blob/954e05118be9956e0c8631e44958af4ba42606b3/src/Publisher/Mode/ContentTransformer.php#L35-L57
5,866
indigophp-archive/http-adapter
src/Stream.php
Stream.create
public static function create($resource) { $type = gettype($resource); if ($type == 'string') { $stream = fopen('php://temp', 'r+'); if ($resource !== '') { fwrite($stream, $resource); fseek($stream, 0); } return new self($stream); } if ($type == 'resource') { return new self($resource); } if ($resource instanceof StreamableInterface) { return $resource; } throw new \InvalidArgumentException('Invalid resource type: ' . $type); }
php
public static function create($resource) { $type = gettype($resource); if ($type == 'string') { $stream = fopen('php://temp', 'r+'); if ($resource !== '') { fwrite($stream, $resource); fseek($stream, 0); } return new self($stream); } if ($type == 'resource') { return new self($resource); } if ($resource instanceof StreamableInterface) { return $resource; } throw new \InvalidArgumentException('Invalid resource type: ' . $type); }
[ "public", "static", "function", "create", "(", "$", "resource", ")", "{", "$", "type", "=", "gettype", "(", "$", "resource", ")", ";", "if", "(", "$", "type", "==", "'string'", ")", "{", "$", "stream", "=", "fopen", "(", "'php://temp'", ",", "'r+'", ")", ";", "if", "(", "$", "resource", "!==", "''", ")", "{", "fwrite", "(", "$", "stream", ",", "$", "resource", ")", ";", "fseek", "(", "$", "stream", ",", "0", ")", ";", "}", "return", "new", "self", "(", "$", "stream", ")", ";", "}", "if", "(", "$", "type", "==", "'resource'", ")", "{", "return", "new", "self", "(", "$", "resource", ")", ";", "}", "if", "(", "$", "resource", "instanceof", "StreamableInterface", ")", "{", "return", "$", "resource", ";", "}", "throw", "new", "\\", "InvalidArgumentException", "(", "'Invalid resource type: '", ".", "$", "type", ")", ";", "}" ]
Creates a new stream From Guzzle @param mixed $resource @return self
[ "Creates", "a", "new", "stream" ]
2233e8329a0704e020857228c2b538438e127475
https://github.com/indigophp-archive/http-adapter/blob/2233e8329a0704e020857228c2b538438e127475/src/Stream.php#L90-L114
5,867
dlevacher/php-git-hg-repo
lib/PHPHg/Repository.php
Repository.checkVers
public function checkVers($options = "-i") { $output = $this->cmd(sprintf('identify %s', $options)); $output = substr($output['output'], 0, 11); return $output; }
php
public function checkVers($options = "-i") { $output = $this->cmd(sprintf('identify %s', $options)); $output = substr($output['output'], 0, 11); return $output; }
[ "public", "function", "checkVers", "(", "$", "options", "=", "\"-i\"", ")", "{", "$", "output", "=", "$", "this", "->", "cmd", "(", "sprintf", "(", "'identify %s'", ",", "$", "options", ")", ")", ";", "$", "output", "=", "substr", "(", "$", "output", "[", "'output'", "]", ",", "0", ",", "11", ")", ";", "return", "$", "output", ";", "}" ]
Check current version
[ "Check", "current", "version" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Repository.php#L135-L139
5,868
dlevacher/php-git-hg-repo
lib/PHPHg/Repository.php
Repository.checkFiles
public function checkFiles($options = "-m") { try { $output = $this->cmd(sprintf('status %s', $options)); if (strlen($output['output']) == 0) { $output['output'] = "No files modified."; $output['modified'] = false; } else { $output['modified'] = true; } return $output; } catch (Exception $ex) { return $ex; } }
php
public function checkFiles($options = "-m") { try { $output = $this->cmd(sprintf('status %s', $options)); if (strlen($output['output']) == 0) { $output['output'] = "No files modified."; $output['modified'] = false; } else { $output['modified'] = true; } return $output; } catch (Exception $ex) { return $ex; } }
[ "public", "function", "checkFiles", "(", "$", "options", "=", "\"-m\"", ")", "{", "try", "{", "$", "output", "=", "$", "this", "->", "cmd", "(", "sprintf", "(", "'status %s'", ",", "$", "options", ")", ")", ";", "if", "(", "strlen", "(", "$", "output", "[", "'output'", "]", ")", "==", "0", ")", "{", "$", "output", "[", "'output'", "]", "=", "\"No files modified.\"", ";", "$", "output", "[", "'modified'", "]", "=", "false", ";", "}", "else", "{", "$", "output", "[", "'modified'", "]", "=", "true", ";", "}", "return", "$", "output", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "ex", ";", "}", "}" ]
Check if they are local files modified
[ "Check", "if", "they", "are", "local", "files", "modified" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Repository.php#L144-L158
5,869
dlevacher/php-git-hg-repo
lib/PHPHg/Repository.php
Repository.updateClean
public function updateClean($options = "-C") { try { $output = $this->cmd(sprintf('update %s', $options)); return $output; } catch (Exception $ex) { return $ex; } }
php
public function updateClean($options = "-C") { try { $output = $this->cmd(sprintf('update %s', $options)); return $output; } catch (Exception $ex) { return $ex; } }
[ "public", "function", "updateClean", "(", "$", "options", "=", "\"-C\"", ")", "{", "try", "{", "$", "output", "=", "$", "this", "->", "cmd", "(", "sprintf", "(", "'update %s'", ",", "$", "options", ")", ")", ";", "return", "$", "output", ";", "}", "catch", "(", "Exception", "$", "ex", ")", "{", "return", "$", "ex", ";", "}", "}" ]
Clean local modified files
[ "Clean", "local", "modified", "files" ]
415cb600cc8a8cba8817c92c9d6bc4e02f2d7535
https://github.com/dlevacher/php-git-hg-repo/blob/415cb600cc8a8cba8817c92c9d6bc4e02f2d7535/lib/PHPHg/Repository.php#L163-L171
5,870
faustbrian/binary
src/Buffer/Reader/Buffer.php
Buffer.position
public function position(int $value): self { $this->offset = $value; $this->bytes = substr(hex2bin($this->hex), $value); return $this; }
php
public function position(int $value): self { $this->offset = $value; $this->bytes = substr(hex2bin($this->hex), $value); return $this; }
[ "public", "function", "position", "(", "int", "$", "value", ")", ":", "self", "{", "$", "this", "->", "offset", "=", "$", "value", ";", "$", "this", "->", "bytes", "=", "substr", "(", "hex2bin", "(", "$", "this", "->", "hex", ")", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set the cursor to N. @param int $value @return \BrianFaust\Binary\Buffer\Reader\Buffer
[ "Set", "the", "cursor", "to", "N", "." ]
7d845497460c2dabf7e369ec8e55baf989ef74cb
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/Buffer/Reader/Buffer.php#L69-L75
5,871
faustbrian/binary
src/Buffer/Reader/Buffer.php
Buffer.skip
public function skip(int $value): self { $this->offset += $value; $this->bytes = substr($this->bytes, $value); return $this; }
php
public function skip(int $value): self { $this->offset += $value; $this->bytes = substr($this->bytes, $value); return $this; }
[ "public", "function", "skip", "(", "int", "$", "value", ")", ":", "self", "{", "$", "this", "->", "offset", "+=", "$", "value", ";", "$", "this", "->", "bytes", "=", "substr", "(", "$", "this", "->", "bytes", ",", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Move the cursor by N amount of bytes. @param int $value @return \BrianFaust\Binary\Buffer\Reader\Buffer
[ "Move", "the", "cursor", "by", "N", "amount", "of", "bytes", "." ]
7d845497460c2dabf7e369ec8e55baf989ef74cb
https://github.com/faustbrian/binary/blob/7d845497460c2dabf7e369ec8e55baf989ef74cb/src/Buffer/Reader/Buffer.php#L84-L90
5,872
common-libs/user
src/users.php
users.isUser
public static function isUser(string $username): bool { $userdbname = setup::getValidation("username"); if (R::findOne('user', ' ' . $userdbname . ' = ? ', [$username])) { return true; } return false; }
php
public static function isUser(string $username): bool { $userdbname = setup::getValidation("username"); if (R::findOne('user', ' ' . $userdbname . ' = ? ', [$username])) { return true; } return false; }
[ "public", "static", "function", "isUser", "(", "string", "$", "username", ")", ":", "bool", "{", "$", "userdbname", "=", "setup", "::", "getValidation", "(", "\"username\"", ")", ";", "if", "(", "R", "::", "findOne", "(", "'user'", ",", "' '", ".", "$", "userdbname", ".", "' = ? '", ",", "[", "$", "username", "]", ")", ")", "{", "return", "true", ";", "}", "return", "false", ";", "}" ]
checks if a user exists @param string $username Username @return bool
[ "checks", "if", "a", "user", "exists" ]
820fce6748a59e8d692bf613b4694f903d9db6c1
https://github.com/common-libs/user/blob/820fce6748a59e8d692bf613b4694f903d9db6c1/src/users.php#L43-L50
5,873
common-libs/user
src/users.php
users.removeByUsername
public static function removeByUsername(string $username) { $userdbname = setup::getValidation("username"); if ($user = R::findOne('user', ' ' . $userdbname . ' = ? ', [$username])) { R::trash($user); } }
php
public static function removeByUsername(string $username) { $userdbname = setup::getValidation("username"); if ($user = R::findOne('user', ' ' . $userdbname . ' = ? ', [$username])) { R::trash($user); } }
[ "public", "static", "function", "removeByUsername", "(", "string", "$", "username", ")", "{", "$", "userdbname", "=", "setup", "::", "getValidation", "(", "\"username\"", ")", ";", "if", "(", "$", "user", "=", "R", "::", "findOne", "(", "'user'", ",", "' '", ".", "$", "userdbname", ".", "' = ? '", ",", "[", "$", "username", "]", ")", ")", "{", "R", "::", "trash", "(", "$", "user", ")", ";", "}", "}" ]
Removes an user by his name @param string $username Username
[ "Removes", "an", "user", "by", "his", "name" ]
820fce6748a59e8d692bf613b4694f903d9db6c1
https://github.com/common-libs/user/blob/820fce6748a59e8d692bf613b4694f903d9db6c1/src/users.php#L57-L62
5,874
common-libs/user
src/users.php
users.removeById
public static function removeById(int $id) { if ($user = R::findOne('user', ' id = ? ', [$id])) { R::trash($user); } }
php
public static function removeById(int $id) { if ($user = R::findOne('user', ' id = ? ', [$id])) { R::trash($user); } }
[ "public", "static", "function", "removeById", "(", "int", "$", "id", ")", "{", "if", "(", "$", "user", "=", "R", "::", "findOne", "(", "'user'", ",", "' id = ? '", ",", "[", "$", "id", "]", ")", ")", "{", "R", "::", "trash", "(", "$", "user", ")", ";", "}", "}" ]
Removes an user by his id @param integer $id id of user
[ "Removes", "an", "user", "by", "his", "id" ]
820fce6748a59e8d692bf613b4694f903d9db6c1
https://github.com/common-libs/user/blob/820fce6748a59e8d692bf613b4694f903d9db6c1/src/users.php#L69-L73
5,875
dlin-me/geocoder
src/Dlin/Geocoder/Geocoding/GoogleGeocoding.php
GoogleGeocoding._parseComponent
private function _parseComponent($components) { $address = new GeoAddress(); $address->geoCoding = $this->name; $streetNumber = ''; $routeName = ''; foreach ($components as $component) { if (isset($component['types'])) { if (in_array('street_number', $component['types'])) { $streetNumber = $component['short_name']; } if (in_array('route', $component['types'])) { $routeName = $component['short_name']; } if (in_array('administrative_area_level_1', $component['types'])) { $address->state = $component['short_name']; } if (in_array('locality', $component['types'])) { $address->suburb = $component['short_name']; } if (in_array('postal_code', $component['types'])) { $address->postcode = $component['short_name']; } if (in_array('country', $component['types'])) { $address->country = $component['long_name']; } } } if ($routeName || $streetNumber) { $address->addressLine1 = trim($streetNumber . ' ' . $routeName); } return $address; }
php
private function _parseComponent($components) { $address = new GeoAddress(); $address->geoCoding = $this->name; $streetNumber = ''; $routeName = ''; foreach ($components as $component) { if (isset($component['types'])) { if (in_array('street_number', $component['types'])) { $streetNumber = $component['short_name']; } if (in_array('route', $component['types'])) { $routeName = $component['short_name']; } if (in_array('administrative_area_level_1', $component['types'])) { $address->state = $component['short_name']; } if (in_array('locality', $component['types'])) { $address->suburb = $component['short_name']; } if (in_array('postal_code', $component['types'])) { $address->postcode = $component['short_name']; } if (in_array('country', $component['types'])) { $address->country = $component['long_name']; } } } if ($routeName || $streetNumber) { $address->addressLine1 = trim($streetNumber . ' ' . $routeName); } return $address; }
[ "private", "function", "_parseComponent", "(", "$", "components", ")", "{", "$", "address", "=", "new", "GeoAddress", "(", ")", ";", "$", "address", "->", "geoCoding", "=", "$", "this", "->", "name", ";", "$", "streetNumber", "=", "''", ";", "$", "routeName", "=", "''", ";", "foreach", "(", "$", "components", "as", "$", "component", ")", "{", "if", "(", "isset", "(", "$", "component", "[", "'types'", "]", ")", ")", "{", "if", "(", "in_array", "(", "'street_number'", ",", "$", "component", "[", "'types'", "]", ")", ")", "{", "$", "streetNumber", "=", "$", "component", "[", "'short_name'", "]", ";", "}", "if", "(", "in_array", "(", "'route'", ",", "$", "component", "[", "'types'", "]", ")", ")", "{", "$", "routeName", "=", "$", "component", "[", "'short_name'", "]", ";", "}", "if", "(", "in_array", "(", "'administrative_area_level_1'", ",", "$", "component", "[", "'types'", "]", ")", ")", "{", "$", "address", "->", "state", "=", "$", "component", "[", "'short_name'", "]", ";", "}", "if", "(", "in_array", "(", "'locality'", ",", "$", "component", "[", "'types'", "]", ")", ")", "{", "$", "address", "->", "suburb", "=", "$", "component", "[", "'short_name'", "]", ";", "}", "if", "(", "in_array", "(", "'postal_code'", ",", "$", "component", "[", "'types'", "]", ")", ")", "{", "$", "address", "->", "postcode", "=", "$", "component", "[", "'short_name'", "]", ";", "}", "if", "(", "in_array", "(", "'country'", ",", "$", "component", "[", "'types'", "]", ")", ")", "{", "$", "address", "->", "country", "=", "$", "component", "[", "'long_name'", "]", ";", "}", "}", "}", "if", "(", "$", "routeName", "||", "$", "streetNumber", ")", "{", "$", "address", "->", "addressLine1", "=", "trim", "(", "$", "streetNumber", ".", "' '", ".", "$", "routeName", ")", ";", "}", "return", "$", "address", ";", "}" ]
This function use to parse the return components from google geocoding api @param $components @return GeoAddress
[ "This", "function", "use", "to", "parse", "the", "return", "components", "from", "google", "geocoding", "api" ]
50596ff3dcaccd95034e5799ae02fd1c753b5cd2
https://github.com/dlin-me/geocoder/blob/50596ff3dcaccd95034e5799ae02fd1c753b5cd2/src/Dlin/Geocoder/Geocoding/GoogleGeocoding.php#L53-L99
5,876
budkit/budkit-framework
src/Budkit/Application/Support/Mockery.php
Mockery.createAliasMock
public function createAliasMock($alias, $original = null, $autoload = true) { //If we are passing a large array; if (is_array($alias)) { foreach ($alias as $mock => $original) { $this->createAliasMock($mock, $original); } return; } //If the original class is mockable? try { $mockable = new ReflectionClass($original); if ($mockable->implementsInterface(static::$mockableInterface)) { //All mockable classes must use the MockTrait! $traits = $mockable->getTraits(); if (!array_key_exists(static::$mockableTrait, $traits)) { //@TODO throw an exception saying there is no mock; throw new Exception("Mocked class for alias '{$alias}'=>'{$original}' must use the trait 'Budkit\\Application\\Mock'"); return; } //The MockClass Name $class = $alias = ucfirst($alias); if ($mockable->isInstantiable()) { if (!class_exists($class)) { class_alias($original, $class); //Define the original mocking container; return $class::resolveOriginalClass($this, $original); } } } } catch (ReflectionException $E) { //Do nothing; //@TODO maybe log to class saying not mockable; } }
php
public function createAliasMock($alias, $original = null, $autoload = true) { //If we are passing a large array; if (is_array($alias)) { foreach ($alias as $mock => $original) { $this->createAliasMock($mock, $original); } return; } //If the original class is mockable? try { $mockable = new ReflectionClass($original); if ($mockable->implementsInterface(static::$mockableInterface)) { //All mockable classes must use the MockTrait! $traits = $mockable->getTraits(); if (!array_key_exists(static::$mockableTrait, $traits)) { //@TODO throw an exception saying there is no mock; throw new Exception("Mocked class for alias '{$alias}'=>'{$original}' must use the trait 'Budkit\\Application\\Mock'"); return; } //The MockClass Name $class = $alias = ucfirst($alias); if ($mockable->isInstantiable()) { if (!class_exists($class)) { class_alias($original, $class); //Define the original mocking container; return $class::resolveOriginalClass($this, $original); } } } } catch (ReflectionException $E) { //Do nothing; //@TODO maybe log to class saying not mockable; } }
[ "public", "function", "createAliasMock", "(", "$", "alias", ",", "$", "original", "=", "null", ",", "$", "autoload", "=", "true", ")", "{", "//If we are passing a large array;", "if", "(", "is_array", "(", "$", "alias", ")", ")", "{", "foreach", "(", "$", "alias", "as", "$", "mock", "=>", "$", "original", ")", "{", "$", "this", "->", "createAliasMock", "(", "$", "mock", ",", "$", "original", ")", ";", "}", "return", ";", "}", "//If the original class is mockable?", "try", "{", "$", "mockable", "=", "new", "ReflectionClass", "(", "$", "original", ")", ";", "if", "(", "$", "mockable", "->", "implementsInterface", "(", "static", "::", "$", "mockableInterface", ")", ")", "{", "//All mockable classes must use the MockTrait!", "$", "traits", "=", "$", "mockable", "->", "getTraits", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "static", "::", "$", "mockableTrait", ",", "$", "traits", ")", ")", "{", "//@TODO throw an exception saying there is no mock;", "throw", "new", "Exception", "(", "\"Mocked class for alias '{$alias}'=>'{$original}' must use the trait 'Budkit\\\\Application\\\\Mock'\"", ")", ";", "return", ";", "}", "//The MockClass Name", "$", "class", "=", "$", "alias", "=", "ucfirst", "(", "$", "alias", ")", ";", "if", "(", "$", "mockable", "->", "isInstantiable", "(", ")", ")", "{", "if", "(", "!", "class_exists", "(", "$", "class", ")", ")", "{", "class_alias", "(", "$", "original", ",", "$", "class", ")", ";", "//Define the original mocking container;", "return", "$", "class", "::", "resolveOriginalClass", "(", "$", "this", ",", "$", "original", ")", ";", "}", "}", "}", "}", "catch", "(", "ReflectionException", "$", "E", ")", "{", "//Do nothing; //@TODO maybe log to class saying not mockable;", "}", "}" ]
Create a mock of the container object @$alias can also take an array or mocks e.g `[ ["MockName"=>MockableClass::class], ...]` @$original If a single ** *$alias* ** parameter is passed provide the original class name here e.g. `MockableClass::class` @$autoload bool|true $autoload If you will like these mocked classes to be loaded after the containers initiation events @throws Exception if any passed class is not mockable i.e. does not implement the Mockable interface
[ "Create", "a", "mock", "of", "the", "container", "object" ]
0635061815fe07a8c63f9514b845d199b3c0d485
https://github.com/budkit/budkit-framework/blob/0635061815fe07a8c63f9514b845d199b3c0d485/src/Budkit/Application/Support/Mockery.php#L63-L104
5,877
osflab/view
Helper/Bootstrap/Box.php
Box.addNav
public function addNav(Nav $nav) { $nav->setStacked(); $this->setContent((string) $nav); $this->setStackContainer(); return $this; }
php
public function addNav(Nav $nav) { $nav->setStacked(); $this->setContent((string) $nav); $this->setStackContainer(); return $this; }
[ "public", "function", "addNav", "(", "Nav", "$", "nav", ")", "{", "$", "nav", "->", "setStacked", "(", ")", ";", "$", "this", "->", "setContent", "(", "(", "string", ")", "$", "nav", ")", ";", "$", "this", "->", "setStackContainer", "(", ")", ";", "return", "$", "this", ";", "}" ]
Add nav in content @param \Osf\View\Helper\Bootstrap\Nav $nav @return $this
[ "Add", "nav", "in", "content" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Box.php#L141-L147
5,878
osflab/view
Helper/Bootstrap/Box.php
Box.setContentHtmlTable
public function setContentHtmlTable(bool $responsive = true) { $this->setStackContainer(); $this->addCssClass($responsive ? 'table-responsive' : 'table'); return $this; }
php
public function setContentHtmlTable(bool $responsive = true) { $this->setStackContainer(); $this->addCssClass($responsive ? 'table-responsive' : 'table'); return $this; }
[ "public", "function", "setContentHtmlTable", "(", "bool", "$", "responsive", "=", "true", ")", "{", "$", "this", "->", "setStackContainer", "(", ")", ";", "$", "this", "->", "addCssClass", "(", "$", "responsive", "?", "'table-responsive'", ":", "'table'", ")", ";", "return", "$", "this", ";", "}" ]
Content is html table @param bool $responsive @return $this
[ "Content", "is", "html", "table" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Box.php#L173-L178
5,879
osflab/view
Helper/Bootstrap/Box.php
Box.render
public function render() { $this->addCssClass('box'); $this->addCssClass('box-' . $this->getStatus(), $this->getStatus()); $this->addCssClass('collapsed-box', $this->expandable); $this->addCssClass('box-solid', $this->coloredTitleBox); $boxTools = isset($this->badges[0]) || $this->expandable || $this->collapsable || $this->removable; $badges = isset($this->badges[0]) ? $this->getBadgesHtml() : ''; return $this ->html('<div id="' . $this->containerId . '">', $this->containerId) ->html($this->getPrepend(), $this->hasPrepend()) ->html('<div' . $this->getEltDecorationStr() . '>') ->html(' <div class="box-header with-border">') ->html(' <div class="lg-head">', $this->largeHeader) ->html(' ' . $this->getIconHtml(), $this->icon) ->html(' <h3 class="box-title">' . $this->title . '</h3>') ->html(' </div>', $this->largeHeader) ->html(' <div class="box-tools pull-right">', $boxTools) ->html($badges) ->html(' <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>', $this->expandable) ->html(' <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>', $this->collapsable) ->html(' <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>', $this->removable) ->html(' </div>', $boxTools) ->html(' <div class="pull-right">' . $this->header . '</div>', $this->header) ->html(' </div>') ->html(' <div class="box-body' . ($this->stackContainer ? ' no-padding' : '') . '">' . $this->content . '</div>') ->html(' <div class="' . implode(' ', $this->footerClasses) . '">', $this->footer) ->html(' <div class="pull-right">', $this->footer && $this->footerAlignRight) ->html($this->footer, $this->footer) ->html(' </div>', $this->footer && $this->footerAlignRight) ->html(' </div>', $this->footer) ->html('</div>') ->html($this->getAppend(), $this->hasAppend()) ->html('</div>', $this->containerId) ->getHtml(); }
php
public function render() { $this->addCssClass('box'); $this->addCssClass('box-' . $this->getStatus(), $this->getStatus()); $this->addCssClass('collapsed-box', $this->expandable); $this->addCssClass('box-solid', $this->coloredTitleBox); $boxTools = isset($this->badges[0]) || $this->expandable || $this->collapsable || $this->removable; $badges = isset($this->badges[0]) ? $this->getBadgesHtml() : ''; return $this ->html('<div id="' . $this->containerId . '">', $this->containerId) ->html($this->getPrepend(), $this->hasPrepend()) ->html('<div' . $this->getEltDecorationStr() . '>') ->html(' <div class="box-header with-border">') ->html(' <div class="lg-head">', $this->largeHeader) ->html(' ' . $this->getIconHtml(), $this->icon) ->html(' <h3 class="box-title">' . $this->title . '</h3>') ->html(' </div>', $this->largeHeader) ->html(' <div class="box-tools pull-right">', $boxTools) ->html($badges) ->html(' <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-plus"></i></button>', $this->expandable) ->html(' <button type="button" class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>', $this->collapsable) ->html(' <button type="button" class="btn btn-box-tool" data-widget="remove"><i class="fa fa-times"></i></button>', $this->removable) ->html(' </div>', $boxTools) ->html(' <div class="pull-right">' . $this->header . '</div>', $this->header) ->html(' </div>') ->html(' <div class="box-body' . ($this->stackContainer ? ' no-padding' : '') . '">' . $this->content . '</div>') ->html(' <div class="' . implode(' ', $this->footerClasses) . '">', $this->footer) ->html(' <div class="pull-right">', $this->footer && $this->footerAlignRight) ->html($this->footer, $this->footer) ->html(' </div>', $this->footer && $this->footerAlignRight) ->html(' </div>', $this->footer) ->html('</div>') ->html($this->getAppend(), $this->hasAppend()) ->html('</div>', $this->containerId) ->getHtml(); }
[ "public", "function", "render", "(", ")", "{", "$", "this", "->", "addCssClass", "(", "'box'", ")", ";", "$", "this", "->", "addCssClass", "(", "'box-'", ".", "$", "this", "->", "getStatus", "(", ")", ",", "$", "this", "->", "getStatus", "(", ")", ")", ";", "$", "this", "->", "addCssClass", "(", "'collapsed-box'", ",", "$", "this", "->", "expandable", ")", ";", "$", "this", "->", "addCssClass", "(", "'box-solid'", ",", "$", "this", "->", "coloredTitleBox", ")", ";", "$", "boxTools", "=", "isset", "(", "$", "this", "->", "badges", "[", "0", "]", ")", "||", "$", "this", "->", "expandable", "||", "$", "this", "->", "collapsable", "||", "$", "this", "->", "removable", ";", "$", "badges", "=", "isset", "(", "$", "this", "->", "badges", "[", "0", "]", ")", "?", "$", "this", "->", "getBadgesHtml", "(", ")", ":", "''", ";", "return", "$", "this", "->", "html", "(", "'<div id=\"'", ".", "$", "this", "->", "containerId", ".", "'\">'", ",", "$", "this", "->", "containerId", ")", "->", "html", "(", "$", "this", "->", "getPrepend", "(", ")", ",", "$", "this", "->", "hasPrepend", "(", ")", ")", "->", "html", "(", "'<div'", ".", "$", "this", "->", "getEltDecorationStr", "(", ")", ".", "'>'", ")", "->", "html", "(", "' <div class=\"box-header with-border\">'", ")", "->", "html", "(", "' <div class=\"lg-head\">'", ",", "$", "this", "->", "largeHeader", ")", "->", "html", "(", "' '", ".", "$", "this", "->", "getIconHtml", "(", ")", ",", "$", "this", "->", "icon", ")", "->", "html", "(", "' <h3 class=\"box-title\">'", ".", "$", "this", "->", "title", ".", "'</h3>'", ")", "->", "html", "(", "' </div>'", ",", "$", "this", "->", "largeHeader", ")", "->", "html", "(", "' <div class=\"box-tools pull-right\">'", ",", "$", "boxTools", ")", "->", "html", "(", "$", "badges", ")", "->", "html", "(", "' <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"collapse\"><i class=\"fa fa-plus\"></i></button>'", ",", "$", "this", "->", "expandable", ")", "->", "html", "(", "' <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"collapse\"><i class=\"fa fa-minus\"></i></button>'", ",", "$", "this", "->", "collapsable", ")", "->", "html", "(", "' <button type=\"button\" class=\"btn btn-box-tool\" data-widget=\"remove\"><i class=\"fa fa-times\"></i></button>'", ",", "$", "this", "->", "removable", ")", "->", "html", "(", "' </div>'", ",", "$", "boxTools", ")", "->", "html", "(", "' <div class=\"pull-right\">'", ".", "$", "this", "->", "header", ".", "'</div>'", ",", "$", "this", "->", "header", ")", "->", "html", "(", "' </div>'", ")", "->", "html", "(", "' <div class=\"box-body'", ".", "(", "$", "this", "->", "stackContainer", "?", "' no-padding'", ":", "''", ")", ".", "'\">'", ".", "$", "this", "->", "content", ".", "'</div>'", ")", "->", "html", "(", "' <div class=\"'", ".", "implode", "(", "' '", ",", "$", "this", "->", "footerClasses", ")", ".", "'\">'", ",", "$", "this", "->", "footer", ")", "->", "html", "(", "' <div class=\"pull-right\">'", ",", "$", "this", "->", "footer", "&&", "$", "this", "->", "footerAlignRight", ")", "->", "html", "(", "$", "this", "->", "footer", ",", "$", "this", "->", "footer", ")", "->", "html", "(", "' </div>'", ",", "$", "this", "->", "footer", "&&", "$", "this", "->", "footerAlignRight", ")", "->", "html", "(", "' </div>'", ",", "$", "this", "->", "footer", ")", "->", "html", "(", "'</div>'", ")", "->", "html", "(", "$", "this", "->", "getAppend", "(", ")", ",", "$", "this", "->", "hasAppend", "(", ")", ")", "->", "html", "(", "'</div>'", ",", "$", "this", "->", "containerId", ")", "->", "getHtml", "(", ")", ";", "}" ]
Render the box at the end of configuration @return string
[ "Render", "the", "box", "at", "the", "end", "of", "configuration" ]
e06601013e8ec86dc2055e000e58dffd963c78e2
https://github.com/osflab/view/blob/e06601013e8ec86dc2055e000e58dffd963c78e2/Helper/Bootstrap/Box.php#L220-L255
5,880
xloit/xloit-bridge-zend-validator
src/File/IsImage.php
IsImage.isValid
public function isValid($value, $file = null) { if ($this->allowEmpty && $this->isFileEmpty($value, $file)) { return true; } return parent::isValid($value, $file); }
php
public function isValid($value, $file = null) { if ($this->allowEmpty && $this->isFileEmpty($value, $file)) { return true; } return parent::isValid($value, $file); }
[ "public", "function", "isValid", "(", "$", "value", ",", "$", "file", "=", "null", ")", "{", "if", "(", "$", "this", "->", "allowEmpty", "&&", "$", "this", "->", "isFileEmpty", "(", "$", "value", ",", "$", "file", ")", ")", "{", "return", "true", ";", "}", "return", "parent", "::", "isValid", "(", "$", "value", ",", "$", "file", ")", ";", "}" ]
Returns true if and only if the file input is an image. @param string|array $value Real file to check. @param array $file File data from {@link \Zend\File\Transfer\Transfer} (optional). @return bool
[ "Returns", "true", "if", "and", "only", "if", "the", "file", "input", "is", "an", "image", "." ]
2e789986e6551f157d4e07cf4c27d027dd070324
https://github.com/xloit/xloit-bridge-zend-validator/blob/2e789986e6551f157d4e07cf4c27d027dd070324/src/File/IsImage.php#L39-L46
5,881
routegroup/native-media
src/Helpers/Thumbnail.php
Thumbnail.name
public function name($width, $height = null) { $parts = explode('.', $this->file->filename); $extension = array_pop($parts); $prefix = '-' . $width . 'x' . ($height ?: $width); $name = implode('.', $parts) . $prefix; return "{$name}.{$extension}"; }
php
public function name($width, $height = null) { $parts = explode('.', $this->file->filename); $extension = array_pop($parts); $prefix = '-' . $width . 'x' . ($height ?: $width); $name = implode('.', $parts) . $prefix; return "{$name}.{$extension}"; }
[ "public", "function", "name", "(", "$", "width", ",", "$", "height", "=", "null", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "this", "->", "file", "->", "filename", ")", ";", "$", "extension", "=", "array_pop", "(", "$", "parts", ")", ";", "$", "prefix", "=", "'-'", ".", "$", "width", ".", "'x'", ".", "(", "$", "height", "?", ":", "$", "width", ")", ";", "$", "name", "=", "implode", "(", "'.'", ",", "$", "parts", ")", ".", "$", "prefix", ";", "return", "\"{$name}.{$extension}\"", ";", "}" ]
Resolves thumbnail name. @param integer $width @param integer $height @return string
[ "Resolves", "thumbnail", "name", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Helpers/Thumbnail.php#L34-L45
5,882
routegroup/native-media
src/Helpers/Thumbnail.php
Thumbnail.exists
public function exists($filename) { return $this->file->storage->exists($this->file->path($filename)); }
php
public function exists($filename) { return $this->file->storage->exists($this->file->path($filename)); }
[ "public", "function", "exists", "(", "$", "filename", ")", "{", "return", "$", "this", "->", "file", "->", "storage", "->", "exists", "(", "$", "this", "->", "file", "->", "path", "(", "$", "filename", ")", ")", ";", "}" ]
Check if thumbnail with given name exists. @param string $filename @return boolean
[ "Check", "if", "thumbnail", "with", "given", "name", "exists", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Helpers/Thumbnail.php#L53-L56
5,883
routegroup/native-media
src/Helpers/Thumbnail.php
Thumbnail.create
public function create($filename, $width, $height = null) { try { $image = app('image')->make($this->file->realPath) ->fit($width, ($height ?: $width)) ->encode(); $this->file->storage->put($this->file->path($filename), $image); } catch (NotReadableException $e) { return null; } return $this->file->storage->url($this->file->path($filename)); }
php
public function create($filename, $width, $height = null) { try { $image = app('image')->make($this->file->realPath) ->fit($width, ($height ?: $width)) ->encode(); $this->file->storage->put($this->file->path($filename), $image); } catch (NotReadableException $e) { return null; } return $this->file->storage->url($this->file->path($filename)); }
[ "public", "function", "create", "(", "$", "filename", ",", "$", "width", ",", "$", "height", "=", "null", ")", "{", "try", "{", "$", "image", "=", "app", "(", "'image'", ")", "->", "make", "(", "$", "this", "->", "file", "->", "realPath", ")", "->", "fit", "(", "$", "width", ",", "(", "$", "height", "?", ":", "$", "width", ")", ")", "->", "encode", "(", ")", ";", "$", "this", "->", "file", "->", "storage", "->", "put", "(", "$", "this", "->", "file", "->", "path", "(", "$", "filename", ")", ",", "$", "image", ")", ";", "}", "catch", "(", "NotReadableException", "$", "e", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "file", "->", "storage", "->", "url", "(", "$", "this", "->", "file", "->", "path", "(", "$", "filename", ")", ")", ";", "}" ]
Create thumbnail. @param string $filename @param integer $width @param integer|null $height @return string
[ "Create", "thumbnail", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Helpers/Thumbnail.php#L66-L79
5,884
routegroup/native-media
src/Helpers/Thumbnail.php
Thumbnail.lists
public function lists() { $parts = explode('.', $this->file->filename); $extension = array_pop($parts); $name = $this->file->path(implode('.', $parts)); $files = glob($this->file->realPath("{$name}-*")); array_walk($files, function (&$file) { $file = substr($file, strrpos($file, '/') + 1, strlen($file)); $file = $this->file->path($file); }); return collect($files); }
php
public function lists() { $parts = explode('.', $this->file->filename); $extension = array_pop($parts); $name = $this->file->path(implode('.', $parts)); $files = glob($this->file->realPath("{$name}-*")); array_walk($files, function (&$file) { $file = substr($file, strrpos($file, '/') + 1, strlen($file)); $file = $this->file->path($file); }); return collect($files); }
[ "public", "function", "lists", "(", ")", "{", "$", "parts", "=", "explode", "(", "'.'", ",", "$", "this", "->", "file", "->", "filename", ")", ";", "$", "extension", "=", "array_pop", "(", "$", "parts", ")", ";", "$", "name", "=", "$", "this", "->", "file", "->", "path", "(", "implode", "(", "'.'", ",", "$", "parts", ")", ")", ";", "$", "files", "=", "glob", "(", "$", "this", "->", "file", "->", "realPath", "(", "\"{$name}-*\"", ")", ")", ";", "array_walk", "(", "$", "files", ",", "function", "(", "&", "$", "file", ")", "{", "$", "file", "=", "substr", "(", "$", "file", ",", "strrpos", "(", "$", "file", ",", "'/'", ")", "+", "1", ",", "strlen", "(", "$", "file", ")", ")", ";", "$", "file", "=", "$", "this", "->", "file", "->", "path", "(", "$", "file", ")", ";", "}", ")", ";", "return", "collect", "(", "$", "files", ")", ";", "}" ]
Return all thumbnails. @return \Illuminate\Support\Collection
[ "Return", "all", "thumbnails", "." ]
5ea35c46c2ac1019e277ec4fe698f17581524631
https://github.com/routegroup/native-media/blob/5ea35c46c2ac1019e277ec4fe698f17581524631/src/Helpers/Thumbnail.php#L86-L102
5,885
neemzy/patchwork-core
src/Controller/EntityController.php
EntityController.connect
public function connect(Application $app) { $this->modelProvider = function ($id) use ($app) { return $app['redbean']->load($this->table, $id); }; return $app['controllers_factory']; }
php
public function connect(Application $app) { $this->modelProvider = function ($id) use ($app) { return $app['redbean']->load($this->table, $id); }; return $app['controllers_factory']; }
[ "public", "function", "connect", "(", "Application", "$", "app", ")", "{", "$", "this", "->", "modelProvider", "=", "function", "(", "$", "id", ")", "use", "(", "$", "app", ")", "{", "return", "$", "app", "[", "'redbean'", "]", "->", "load", "(", "$", "this", "->", "table", ",", "$", "id", ")", ";", "}", ";", "return", "$", "app", "[", "'controllers_factory'", "]", ";", "}" ]
Silex method that exposes routes to the app Attaches a model provider to the controller @param Silex\Application $app Application instance @return Silex\ControllerCollection Object encapsulating crafted routes
[ "Silex", "method", "that", "exposes", "routes", "to", "the", "app", "Attaches", "a", "model", "provider", "to", "the", "controller" ]
81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee
https://github.com/neemzy/patchwork-core/blob/81c31b5c0b3a82a04ed90eb17cefaf2faddee4ee/src/Controller/EntityController.php#L44-L51
5,886
Apatis/Prima
src/Service.php
Service.getNormalizeResponseChunkSize
public function getNormalizeResponseChunkSize() : int { $chunkSize = $this->getConfiguration('responseChunkSize', static::DEFAULT_CHUNK_SIZE); $chunkSize = ! is_numeric($chunkSize) ? static::DEFAULT_CHUNK_SIZE : intval(abs($chunkSize)); $chunkSize = $chunkSize < 512 ? 512 : $chunkSize; return $chunkSize; }
php
public function getNormalizeResponseChunkSize() : int { $chunkSize = $this->getConfiguration('responseChunkSize', static::DEFAULT_CHUNK_SIZE); $chunkSize = ! is_numeric($chunkSize) ? static::DEFAULT_CHUNK_SIZE : intval(abs($chunkSize)); $chunkSize = $chunkSize < 512 ? 512 : $chunkSize; return $chunkSize; }
[ "public", "function", "getNormalizeResponseChunkSize", "(", ")", ":", "int", "{", "$", "chunkSize", "=", "$", "this", "->", "getConfiguration", "(", "'responseChunkSize'", ",", "static", "::", "DEFAULT_CHUNK_SIZE", ")", ";", "$", "chunkSize", "=", "!", "is_numeric", "(", "$", "chunkSize", ")", "?", "static", "::", "DEFAULT_CHUNK_SIZE", ":", "intval", "(", "abs", "(", "$", "chunkSize", ")", ")", ";", "$", "chunkSize", "=", "$", "chunkSize", "<", "512", "?", "512", ":", "$", "chunkSize", ";", "return", "$", "chunkSize", ";", "}" ]
Get normalized chunk size from configuration @return int chunk size
[ "Get", "normalized", "chunk", "size", "from", "configuration" ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L281-L287
5,887
Apatis/Prima
src/Service.php
Service.setConfig
public function setConfig(ConfigInterface $config) { // get keys & flip $configKeys = array_flip($config->keys()); // put default config foreach ($this->defaultConfiguration as $key => $value) { if (!isset($configKeys[$key])) { $config->set($key, $value); } } $this->config = $config; }
php
public function setConfig(ConfigInterface $config) { // get keys & flip $configKeys = array_flip($config->keys()); // put default config foreach ($this->defaultConfiguration as $key => $value) { if (!isset($configKeys[$key])) { $config->set($key, $value); } } $this->config = $config; }
[ "public", "function", "setConfig", "(", "ConfigInterface", "$", "config", ")", "{", "// get keys & flip", "$", "configKeys", "=", "array_flip", "(", "$", "config", "->", "keys", "(", ")", ")", ";", "// put default config", "foreach", "(", "$", "this", "->", "defaultConfiguration", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "isset", "(", "$", "configKeys", "[", "$", "key", "]", ")", ")", "{", "$", "config", "->", "set", "(", "$", "key", ",", "$", "value", ")", ";", "}", "}", "$", "this", "->", "config", "=", "$", "config", ";", "}" ]
Set config object Behavior this will be override your current configuration @param ConfigInterface $config
[ "Set", "config", "object", "Behavior", "this", "will", "be", "override", "your", "current", "configuration" ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L326-L338
5,888
Apatis/Prima
src/Service.php
Service.getRouter
public function getRouter() : RouterInterface { if (! $this->router instanceof RouterInterface) { $router = new Router(); $resolver = $this->getCallbackResolver(); if ($resolver instanceof CallbackResolverInterface) { $router->setCallbackResolver($resolver); } $routerCacheFile = $this->getConfiguration('routerCacheFile', false); if ($routerCacheFile) { $router->setCacheFile($routerCacheFile); } $this->router = $router; } return $this->router; }
php
public function getRouter() : RouterInterface { if (! $this->router instanceof RouterInterface) { $router = new Router(); $resolver = $this->getCallbackResolver(); if ($resolver instanceof CallbackResolverInterface) { $router->setCallbackResolver($resolver); } $routerCacheFile = $this->getConfiguration('routerCacheFile', false); if ($routerCacheFile) { $router->setCacheFile($routerCacheFile); } $this->router = $router; } return $this->router; }
[ "public", "function", "getRouter", "(", ")", ":", "RouterInterface", "{", "if", "(", "!", "$", "this", "->", "router", "instanceof", "RouterInterface", ")", "{", "$", "router", "=", "new", "Router", "(", ")", ";", "$", "resolver", "=", "$", "this", "->", "getCallbackResolver", "(", ")", ";", "if", "(", "$", "resolver", "instanceof", "CallbackResolverInterface", ")", "{", "$", "router", "->", "setCallbackResolver", "(", "$", "resolver", ")", ";", "}", "$", "routerCacheFile", "=", "$", "this", "->", "getConfiguration", "(", "'routerCacheFile'", ",", "false", ")", ";", "if", "(", "$", "routerCacheFile", ")", "{", "$", "router", "->", "setCacheFile", "(", "$", "routerCacheFile", ")", ";", "}", "$", "this", "->", "router", "=", "$", "router", ";", "}", "return", "$", "this", "->", "router", ";", "}" ]
Get router handler @return RouterInterface
[ "Get", "router", "handler" ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L406-L424
5,889
Apatis/Prima
src/Service.php
Service.getCallbackResolver
public function getCallbackResolver() { if (! $this->callbackResolver instanceof CallbackResolverInterface) { $this->callbackResolver = new CallbackResolver($this); } return $this->callbackResolver; }
php
public function getCallbackResolver() { if (! $this->callbackResolver instanceof CallbackResolverInterface) { $this->callbackResolver = new CallbackResolver($this); } return $this->callbackResolver; }
[ "public", "function", "getCallbackResolver", "(", ")", "{", "if", "(", "!", "$", "this", "->", "callbackResolver", "instanceof", "CallbackResolverInterface", ")", "{", "$", "this", "->", "callbackResolver", "=", "new", "CallbackResolver", "(", "$", "this", ")", ";", "}", "return", "$", "this", "->", "callbackResolver", ";", "}" ]
Get callable resolver @return CallbackResolverInterface|null
[ "Get", "callable", "resolver" ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L443-L450
5,890
Apatis/Prima
src/Service.php
Service.shutdownHandlerCallback
protected function shutdownHandlerCallback( ServerRequestInterface $request, ResponseInterface $response ) : callable { /** * Shutdown Handler */ return function () use($request, $response) { if ($this->haltShutDown === true) { return; } $lastError = error_get_last(); if (empty($lastError['type']) // check if error type is valid error || ! in_array($lastError['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR]) ) { return; } // serve the end of response $this->serveResponse( $this->getErrorHandler()( $request, $response, new \Error($lastError['message'], $lastError['type']) )); // exit with 255 code exit(255); }; }
php
protected function shutdownHandlerCallback( ServerRequestInterface $request, ResponseInterface $response ) : callable { /** * Shutdown Handler */ return function () use($request, $response) { if ($this->haltShutDown === true) { return; } $lastError = error_get_last(); if (empty($lastError['type']) // check if error type is valid error || ! in_array($lastError['type'], [E_ERROR, E_CORE_ERROR, E_COMPILE_ERROR]) ) { return; } // serve the end of response $this->serveResponse( $this->getErrorHandler()( $request, $response, new \Error($lastError['message'], $lastError['type']) )); // exit with 255 code exit(255); }; }
[ "protected", "function", "shutdownHandlerCallback", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ")", ":", "callable", "{", "/**\n * Shutdown Handler\n */", "return", "function", "(", ")", "use", "(", "$", "request", ",", "$", "response", ")", "{", "if", "(", "$", "this", "->", "haltShutDown", "===", "true", ")", "{", "return", ";", "}", "$", "lastError", "=", "error_get_last", "(", ")", ";", "if", "(", "empty", "(", "$", "lastError", "[", "'type'", "]", ")", "// check if error type is valid error", "||", "!", "in_array", "(", "$", "lastError", "[", "'type'", "]", ",", "[", "E_ERROR", ",", "E_CORE_ERROR", ",", "E_COMPILE_ERROR", "]", ")", ")", "{", "return", ";", "}", "// serve the end of response", "$", "this", "->", "serveResponse", "(", "$", "this", "->", "getErrorHandler", "(", ")", "(", "$", "request", ",", "$", "response", ",", "new", "\\", "Error", "(", "$", "lastError", "[", "'message'", "]", ",", "$", "lastError", "[", "'type'", "]", ")", ")", ")", ";", "// exit with 255 code", "exit", "(", "255", ")", ";", "}", ";", "}" ]
Shutdown Handler callback to print Output Response @param ServerRequestInterface $request @param ResponseInterface $response @return callable
[ "Shutdown", "Handler", "callback", "to", "print", "Output", "Response" ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L579-L607
5,891
Apatis/Prima
src/Service.php
Service.handleForResponseException
protected function handleForResponseException( ServerRequestInterface $request, ResponseInterface $response, \Throwable $e ) : ResponseInterface { if ($e instanceof MethodNotAllowedException) { $handler = $this->getNotAllowedHandler(); } elseif ($e instanceof NotFoundException) { $handler = $this->getNotFoundHandler(); } elseif ($e instanceof \Exception) { $handler = $this->getExceptionHandler(); } else { $handler = $this->getErrorHandler(); } $response = $handler($request, $response, $e); // check if buffer is zero and add the buffer if (ob_get_level() === 0) { $this->addCreateBuffer(); } return $response; }
php
protected function handleForResponseException( ServerRequestInterface $request, ResponseInterface $response, \Throwable $e ) : ResponseInterface { if ($e instanceof MethodNotAllowedException) { $handler = $this->getNotAllowedHandler(); } elseif ($e instanceof NotFoundException) { $handler = $this->getNotFoundHandler(); } elseif ($e instanceof \Exception) { $handler = $this->getExceptionHandler(); } else { $handler = $this->getErrorHandler(); } $response = $handler($request, $response, $e); // check if buffer is zero and add the buffer if (ob_get_level() === 0) { $this->addCreateBuffer(); } return $response; }
[ "protected", "function", "handleForResponseException", "(", "ServerRequestInterface", "$", "request", ",", "ResponseInterface", "$", "response", ",", "\\", "Throwable", "$", "e", ")", ":", "ResponseInterface", "{", "if", "(", "$", "e", "instanceof", "MethodNotAllowedException", ")", "{", "$", "handler", "=", "$", "this", "->", "getNotAllowedHandler", "(", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "NotFoundException", ")", "{", "$", "handler", "=", "$", "this", "->", "getNotFoundHandler", "(", ")", ";", "}", "elseif", "(", "$", "e", "instanceof", "\\", "Exception", ")", "{", "$", "handler", "=", "$", "this", "->", "getExceptionHandler", "(", ")", ";", "}", "else", "{", "$", "handler", "=", "$", "this", "->", "getErrorHandler", "(", ")", ";", "}", "$", "response", "=", "$", "handler", "(", "$", "request", ",", "$", "response", ",", "$", "e", ")", ";", "// check if buffer is zero and add the buffer", "if", "(", "ob_get_level", "(", ")", "===", "0", ")", "{", "$", "this", "->", "addCreateBuffer", "(", ")", ";", "}", "return", "$", "response", ";", "}" ]
Handle Response Exception @param ServerRequestInterface $request @param ResponseInterface $response @param \Throwable $e @return ResponseInterface
[ "Handle", "Response", "Exception" ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L817-L840
5,892
Apatis/Prima
src/Service.php
Service.dispatchRouterRoute
protected function dispatchRouterRoute( ServerRequestInterface $request, RouterInterface $router ) : ServerRequestInterface { $routeInfo = $router->dispatch($request); if ($routeInfo[0] === Dispatcher::FOUND) { $routeArguments = []; foreach ($routeInfo[2] as $k => $v) { $routeArguments[$k] = urldecode($v); } $route = $router->getRouteByIdentifier($routeInfo[1]); $route->prepare($request, $routeArguments); /** * Add route to request to allow handler or other access route */ $request = $request->withAttribute('route', $route); } $routeInfo['request'] = [$request->getMethod(), (string) $request->getUri()]; return $request->withAttribute('routeInfo', $routeInfo); }
php
protected function dispatchRouterRoute( ServerRequestInterface $request, RouterInterface $router ) : ServerRequestInterface { $routeInfo = $router->dispatch($request); if ($routeInfo[0] === Dispatcher::FOUND) { $routeArguments = []; foreach ($routeInfo[2] as $k => $v) { $routeArguments[$k] = urldecode($v); } $route = $router->getRouteByIdentifier($routeInfo[1]); $route->prepare($request, $routeArguments); /** * Add route to request to allow handler or other access route */ $request = $request->withAttribute('route', $route); } $routeInfo['request'] = [$request->getMethod(), (string) $request->getUri()]; return $request->withAttribute('routeInfo', $routeInfo); }
[ "protected", "function", "dispatchRouterRoute", "(", "ServerRequestInterface", "$", "request", ",", "RouterInterface", "$", "router", ")", ":", "ServerRequestInterface", "{", "$", "routeInfo", "=", "$", "router", "->", "dispatch", "(", "$", "request", ")", ";", "if", "(", "$", "routeInfo", "[", "0", "]", "===", "Dispatcher", "::", "FOUND", ")", "{", "$", "routeArguments", "=", "[", "]", ";", "foreach", "(", "$", "routeInfo", "[", "2", "]", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "routeArguments", "[", "$", "k", "]", "=", "urldecode", "(", "$", "v", ")", ";", "}", "$", "route", "=", "$", "router", "->", "getRouteByIdentifier", "(", "$", "routeInfo", "[", "1", "]", ")", ";", "$", "route", "->", "prepare", "(", "$", "request", ",", "$", "routeArguments", ")", ";", "/**\n * Add route to request to allow handler or other access route\n */", "$", "request", "=", "$", "request", "->", "withAttribute", "(", "'route'", ",", "$", "route", ")", ";", "}", "$", "routeInfo", "[", "'request'", "]", "=", "[", "$", "request", "->", "getMethod", "(", ")", ",", "(", "string", ")", "$", "request", "->", "getUri", "(", ")", "]", ";", "return", "$", "request", "->", "withAttribute", "(", "'routeInfo'", ",", "$", "routeInfo", ")", ";", "}" ]
Dispatch the router to find the route. Prepare the route for use. @param ServerRequestInterface $request @param RouterInterface $router @return ServerRequestInterface
[ "Dispatch", "the", "router", "to", "find", "the", "route", ".", "Prepare", "the", "route", "for", "use", "." ]
342cb8e51f185413a2ee1a769674da0bdc7368e6
https://github.com/Apatis/Prima/blob/342cb8e51f185413a2ee1a769674da0bdc7368e6/src/Service.php#L960-L981
5,893
derokorian/gen-synth
src/GenSynth.php
GenSynth.highlight_string
public static function highlight_string($source, $language, $return = false, $opts = 0) { if (is_int($return)) { $opts = $return; $return = false; } $gs = new static($source, $language, $opts); $s = $gs->parseCode(); if ($gs->error()) { return false; } if ($return) { return '<code>' . $s . '</code>'; } echo '<code>' . $s . '</code>'; return true; }
php
public static function highlight_string($source, $language, $return = false, $opts = 0) { if (is_int($return)) { $opts = $return; $return = false; } $gs = new static($source, $language, $opts); $s = $gs->parseCode(); if ($gs->error()) { return false; } if ($return) { return '<code>' . $s . '</code>'; } echo '<code>' . $s . '</code>'; return true; }
[ "public", "static", "function", "highlight_string", "(", "$", "source", ",", "$", "language", ",", "$", "return", "=", "false", ",", "$", "opts", "=", "0", ")", "{", "if", "(", "is_int", "(", "$", "return", ")", ")", "{", "$", "opts", "=", "$", "return", ";", "$", "return", "=", "false", ";", "}", "$", "gs", "=", "new", "static", "(", "$", "source", ",", "$", "language", ",", "$", "opts", ")", ";", "$", "s", "=", "$", "gs", "->", "parseCode", "(", ")", ";", "if", "(", "$", "gs", "->", "error", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "return", ")", "{", "return", "'<code>'", ".", "$", "s", ".", "'</code>'", ";", "}", "echo", "'<code>'", ".", "$", "s", ".", "'</code>'", ";", "return", "true", ";", "}" ]
Easy way to highlight stuff. Behaves just like highlight_string @param string $source @param string $language @param bool $return [Default: false] *Can be skipped* @param int $opts [Default: 0] @return bool|string
[ "Easy", "way", "to", "highlight", "stuff", ".", "Behaves", "just", "like", "highlight_string" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L389-L409
5,894
derokorian/gen-synth
src/GenSynth.php
GenSynth.highlight_file
public static function highlight_file($filename, $language = '', $return = false, $opts = 0) { if (is_bool($language)) { !is_int($return) ?: $opts = $return; $return = $language; $language = ''; } elseif (is_int($language)) { $opts = $language; $language = ''; } if (file_exists($filename) && is_readable($filename)) { $gs = new static($filename, '', $opts); if ($language == '') { $ext = pathinfo($filename, PATHINFO_EXTENSION); $language = $gs->get_language_name_from_extension($ext); } $gs->setLanguage($language); $s = $gs->parseCode(); if ($gs->error()) { return false; } if ($return) { return '<code>' . $s . '</code>'; } echo '<code>' . $s . '</code>'; return true; } return false; }
php
public static function highlight_file($filename, $language = '', $return = false, $opts = 0) { if (is_bool($language)) { !is_int($return) ?: $opts = $return; $return = $language; $language = ''; } elseif (is_int($language)) { $opts = $language; $language = ''; } if (file_exists($filename) && is_readable($filename)) { $gs = new static($filename, '', $opts); if ($language == '') { $ext = pathinfo($filename, PATHINFO_EXTENSION); $language = $gs->get_language_name_from_extension($ext); } $gs->setLanguage($language); $s = $gs->parseCode(); if ($gs->error()) { return false; } if ($return) { return '<code>' . $s . '</code>'; } echo '<code>' . $s . '</code>'; return true; } return false; }
[ "public", "static", "function", "highlight_file", "(", "$", "filename", ",", "$", "language", "=", "''", ",", "$", "return", "=", "false", ",", "$", "opts", "=", "0", ")", "{", "if", "(", "is_bool", "(", "$", "language", ")", ")", "{", "!", "is_int", "(", "$", "return", ")", "?", ":", "$", "opts", "=", "$", "return", ";", "$", "return", "=", "$", "language", ";", "$", "language", "=", "''", ";", "}", "elseif", "(", "is_int", "(", "$", "language", ")", ")", "{", "$", "opts", "=", "$", "language", ";", "$", "language", "=", "''", ";", "}", "if", "(", "file_exists", "(", "$", "filename", ")", "&&", "is_readable", "(", "$", "filename", ")", ")", "{", "$", "gs", "=", "new", "static", "(", "$", "filename", ",", "''", ",", "$", "opts", ")", ";", "if", "(", "$", "language", "==", "''", ")", "{", "$", "ext", "=", "pathinfo", "(", "$", "filename", ",", "PATHINFO_EXTENSION", ")", ";", "$", "language", "=", "$", "gs", "->", "get_language_name_from_extension", "(", "$", "ext", ")", ";", "}", "$", "gs", "->", "setLanguage", "(", "$", "language", ")", ";", "$", "s", "=", "$", "gs", "->", "parseCode", "(", ")", ";", "if", "(", "$", "gs", "->", "error", "(", ")", ")", "{", "return", "false", ";", "}", "if", "(", "$", "return", ")", "{", "return", "'<code>'", ".", "$", "s", ".", "'</code>'", ";", "}", "echo", "'<code>'", ".", "$", "s", ".", "'</code>'", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Easy way to highlight stuff. Behaves just like highlight_file @param string $filename the full filepath of the file to highlight @param string $language language to use (will try to determine from extension if not provided) [Default: ''] *Can be skipped* @param bool $return [Default: false] *Can be skipped* @param int $opts [Default: 0] @return bool|string
[ "Easy", "way", "to", "highlight", "stuff", ".", "Behaves", "just", "like", "highlight_file" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L423-L459
5,895
derokorian/gen-synth
src/GenSynth.php
GenSynth.enable_highlighting
function enable_highlighting($flag = true) { $flag = $flag ? true : false; foreach ($this->lexic_permissions as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $this->lexic_permissions[$key][$k] = $flag; } } else { $this->lexic_permissions[$key] = $flag; } } }
php
function enable_highlighting($flag = true) { $flag = $flag ? true : false; foreach ($this->lexic_permissions as $key => $value) { if (is_array($value)) { foreach ($value as $k => $v) { $this->lexic_permissions[$key][$k] = $flag; } } else { $this->lexic_permissions[$key] = $flag; } } }
[ "function", "enable_highlighting", "(", "$", "flag", "=", "true", ")", "{", "$", "flag", "=", "$", "flag", "?", "true", ":", "false", ";", "foreach", "(", "$", "this", "->", "lexic_permissions", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "foreach", "(", "$", "value", "as", "$", "k", "=>", "$", "v", ")", "{", "$", "this", "->", "lexic_permissions", "[", "$", "key", "]", "[", "$", "k", "]", "=", "$", "flag", ";", "}", "}", "else", "{", "$", "this", "->", "lexic_permissions", "[", "$", "key", "]", "=", "$", "flag", ";", "}", "}", "}" ]
Enables all highlighting The optional flag parameter was added in version 1.0.7.21 and can be used to enable (true) or disable (false) all highlighting. @param boolean A flag specifying whether to enable or disable all highlighting @todo Rewrite with array traversal
[ "Enables", "all", "highlighting" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L608-L621
5,896
derokorian/gen-synth
src/GenSynth.php
GenSynth.error
public function error() { if ($this->error) { $debug_tpl_vars = [ '{LANGUAGE}' => $this->language, '{PATH}' => self::LANG_ROOT, ]; $msg = strtr($this->error_messages[$this->error], $debug_tpl_vars); return "<br /><strong>GenSynth Error:</strong> $msg (code {$this->error})<br />"; } return false; }
php
public function error() { if ($this->error) { $debug_tpl_vars = [ '{LANGUAGE}' => $this->language, '{PATH}' => self::LANG_ROOT, ]; $msg = strtr($this->error_messages[$this->error], $debug_tpl_vars); return "<br /><strong>GenSynth Error:</strong> $msg (code {$this->error})<br />"; } return false; }
[ "public", "function", "error", "(", ")", "{", "if", "(", "$", "this", "->", "error", ")", "{", "$", "debug_tpl_vars", "=", "[", "'{LANGUAGE}'", "=>", "$", "this", "->", "language", ",", "'{PATH}'", "=>", "self", "::", "LANG_ROOT", ",", "]", ";", "$", "msg", "=", "strtr", "(", "$", "this", "->", "error_messages", "[", "$", "this", "->", "error", "]", ",", "$", "debug_tpl_vars", ")", ";", "return", "\"<br /><strong>GenSynth Error:</strong> $msg (code {$this->error})<br />\"", ";", "}", "return", "false", ";", "}" ]
Returns an error message associated with the last GenSynth operation @return string|false An error message if there has been an error, else false
[ "Returns", "an", "error", "message", "associated", "with", "the", "last", "GenSynth", "operation" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L706-L719
5,897
derokorian/gen-synth
src/GenSynth.php
GenSynth.get_language_name_from_extension
function get_language_name_from_extension($ext, $lookup = []) { $ext = strtolower($ext); if (!is_array($lookup) || empty($lookup)) { $lookup = [ 'as' => 'actionscript', 'as3' => 'actionscript3', 'conf' => 'apache', 'asp' => 'asp', 'sh' => 'bash', 'bf' => 'bf', 'c' => 'c', 'h' => 'c', 'cbl' => 'cobol', 'cpp' => 'cpp', 'hpp' => 'cpp', 'C' => 'cpp', 'H' => 'cpp', 'CPP' => 'cpp', 'HPP' => 'cpp', 'cs' => 'csharp', 'css' => 'css', 'bat' => 'dos', 'cmd' => 'dos', 'html' => 'html', 'htm' => 'html', 'ini' => 'ini', 'desktop' => 'ini', 'java' => 'java', 'js' => 'javascript', 'sql' => 'mysql', 'pl' => 'perl', 'pm' => 'perl', 'php' => 'php', 'php5' => 'php', 'phtml' => 'php', 'phps' => 'php', 'py' => 'python', 'rb' => 'ruby', 'txt' => 'text', 'bas' => 'vb', 'vb' => 'vbnet', 'xml' => 'xml', 'svg' => 'xml', 'xrc' => 'xml', ]; } return $lookup[$ext] ?: 'text'; }
php
function get_language_name_from_extension($ext, $lookup = []) { $ext = strtolower($ext); if (!is_array($lookup) || empty($lookup)) { $lookup = [ 'as' => 'actionscript', 'as3' => 'actionscript3', 'conf' => 'apache', 'asp' => 'asp', 'sh' => 'bash', 'bf' => 'bf', 'c' => 'c', 'h' => 'c', 'cbl' => 'cobol', 'cpp' => 'cpp', 'hpp' => 'cpp', 'C' => 'cpp', 'H' => 'cpp', 'CPP' => 'cpp', 'HPP' => 'cpp', 'cs' => 'csharp', 'css' => 'css', 'bat' => 'dos', 'cmd' => 'dos', 'html' => 'html', 'htm' => 'html', 'ini' => 'ini', 'desktop' => 'ini', 'java' => 'java', 'js' => 'javascript', 'sql' => 'mysql', 'pl' => 'perl', 'pm' => 'perl', 'php' => 'php', 'php5' => 'php', 'phtml' => 'php', 'phps' => 'php', 'py' => 'python', 'rb' => 'ruby', 'txt' => 'text', 'bas' => 'vb', 'vb' => 'vbnet', 'xml' => 'xml', 'svg' => 'xml', 'xrc' => 'xml', ]; } return $lookup[$ext] ?: 'text'; }
[ "function", "get_language_name_from_extension", "(", "$", "ext", ",", "$", "lookup", "=", "[", "]", ")", "{", "$", "ext", "=", "strtolower", "(", "$", "ext", ")", ";", "if", "(", "!", "is_array", "(", "$", "lookup", ")", "||", "empty", "(", "$", "lookup", ")", ")", "{", "$", "lookup", "=", "[", "'as'", "=>", "'actionscript'", ",", "'as3'", "=>", "'actionscript3'", ",", "'conf'", "=>", "'apache'", ",", "'asp'", "=>", "'asp'", ",", "'sh'", "=>", "'bash'", ",", "'bf'", "=>", "'bf'", ",", "'c'", "=>", "'c'", ",", "'h'", "=>", "'c'", ",", "'cbl'", "=>", "'cobol'", ",", "'cpp'", "=>", "'cpp'", ",", "'hpp'", "=>", "'cpp'", ",", "'C'", "=>", "'cpp'", ",", "'H'", "=>", "'cpp'", ",", "'CPP'", "=>", "'cpp'", ",", "'HPP'", "=>", "'cpp'", ",", "'cs'", "=>", "'csharp'", ",", "'css'", "=>", "'css'", ",", "'bat'", "=>", "'dos'", ",", "'cmd'", "=>", "'dos'", ",", "'html'", "=>", "'html'", ",", "'htm'", "=>", "'html'", ",", "'ini'", "=>", "'ini'", ",", "'desktop'", "=>", "'ini'", ",", "'java'", "=>", "'java'", ",", "'js'", "=>", "'javascript'", ",", "'sql'", "=>", "'mysql'", ",", "'pl'", "=>", "'perl'", ",", "'pm'", "=>", "'perl'", ",", "'php'", "=>", "'php'", ",", "'php5'", "=>", "'php'", ",", "'phtml'", "=>", "'php'", ",", "'phps'", "=>", "'php'", ",", "'py'", "=>", "'python'", ",", "'rb'", "=>", "'ruby'", ",", "'txt'", "=>", "'text'", ",", "'bas'", "=>", "'vb'", ",", "'vb'", "=>", "'vbnet'", ",", "'xml'", "=>", "'xml'", ",", "'svg'", "=>", "'xml'", ",", "'xrc'", "=>", "'xml'", ",", "]", ";", "}", "return", "$", "lookup", "[", "$", "ext", "]", "?", ":", "'text'", ";", "}" ]
Given a file extension, this method returns either a valid GenSynth language name, or the empty string if it couldn't be found @param string The extension to get a language name for @param array A lookup array to use instead of the default one @return string
[ "Given", "a", "file", "extension", "this", "method", "returns", "either", "a", "valid", "GenSynth", "language", "name", "or", "the", "empty", "string", "if", "it", "couldn", "t", "be", "found" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L1310-L1360
5,898
derokorian/gen-synth
src/GenSynth.php
GenSynth.remove_keyword
function remove_keyword($key, $word, $recompile = true) { $key_to_remove = array_search($word, $this->language_data['KEYWORDS'][$key]); if ($key_to_remove !== false) { unset($this->language_data['KEYWORDS'][$key][$key_to_remove]); //NEW in 1.0.8, optionally recompile keyword group if ($recompile && $this->parse_cache_built) { $this->optimize_keyword_group($key); } } }
php
function remove_keyword($key, $word, $recompile = true) { $key_to_remove = array_search($word, $this->language_data['KEYWORDS'][$key]); if ($key_to_remove !== false) { unset($this->language_data['KEYWORDS'][$key][$key_to_remove]); //NEW in 1.0.8, optionally recompile keyword group if ($recompile && $this->parse_cache_built) { $this->optimize_keyword_group($key); } } }
[ "function", "remove_keyword", "(", "$", "key", ",", "$", "word", ",", "$", "recompile", "=", "true", ")", "{", "$", "key_to_remove", "=", "array_search", "(", "$", "word", ",", "$", "this", "->", "language_data", "[", "'KEYWORDS'", "]", "[", "$", "key", "]", ")", ";", "if", "(", "$", "key_to_remove", "!==", "false", ")", "{", "unset", "(", "$", "this", "->", "language_data", "[", "'KEYWORDS'", "]", "[", "$", "key", "]", "[", "$", "key_to_remove", "]", ")", ";", "//NEW in 1.0.8, optionally recompile keyword group\r", "if", "(", "$", "recompile", "&&", "$", "this", "->", "parse_cache_built", ")", "{", "$", "this", "->", "optimize_keyword_group", "(", "$", "key", ")", ";", "}", "}", "}" ]
Removes a keyword from a keyword group @param int The key of the keyword group to remove the keyword from @param string The word to remove from the keyword group @param bool Wether to automatically recompile the optimized regexp list or not. Note: if you set this to false and @see GenSynth->parse_code() was already called once, for the current language, you have to manually call @see GenSynth->optimize_keyword_group() or the removed keyword will stay in cache and still be highlighted! On the other hand it might be too expensive to recompile the regexp list for every removal if you want to remove a lot of keywords.
[ "Removes", "a", "keyword", "from", "a", "keyword", "group" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L1396-L1407
5,899
derokorian/gen-synth
src/GenSynth.php
GenSynth.highlight_lines_extra
function highlight_lines_extra($lines, $style = null) { if (is_array($lines)) { //Split up the job using single lines at a time foreach ($lines as $line) { $this->highlight_lines_extra($line, $style); } } else { //Mark the line as being highlighted specially $lines = intval($lines); $this->highlight_extra_lines[$lines] = $lines; //Decide on which style to use if ($style === null) { //Check if we should use default style unset($this->highlight_extra_lines_styles[$lines]); } elseif ($style === false) { //Check if to remove this line unset($this->highlight_extra_lines[$lines]); unset($this->highlight_extra_lines_styles[$lines]); } else { $this->highlight_extra_lines_styles[$lines] = $style; } } }
php
function highlight_lines_extra($lines, $style = null) { if (is_array($lines)) { //Split up the job using single lines at a time foreach ($lines as $line) { $this->highlight_lines_extra($line, $style); } } else { //Mark the line as being highlighted specially $lines = intval($lines); $this->highlight_extra_lines[$lines] = $lines; //Decide on which style to use if ($style === null) { //Check if we should use default style unset($this->highlight_extra_lines_styles[$lines]); } elseif ($style === false) { //Check if to remove this line unset($this->highlight_extra_lines[$lines]); unset($this->highlight_extra_lines_styles[$lines]); } else { $this->highlight_extra_lines_styles[$lines] = $style; } } }
[ "function", "highlight_lines_extra", "(", "$", "lines", ",", "$", "style", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "lines", ")", ")", "{", "//Split up the job using single lines at a time\r", "foreach", "(", "$", "lines", "as", "$", "line", ")", "{", "$", "this", "->", "highlight_lines_extra", "(", "$", "line", ",", "$", "style", ")", ";", "}", "}", "else", "{", "//Mark the line as being highlighted specially\r", "$", "lines", "=", "intval", "(", "$", "lines", ")", ";", "$", "this", "->", "highlight_extra_lines", "[", "$", "lines", "]", "=", "$", "lines", ";", "//Decide on which style to use\r", "if", "(", "$", "style", "===", "null", ")", "{", "//Check if we should use default style\r", "unset", "(", "$", "this", "->", "highlight_extra_lines_styles", "[", "$", "lines", "]", ")", ";", "}", "elseif", "(", "$", "style", "===", "false", ")", "{", "//Check if to remove this line\r", "unset", "(", "$", "this", "->", "highlight_extra_lines", "[", "$", "lines", "]", ")", ";", "unset", "(", "$", "this", "->", "highlight_extra_lines_styles", "[", "$", "lines", "]", ")", ";", "}", "else", "{", "$", "this", "->", "highlight_extra_lines_styles", "[", "$", "lines", "]", "=", "$", "style", ";", "}", "}", "}" ]
Specifies which lines to highlight extra The extra style parameter was added in 1.0.7.21. @param mixed An array of line numbers to highlight, or just a line number on its own. @param string A string specifying the style to use for this line. If null is specified, the default style is used. If false is specified, the line will be removed from special highlighting @todo Some data replication here that could be cut down on
[ "Specifies", "which", "lines", "to", "highlight", "extra" ]
7114d25246da3f34adfb0ffd68464f2fca12df47
https://github.com/derokorian/gen-synth/blob/7114d25246da3f34adfb0ffd68464f2fca12df47/src/GenSynth.php#L1791-L1816