id
int32 0
241k
| repo
stringlengths 6
63
| path
stringlengths 5
140
| func_name
stringlengths 3
151
| original_string
stringlengths 84
13k
| language
stringclasses 1
value | code
stringlengths 84
13k
| code_tokens
list | docstring
stringlengths 3
47.2k
| docstring_tokens
list | sha
stringlengths 40
40
| url
stringlengths 91
247
|
---|---|---|---|---|---|---|---|---|---|---|---|
15,200 | drpdigital/json-api-parser | src/RelationshipResourceFinder.php | RelationshipResourceFinder.fromRelationshipType | public function fromRelationshipType($type)
{
$relationships = $this->getRelationshipsThatMatchType($type);
if (count($relationships) === 0) {
return null;
}
$resource = reset($relationships);
return new RelationshipResource(
key($relationships),
$resource
);
} | php | public function fromRelationshipType($type)
{
$relationships = $this->getRelationshipsThatMatchType($type);
if (count($relationships) === 0) {
return null;
}
$resource = reset($relationships);
return new RelationshipResource(
key($relationships),
$resource
);
} | [
"public",
"function",
"fromRelationshipType",
"(",
"$",
"type",
")",
"{",
"$",
"relationships",
"=",
"$",
"this",
"->",
"getRelationshipsThatMatchType",
"(",
"$",
"type",
")",
";",
"if",
"(",
"count",
"(",
"$",
"relationships",
")",
"===",
"0",
")",
"{",
"return",
"null",
";",
"}",
"$",
"resource",
"=",
"reset",
"(",
"$",
"relationships",
")",
";",
"return",
"new",
"RelationshipResource",
"(",
"key",
"(",
"$",
"relationships",
")",
",",
"$",
"resource",
")",
";",
"}"
]
| Get a resource from just the relationship type.
@param string $type
@return \Drp\JsonApiParser\RelationshipResource|null | [
"Get",
"a",
"resource",
"from",
"just",
"the",
"relationship",
"type",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L29-L43 |
15,201 | drpdigital/json-api-parser | src/RelationshipResourceFinder.php | RelationshipResourceFinder.getRelationshipsThatMatchType | protected function getRelationshipsThatMatchType($type)
{
return array_filter(
$this->mapRelationshipsToIdAndData(),
function ($relationship) use ($type) {
$relationshipType = Arr::get($relationship, 'type');
return Str::snakeCase($type) === Str::snakeCase($relationshipType);
}
);
} | php | protected function getRelationshipsThatMatchType($type)
{
return array_filter(
$this->mapRelationshipsToIdAndData(),
function ($relationship) use ($type) {
$relationshipType = Arr::get($relationship, 'type');
return Str::snakeCase($type) === Str::snakeCase($relationshipType);
}
);
} | [
"protected",
"function",
"getRelationshipsThatMatchType",
"(",
"$",
"type",
")",
"{",
"return",
"array_filter",
"(",
"$",
"this",
"->",
"mapRelationshipsToIdAndData",
"(",
")",
",",
"function",
"(",
"$",
"relationship",
")",
"use",
"(",
"$",
"type",
")",
"{",
"$",
"relationshipType",
"=",
"Arr",
"::",
"get",
"(",
"$",
"relationship",
",",
"'type'",
")",
";",
"return",
"Str",
"::",
"snakeCase",
"(",
"$",
"type",
")",
"===",
"Str",
"::",
"snakeCase",
"(",
"$",
"relationshipType",
")",
";",
"}",
")",
";",
"}"
]
| Get all the relationships that their type matches the given type.
@param string $type
@return array|mixed | [
"Get",
"all",
"the",
"relationships",
"that",
"their",
"type",
"matches",
"the",
"given",
"type",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L51-L61 |
15,202 | drpdigital/json-api-parser | src/RelationshipResourceFinder.php | RelationshipResourceFinder.getRelationshipResourceForReference | protected function getRelationshipResourceForReference($fullRelationshipReference)
{
$relationshipParts = explode('.', $fullRelationshipReference);
if (count($relationshipParts) !== 3) {
return null;
}
if ($this->resourceType() !== array_shift($relationshipParts)) {
return null;
}
$relationshipName = array_shift($relationshipParts);
$relationshipReference = Arr::get(
$this->mapRelationshipsToIdAndData(),
$relationshipName
);
if ($relationshipReference === null) {
return null;
}
if (Arr::get($relationshipReference, 'type') === array_shift($relationshipParts)) {
return new RelationshipResource($relationshipName, $relationshipReference);
}
return null;
} | php | protected function getRelationshipResourceForReference($fullRelationshipReference)
{
$relationshipParts = explode('.', $fullRelationshipReference);
if (count($relationshipParts) !== 3) {
return null;
}
if ($this->resourceType() !== array_shift($relationshipParts)) {
return null;
}
$relationshipName = array_shift($relationshipParts);
$relationshipReference = Arr::get(
$this->mapRelationshipsToIdAndData(),
$relationshipName
);
if ($relationshipReference === null) {
return null;
}
if (Arr::get($relationshipReference, 'type') === array_shift($relationshipParts)) {
return new RelationshipResource($relationshipName, $relationshipReference);
}
return null;
} | [
"protected",
"function",
"getRelationshipResourceForReference",
"(",
"$",
"fullRelationshipReference",
")",
"{",
"$",
"relationshipParts",
"=",
"explode",
"(",
"'.'",
",",
"$",
"fullRelationshipReference",
")",
";",
"if",
"(",
"count",
"(",
"$",
"relationshipParts",
")",
"!==",
"3",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"resourceType",
"(",
")",
"!==",
"array_shift",
"(",
"$",
"relationshipParts",
")",
")",
"{",
"return",
"null",
";",
"}",
"$",
"relationshipName",
"=",
"array_shift",
"(",
"$",
"relationshipParts",
")",
";",
"$",
"relationshipReference",
"=",
"Arr",
"::",
"get",
"(",
"$",
"this",
"->",
"mapRelationshipsToIdAndData",
"(",
")",
",",
"$",
"relationshipName",
")",
";",
"if",
"(",
"$",
"relationshipReference",
"===",
"null",
")",
"{",
"return",
"null",
";",
"}",
"if",
"(",
"Arr",
"::",
"get",
"(",
"$",
"relationshipReference",
",",
"'type'",
")",
"===",
"array_shift",
"(",
"$",
"relationshipParts",
")",
")",
"{",
"return",
"new",
"RelationshipResource",
"(",
"$",
"relationshipName",
",",
"$",
"relationshipReference",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| Get a relationship resource for a fully qualified reference.
@param string $fullRelationshipReference
@return \Drp\JsonApiParser\RelationshipResource|null | [
"Get",
"a",
"relationship",
"resource",
"for",
"a",
"fully",
"qualified",
"reference",
"."
]
| b1ceefc0c19ec326129126253114c121e97ca943 | https://github.com/drpdigital/json-api-parser/blob/b1ceefc0c19ec326129126253114c121e97ca943/src/RelationshipResourceFinder.php#L89-L115 |
15,203 | Konstantin-Vl/yii2-ulogin-widget | UloginWidget.php | UloginWidget.setStateListener | public function setStateListener($event, $listener)
{
$js = sprintf(
'uLogin.setStateListener("%s", "%s", %s);',
$this->id,
$event,
$listener
);
$this->getView()->registerJs($js);
return $this;
} | php | public function setStateListener($event, $listener)
{
$js = sprintf(
'uLogin.setStateListener("%s", "%s", %s);',
$this->id,
$event,
$listener
);
$this->getView()->registerJs($js);
return $this;
} | [
"public",
"function",
"setStateListener",
"(",
"$",
"event",
",",
"$",
"listener",
")",
"{",
"$",
"js",
"=",
"sprintf",
"(",
"'uLogin.setStateListener(\"%s\", \"%s\", %s);'",
",",
"$",
"this",
"->",
"id",
",",
"$",
"event",
",",
"$",
"listener",
")",
";",
"$",
"this",
"->",
"getView",
"(",
")",
"->",
"registerJs",
"(",
"$",
"js",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets the event handler in the event ulogin
@param string $event Js event name
@param string $listener Js event handler
@return $this
@see https://ulogin.ru/help.php#listeners | [
"Sets",
"the",
"event",
"handler",
"in",
"the",
"event",
"ulogin"
]
| b562b671dbb71926941df148d0d3d5a169a7b489 | https://github.com/Konstantin-Vl/yii2-ulogin-widget/blob/b562b671dbb71926941df148d0d3d5a169a7b489/UloginWidget.php#L110-L121 |
15,204 | devhelp/piwik-api | src/Method/Method.php | Method.call | public function call(array $params)
{
$this->initResolver();
/**
* makes sure that 'format' is passed and that 'API' and 'method'
* parameters are not overwritten by defaults nor by call parameters
*/
$defaults = array_merge(array('format' => $this->format), $this->defaultParams);
$this->resolver->setDefaults($defaults);
$this->resolver->setMandatory(array(
'module' => 'API',
'method' => $this->name()
));
return $this->piwikClient->call($this->url(), $this->resolver->resolve($params));
} | php | public function call(array $params)
{
$this->initResolver();
/**
* makes sure that 'format' is passed and that 'API' and 'method'
* parameters are not overwritten by defaults nor by call parameters
*/
$defaults = array_merge(array('format' => $this->format), $this->defaultParams);
$this->resolver->setDefaults($defaults);
$this->resolver->setMandatory(array(
'module' => 'API',
'method' => $this->name()
));
return $this->piwikClient->call($this->url(), $this->resolver->resolve($params));
} | [
"public",
"function",
"call",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"this",
"->",
"initResolver",
"(",
")",
";",
"/**\n * makes sure that 'format' is passed and that 'API' and 'method'\n * parameters are not overwritten by defaults nor by call parameters\n */",
"$",
"defaults",
"=",
"array_merge",
"(",
"array",
"(",
"'format'",
"=>",
"$",
"this",
"->",
"format",
")",
",",
"$",
"this",
"->",
"defaultParams",
")",
";",
"$",
"this",
"->",
"resolver",
"->",
"setDefaults",
"(",
"$",
"defaults",
")",
";",
"$",
"this",
"->",
"resolver",
"->",
"setMandatory",
"(",
"array",
"(",
"'module'",
"=>",
"'API'",
",",
"'method'",
"=>",
"$",
"this",
"->",
"name",
"(",
")",
")",
")",
";",
"return",
"$",
"this",
"->",
"piwikClient",
"->",
"call",
"(",
"$",
"this",
"->",
"url",
"(",
")",
",",
"$",
"this",
"->",
"resolver",
"->",
"resolve",
"(",
"$",
"params",
")",
")",
";",
"}"
]
| calls piwik api
@param array $params
@return ResponseInterface | [
"calls",
"piwik",
"api"
]
| b50569fac9736a87be48228d8a336a84418be8da | https://github.com/devhelp/piwik-api/blob/b50569fac9736a87be48228d8a336a84418be8da/src/Method/Method.php#L79-L95 |
15,205 | prooph/event-store-zf2-adapter | src/Zf2EventStoreAdapter.php | Zf2EventStoreAdapter.dropSchemaFor | public function dropSchemaFor(StreamName $streamName, $returnSql = false)
{
$dropTable = new DropTable($this->getTable($streamName));
if ($returnSql) {
return $dropTable->getSqlString($this->dbAdapter->getPlatform());
}
$this->dbAdapter->getDriver()
->getConnection()
->execute($dropTable->getSqlString($this->dbAdapter->getPlatform()));
} | php | public function dropSchemaFor(StreamName $streamName, $returnSql = false)
{
$dropTable = new DropTable($this->getTable($streamName));
if ($returnSql) {
return $dropTable->getSqlString($this->dbAdapter->getPlatform());
}
$this->dbAdapter->getDriver()
->getConnection()
->execute($dropTable->getSqlString($this->dbAdapter->getPlatform()));
} | [
"public",
"function",
"dropSchemaFor",
"(",
"StreamName",
"$",
"streamName",
",",
"$",
"returnSql",
"=",
"false",
")",
"{",
"$",
"dropTable",
"=",
"new",
"DropTable",
"(",
"$",
"this",
"->",
"getTable",
"(",
"$",
"streamName",
")",
")",
";",
"if",
"(",
"$",
"returnSql",
")",
"{",
"return",
"$",
"dropTable",
"->",
"getSqlString",
"(",
"$",
"this",
"->",
"dbAdapter",
"->",
"getPlatform",
"(",
")",
")",
";",
"}",
"$",
"this",
"->",
"dbAdapter",
"->",
"getDriver",
"(",
")",
"->",
"getConnection",
"(",
")",
"->",
"execute",
"(",
"$",
"dropTable",
"->",
"getSqlString",
"(",
"$",
"this",
"->",
"dbAdapter",
"->",
"getPlatform",
"(",
")",
")",
")",
";",
"}"
]
| Drops a stream table
Use this function with caution. All your events will be lost! But it can be useful in migration scenarios.
@param StreamName $streamName
@param bool $returnSql
@return string|null Whether $returnSql is true or not function will return generated sql or execute it directly | [
"Drops",
"a",
"stream",
"table"
]
| 607223d0e112f85ddc6568bb6bb7c9ca7b83e95b | https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L256-L267 |
15,206 | prooph/event-store-zf2-adapter | src/Zf2EventStoreAdapter.php | Zf2EventStoreAdapter.insertEvent | protected function insertEvent(StreamName $streamName, DomainEvent $e)
{
$eventData = array(
'event_id' => $e->uuid()->toString(),
'version' => $e->version(),
'event_name' => $e->messageName(),
'event_class' => get_class($e),
'payload' => Serializer::serialize($e->payload(), $this->serializerAdapter),
'created_at' => $e->createdAt()->format(\DateTime::ISO8601)
);
foreach ($e->metadata() as $key => $value) {
$eventData[$key] = (string)$value;
}
$tableGateway = $this->getTablegateway($streamName);
$tableGateway->insert($eventData);
} | php | protected function insertEvent(StreamName $streamName, DomainEvent $e)
{
$eventData = array(
'event_id' => $e->uuid()->toString(),
'version' => $e->version(),
'event_name' => $e->messageName(),
'event_class' => get_class($e),
'payload' => Serializer::serialize($e->payload(), $this->serializerAdapter),
'created_at' => $e->createdAt()->format(\DateTime::ISO8601)
);
foreach ($e->metadata() as $key => $value) {
$eventData[$key] = (string)$value;
}
$tableGateway = $this->getTablegateway($streamName);
$tableGateway->insert($eventData);
} | [
"protected",
"function",
"insertEvent",
"(",
"StreamName",
"$",
"streamName",
",",
"DomainEvent",
"$",
"e",
")",
"{",
"$",
"eventData",
"=",
"array",
"(",
"'event_id'",
"=>",
"$",
"e",
"->",
"uuid",
"(",
")",
"->",
"toString",
"(",
")",
",",
"'version'",
"=>",
"$",
"e",
"->",
"version",
"(",
")",
",",
"'event_name'",
"=>",
"$",
"e",
"->",
"messageName",
"(",
")",
",",
"'event_class'",
"=>",
"get_class",
"(",
"$",
"e",
")",
",",
"'payload'",
"=>",
"Serializer",
"::",
"serialize",
"(",
"$",
"e",
"->",
"payload",
"(",
")",
",",
"$",
"this",
"->",
"serializerAdapter",
")",
",",
"'created_at'",
"=>",
"$",
"e",
"->",
"createdAt",
"(",
")",
"->",
"format",
"(",
"\\",
"DateTime",
"::",
"ISO8601",
")",
")",
";",
"foreach",
"(",
"$",
"e",
"->",
"metadata",
"(",
")",
"as",
"$",
"key",
"=>",
"$",
"value",
")",
"{",
"$",
"eventData",
"[",
"$",
"key",
"]",
"=",
"(",
"string",
")",
"$",
"value",
";",
"}",
"$",
"tableGateway",
"=",
"$",
"this",
"->",
"getTablegateway",
"(",
"$",
"streamName",
")",
";",
"$",
"tableGateway",
"->",
"insert",
"(",
"$",
"eventData",
")",
";",
"}"
]
| Insert an event
@param StreamName $streamName
@param DomainEvent $e
@return void | [
"Insert",
"an",
"event"
]
| 607223d0e112f85ddc6568bb6bb7c9ca7b83e95b | https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L276-L294 |
15,207 | prooph/event-store-zf2-adapter | src/Zf2EventStoreAdapter.php | Zf2EventStoreAdapter.getTablegateway | protected function getTablegateway(StreamName $streamName)
{
if (!isset($this->tableGateways[$streamName->toString()])) {
$this->tableGateways[$streamName->toString()] = new TableGateway($this->getTable($streamName), $this->dbAdapter);
}
return $this->tableGateways[$streamName->toString()];
} | php | protected function getTablegateway(StreamName $streamName)
{
if (!isset($this->tableGateways[$streamName->toString()])) {
$this->tableGateways[$streamName->toString()] = new TableGateway($this->getTable($streamName), $this->dbAdapter);
}
return $this->tableGateways[$streamName->toString()];
} | [
"protected",
"function",
"getTablegateway",
"(",
"StreamName",
"$",
"streamName",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"tableGateways",
"[",
"$",
"streamName",
"->",
"toString",
"(",
")",
"]",
")",
")",
"{",
"$",
"this",
"->",
"tableGateways",
"[",
"$",
"streamName",
"->",
"toString",
"(",
")",
"]",
"=",
"new",
"TableGateway",
"(",
"$",
"this",
"->",
"getTable",
"(",
"$",
"streamName",
")",
",",
"$",
"this",
"->",
"dbAdapter",
")",
";",
"}",
"return",
"$",
"this",
"->",
"tableGateways",
"[",
"$",
"streamName",
"->",
"toString",
"(",
")",
"]",
";",
"}"
]
| Get the corresponding Tablegateway of the given stream name
@param StreamName $streamName
@return TableGateway | [
"Get",
"the",
"corresponding",
"Tablegateway",
"of",
"the",
"given",
"stream",
"name"
]
| 607223d0e112f85ddc6568bb6bb7c9ca7b83e95b | https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L303-L310 |
15,208 | prooph/event-store-zf2-adapter | src/Zf2EventStoreAdapter.php | Zf2EventStoreAdapter.getTable | protected function getTable(StreamName $streamName)
{
if (isset($this->streamTableMap[$streamName->toString()])) {
$tableName = $this->streamTableMap[$streamName->toString()];
} else {
$tableName = strtolower($this->getShortStreamName($streamName));
if (strpos($tableName, "_stream") === false) {
$tableName.= "_stream";
}
}
return $tableName;
} | php | protected function getTable(StreamName $streamName)
{
if (isset($this->streamTableMap[$streamName->toString()])) {
$tableName = $this->streamTableMap[$streamName->toString()];
} else {
$tableName = strtolower($this->getShortStreamName($streamName));
if (strpos($tableName, "_stream") === false) {
$tableName.= "_stream";
}
}
return $tableName;
} | [
"protected",
"function",
"getTable",
"(",
"StreamName",
"$",
"streamName",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"streamTableMap",
"[",
"$",
"streamName",
"->",
"toString",
"(",
")",
"]",
")",
")",
"{",
"$",
"tableName",
"=",
"$",
"this",
"->",
"streamTableMap",
"[",
"$",
"streamName",
"->",
"toString",
"(",
")",
"]",
";",
"}",
"else",
"{",
"$",
"tableName",
"=",
"strtolower",
"(",
"$",
"this",
"->",
"getShortStreamName",
"(",
"$",
"streamName",
")",
")",
";",
"if",
"(",
"strpos",
"(",
"$",
"tableName",
",",
"\"_stream\"",
")",
"===",
"false",
")",
"{",
"$",
"tableName",
".=",
"\"_stream\"",
";",
"}",
"}",
"return",
"$",
"tableName",
";",
"}"
]
| Get table name for given stream name
@param StreamName $streamName
@return string | [
"Get",
"table",
"name",
"for",
"given",
"stream",
"name"
]
| 607223d0e112f85ddc6568bb6bb7c9ca7b83e95b | https://github.com/prooph/event-store-zf2-adapter/blob/607223d0e112f85ddc6568bb6bb7c9ca7b83e95b/src/Zf2EventStoreAdapter.php#L318-L331 |
15,209 | stubbles/stubbles-webapp-core | src/main/php/session/id/WebBoundSessionId.php | WebBoundSessionId.read | private function read()
{
if ($this->request->hasParam($this->sessionName)) {
return $this->request->readParam($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
} elseif ($this->request->hasCookie($this->sessionName)) {
return $this->request->readCookie($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
}
return null;
} | php | private function read()
{
if ($this->request->hasParam($this->sessionName)) {
return $this->request->readParam($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
} elseif ($this->request->hasCookie($this->sessionName)) {
return $this->request->readCookie($this->sessionName)->ifMatches(self::SESSION_ID_REGEX);
}
return null;
} | [
"private",
"function",
"read",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"request",
"->",
"hasParam",
"(",
"$",
"this",
"->",
"sessionName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"readParam",
"(",
"$",
"this",
"->",
"sessionName",
")",
"->",
"ifMatches",
"(",
"self",
"::",
"SESSION_ID_REGEX",
")",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",
"request",
"->",
"hasCookie",
"(",
"$",
"this",
"->",
"sessionName",
")",
")",
"{",
"return",
"$",
"this",
"->",
"request",
"->",
"readCookie",
"(",
"$",
"this",
"->",
"sessionName",
")",
"->",
"ifMatches",
"(",
"self",
"::",
"SESSION_ID_REGEX",
")",
";",
"}",
"return",
"null",
";",
"}"
]
| reads session id
@return string|null | [
"reads",
"session",
"id"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/session/id/WebBoundSessionId.php#L100-L109 |
15,210 | stubbles/stubbles-webapp-core | src/main/php/session/id/WebBoundSessionId.php | WebBoundSessionId.regenerate | public function regenerate(): SessionId
{
$this->id = $this->create();
$this->response->addCookie(
Cookie::create($this->sessionName, $this->id)->forPath('/')
);
return $this;
} | php | public function regenerate(): SessionId
{
$this->id = $this->create();
$this->response->addCookie(
Cookie::create($this->sessionName, $this->id)->forPath('/')
);
return $this;
} | [
"public",
"function",
"regenerate",
"(",
")",
":",
"SessionId",
"{",
"$",
"this",
"->",
"id",
"=",
"$",
"this",
"->",
"create",
"(",
")",
";",
"$",
"this",
"->",
"response",
"->",
"addCookie",
"(",
"Cookie",
"::",
"create",
"(",
"$",
"this",
"->",
"sessionName",
",",
"$",
"this",
"->",
"id",
")",
"->",
"forPath",
"(",
"'/'",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| stores session id for given session name
@return \stubbles\webapp\session\id\SessionId | [
"stores",
"session",
"id",
"for",
"given",
"session",
"name"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/session/id/WebBoundSessionId.php#L126-L133 |
15,211 | harp-orm/query | src/Compiler/Aliased.php | Aliased.render | public static function render(SQL\Aliased $aliased)
{
$content = $aliased->getContent();
if ($content instanceof Query\Select) {
$content = "(".Select::render($content).")";
} else {
$content = Compiler::name($content);
}
return Compiler::expression(array(
$content,
Compiler::word('AS', Compiler::name($aliased->getAlias()))
));
} | php | public static function render(SQL\Aliased $aliased)
{
$content = $aliased->getContent();
if ($content instanceof Query\Select) {
$content = "(".Select::render($content).")";
} else {
$content = Compiler::name($content);
}
return Compiler::expression(array(
$content,
Compiler::word('AS', Compiler::name($aliased->getAlias()))
));
} | [
"public",
"static",
"function",
"render",
"(",
"SQL",
"\\",
"Aliased",
"$",
"aliased",
")",
"{",
"$",
"content",
"=",
"$",
"aliased",
"->",
"getContent",
"(",
")",
";",
"if",
"(",
"$",
"content",
"instanceof",
"Query",
"\\",
"Select",
")",
"{",
"$",
"content",
"=",
"\"(\"",
".",
"Select",
"::",
"render",
"(",
"$",
"content",
")",
".",
"\")\"",
";",
"}",
"else",
"{",
"$",
"content",
"=",
"Compiler",
"::",
"name",
"(",
"$",
"content",
")",
";",
"}",
"return",
"Compiler",
"::",
"expression",
"(",
"array",
"(",
"$",
"content",
",",
"Compiler",
"::",
"word",
"(",
"'AS'",
",",
"Compiler",
"::",
"name",
"(",
"$",
"aliased",
"->",
"getAlias",
"(",
")",
")",
")",
")",
")",
";",
"}"
]
| Render SQL for Aliased
@param SQL\Aliased $aliased
@return string | [
"Render",
"SQL",
"for",
"Aliased"
]
| 98ce2468a0a31fe15ed3692bad32547bf6dbe41a | https://github.com/harp-orm/query/blob/98ce2468a0a31fe15ed3692bad32547bf6dbe41a/src/Compiler/Aliased.php#L33-L47 |
15,212 | ejsmont-artur/phpProxyBuilder | src/PhpProxyBuilder/Aop/Advice/InstrumentationAdvice.php | InstrumentationAdvice.interceptMethodCall | public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) {
$time = $this->monitor->getTime();
if ($this->namePrefix) {
$name = $this->namePrefix;
} else {
$name = get_class($jointPoint->getTarget());
}
if ($this->metricPerMethod) {
$name .= '.' . $jointPoint->getMethodName();
}
try {
$result = $jointPoint->proceed();
$this->monitor->incrementTimer($name . self::SUFFIX_SUCCESS, $time);
$this->monitor->incrementCounter($name . self::SUFFIX_SUCCESS);
return $result;
} catch (Exception $e) {
$this->monitor->incrementTimer($name . self::SUFFIX_EXCEPTION, $time);
$this->monitor->incrementCounter($name . self::SUFFIX_EXCEPTION);
throw $e;
}
} | php | public function interceptMethodCall(ProceedingJoinPointInterface $jointPoint) {
$time = $this->monitor->getTime();
if ($this->namePrefix) {
$name = $this->namePrefix;
} else {
$name = get_class($jointPoint->getTarget());
}
if ($this->metricPerMethod) {
$name .= '.' . $jointPoint->getMethodName();
}
try {
$result = $jointPoint->proceed();
$this->monitor->incrementTimer($name . self::SUFFIX_SUCCESS, $time);
$this->monitor->incrementCounter($name . self::SUFFIX_SUCCESS);
return $result;
} catch (Exception $e) {
$this->monitor->incrementTimer($name . self::SUFFIX_EXCEPTION, $time);
$this->monitor->incrementCounter($name . self::SUFFIX_EXCEPTION);
throw $e;
}
} | [
"public",
"function",
"interceptMethodCall",
"(",
"ProceedingJoinPointInterface",
"$",
"jointPoint",
")",
"{",
"$",
"time",
"=",
"$",
"this",
"->",
"monitor",
"->",
"getTime",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"namePrefix",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"namePrefix",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"get_class",
"(",
"$",
"jointPoint",
"->",
"getTarget",
"(",
")",
")",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"metricPerMethod",
")",
"{",
"$",
"name",
".=",
"'.'",
".",
"$",
"jointPoint",
"->",
"getMethodName",
"(",
")",
";",
"}",
"try",
"{",
"$",
"result",
"=",
"$",
"jointPoint",
"->",
"proceed",
"(",
")",
";",
"$",
"this",
"->",
"monitor",
"->",
"incrementTimer",
"(",
"$",
"name",
".",
"self",
"::",
"SUFFIX_SUCCESS",
",",
"$",
"time",
")",
";",
"$",
"this",
"->",
"monitor",
"->",
"incrementCounter",
"(",
"$",
"name",
".",
"self",
"::",
"SUFFIX_SUCCESS",
")",
";",
"return",
"$",
"result",
";",
"}",
"catch",
"(",
"Exception",
"$",
"e",
")",
"{",
"$",
"this",
"->",
"monitor",
"->",
"incrementTimer",
"(",
"$",
"name",
".",
"self",
"::",
"SUFFIX_EXCEPTION",
",",
"$",
"time",
")",
";",
"$",
"this",
"->",
"monitor",
"->",
"incrementCounter",
"(",
"$",
"name",
".",
"self",
"::",
"SUFFIX_EXCEPTION",
")",
";",
"throw",
"$",
"e",
";",
"}",
"}"
]
| In this implementation we measure time and count every method call
@param ProceedingJoinPointInterface $jointPoint
@return mixed | [
"In",
"this",
"implementation",
"we",
"measure",
"time",
"and",
"count",
"every",
"method",
"call"
]
| ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480 | https://github.com/ejsmont-artur/phpProxyBuilder/blob/ef7ec14e5d18eeba7a93e3617a0fdb5b146d6480/src/PhpProxyBuilder/Aop/Advice/InstrumentationAdvice.php#L85-L107 |
15,213 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/ConditionAbstract.php | ConditionAbstract.setValue | protected function setValue($value)
{
if (is_string($value)) {
$this->value = $value;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($value). "' for argument 'value' given."
);
}
return $this;
} | php | protected function setValue($value)
{
if (is_string($value)) {
$this->value = $value;
} else {
throw new \InvalidArgumentException(
"Invalid type '" . gettype($value). "' for argument 'value' given."
);
}
return $this;
} | [
"protected",
"function",
"setValue",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"value",
")",
")",
"{",
"$",
"this",
"->",
"value",
"=",
"$",
"value",
";",
"}",
"else",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Invalid type '\"",
".",
"gettype",
"(",
"$",
"value",
")",
".",
"\"' for argument 'value' given.\"",
")",
";",
"}",
"return",
"$",
"this",
";",
"}"
]
| Sets the condition value.
@param string $value
@return $this | [
"Sets",
"the",
"condition",
"value",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/ConditionAbstract.php#L29-L40 |
15,214 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getUser | public function getUser()
{
$resource = '/users/' . $this->userId;
$response = $this->makeAuthenticatedApiRequest($resource);
return $response->user;
} | php | public function getUser()
{
$resource = '/users/' . $this->userId;
$response = $this->makeAuthenticatedApiRequest($resource);
return $response->user;
} | [
"public",
"function",
"getUser",
"(",
")",
"{",
"$",
"resource",
"=",
"'/users/'",
".",
"$",
"this",
"->",
"userId",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"resource",
")",
";",
"return",
"$",
"response",
"->",
"user",
";",
"}"
]
| get a user
@see https://developer.foursquare.com/docs/users/users
@return \stdClass | [
"get",
"a",
"user"
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L39-L46 |
15,215 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getBadges | public function getBadges()
{
$uri = $this->buildUserResourceUri('badges');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->badges;
} | php | public function getBadges()
{
$uri = $this->buildUserResourceUri('badges');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->badges;
} | [
"public",
"function",
"getBadges",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'badges'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"badges",
";",
"}"
]
| Returns badges for a given user.
@see https://developer.foursquare.com/docs/users/badges | [
"Returns",
"badges",
"for",
"a",
"given",
"user",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L96-L104 |
15,216 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getCheckins | public function getCheckins(array $options = array())
{
$uri = $this->buildUserResourceUri('checkins');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->checkins->items;
} | php | public function getCheckins(array $options = array())
{
$uri = $this->buildUserResourceUri('checkins');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->checkins->items;
} | [
"public",
"function",
"getCheckins",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'checkins'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
",",
"$",
"options",
")",
";",
"return",
"$",
"response",
"->",
"checkins",
"->",
"items",
";",
"}"
]
| Returns a history of checkins for the authenticated user.
@see https://developer.foursquare.com/docs/users/checkins
@param array $options
@return array | [
"Returns",
"a",
"history",
"of",
"checkins",
"for",
"the",
"authenticated",
"user",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L112-L120 |
15,217 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getFriends | public function getFriends(array $options = array())
{
$uri = $this->buildUserResourceUri('friends');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->friends->items;
} | php | public function getFriends(array $options = array())
{
$uri = $this->buildUserResourceUri('friends');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->friends->items;
} | [
"public",
"function",
"getFriends",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'friends'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
",",
"$",
"options",
")",
";",
"return",
"$",
"response",
"->",
"friends",
"->",
"items",
";",
"}"
]
| Returns an array of a user's friends.
@see https://developer.foursquare.com/docs/users/friends
@param array $options | [
"Returns",
"an",
"array",
"of",
"a",
"user",
"s",
"friends",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L127-L135 |
15,218 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getTips | public function getTips(array $options = array())
{
$uri = $this->buildUserResourceUri('tips');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->tips->items;
} | php | public function getTips(array $options = array())
{
$uri = $this->buildUserResourceUri('tips');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->tips->items;
} | [
"public",
"function",
"getTips",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'tips'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
",",
"$",
"options",
")",
";",
"return",
"$",
"response",
"->",
"tips",
"->",
"items",
";",
"}"
]
| Returns an array of a user's tips.
@see https://developer.foursquare.com/docs/users/tips
@param array $options | [
"Returns",
"an",
"array",
"of",
"a",
"user",
"s",
"tips",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L142-L150 |
15,219 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getLists | public function getLists(array $options = array())
{
$uri = $this->buildUserResourceUri('lists');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->lists;
} | php | public function getLists(array $options = array())
{
$uri = $this->buildUserResourceUri('lists');
$response = $this->makeAuthenticatedApiRequest($uri, $options);
return $response->lists;
} | [
"public",
"function",
"getLists",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'lists'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
",",
"$",
"options",
")",
";",
"return",
"$",
"response",
"->",
"lists",
";",
"}"
]
| A User's Lists.
@see https://developer.foursquare.com/docs/users/lists
@param array $options | [
"A",
"User",
"s",
"Lists",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L157-L165 |
15,220 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getMayorships | public function getMayorships()
{
$uri = $this->buildUserResourceUri('mayorships');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->mayorships->items;
} | php | public function getMayorships()
{
$uri = $this->buildUserResourceUri('mayorships');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->mayorships->items;
} | [
"public",
"function",
"getMayorships",
"(",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'mayorships'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"mayorships",
"->",
"items",
";",
"}"
]
| Returns a user's mayorships.
@see https://developer.foursquare.com/docs/users/mayorships | [
"Returns",
"a",
"user",
"s",
"mayorships",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L171-L179 |
15,221 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getPhotos | public function getPhotos(array $options = array())
{
$uri = $this->buildUserResourceUri('photos');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->photos->items;
} | php | public function getPhotos(array $options = array())
{
$uri = $this->buildUserResourceUri('photos');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->photos->items;
} | [
"public",
"function",
"getPhotos",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'photos'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"photos",
"->",
"items",
";",
"}"
]
| Returns photos from a user.
@see https://developer.foursquare.com/docs/users/photos
@param array $options | [
"Returns",
"photos",
"from",
"a",
"user",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L186-L194 |
15,222 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.getVenueHistory | public function getVenueHistory(array $options = array())
{
$uri = $this->buildUserResourceUri('venuehistory');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->venues->items;
} | php | public function getVenueHistory(array $options = array())
{
$uri = $this->buildUserResourceUri('venuehistory');
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->venues->items;
} | [
"public",
"function",
"getVenueHistory",
"(",
"array",
"$",
"options",
"=",
"array",
"(",
")",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'venuehistory'",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"venues",
"->",
"items",
";",
"}"
]
| Returns a list of all venues visited by the specified user, along with
how many visits and when they were last there.
@see https://developer.foursquare.com/docs/users/venuehistory
@param array $options | [
"Returns",
"a",
"list",
"of",
"all",
"venues",
"visited",
"by",
"the",
"specified",
"user",
"along",
"with",
"how",
"many",
"visits",
"and",
"when",
"they",
"were",
"last",
"there",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L202-L210 |
15,223 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.approve | public function approve($friendId)
{
$uri = $this->buildUserResourceUri('approve', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | php | public function approve($friendId)
{
$uri = $this->buildUserResourceUri('approve', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | [
"public",
"function",
"approve",
"(",
"$",
"friendId",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'approve'",
",",
"$",
"friendId",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"user",
";",
"}"
]
| Approves a pending friend request from another user.
@param string $friendId
@return \stdClass | [
"Approves",
"a",
"pending",
"friend",
"request",
"from",
"another",
"user",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L217-L225 |
15,224 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.deny | public function deny($friendId)
{
$uri = $this->buildUserResourceUri('deny', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | php | public function deny($friendId)
{
$uri = $this->buildUserResourceUri('deny', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | [
"public",
"function",
"deny",
"(",
"$",
"friendId",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'deny'",
",",
"$",
"friendId",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"user",
";",
"}"
]
| Denies a pending friend request from another user.
@param string $friendId
@return \stdClass | [
"Denies",
"a",
"pending",
"friend",
"request",
"from",
"another",
"user",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L232-L240 |
15,225 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.request | public function request($friendId)
{
$uri = $this->buildUserResourceUri('request', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | php | public function request($friendId)
{
$uri = $this->buildUserResourceUri('request', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | [
"public",
"function",
"request",
"(",
"$",
"friendId",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'request'",
",",
"$",
"friendId",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"user",
";",
"}"
]
| Sends a friend request to another user. If the other user is a page
then the requesting user will automatically start following the page.
@param string $friendId
@return \stdClass | [
"Sends",
"a",
"friend",
"request",
"to",
"another",
"user",
".",
"If",
"the",
"other",
"user",
"is",
"a",
"page",
"then",
"the",
"requesting",
"user",
"will",
"automatically",
"start",
"following",
"the",
"page",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L248-L256 |
15,226 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.unfriend | public function unfriend($friendId)
{
$uri = $this->buildUserResourceUri('unfriend', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | php | public function unfriend($friendId)
{
$uri = $this->buildUserResourceUri('unfriend', $friendId);
$response = $this->makeAuthenticatedApiRequest($uri);
return $response->user;
} | [
"public",
"function",
"unfriend",
"(",
"$",
"friendId",
")",
"{",
"$",
"uri",
"=",
"$",
"this",
"->",
"buildUserResourceUri",
"(",
"'unfriend'",
",",
"$",
"friendId",
")",
";",
"$",
"response",
"=",
"$",
"this",
"->",
"makeAuthenticatedApiRequest",
"(",
"$",
"uri",
")",
";",
"return",
"$",
"response",
"->",
"user",
";",
"}"
]
| Cancels any relationship between the acting user and the specified user
Removes a friend, unfollows a celebrity, or cancels a pending friend
request.
@param string $friendId
@return \stdClass | [
"Cancels",
"any",
"relationship",
"between",
"the",
"acting",
"user",
"and",
"the",
"specified",
"user",
"Removes",
"a",
"friend",
"unfollows",
"a",
"celebrity",
"or",
"cancels",
"a",
"pending",
"friend",
"request",
"."
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L265-L273 |
15,227 | chriswoodford/foursquare-php | lib/TheTwelve/Foursquare/UsersGateway.php | UsersGateway.buildUserResourceUri | protected function buildUserResourceUri($resource, $userId = null)
{
$userId = is_null($userId) ? $this->userId : $userId;
return '/users/' . $userId . '/' . $resource;
} | php | protected function buildUserResourceUri($resource, $userId = null)
{
$userId = is_null($userId) ? $this->userId : $userId;
return '/users/' . $userId . '/' . $resource;
} | [
"protected",
"function",
"buildUserResourceUri",
"(",
"$",
"resource",
",",
"$",
"userId",
"=",
"null",
")",
"{",
"$",
"userId",
"=",
"is_null",
"(",
"$",
"userId",
")",
"?",
"$",
"this",
"->",
"userId",
":",
"$",
"userId",
";",
"return",
"'/users/'",
".",
"$",
"userId",
".",
"'/'",
".",
"$",
"resource",
";",
"}"
]
| build the resource URI
@param string $resource
@param string|null $userId
@return string | [
"build",
"the",
"resource",
"URI"
]
| edbfcba2993a101ead8f381394742a4689aec398 | https://github.com/chriswoodford/foursquare-php/blob/edbfcba2993a101ead8f381394742a4689aec398/lib/TheTwelve/Foursquare/UsersGateway.php#L281-L287 |
15,228 | kiwiz/ecl | src/ResultSet.php | ResultSet.& | public function &offsetGet($n) {
if(!$this->offsetExists($n)) {
throw new IndexNotFoundException((string) $n);
}
return $this->data[$n];
} | php | public function &offsetGet($n) {
if(!$this->offsetExists($n)) {
throw new IndexNotFoundException((string) $n);
}
return $this->data[$n];
} | [
"public",
"function",
"&",
"offsetGet",
"(",
"$",
"n",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"offsetExists",
"(",
"$",
"n",
")",
")",
"{",
"throw",
"new",
"IndexNotFoundException",
"(",
"(",
"string",
")",
"$",
"n",
")",
";",
"}",
"return",
"$",
"this",
"->",
"data",
"[",
"$",
"n",
"]",
";",
"}"
]
| Get the nth entry.
@param int $n Index.
@return mixed[] Value. | [
"Get",
"the",
"nth",
"entry",
"."
]
| 6536dd2a4c1905a08cf718bdbef56a22f0e9b488 | https://github.com/kiwiz/ecl/blob/6536dd2a4c1905a08cf718bdbef56a22f0e9b488/src/ResultSet.php#L51-L56 |
15,229 | matthiasbayer/datadog-client | src/Bayer/DataDogClient/Series/Metric.php | Metric.addPoint | public function addPoint(array $point) {
// Add timestamp if non provided
if (!isset($point[1])) {
$point = array(time(), $point[0]);
}
if (!is_integer($point[0])) {
throw new InvalidPointException('Timestamp must be an integer');
}
if (!is_int($point[1]) && !is_float($point[1])) {
throw new InvalidPointException('Value must be integer or float');
}
$this->points[] = $point;
return $this;
} | php | public function addPoint(array $point) {
// Add timestamp if non provided
if (!isset($point[1])) {
$point = array(time(), $point[0]);
}
if (!is_integer($point[0])) {
throw new InvalidPointException('Timestamp must be an integer');
}
if (!is_int($point[1]) && !is_float($point[1])) {
throw new InvalidPointException('Value must be integer or float');
}
$this->points[] = $point;
return $this;
} | [
"public",
"function",
"addPoint",
"(",
"array",
"$",
"point",
")",
"{",
"// Add timestamp if non provided",
"if",
"(",
"!",
"isset",
"(",
"$",
"point",
"[",
"1",
"]",
")",
")",
"{",
"$",
"point",
"=",
"array",
"(",
"time",
"(",
")",
",",
"$",
"point",
"[",
"0",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_integer",
"(",
"$",
"point",
"[",
"0",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidPointException",
"(",
"'Timestamp must be an integer'",
")",
";",
"}",
"if",
"(",
"!",
"is_int",
"(",
"$",
"point",
"[",
"1",
"]",
")",
"&&",
"!",
"is_float",
"(",
"$",
"point",
"[",
"1",
"]",
")",
")",
"{",
"throw",
"new",
"InvalidPointException",
"(",
"'Value must be integer or float'",
")",
";",
"}",
"$",
"this",
"->",
"points",
"[",
"]",
"=",
"$",
"point",
";",
"return",
"$",
"this",
";",
"}"
]
| Add a new measure point to the metric.
A point consists of an optional timestamp and a numeric value. If
no timestamp is specified, the current timestamp will be used. Order
matters. If a timestamp is specified, it should be the first value.
Examples:
Simple point: array(20)
With timestamp: array(1234567, 20)
@param array $point
@throws InvalidPointException
@return Metric | [
"Add",
"a",
"new",
"measure",
"point",
"to",
"the",
"metric",
"."
]
| e625132c34bf36f783077c9ee4ed3214633cd272 | https://github.com/matthiasbayer/datadog-client/blob/e625132c34bf36f783077c9ee4ed3214633cd272/src/Bayer/DataDogClient/Series/Metric.php#L169-L186 |
15,230 | bocharsky-bw/FileNamingResolver | src/FileInfo.php | FileInfo.changeExtension | public function changeExtension($extension)
{
$pathname = $this->createPathname($this->getPath(), $this->getBasename(), $extension);
return new static($pathname);
} | php | public function changeExtension($extension)
{
$pathname = $this->createPathname($this->getPath(), $this->getBasename(), $extension);
return new static($pathname);
} | [
"public",
"function",
"changeExtension",
"(",
"$",
"extension",
")",
"{",
"$",
"pathname",
"=",
"$",
"this",
"->",
"createPathname",
"(",
"$",
"this",
"->",
"getPath",
"(",
")",
",",
"$",
"this",
"->",
"getBasename",
"(",
")",
",",
"$",
"extension",
")",
";",
"return",
"new",
"static",
"(",
"$",
"pathname",
")",
";",
"}"
]
| Changes file extension.
@param string $extension
@return FileInfo | [
"Changes",
"file",
"extension",
"."
]
| 0a0fe86fee0e7acf1ab43a84c1abd51954ce2fbe | https://github.com/bocharsky-bw/FileNamingResolver/blob/0a0fe86fee0e7acf1ab43a84c1abd51954ce2fbe/src/FileInfo.php#L144-L149 |
15,231 | puli/discovery | src/AbstractEditableDiscovery.php | AbstractEditableDiscovery.initializeBinding | protected function initializeBinding(Binding $binding)
{
$binding->initialize($this->getBindingType($binding->getTypeName()));
$bindingClass = get_class($binding);
if (!isset($this->initializersByBindingClass[$bindingClass])) {
$this->initializersByBindingClass[$bindingClass] = array();
// Find out which initializers accept the binding
foreach ($this->initializers as $initializer) {
if ($initializer->acceptsBinding($bindingClass)) {
$this->initializersByBindingClass[$bindingClass][] = $initializer;
}
}
}
// Apply all initializers that we found
foreach ($this->initializersByBindingClass[$bindingClass] as $initializer) {
$initializer->initializeBinding($binding);
}
} | php | protected function initializeBinding(Binding $binding)
{
$binding->initialize($this->getBindingType($binding->getTypeName()));
$bindingClass = get_class($binding);
if (!isset($this->initializersByBindingClass[$bindingClass])) {
$this->initializersByBindingClass[$bindingClass] = array();
// Find out which initializers accept the binding
foreach ($this->initializers as $initializer) {
if ($initializer->acceptsBinding($bindingClass)) {
$this->initializersByBindingClass[$bindingClass][] = $initializer;
}
}
}
// Apply all initializers that we found
foreach ($this->initializersByBindingClass[$bindingClass] as $initializer) {
$initializer->initializeBinding($binding);
}
} | [
"protected",
"function",
"initializeBinding",
"(",
"Binding",
"$",
"binding",
")",
"{",
"$",
"binding",
"->",
"initialize",
"(",
"$",
"this",
"->",
"getBindingType",
"(",
"$",
"binding",
"->",
"getTypeName",
"(",
")",
")",
")",
";",
"$",
"bindingClass",
"=",
"get_class",
"(",
"$",
"binding",
")",
";",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"initializersByBindingClass",
"[",
"$",
"bindingClass",
"]",
")",
")",
"{",
"$",
"this",
"->",
"initializersByBindingClass",
"[",
"$",
"bindingClass",
"]",
"=",
"array",
"(",
")",
";",
"// Find out which initializers accept the binding",
"foreach",
"(",
"$",
"this",
"->",
"initializers",
"as",
"$",
"initializer",
")",
"{",
"if",
"(",
"$",
"initializer",
"->",
"acceptsBinding",
"(",
"$",
"bindingClass",
")",
")",
"{",
"$",
"this",
"->",
"initializersByBindingClass",
"[",
"$",
"bindingClass",
"]",
"[",
"]",
"=",
"$",
"initializer",
";",
"}",
"}",
"}",
"// Apply all initializers that we found",
"foreach",
"(",
"$",
"this",
"->",
"initializersByBindingClass",
"[",
"$",
"bindingClass",
"]",
"as",
"$",
"initializer",
")",
"{",
"$",
"initializer",
"->",
"initializeBinding",
"(",
"$",
"binding",
")",
";",
"}",
"}"
]
| Initializes a binding.
@param Binding $binding The binding to initialize.
@throws BindingNotAcceptedException If the loaded type does not accept
the binding. | [
"Initializes",
"a",
"binding",
"."
]
| 975f5e099563f1096bfabc17fbe4d1816408ad98 | https://github.com/puli/discovery/blob/975f5e099563f1096bfabc17fbe4d1816408ad98/src/AbstractEditableDiscovery.php#L169-L190 |
15,232 | activecollab/databasestructure | src/Behaviour/AdditionalPropertiesInterface/Implementation.php | Implementation.getAdditionalProperties | public function getAdditionalProperties()
{
if ($this->decoded_additional_properties === false) {
$raw = trim($this->getRawAdditionalProperties());
$this->decoded_additional_properties = empty($raw) ? [] : json_decode($raw, true);
if (!is_array($this->decoded_additional_properties)) {
$this->decoded_additional_properties = [];
}
}
return $this->decoded_additional_properties;
} | php | public function getAdditionalProperties()
{
if ($this->decoded_additional_properties === false) {
$raw = trim($this->getRawAdditionalProperties());
$this->decoded_additional_properties = empty($raw) ? [] : json_decode($raw, true);
if (!is_array($this->decoded_additional_properties)) {
$this->decoded_additional_properties = [];
}
}
return $this->decoded_additional_properties;
} | [
"public",
"function",
"getAdditionalProperties",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"decoded_additional_properties",
"===",
"false",
")",
"{",
"$",
"raw",
"=",
"trim",
"(",
"$",
"this",
"->",
"getRawAdditionalProperties",
"(",
")",
")",
";",
"$",
"this",
"->",
"decoded_additional_properties",
"=",
"empty",
"(",
"$",
"raw",
")",
"?",
"[",
"]",
":",
"json_decode",
"(",
"$",
"raw",
",",
"true",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"decoded_additional_properties",
")",
")",
"{",
"$",
"this",
"->",
"decoded_additional_properties",
"=",
"[",
"]",
";",
"}",
"}",
"return",
"$",
"this",
"->",
"decoded_additional_properties",
";",
"}"
]
| Return additional log properties as array.
@return array | [
"Return",
"additional",
"log",
"properties",
"as",
"array",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/AdditionalPropertiesInterface/Implementation.php#L28-L40 |
15,233 | activecollab/databasestructure | src/Behaviour/AdditionalPropertiesInterface/Implementation.php | Implementation.& | public function &setAdditionalProperties(array $value = null)
{
$this->decoded_additional_properties = false; // Reset...
$this->setRawAdditionalProperties(json_encode($value));
return $this;
} | php | public function &setAdditionalProperties(array $value = null)
{
$this->decoded_additional_properties = false; // Reset...
$this->setRawAdditionalProperties(json_encode($value));
return $this;
} | [
"public",
"function",
"&",
"setAdditionalProperties",
"(",
"array",
"$",
"value",
"=",
"null",
")",
"{",
"$",
"this",
"->",
"decoded_additional_properties",
"=",
"false",
";",
"// Reset...",
"$",
"this",
"->",
"setRawAdditionalProperties",
"(",
"json_encode",
"(",
"$",
"value",
")",
")",
";",
"return",
"$",
"this",
";",
"}"
]
| Set attributes value.
@param array|null $value
@return $this | [
"Set",
"attributes",
"value",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/AdditionalPropertiesInterface/Implementation.php#L48-L55 |
15,234 | activecollab/databasestructure | src/Behaviour/AdditionalPropertiesInterface/Implementation.php | Implementation.getAdditionalProperty | public function getAdditionalProperty($name, $default = null)
{
$additional_properties = $this->getAdditionalProperties();
return $additional_properties && isset($additional_properties[$name]) ? $additional_properties[$name] : $default;
} | php | public function getAdditionalProperty($name, $default = null)
{
$additional_properties = $this->getAdditionalProperties();
return $additional_properties && isset($additional_properties[$name]) ? $additional_properties[$name] : $default;
} | [
"public",
"function",
"getAdditionalProperty",
"(",
"$",
"name",
",",
"$",
"default",
"=",
"null",
")",
"{",
"$",
"additional_properties",
"=",
"$",
"this",
"->",
"getAdditionalProperties",
"(",
")",
";",
"return",
"$",
"additional_properties",
"&&",
"isset",
"(",
"$",
"additional_properties",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"additional_properties",
"[",
"$",
"name",
"]",
":",
"$",
"default",
";",
"}"
]
| Returna attribute value.
@param string $name
@param mixed $default
@return mixed | [
"Returna",
"attribute",
"value",
"."
]
| 4b2353c4422186bcfce63b3212da3e70e63eb5df | https://github.com/activecollab/databasestructure/blob/4b2353c4422186bcfce63b3212da3e70e63eb5df/src/Behaviour/AdditionalPropertiesInterface/Implementation.php#L64-L69 |
15,235 | chippyash/Math-Type-Calculator | src/Chippyash/Math/Type/Traits/CheckFloatTypes.php | CheckFloatTypes.checkFloatTypes | protected function checkFloatTypes(NumericTypeInterface $a, NumericTypeInterface $b)
{
$a1 = ($a instanceof FloatType ? $a : $a->asFloatType());
$b1 = ($b instanceof FloatType ? $b : $b->asFloatType());
return [$a1, $b1];
} | php | protected function checkFloatTypes(NumericTypeInterface $a, NumericTypeInterface $b)
{
$a1 = ($a instanceof FloatType ? $a : $a->asFloatType());
$b1 = ($b instanceof FloatType ? $b : $b->asFloatType());
return [$a1, $b1];
} | [
"protected",
"function",
"checkFloatTypes",
"(",
"NumericTypeInterface",
"$",
"a",
",",
"NumericTypeInterface",
"$",
"b",
")",
"{",
"$",
"a1",
"=",
"(",
"$",
"a",
"instanceof",
"FloatType",
"?",
"$",
"a",
":",
"$",
"a",
"->",
"asFloatType",
"(",
")",
")",
";",
"$",
"b1",
"=",
"(",
"$",
"b",
"instanceof",
"FloatType",
"?",
"$",
"b",
":",
"$",
"b",
"->",
"asFloatType",
"(",
")",
")",
";",
"return",
"[",
"$",
"a1",
",",
"$",
"b1",
"]",
";",
"}"
]
| Check for float type, converting if necessary
@param NumericTypeInterface $a
@param NumericTypeInterface $b
@return array [FloatType, FloatType] | [
"Check",
"for",
"float",
"type",
"converting",
"if",
"necessary"
]
| 2a2fae0ab4d052772d3dd45745efd5a91f88b9e3 | https://github.com/chippyash/Math-Type-Calculator/blob/2a2fae0ab4d052772d3dd45745efd5a91f88b9e3/src/Chippyash/Math/Type/Traits/CheckFloatTypes.php#L27-L33 |
15,236 | chippyash/Math-Type-Calculator | src/Chippyash/Math/Type/Traits/CheckRationalTypes.php | CheckRationalTypes.checkRationalTypes | protected function checkRationalTypes(NumericTypeInterface $a, NumericTypeInterface $b)
{
$a1 = ($a instanceof RationalType ? $a : $a->asRational());
$b1 = ($b instanceof RationalType ? $b : $b->asRational());
return [$a1, $b1];
} | php | protected function checkRationalTypes(NumericTypeInterface $a, NumericTypeInterface $b)
{
$a1 = ($a instanceof RationalType ? $a : $a->asRational());
$b1 = ($b instanceof RationalType ? $b : $b->asRational());
return [$a1, $b1];
} | [
"protected",
"function",
"checkRationalTypes",
"(",
"NumericTypeInterface",
"$",
"a",
",",
"NumericTypeInterface",
"$",
"b",
")",
"{",
"$",
"a1",
"=",
"(",
"$",
"a",
"instanceof",
"RationalType",
"?",
"$",
"a",
":",
"$",
"a",
"->",
"asRational",
"(",
")",
")",
";",
"$",
"b1",
"=",
"(",
"$",
"b",
"instanceof",
"RationalType",
"?",
"$",
"b",
":",
"$",
"b",
"->",
"asRational",
"(",
")",
")",
";",
"return",
"[",
"$",
"a1",
",",
"$",
"b1",
"]",
";",
"}"
]
| Check for rational type, converting if necessary
@param NumericTypeInterface $a
@param NumericTypeInterface $b
@return array [RationalType, RationalType] | [
"Check",
"for",
"rational",
"type",
"converting",
"if",
"necessary"
]
| 2a2fae0ab4d052772d3dd45745efd5a91f88b9e3 | https://github.com/chippyash/Math-Type-Calculator/blob/2a2fae0ab4d052772d3dd45745efd5a91f88b9e3/src/Chippyash/Math/Type/Traits/CheckRationalTypes.php#L28-L34 |
15,237 | awesomite/chariot | src/Pattern/PatternRoute.php | PatternRoute.matchParams | public function matchParams(array $params)
{
$result = [];
foreach ($this->explodedParams as $name => list($default, $pattern, $patternName)) {
if (!\array_key_exists($name, $params)) {
if (\is_null($default)) {
return false;
}
$currentParam = $default;
} else {
$currentParam = $params[$name];
}
if (!\is_null($patternName)) {
$patternObj = $this->patterns[$patternName];
try {
$result[$name] = $patternObj->toUrl($currentParam);
} catch (PatternException $exception) {
return false;
}
} else {
if (\is_object($currentParam) && \method_exists($currentParam, '__toString')) {
$currentParam = (string) $currentParam;
}
if (!$this->pregMatchMultiType($pattern, $currentParam)) {
return false;
}
$result[$name] = $currentParam;
}
}
return $result;
} | php | public function matchParams(array $params)
{
$result = [];
foreach ($this->explodedParams as $name => list($default, $pattern, $patternName)) {
if (!\array_key_exists($name, $params)) {
if (\is_null($default)) {
return false;
}
$currentParam = $default;
} else {
$currentParam = $params[$name];
}
if (!\is_null($patternName)) {
$patternObj = $this->patterns[$patternName];
try {
$result[$name] = $patternObj->toUrl($currentParam);
} catch (PatternException $exception) {
return false;
}
} else {
if (\is_object($currentParam) && \method_exists($currentParam, '__toString')) {
$currentParam = (string) $currentParam;
}
if (!$this->pregMatchMultiType($pattern, $currentParam)) {
return false;
}
$result[$name] = $currentParam;
}
}
return $result;
} | [
"public",
"function",
"matchParams",
"(",
"array",
"$",
"params",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"explodedParams",
"as",
"$",
"name",
"=>",
"list",
"(",
"$",
"default",
",",
"$",
"pattern",
",",
"$",
"patternName",
")",
")",
"{",
"if",
"(",
"!",
"\\",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"params",
")",
")",
"{",
"if",
"(",
"\\",
"is_null",
"(",
"$",
"default",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"currentParam",
"=",
"$",
"default",
";",
"}",
"else",
"{",
"$",
"currentParam",
"=",
"$",
"params",
"[",
"$",
"name",
"]",
";",
"}",
"if",
"(",
"!",
"\\",
"is_null",
"(",
"$",
"patternName",
")",
")",
"{",
"$",
"patternObj",
"=",
"$",
"this",
"->",
"patterns",
"[",
"$",
"patternName",
"]",
";",
"try",
"{",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"$",
"patternObj",
"->",
"toUrl",
"(",
"$",
"currentParam",
")",
";",
"}",
"catch",
"(",
"PatternException",
"$",
"exception",
")",
"{",
"return",
"false",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"currentParam",
")",
"&&",
"\\",
"method_exists",
"(",
"$",
"currentParam",
",",
"'__toString'",
")",
")",
"{",
"$",
"currentParam",
"=",
"(",
"string",
")",
"$",
"currentParam",
";",
"}",
"if",
"(",
"!",
"$",
"this",
"->",
"pregMatchMultiType",
"(",
"$",
"pattern",
",",
"$",
"currentParam",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"result",
"[",
"$",
"name",
"]",
"=",
"$",
"currentParam",
";",
"}",
"}",
"return",
"$",
"result",
";",
"}"
]
| Returns false or converted params
@param string[] $params
@return bool|array | [
"Returns",
"false",
"or",
"converted",
"params"
]
| 3229e38537b857be1d352308ba340dc530b12afb | https://github.com/awesomite/chariot/blob/3229e38537b857be1d352308ba340dc530b12afb/src/Pattern/PatternRoute.php#L255-L288 |
15,238 | mnapoli/assembly | src/Container/DefinitionResolver.php | DefinitionResolver.resolve | public function resolve(DefinitionInterface $definition)
{
switch (true) {
case $definition instanceof ReferenceDefinitionInterface:
return $this->container->get($definition->getTarget());
case $definition instanceof ParameterDefinitionInterface:
return $definition->getValue();
case $definition instanceof ObjectDefinitionInterface:
$reflection = new \ReflectionClass($definition->getClassName());
// Create the instance
$constructorArguments = $definition->getConstructorArguments();
$constructorArguments = array_map([$this, 'resolveSubDefinition'], $constructorArguments);
$service = $reflection->newInstanceArgs($constructorArguments);
// Set properties
foreach ($definition->getPropertyAssignments() as $propertyAssignment) {
$propertyName = $propertyAssignment->getPropertyName();
$service->$propertyName = $this->resolveSubDefinition($propertyAssignment->getValue());
}
// Call methods
foreach ($definition->getMethodCalls() as $methodCall) {
$methodArguments = $methodCall->getArguments();
$methodArguments = array_map([$this, 'resolveSubDefinition'], $methodArguments);
call_user_func_array([$service, $methodCall->getMethodName()], $methodArguments);
}
return $service;
case $definition instanceof FactoryCallDefinitionInterface:
$factory = $definition->getFactory();
$methodName = $definition->getMethodName();
$arguments = (array) $definition->getArguments();
$arguments = array_map([$this, 'resolveSubDefinition'], $arguments);
if (is_string($factory)) {
return call_user_func_array([$factory, $methodName], $arguments);
} elseif ($factory instanceof ReferenceDefinitionInterface) {
$factory = $this->container->get($factory->getTarget());
return call_user_func_array([$factory, $methodName], $arguments);
}
throw new InvalidDefinition(sprintf('Definition "%s" does not return a valid factory'));
default:
throw UnsupportedDefinition::fromDefinition($definition);
}
} | php | public function resolve(DefinitionInterface $definition)
{
switch (true) {
case $definition instanceof ReferenceDefinitionInterface:
return $this->container->get($definition->getTarget());
case $definition instanceof ParameterDefinitionInterface:
return $definition->getValue();
case $definition instanceof ObjectDefinitionInterface:
$reflection = new \ReflectionClass($definition->getClassName());
// Create the instance
$constructorArguments = $definition->getConstructorArguments();
$constructorArguments = array_map([$this, 'resolveSubDefinition'], $constructorArguments);
$service = $reflection->newInstanceArgs($constructorArguments);
// Set properties
foreach ($definition->getPropertyAssignments() as $propertyAssignment) {
$propertyName = $propertyAssignment->getPropertyName();
$service->$propertyName = $this->resolveSubDefinition($propertyAssignment->getValue());
}
// Call methods
foreach ($definition->getMethodCalls() as $methodCall) {
$methodArguments = $methodCall->getArguments();
$methodArguments = array_map([$this, 'resolveSubDefinition'], $methodArguments);
call_user_func_array([$service, $methodCall->getMethodName()], $methodArguments);
}
return $service;
case $definition instanceof FactoryCallDefinitionInterface:
$factory = $definition->getFactory();
$methodName = $definition->getMethodName();
$arguments = (array) $definition->getArguments();
$arguments = array_map([$this, 'resolveSubDefinition'], $arguments);
if (is_string($factory)) {
return call_user_func_array([$factory, $methodName], $arguments);
} elseif ($factory instanceof ReferenceDefinitionInterface) {
$factory = $this->container->get($factory->getTarget());
return call_user_func_array([$factory, $methodName], $arguments);
}
throw new InvalidDefinition(sprintf('Definition "%s" does not return a valid factory'));
default:
throw UnsupportedDefinition::fromDefinition($definition);
}
} | [
"public",
"function",
"resolve",
"(",
"DefinitionInterface",
"$",
"definition",
")",
"{",
"switch",
"(",
"true",
")",
"{",
"case",
"$",
"definition",
"instanceof",
"ReferenceDefinitionInterface",
":",
"return",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"definition",
"->",
"getTarget",
"(",
")",
")",
";",
"case",
"$",
"definition",
"instanceof",
"ParameterDefinitionInterface",
":",
"return",
"$",
"definition",
"->",
"getValue",
"(",
")",
";",
"case",
"$",
"definition",
"instanceof",
"ObjectDefinitionInterface",
":",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"definition",
"->",
"getClassName",
"(",
")",
")",
";",
"// Create the instance",
"$",
"constructorArguments",
"=",
"$",
"definition",
"->",
"getConstructorArguments",
"(",
")",
";",
"$",
"constructorArguments",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'resolveSubDefinition'",
"]",
",",
"$",
"constructorArguments",
")",
";",
"$",
"service",
"=",
"$",
"reflection",
"->",
"newInstanceArgs",
"(",
"$",
"constructorArguments",
")",
";",
"// Set properties",
"foreach",
"(",
"$",
"definition",
"->",
"getPropertyAssignments",
"(",
")",
"as",
"$",
"propertyAssignment",
")",
"{",
"$",
"propertyName",
"=",
"$",
"propertyAssignment",
"->",
"getPropertyName",
"(",
")",
";",
"$",
"service",
"->",
"$",
"propertyName",
"=",
"$",
"this",
"->",
"resolveSubDefinition",
"(",
"$",
"propertyAssignment",
"->",
"getValue",
"(",
")",
")",
";",
"}",
"// Call methods",
"foreach",
"(",
"$",
"definition",
"->",
"getMethodCalls",
"(",
")",
"as",
"$",
"methodCall",
")",
"{",
"$",
"methodArguments",
"=",
"$",
"methodCall",
"->",
"getArguments",
"(",
")",
";",
"$",
"methodArguments",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'resolveSubDefinition'",
"]",
",",
"$",
"methodArguments",
")",
";",
"call_user_func_array",
"(",
"[",
"$",
"service",
",",
"$",
"methodCall",
"->",
"getMethodName",
"(",
")",
"]",
",",
"$",
"methodArguments",
")",
";",
"}",
"return",
"$",
"service",
";",
"case",
"$",
"definition",
"instanceof",
"FactoryCallDefinitionInterface",
":",
"$",
"factory",
"=",
"$",
"definition",
"->",
"getFactory",
"(",
")",
";",
"$",
"methodName",
"=",
"$",
"definition",
"->",
"getMethodName",
"(",
")",
";",
"$",
"arguments",
"=",
"(",
"array",
")",
"$",
"definition",
"->",
"getArguments",
"(",
")",
";",
"$",
"arguments",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'resolveSubDefinition'",
"]",
",",
"$",
"arguments",
")",
";",
"if",
"(",
"is_string",
"(",
"$",
"factory",
")",
")",
"{",
"return",
"call_user_func_array",
"(",
"[",
"$",
"factory",
",",
"$",
"methodName",
"]",
",",
"$",
"arguments",
")",
";",
"}",
"elseif",
"(",
"$",
"factory",
"instanceof",
"ReferenceDefinitionInterface",
")",
"{",
"$",
"factory",
"=",
"$",
"this",
"->",
"container",
"->",
"get",
"(",
"$",
"factory",
"->",
"getTarget",
"(",
")",
")",
";",
"return",
"call_user_func_array",
"(",
"[",
"$",
"factory",
",",
"$",
"methodName",
"]",
",",
"$",
"arguments",
")",
";",
"}",
"throw",
"new",
"InvalidDefinition",
"(",
"sprintf",
"(",
"'Definition \"%s\" does not return a valid factory'",
")",
")",
";",
"default",
":",
"throw",
"UnsupportedDefinition",
"::",
"fromDefinition",
"(",
"$",
"definition",
")",
";",
"}",
"}"
]
| Resolve a definition and return the resulting value.
@param DefinitionInterface $definition
@return mixed
@throws UnsupportedDefinition
@throws InvalidDefinition
@throws EntryNotFound A dependency was not found. | [
"Resolve",
"a",
"definition",
"and",
"return",
"the",
"resulting",
"value",
"."
]
| bdaff7455d34958f2c2a5a3379de3d88b567b9fc | https://github.com/mnapoli/assembly/blob/bdaff7455d34958f2c2a5a3379de3d88b567b9fc/src/Container/DefinitionResolver.php#L38-L87 |
15,239 | mnapoli/assembly | src/Container/DefinitionResolver.php | DefinitionResolver.resolveSubDefinition | private function resolveSubDefinition($value)
{
if (is_array($value)) {
return array_map([$this, 'resolveSubDefinition'], $value);
} elseif ($value instanceof DefinitionInterface) {
return $this->resolve($value);
}
return $value;
} | php | private function resolveSubDefinition($value)
{
if (is_array($value)) {
return array_map([$this, 'resolveSubDefinition'], $value);
} elseif ($value instanceof DefinitionInterface) {
return $this->resolve($value);
}
return $value;
} | [
"private",
"function",
"resolveSubDefinition",
"(",
"$",
"value",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
")",
"{",
"return",
"array_map",
"(",
"[",
"$",
"this",
",",
"'resolveSubDefinition'",
"]",
",",
"$",
"value",
")",
";",
"}",
"elseif",
"(",
"$",
"value",
"instanceof",
"DefinitionInterface",
")",
"{",
"return",
"$",
"this",
"->",
"resolve",
"(",
"$",
"value",
")",
";",
"}",
"return",
"$",
"value",
";",
"}"
]
| Resolve a variable that can be a sub-definition.
@param mixed|DefinitionInterface $value
@return mixed | [
"Resolve",
"a",
"variable",
"that",
"can",
"be",
"a",
"sub",
"-",
"definition",
"."
]
| bdaff7455d34958f2c2a5a3379de3d88b567b9fc | https://github.com/mnapoli/assembly/blob/bdaff7455d34958f2c2a5a3379de3d88b567b9fc/src/Container/DefinitionResolver.php#L95-L104 |
15,240 | drmvc/framework | src/Framework/Containers.php | Containers.set | public function set(string $container, $object, ConfigInterface $config = null): ContainersInterface
{
if (!$this->has($container)) {
if (\is_object($object)) {
$this->setContainer($container, $object);
} else {
$class = '\\DrMVC\\' . $object;
$this->setContainer($container, new $class($config));
}
}
return $this;
} | php | public function set(string $container, $object, ConfigInterface $config = null): ContainersInterface
{
if (!$this->has($container)) {
if (\is_object($object)) {
$this->setContainer($container, $object);
} else {
$class = '\\DrMVC\\' . $object;
$this->setContainer($container, new $class($config));
}
}
return $this;
} | [
"public",
"function",
"set",
"(",
"string",
"$",
"container",
",",
"$",
"object",
",",
"ConfigInterface",
"$",
"config",
"=",
"null",
")",
":",
"ContainersInterface",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"container",
")",
")",
"{",
"if",
"(",
"\\",
"is_object",
"(",
"$",
"object",
")",
")",
"{",
"$",
"this",
"->",
"setContainer",
"(",
"$",
"container",
",",
"$",
"object",
")",
";",
"}",
"else",
"{",
"$",
"class",
"=",
"'\\\\DrMVC\\\\'",
".",
"$",
"object",
";",
"$",
"this",
"->",
"setContainer",
"(",
"$",
"container",
",",
"new",
"$",
"class",
"(",
"$",
"config",
")",
")",
";",
"}",
"}",
"return",
"$",
"this",
";",
"}"
]
| PSR-11 set container
@param string $container
@param string|object $object
@param ConfigInterface $config
@return ContainersInterface | [
"PSR",
"-",
"11",
"set",
"container"
]
| 6a49aa4e0314b37343a95d7c8ac5d10f72b45d71 | https://github.com/drmvc/framework/blob/6a49aa4e0314b37343a95d7c8ac5d10f72b45d71/src/Framework/Containers.php#L47-L58 |
15,241 | withfatpanda/illuminate-wordpress | src/WordPress/Http/Router.php | Router.getControllerClass | protected function getControllerClass($name)
{
$controllerClass = $name;
if (!class_exists($name)) {
$controllerClass = $this->controllerClasspath . '\\' . $name;
if (!class_exists($controllerClass)) {
$controllerClass = '\\FatPanda\\Illuminate\\WordPress\\Http\\Controllers\\' . $name;
if (!class_exists($controllerClass)) {
$controllerClass = new \WP_Error('class_not_found', "Class Not Found: {$name}");
}
}
}
return $controllerClass;
} | php | protected function getControllerClass($name)
{
$controllerClass = $name;
if (!class_exists($name)) {
$controllerClass = $this->controllerClasspath . '\\' . $name;
if (!class_exists($controllerClass)) {
$controllerClass = '\\FatPanda\\Illuminate\\WordPress\\Http\\Controllers\\' . $name;
if (!class_exists($controllerClass)) {
$controllerClass = new \WP_Error('class_not_found', "Class Not Found: {$name}");
}
}
}
return $controllerClass;
} | [
"protected",
"function",
"getControllerClass",
"(",
"$",
"name",
")",
"{",
"$",
"controllerClass",
"=",
"$",
"name",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"name",
")",
")",
"{",
"$",
"controllerClass",
"=",
"$",
"this",
"->",
"controllerClasspath",
".",
"'\\\\'",
".",
"$",
"name",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"controllerClass",
")",
")",
"{",
"$",
"controllerClass",
"=",
"'\\\\FatPanda\\\\Illuminate\\\\WordPress\\\\Http\\\\Controllers\\\\'",
".",
"$",
"name",
";",
"if",
"(",
"!",
"class_exists",
"(",
"$",
"controllerClass",
")",
")",
"{",
"$",
"controllerClass",
"=",
"new",
"\\",
"WP_Error",
"(",
"'class_not_found'",
",",
"\"Class Not Found: {$name}\"",
")",
";",
"}",
"}",
"}",
"return",
"$",
"controllerClass",
";",
"}"
]
| Given the classname of a controller, seek out a proper
namespace; start with the set controller classpath, then
move on to the core default, then try looking for the
class without any classpath at all.
@return The fully-qualified classpath, or, if not found, a
WP_Error object | [
"Given",
"the",
"classname",
"of",
"a",
"controller",
"seek",
"out",
"a",
"proper",
"namespace",
";",
"start",
"with",
"the",
"set",
"controller",
"classpath",
"then",
"move",
"on",
"to",
"the",
"core",
"default",
"then",
"try",
"looking",
"for",
"the",
"class",
"without",
"any",
"classpath",
"at",
"all",
"."
]
| b426ca81a55367459430c974932ee5a941d759d8 | https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Http/Router.php#L270-L284 |
15,242 | withfatpanda/illuminate-wordpress | src/WordPress/Http/Router.php | Router.invokeControllerAction | private function invokeControllerAction($controllerClassNamed, $actionNamed, array $givenArgs = [])
{
if (is_wp_error($controllerClass = $this->getControllerClass($controllerClassNamed))) {
return $controllerClass;
}
$reflection = new \ReflectionClass($controllerClass);
$controller = new $controllerClass($this);
if (!$reflection->hasMethod($actionNamed)) {
return new \WP_Error('method_not_found', "Method Not Found: {$controllerClassNamed}@{$actionNamed}", ['status' => 404]);
}
$method = $reflection->getMethod($actionNamed);
$args = [];
if (!empty($givenArgs)) {
$args[] = $givenArgs[0];
}
if (count($givenArgs) > 1) {
$params = $method->getParameters();
// loop over method params, ignoring the first
for ($i=1; $i<count($params); $i++) {
$param = $params[$i];
// if the param has no type
if (!$param->hasType()) {
if ($this->getPlugin()->bound($param->name)) {
$args[] = $this->getPlugin()->make($param->name);
}
} else {
$class = $param->getClass();
// map in plugin
if ($class->isSubclassOf(\Illuminate\Container\Container::class)) {
$args[] = $this->getPlugin();
// otherwise, use the service container to build whatever
} else {
$args[] = $this->getPlugin()->make($class->name);
}
}
}
}
return $method->invokeArgs($controller, $args);
} | php | private function invokeControllerAction($controllerClassNamed, $actionNamed, array $givenArgs = [])
{
if (is_wp_error($controllerClass = $this->getControllerClass($controllerClassNamed))) {
return $controllerClass;
}
$reflection = new \ReflectionClass($controllerClass);
$controller = new $controllerClass($this);
if (!$reflection->hasMethod($actionNamed)) {
return new \WP_Error('method_not_found', "Method Not Found: {$controllerClassNamed}@{$actionNamed}", ['status' => 404]);
}
$method = $reflection->getMethod($actionNamed);
$args = [];
if (!empty($givenArgs)) {
$args[] = $givenArgs[0];
}
if (count($givenArgs) > 1) {
$params = $method->getParameters();
// loop over method params, ignoring the first
for ($i=1; $i<count($params); $i++) {
$param = $params[$i];
// if the param has no type
if (!$param->hasType()) {
if ($this->getPlugin()->bound($param->name)) {
$args[] = $this->getPlugin()->make($param->name);
}
} else {
$class = $param->getClass();
// map in plugin
if ($class->isSubclassOf(\Illuminate\Container\Container::class)) {
$args[] = $this->getPlugin();
// otherwise, use the service container to build whatever
} else {
$args[] = $this->getPlugin()->make($class->name);
}
}
}
}
return $method->invokeArgs($controller, $args);
} | [
"private",
"function",
"invokeControllerAction",
"(",
"$",
"controllerClassNamed",
",",
"$",
"actionNamed",
",",
"array",
"$",
"givenArgs",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"is_wp_error",
"(",
"$",
"controllerClass",
"=",
"$",
"this",
"->",
"getControllerClass",
"(",
"$",
"controllerClassNamed",
")",
")",
")",
"{",
"return",
"$",
"controllerClass",
";",
"}",
"$",
"reflection",
"=",
"new",
"\\",
"ReflectionClass",
"(",
"$",
"controllerClass",
")",
";",
"$",
"controller",
"=",
"new",
"$",
"controllerClass",
"(",
"$",
"this",
")",
";",
"if",
"(",
"!",
"$",
"reflection",
"->",
"hasMethod",
"(",
"$",
"actionNamed",
")",
")",
"{",
"return",
"new",
"\\",
"WP_Error",
"(",
"'method_not_found'",
",",
"\"Method Not Found: {$controllerClassNamed}@{$actionNamed}\"",
",",
"[",
"'status'",
"=>",
"404",
"]",
")",
";",
"}",
"$",
"method",
"=",
"$",
"reflection",
"->",
"getMethod",
"(",
"$",
"actionNamed",
")",
";",
"$",
"args",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"givenArgs",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"givenArgs",
"[",
"0",
"]",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"givenArgs",
")",
">",
"1",
")",
"{",
"$",
"params",
"=",
"$",
"method",
"->",
"getParameters",
"(",
")",
";",
"// loop over method params, ignoring the first",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"count",
"(",
"$",
"params",
")",
";",
"$",
"i",
"++",
")",
"{",
"$",
"param",
"=",
"$",
"params",
"[",
"$",
"i",
"]",
";",
"// if the param has no type ",
"if",
"(",
"!",
"$",
"param",
"->",
"hasType",
"(",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getPlugin",
"(",
")",
"->",
"bound",
"(",
"$",
"param",
"->",
"name",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"this",
"->",
"getPlugin",
"(",
")",
"->",
"make",
"(",
"$",
"param",
"->",
"name",
")",
";",
"}",
"}",
"else",
"{",
"$",
"class",
"=",
"$",
"param",
"->",
"getClass",
"(",
")",
";",
"// map in plugin",
"if",
"(",
"$",
"class",
"->",
"isSubclassOf",
"(",
"\\",
"Illuminate",
"\\",
"Container",
"\\",
"Container",
"::",
"class",
")",
")",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"this",
"->",
"getPlugin",
"(",
")",
";",
"// otherwise, use the service container to build whatever",
"}",
"else",
"{",
"$",
"args",
"[",
"]",
"=",
"$",
"this",
"->",
"getPlugin",
"(",
")",
"->",
"make",
"(",
"$",
"class",
"->",
"name",
")",
";",
"}",
"}",
"}",
"}",
"return",
"$",
"method",
"->",
"invokeArgs",
"(",
"$",
"controller",
",",
"$",
"args",
")",
";",
"}"
]
| Invoke the given action on the given class, after resolving
an existing Class that matches the given class as named; map
arguments to controller action by dependency injection.
@param String The name of a controller to invoke; presumed to be taken from routes config
@param String The name of the action to invoke; must be a callable method on the controller
@param array Arguments to pass into the invocation of the method
@return mixed The result of the action invocation
@throws Exception For various reasons, generally internal to the Controller's invocation | [
"Invoke",
"the",
"given",
"action",
"on",
"the",
"given",
"class",
"after",
"resolving",
"an",
"existing",
"Class",
"that",
"matches",
"the",
"given",
"class",
"as",
"named",
";",
"map",
"arguments",
"to",
"controller",
"action",
"by",
"dependency",
"injection",
"."
]
| b426ca81a55367459430c974932ee5a941d759d8 | https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Http/Router.php#L296-L342 |
15,243 | withfatpanda/illuminate-wordpress | src/WordPress/Http/Router.php | Router.resource | function resource($name, $controllerClass, $options = [])
{
if (empty($options['idString'])) {
$options['idString'] = '{id}'; // == (?P<id>.+?)";
}
// by default, create routes for all known actions
$actions = array_keys($this->resourceActions);
if (!empty($options['only'])) {
$actions = $options['only'];
} else if (!empty($options['except'])) {
$actions = array_diff($actions, $options['except']);
}
if (!is_array($actions)) {
$actions = [$actions];
}
$group = new RouteGroup();
foreach($actions as $action) {
// make sure this action is one we know how to process
if (empty($this->resourceActions[$action])) {
throw new \Exception("Action [$action] is unrecognized; please use one of: ".implode(',', array_keys($this->resourceActions)));
}
// get the action defintion
$def = $this->resourceActions[$action];
// invoke Router::route
$route = call_user_func_array([ $this, 'route'], [
// the method is specified by the action definition:
$def['methods'],
// the route is a formatted string; drop the idString into it
$name . sprintf($def['route'], $options['idString']),
// inside the callback, we create our controller instance and call the proper action
function() use ($controllerClass, $action) {
return $this->invokeControllerAction($controllerClass, $action, func_get_args());
},
// pass-through options as rest config options
$options
]);
if (!empty($def['args'])) {
$route->args($def['args']);
}
$group[] = $route;
}
return $group;
} | php | function resource($name, $controllerClass, $options = [])
{
if (empty($options['idString'])) {
$options['idString'] = '{id}'; // == (?P<id>.+?)";
}
// by default, create routes for all known actions
$actions = array_keys($this->resourceActions);
if (!empty($options['only'])) {
$actions = $options['only'];
} else if (!empty($options['except'])) {
$actions = array_diff($actions, $options['except']);
}
if (!is_array($actions)) {
$actions = [$actions];
}
$group = new RouteGroup();
foreach($actions as $action) {
// make sure this action is one we know how to process
if (empty($this->resourceActions[$action])) {
throw new \Exception("Action [$action] is unrecognized; please use one of: ".implode(',', array_keys($this->resourceActions)));
}
// get the action defintion
$def = $this->resourceActions[$action];
// invoke Router::route
$route = call_user_func_array([ $this, 'route'], [
// the method is specified by the action definition:
$def['methods'],
// the route is a formatted string; drop the idString into it
$name . sprintf($def['route'], $options['idString']),
// inside the callback, we create our controller instance and call the proper action
function() use ($controllerClass, $action) {
return $this->invokeControllerAction($controllerClass, $action, func_get_args());
},
// pass-through options as rest config options
$options
]);
if (!empty($def['args'])) {
$route->args($def['args']);
}
$group[] = $route;
}
return $group;
} | [
"function",
"resource",
"(",
"$",
"name",
",",
"$",
"controllerClass",
",",
"$",
"options",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"options",
"[",
"'idString'",
"]",
")",
")",
"{",
"$",
"options",
"[",
"'idString'",
"]",
"=",
"'{id}'",
";",
"// == (?P<id>.+?)\";",
"}",
"// by default, create routes for all known actions",
"$",
"actions",
"=",
"array_keys",
"(",
"$",
"this",
"->",
"resourceActions",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'only'",
"]",
")",
")",
"{",
"$",
"actions",
"=",
"$",
"options",
"[",
"'only'",
"]",
";",
"}",
"else",
"if",
"(",
"!",
"empty",
"(",
"$",
"options",
"[",
"'except'",
"]",
")",
")",
"{",
"$",
"actions",
"=",
"array_diff",
"(",
"$",
"actions",
",",
"$",
"options",
"[",
"'except'",
"]",
")",
";",
"}",
"if",
"(",
"!",
"is_array",
"(",
"$",
"actions",
")",
")",
"{",
"$",
"actions",
"=",
"[",
"$",
"actions",
"]",
";",
"}",
"$",
"group",
"=",
"new",
"RouteGroup",
"(",
")",
";",
"foreach",
"(",
"$",
"actions",
"as",
"$",
"action",
")",
"{",
"// make sure this action is one we know how to process",
"if",
"(",
"empty",
"(",
"$",
"this",
"->",
"resourceActions",
"[",
"$",
"action",
"]",
")",
")",
"{",
"throw",
"new",
"\\",
"Exception",
"(",
"\"Action [$action] is unrecognized; please use one of: \"",
".",
"implode",
"(",
"','",
",",
"array_keys",
"(",
"$",
"this",
"->",
"resourceActions",
")",
")",
")",
";",
"}",
"// get the action defintion",
"$",
"def",
"=",
"$",
"this",
"->",
"resourceActions",
"[",
"$",
"action",
"]",
";",
"// invoke Router::route ",
"$",
"route",
"=",
"call_user_func_array",
"(",
"[",
"$",
"this",
",",
"'route'",
"]",
",",
"[",
"// the method is specified by the action definition:",
"$",
"def",
"[",
"'methods'",
"]",
",",
"// the route is a formatted string; drop the idString into it",
"$",
"name",
".",
"sprintf",
"(",
"$",
"def",
"[",
"'route'",
"]",
",",
"$",
"options",
"[",
"'idString'",
"]",
")",
",",
"// inside the callback, we create our controller instance and call the proper action",
"function",
"(",
")",
"use",
"(",
"$",
"controllerClass",
",",
"$",
"action",
")",
"{",
"return",
"$",
"this",
"->",
"invokeControllerAction",
"(",
"$",
"controllerClass",
",",
"$",
"action",
",",
"func_get_args",
"(",
")",
")",
";",
"}",
",",
"// pass-through options as rest config options",
"$",
"options",
"]",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"def",
"[",
"'args'",
"]",
")",
")",
"{",
"$",
"route",
"->",
"args",
"(",
"$",
"def",
"[",
"'args'",
"]",
")",
";",
"}",
"$",
"group",
"[",
"]",
"=",
"$",
"route",
";",
"}",
"return",
"$",
"group",
";",
"}"
]
| Create a resource endpoint set, bound to the given controller
for handling all requests
@param String The name for the resource, e.g., "photo"; this becomes
the base for each REST route, e.g., "photo/{photo}"
@param String The class name or class object of the Controller
that should be used to handle the routes; pro-tip: use the String
method to avoid needing to preload dependencies that might
not be used for the current request
@param array options
- "only" An array of the only actions that this resource allows
- "except" An array of actions that should NOT be handled by this resource
- "idString" Some token to use in the URL instead of "id"; make sure to
wrap it in curly brackets, e.g., "{id}"
@return Route
@see Router::resource() | [
"Create",
"a",
"resource",
"endpoint",
"set",
"bound",
"to",
"the",
"given",
"controller",
"for",
"handling",
"all",
"requests"
]
| b426ca81a55367459430c974932ee5a941d759d8 | https://github.com/withfatpanda/illuminate-wordpress/blob/b426ca81a55367459430c974932ee5a941d759d8/src/WordPress/Http/Router.php#L539-L591 |
15,244 | heyday/heystack | src/State/Traits/DataObjectSerializableTrait.php | DataObjectSerializableTrait.unserialize | public function unserialize($data)
{
$injector = \Injector::inst();
$extraData = null;
if (empty(self::$objectConstructorReflectionMethods[__CLASS__])) {
self::$objectConstructorReflectionMethods[__CLASS__] = new \ReflectionMethod(__CLASS__, '__construct');
}
if (empty(self::$classConfigs[__CLASS__])) {
self::$classConfigs[__CLASS__] = $injector->getConfigLocator()->locateConfigFor(__CLASS__);
}
if ($this instanceof ExtraDataInterface) {
$unserialized = \Heystack\Core\unserialize($data);
self::$objectConstructorReflectionMethods[__CLASS__]->invoke(
$this,
$unserialized[0]
);
$extraData = $unserialized[1];
} else {
self::$objectConstructorReflectionMethods[__CLASS__]->invoke(
$this,
\Heystack\Core\unserialize($data)
);
}
// Ensure that the spec is loaded for the class
if (self::$classConfigs[__CLASS__]) {
$injector->load([__CLASS__ => self::$classConfigs[__CLASS__]]);
}
$injector->inject($this, __CLASS__);
if ($extraData) {
$this->setExtraData($extraData);
}
} | php | public function unserialize($data)
{
$injector = \Injector::inst();
$extraData = null;
if (empty(self::$objectConstructorReflectionMethods[__CLASS__])) {
self::$objectConstructorReflectionMethods[__CLASS__] = new \ReflectionMethod(__CLASS__, '__construct');
}
if (empty(self::$classConfigs[__CLASS__])) {
self::$classConfigs[__CLASS__] = $injector->getConfigLocator()->locateConfigFor(__CLASS__);
}
if ($this instanceof ExtraDataInterface) {
$unserialized = \Heystack\Core\unserialize($data);
self::$objectConstructorReflectionMethods[__CLASS__]->invoke(
$this,
$unserialized[0]
);
$extraData = $unserialized[1];
} else {
self::$objectConstructorReflectionMethods[__CLASS__]->invoke(
$this,
\Heystack\Core\unserialize($data)
);
}
// Ensure that the spec is loaded for the class
if (self::$classConfigs[__CLASS__]) {
$injector->load([__CLASS__ => self::$classConfigs[__CLASS__]]);
}
$injector->inject($this, __CLASS__);
if ($extraData) {
$this->setExtraData($extraData);
}
} | [
"public",
"function",
"unserialize",
"(",
"$",
"data",
")",
"{",
"$",
"injector",
"=",
"\\",
"Injector",
"::",
"inst",
"(",
")",
";",
"$",
"extraData",
"=",
"null",
";",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"objectConstructorReflectionMethods",
"[",
"__CLASS__",
"]",
")",
")",
"{",
"self",
"::",
"$",
"objectConstructorReflectionMethods",
"[",
"__CLASS__",
"]",
"=",
"new",
"\\",
"ReflectionMethod",
"(",
"__CLASS__",
",",
"'__construct'",
")",
";",
"}",
"if",
"(",
"empty",
"(",
"self",
"::",
"$",
"classConfigs",
"[",
"__CLASS__",
"]",
")",
")",
"{",
"self",
"::",
"$",
"classConfigs",
"[",
"__CLASS__",
"]",
"=",
"$",
"injector",
"->",
"getConfigLocator",
"(",
")",
"->",
"locateConfigFor",
"(",
"__CLASS__",
")",
";",
"}",
"if",
"(",
"$",
"this",
"instanceof",
"ExtraDataInterface",
")",
"{",
"$",
"unserialized",
"=",
"\\",
"Heystack",
"\\",
"Core",
"\\",
"unserialize",
"(",
"$",
"data",
")",
";",
"self",
"::",
"$",
"objectConstructorReflectionMethods",
"[",
"__CLASS__",
"]",
"->",
"invoke",
"(",
"$",
"this",
",",
"$",
"unserialized",
"[",
"0",
"]",
")",
";",
"$",
"extraData",
"=",
"$",
"unserialized",
"[",
"1",
"]",
";",
"}",
"else",
"{",
"self",
"::",
"$",
"objectConstructorReflectionMethods",
"[",
"__CLASS__",
"]",
"->",
"invoke",
"(",
"$",
"this",
",",
"\\",
"Heystack",
"\\",
"Core",
"\\",
"unserialize",
"(",
"$",
"data",
")",
")",
";",
"}",
"// Ensure that the spec is loaded for the class",
"if",
"(",
"self",
"::",
"$",
"classConfigs",
"[",
"__CLASS__",
"]",
")",
"{",
"$",
"injector",
"->",
"load",
"(",
"[",
"__CLASS__",
"=>",
"self",
"::",
"$",
"classConfigs",
"[",
"__CLASS__",
"]",
"]",
")",
";",
"}",
"$",
"injector",
"->",
"inject",
"(",
"$",
"this",
",",
"__CLASS__",
")",
";",
"if",
"(",
"$",
"extraData",
")",
"{",
"$",
"this",
"->",
"setExtraData",
"(",
"$",
"extraData",
")",
";",
"}",
"}"
]
| This routine simulates what would happen when a object is constructed
@param string $data
@return void | [
"This",
"routine",
"simulates",
"what",
"would",
"happen",
"when",
"a",
"object",
"is",
"constructed"
]
| 2c051933f8c532d0a9a23be6ee1ff5c619e47dfe | https://github.com/heyday/heystack/blob/2c051933f8c532d0a9a23be6ee1ff5c619e47dfe/src/State/Traits/DataObjectSerializableTrait.php#L41-L81 |
15,245 | stubbles/stubbles-webapp-core | src/main/php/routing/api/Links.php | Links.add | public function add(string $rel, HttpUri $uri): Link
{
$link = new Link($rel, $uri);
if (isset($this->links[$rel])) {
if (!is_array($this->links[$rel])) {
$this->links[$rel] = [$this->links[$rel]];
}
$this->links[$rel][] = $link;
} else {
$this->links[$rel] = $link;
}
return $link;
} | php | public function add(string $rel, HttpUri $uri): Link
{
$link = new Link($rel, $uri);
if (isset($this->links[$rel])) {
if (!is_array($this->links[$rel])) {
$this->links[$rel] = [$this->links[$rel]];
}
$this->links[$rel][] = $link;
} else {
$this->links[$rel] = $link;
}
return $link;
} | [
"public",
"function",
"add",
"(",
"string",
"$",
"rel",
",",
"HttpUri",
"$",
"uri",
")",
":",
"Link",
"{",
"$",
"link",
"=",
"new",
"Link",
"(",
"$",
"rel",
",",
"$",
"uri",
")",
";",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
")",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
")",
")",
"{",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"=",
"[",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"]",
";",
"}",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"[",
"]",
"=",
"$",
"link",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"=",
"$",
"link",
";",
"}",
"return",
"$",
"link",
";",
"}"
]
| adds link to collection of links
@param string $rel
@param \stubbles\peer\http\HttpUri $uri
@return \stubbles\webapp\routing\api\Link | [
"adds",
"link",
"to",
"collection",
"of",
"links"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/api/Links.php#L53-L67 |
15,246 | stubbles/stubbles-webapp-core | src/main/php/routing/api/Links.php | Links.with | public function with(string $rel): array
{
if (isset($this->links[$rel])) {
if (is_array($this->links[$rel])) {
return $this->links[$rel];
}
return [$this->links[$rel]];
}
return [];
} | php | public function with(string $rel): array
{
if (isset($this->links[$rel])) {
if (is_array($this->links[$rel])) {
return $this->links[$rel];
}
return [$this->links[$rel]];
}
return [];
} | [
"public",
"function",
"with",
"(",
"string",
"$",
"rel",
")",
":",
"array",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
")",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
")",
")",
"{",
"return",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
";",
"}",
"return",
"[",
"$",
"this",
"->",
"links",
"[",
"$",
"rel",
"]",
"]",
";",
"}",
"return",
"[",
"]",
";",
"}"
]
| returns all links with given relation
@param string $rel
@return \stubbles\webapp\routing\api\Link[] | [
"returns",
"all",
"links",
"with",
"given",
"relation"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/api/Links.php#L75-L86 |
15,247 | stubbles/stubbles-webapp-core | src/main/php/routing/api/Links.php | Links.getIterator | public function getIterator(): \Traversable
{
$result = [];
foreach ($this->links as $link) {
if (is_array($link)) {
$result = array_merge($result, $link);
} else {
$result[] = $link;
}
}
return new \ArrayIterator($result);
} | php | public function getIterator(): \Traversable
{
$result = [];
foreach ($this->links as $link) {
if (is_array($link)) {
$result = array_merge($result, $link);
} else {
$result[] = $link;
}
}
return new \ArrayIterator($result);
} | [
"public",
"function",
"getIterator",
"(",
")",
":",
"\\",
"Traversable",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"links",
"as",
"$",
"link",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"link",
")",
")",
"{",
"$",
"result",
"=",
"array_merge",
"(",
"$",
"result",
",",
"$",
"link",
")",
";",
"}",
"else",
"{",
"$",
"result",
"[",
"]",
"=",
"$",
"link",
";",
"}",
"}",
"return",
"new",
"\\",
"ArrayIterator",
"(",
"$",
"result",
")",
";",
"}"
]
| allows to iterate over all resources
@return \Traversable | [
"allows",
"to",
"iterate",
"over",
"all",
"resources"
]
| 7705f129011a81d5cc3c76b4b150fab3dadac6a3 | https://github.com/stubbles/stubbles-webapp-core/blob/7705f129011a81d5cc3c76b4b150fab3dadac6a3/src/main/php/routing/api/Links.php#L93-L105 |
15,248 | aindong/pluggables | src/Aindong/Pluggables/PluggablesServiceProvider.php | PluggablesServiceProvider.registerServices | private function registerServices()
{
$this->app->singleton('pluggables', function ($app) {
return new Pluggables($app['config'], $app['files']);
});
$this->app->booting(function ($app) {
$app['pluggables']->register();
});
} | php | private function registerServices()
{
$this->app->singleton('pluggables', function ($app) {
return new Pluggables($app['config'], $app['files']);
});
$this->app->booting(function ($app) {
$app['pluggables']->register();
});
} | [
"private",
"function",
"registerServices",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'pluggables'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"return",
"new",
"Pluggables",
"(",
"$",
"app",
"[",
"'config'",
"]",
",",
"$",
"app",
"[",
"'files'",
"]",
")",
";",
"}",
")",
";",
"$",
"this",
"->",
"app",
"->",
"booting",
"(",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'pluggables'",
"]",
"->",
"register",
"(",
")",
";",
"}",
")",
";",
"}"
]
| Register services of the package.
@return void | [
"Register",
"services",
"of",
"the",
"package",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/PluggablesServiceProvider.php#L74-L83 |
15,249 | aindong/pluggables | src/Aindong/Pluggables/PluggablesServiceProvider.php | PluggablesServiceProvider.registerRepository | private function registerRepository()
{
$this->app->singleton('migration.repository', function ($app) {
$table = $app['config']['database.migrations'];
return new DatabaseMigrationRepository($app['db'], $table);
});
} | php | private function registerRepository()
{
$this->app->singleton('migration.repository', function ($app) {
$table = $app['config']['database.migrations'];
return new DatabaseMigrationRepository($app['db'], $table);
});
} | [
"private",
"function",
"registerRepository",
"(",
")",
"{",
"$",
"this",
"->",
"app",
"->",
"singleton",
"(",
"'migration.repository'",
",",
"function",
"(",
"$",
"app",
")",
"{",
"$",
"table",
"=",
"$",
"app",
"[",
"'config'",
"]",
"[",
"'database.migrations'",
"]",
";",
"return",
"new",
"DatabaseMigrationRepository",
"(",
"$",
"app",
"[",
"'db'",
"]",
",",
"$",
"table",
")",
";",
"}",
")",
";",
"}"
]
| Register the repository service. | [
"Register",
"the",
"repository",
"service",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/PluggablesServiceProvider.php#L88-L95 |
15,250 | aindong/pluggables | src/Aindong/Pluggables/PluggablesServiceProvider.php | PluggablesServiceProvider.registerConsoleCommands | private function registerConsoleCommands()
{
$this->registerMakeCommand();
$this->registerEnableCommand();
$this->registerDisableCommand();
$this->registerListCommand();
$this->registerMigrateCommand();
$this->registerMigrateRefreshCommand();
$this->registerMakeMigrationCommand();
$this->registerMakeRequestCommand();
$this->registerMakeModelCommand();
$this->commands([
'pluggables.makeMigration',
'pluggables.enable',
'pluggables.disable',
'pluggables.list',
'pluggables.make',
'pluggables.make.request',
'pluggables.make.model',
'pluggables.migrate',
'pluggables.migrateRefresh',
]);
} | php | private function registerConsoleCommands()
{
$this->registerMakeCommand();
$this->registerEnableCommand();
$this->registerDisableCommand();
$this->registerListCommand();
$this->registerMigrateCommand();
$this->registerMigrateRefreshCommand();
$this->registerMakeMigrationCommand();
$this->registerMakeRequestCommand();
$this->registerMakeModelCommand();
$this->commands([
'pluggables.makeMigration',
'pluggables.enable',
'pluggables.disable',
'pluggables.list',
'pluggables.make',
'pluggables.make.request',
'pluggables.make.model',
'pluggables.migrate',
'pluggables.migrateRefresh',
]);
} | [
"private",
"function",
"registerConsoleCommands",
"(",
")",
"{",
"$",
"this",
"->",
"registerMakeCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerEnableCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerDisableCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerListCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerMigrateCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerMigrateRefreshCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerMakeMigrationCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerMakeRequestCommand",
"(",
")",
";",
"$",
"this",
"->",
"registerMakeModelCommand",
"(",
")",
";",
"$",
"this",
"->",
"commands",
"(",
"[",
"'pluggables.makeMigration'",
",",
"'pluggables.enable'",
",",
"'pluggables.disable'",
",",
"'pluggables.list'",
",",
"'pluggables.make'",
",",
"'pluggables.make.request'",
",",
"'pluggables.make.model'",
",",
"'pluggables.migrate'",
",",
"'pluggables.migrateRefresh'",
",",
"]",
")",
";",
"}"
]
| Register the package console commands.
@return void | [
"Register",
"the",
"package",
"console",
"commands",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/PluggablesServiceProvider.php#L116-L139 |
15,251 | Srokap/code_review | classes/code_review.php | code_review.getPluginDirsInDir | public static function getPluginDirsInDir($dir = null) {
if ($dir === null) {
$dir = self::$config['pluginspath'];
}
$plugin_dirs = array();
$handle = opendir($dir);
if ($handle) {
while ($plugin_dir = readdir($handle)) {
// must be directory and not begin with a .
if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
$plugin_dirs[] = $plugin_dir;
}
}
}
sort($plugin_dirs);
return $plugin_dirs;
} | php | public static function getPluginDirsInDir($dir = null) {
if ($dir === null) {
$dir = self::$config['pluginspath'];
}
$plugin_dirs = array();
$handle = opendir($dir);
if ($handle) {
while ($plugin_dir = readdir($handle)) {
// must be directory and not begin with a .
if (substr($plugin_dir, 0, 1) !== '.' && is_dir($dir . $plugin_dir)) {
$plugin_dirs[] = $plugin_dir;
}
}
}
sort($plugin_dirs);
return $plugin_dirs;
} | [
"public",
"static",
"function",
"getPluginDirsInDir",
"(",
"$",
"dir",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"dir",
"===",
"null",
")",
"{",
"$",
"dir",
"=",
"self",
"::",
"$",
"config",
"[",
"'pluginspath'",
"]",
";",
"}",
"$",
"plugin_dirs",
"=",
"array",
"(",
")",
";",
"$",
"handle",
"=",
"opendir",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"$",
"handle",
")",
"{",
"while",
"(",
"$",
"plugin_dir",
"=",
"readdir",
"(",
"$",
"handle",
")",
")",
"{",
"// must be directory and not begin with a .",
"if",
"(",
"substr",
"(",
"$",
"plugin_dir",
",",
"0",
",",
"1",
")",
"!==",
"'.'",
"&&",
"is_dir",
"(",
"$",
"dir",
".",
"$",
"plugin_dir",
")",
")",
"{",
"$",
"plugin_dirs",
"[",
"]",
"=",
"$",
"plugin_dir",
";",
"}",
"}",
"}",
"sort",
"(",
"$",
"plugin_dirs",
")",
";",
"return",
"$",
"plugin_dirs",
";",
"}"
]
| Returns a list of plugin directory names from a base directory.
Copied from 1.9 core due to elgg_get_plugin_ids_in_dir removal in 1.9
@param string $dir A dir to scan for plugins. Defaults to config's plugins_path.
Must have a trailing slash.
@return array Array of directory names (not full paths) | [
"Returns",
"a",
"list",
"of",
"plugin",
"directory",
"names",
"from",
"a",
"base",
"directory",
".",
"Copied",
"from",
"1",
".",
"9",
"core",
"due",
"to",
"elgg_get_plugin_ids_in_dir",
"removal",
"in",
"1",
".",
"9"
]
| c79c619f99279cf15713b118ae19b0ef017db362 | https://github.com/Srokap/code_review/blob/c79c619f99279cf15713b118ae19b0ef017db362/classes/code_review.php#L459-L479 |
15,252 | gdbots/pbjx-bundle-php | src/Command/PbjxAwareCommandTrait.php | PbjxAwareCommandTrait.createConsoleRequest | protected function createConsoleRequest(): Request
{
$requestStack = $this->getRequestStack();
$request = $requestStack->getCurrentRequest();
if (!$request instanceof Request) {
$request = new Request();
$requestStack->push($request);
}
$request->attributes->set('pbjx_console', true);
$request->attributes->set('pbjx_bind_unrestricted', true);
return $request;
} | php | protected function createConsoleRequest(): Request
{
$requestStack = $this->getRequestStack();
$request = $requestStack->getCurrentRequest();
if (!$request instanceof Request) {
$request = new Request();
$requestStack->push($request);
}
$request->attributes->set('pbjx_console', true);
$request->attributes->set('pbjx_bind_unrestricted', true);
return $request;
} | [
"protected",
"function",
"createConsoleRequest",
"(",
")",
":",
"Request",
"{",
"$",
"requestStack",
"=",
"$",
"this",
"->",
"getRequestStack",
"(",
")",
";",
"$",
"request",
"=",
"$",
"requestStack",
"->",
"getCurrentRequest",
"(",
")",
";",
"if",
"(",
"!",
"$",
"request",
"instanceof",
"Request",
")",
"{",
"$",
"request",
"=",
"new",
"Request",
"(",
")",
";",
"$",
"requestStack",
"->",
"push",
"(",
"$",
"request",
")",
";",
"}",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'pbjx_console'",
",",
"true",
")",
";",
"$",
"request",
"->",
"attributes",
"->",
"set",
"(",
"'pbjx_bind_unrestricted'",
",",
"true",
")",
";",
"return",
"$",
"request",
";",
"}"
]
| Some pbjx binders, validators, etc. expect a request to exist.
Create one if nothing has been created yet.
@return Request | [
"Some",
"pbjx",
"binders",
"validators",
"etc",
".",
"expect",
"a",
"request",
"to",
"exist",
".",
"Create",
"one",
"if",
"nothing",
"has",
"been",
"created",
"yet",
"."
]
| f3c0088583879fc92f13247a0752634bd8696eac | https://github.com/gdbots/pbjx-bundle-php/blob/f3c0088583879fc92f13247a0752634bd8696eac/src/Command/PbjxAwareCommandTrait.php#L69-L82 |
15,253 | dragosprotung/stc-core | src/Workout/Track.php | Track.lastTrackPoint | public function lastTrackPoint(): TrackPoint
{
$lastTrackPoint = end($this->trackPoints);
if (!$lastTrackPoint instanceof TrackPoint) {
throw new \OutOfBoundsException('No track points points defined.');
}
reset($this->trackPoints);
return $lastTrackPoint;
} | php | public function lastTrackPoint(): TrackPoint
{
$lastTrackPoint = end($this->trackPoints);
if (!$lastTrackPoint instanceof TrackPoint) {
throw new \OutOfBoundsException('No track points points defined.');
}
reset($this->trackPoints);
return $lastTrackPoint;
} | [
"public",
"function",
"lastTrackPoint",
"(",
")",
":",
"TrackPoint",
"{",
"$",
"lastTrackPoint",
"=",
"end",
"(",
"$",
"this",
"->",
"trackPoints",
")",
";",
"if",
"(",
"!",
"$",
"lastTrackPoint",
"instanceof",
"TrackPoint",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"'No track points points defined.'",
")",
";",
"}",
"reset",
"(",
"$",
"this",
"->",
"trackPoints",
")",
";",
"return",
"$",
"lastTrackPoint",
";",
"}"
]
| Get the last track point.
@return TrackPoint
@throws \OutOfBoundsException If no track points are defined. | [
"Get",
"the",
"last",
"track",
"point",
"."
]
| 9783e3414294f4ee555a1d538d2807269deeb9e7 | https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Track.php#L90-L101 |
15,254 | dragosprotung/stc-core | src/Workout/Track.php | Track.duration | public function duration()
{
$start = $this->startDateTime();
$end = $this->endDateTime();
$dateDifference = $start->diff($end);
$dateInterval = new DateInterval('PT1S');
$dateInterval->y = $dateDifference->y;
$dateInterval->m = $dateDifference->m;
$dateInterval->d = $dateDifference->d;
$dateInterval->h = $dateDifference->h;
$dateInterval->i = $dateDifference->i;
$dateInterval->s = $dateDifference->s;
$dateInterval->invert = $dateDifference->invert;
$dateInterval->days = $dateDifference->days;
return $dateInterval;
} | php | public function duration()
{
$start = $this->startDateTime();
$end = $this->endDateTime();
$dateDifference = $start->diff($end);
$dateInterval = new DateInterval('PT1S');
$dateInterval->y = $dateDifference->y;
$dateInterval->m = $dateDifference->m;
$dateInterval->d = $dateDifference->d;
$dateInterval->h = $dateDifference->h;
$dateInterval->i = $dateDifference->i;
$dateInterval->s = $dateDifference->s;
$dateInterval->invert = $dateDifference->invert;
$dateInterval->days = $dateDifference->days;
return $dateInterval;
} | [
"public",
"function",
"duration",
"(",
")",
"{",
"$",
"start",
"=",
"$",
"this",
"->",
"startDateTime",
"(",
")",
";",
"$",
"end",
"=",
"$",
"this",
"->",
"endDateTime",
"(",
")",
";",
"$",
"dateDifference",
"=",
"$",
"start",
"->",
"diff",
"(",
"$",
"end",
")",
";",
"$",
"dateInterval",
"=",
"new",
"DateInterval",
"(",
"'PT1S'",
")",
";",
"$",
"dateInterval",
"->",
"y",
"=",
"$",
"dateDifference",
"->",
"y",
";",
"$",
"dateInterval",
"->",
"m",
"=",
"$",
"dateDifference",
"->",
"m",
";",
"$",
"dateInterval",
"->",
"d",
"=",
"$",
"dateDifference",
"->",
"d",
";",
"$",
"dateInterval",
"->",
"h",
"=",
"$",
"dateDifference",
"->",
"h",
";",
"$",
"dateInterval",
"->",
"i",
"=",
"$",
"dateDifference",
"->",
"i",
";",
"$",
"dateInterval",
"->",
"s",
"=",
"$",
"dateDifference",
"->",
"s",
";",
"$",
"dateInterval",
"->",
"invert",
"=",
"$",
"dateDifference",
"->",
"invert",
";",
"$",
"dateInterval",
"->",
"days",
"=",
"$",
"dateDifference",
"->",
"days",
";",
"return",
"$",
"dateInterval",
";",
"}"
]
| Get the duration of the track.
@return DateInterval | [
"Get",
"the",
"duration",
"of",
"the",
"track",
"."
]
| 9783e3414294f4ee555a1d538d2807269deeb9e7 | https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Track.php#L170-L188 |
15,255 | dragosprotung/stc-core | src/Workout/Track.php | Track.length | public function length(): float
{
if ($this->length === 0) {
$this->length = $this->recomputeLength();
}
return $this->length;
} | php | public function length(): float
{
if ($this->length === 0) {
$this->length = $this->recomputeLength();
}
return $this->length;
} | [
"public",
"function",
"length",
"(",
")",
":",
"float",
"{",
"if",
"(",
"$",
"this",
"->",
"length",
"===",
"0",
")",
"{",
"$",
"this",
"->",
"length",
"=",
"$",
"this",
"->",
"recomputeLength",
"(",
")",
";",
"}",
"return",
"$",
"this",
"->",
"length",
";",
"}"
]
| Get the length of the track in meters.
@return float | [
"Get",
"the",
"length",
"of",
"the",
"track",
"in",
"meters",
"."
]
| 9783e3414294f4ee555a1d538d2807269deeb9e7 | https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Track.php#L206-L214 |
15,256 | dragosprotung/stc-core | src/Workout/Track.php | Track.recomputeLength | private function recomputeLength(): float
{
$this->length = 0;
$trackPoints = $this->trackPoints();
$trackPointsCount = count($trackPoints);
if ($trackPointsCount < 2) {
return 0;
}
for ($i = 1; $i < $trackPointsCount; $i++) {
$previousTrack = $trackPoints[$i - 1];
$currentTrack = $trackPoints[$i];
$this->length += $currentTrack->distanceFromPoint($previousTrack);
}
$this->length = round($this->length, 6);
return $this->length;
} | php | private function recomputeLength(): float
{
$this->length = 0;
$trackPoints = $this->trackPoints();
$trackPointsCount = count($trackPoints);
if ($trackPointsCount < 2) {
return 0;
}
for ($i = 1; $i < $trackPointsCount; $i++) {
$previousTrack = $trackPoints[$i - 1];
$currentTrack = $trackPoints[$i];
$this->length += $currentTrack->distanceFromPoint($previousTrack);
}
$this->length = round($this->length, 6);
return $this->length;
} | [
"private",
"function",
"recomputeLength",
"(",
")",
":",
"float",
"{",
"$",
"this",
"->",
"length",
"=",
"0",
";",
"$",
"trackPoints",
"=",
"$",
"this",
"->",
"trackPoints",
"(",
")",
";",
"$",
"trackPointsCount",
"=",
"count",
"(",
"$",
"trackPoints",
")",
";",
"if",
"(",
"$",
"trackPointsCount",
"<",
"2",
")",
"{",
"return",
"0",
";",
"}",
"for",
"(",
"$",
"i",
"=",
"1",
";",
"$",
"i",
"<",
"$",
"trackPointsCount",
";",
"$",
"i",
"++",
")",
"{",
"$",
"previousTrack",
"=",
"$",
"trackPoints",
"[",
"$",
"i",
"-",
"1",
"]",
";",
"$",
"currentTrack",
"=",
"$",
"trackPoints",
"[",
"$",
"i",
"]",
";",
"$",
"this",
"->",
"length",
"+=",
"$",
"currentTrack",
"->",
"distanceFromPoint",
"(",
"$",
"previousTrack",
")",
";",
"}",
"$",
"this",
"->",
"length",
"=",
"round",
"(",
"$",
"this",
"->",
"length",
",",
"6",
")",
";",
"return",
"$",
"this",
"->",
"length",
";",
"}"
]
| Recompute the length of the track.
@return float | [
"Recompute",
"the",
"length",
"of",
"the",
"track",
"."
]
| 9783e3414294f4ee555a1d538d2807269deeb9e7 | https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/Track.php#L221-L241 |
15,257 | nicoSWD/put.io-api-v2 | src/PutIO/Engines/PutIO/OauthEngine.php | OauthEngine.verifyCode | public function verifyCode($clientID, $clientSecret, $redirectURI, $code)
{
$response = $this->get('oauth2/access_token', [
'client_id' => $clientID,
'client_secret' => $clientSecret,
'grant_type' => 'authorization_code',
'redirect_uri' => $redirectURI,
'code' => $code
]);
$result = \false;
if (!empty($response['access_token'])) {
$result = $response['access_token'];
}
return $result;
} | php | public function verifyCode($clientID, $clientSecret, $redirectURI, $code)
{
$response = $this->get('oauth2/access_token', [
'client_id' => $clientID,
'client_secret' => $clientSecret,
'grant_type' => 'authorization_code',
'redirect_uri' => $redirectURI,
'code' => $code
]);
$result = \false;
if (!empty($response['access_token'])) {
$result = $response['access_token'];
}
return $result;
} | [
"public",
"function",
"verifyCode",
"(",
"$",
"clientID",
",",
"$",
"clientSecret",
",",
"$",
"redirectURI",
",",
"$",
"code",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"get",
"(",
"'oauth2/access_token'",
",",
"[",
"'client_id'",
"=>",
"$",
"clientID",
",",
"'client_secret'",
"=>",
"$",
"clientSecret",
",",
"'grant_type'",
"=>",
"'authorization_code'",
",",
"'redirect_uri'",
"=>",
"$",
"redirectURI",
",",
"'code'",
"=>",
"$",
"code",
"]",
")",
";",
"$",
"result",
"=",
"\\",
"false",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"response",
"[",
"'access_token'",
"]",
")",
")",
"{",
"$",
"result",
"=",
"$",
"response",
"[",
"'access_token'",
"]",
";",
"}",
"return",
"$",
"result",
";",
"}"
]
| Second step of OAuth. This verifies the code obtained by the first
function. If valid, this function returns the user's access token, which
you need to save for all upcoming API requests.
@param int $clientID App ID
@param string $clientSecret App secret
@param string $redirectURI Redirect URI
@param string $code Code obtained by first step
@return string|bool | [
"Second",
"step",
"of",
"OAuth",
".",
"This",
"verifies",
"the",
"code",
"obtained",
"by",
"the",
"first",
"function",
".",
"If",
"valid",
"this",
"function",
"returns",
"the",
"user",
"s",
"access",
"token",
"which",
"you",
"need",
"to",
"save",
"for",
"all",
"upcoming",
"API",
"requests",
"."
]
| d91bedd91ea75793512a921bfd9aa83e86a6f0a7 | https://github.com/nicoSWD/put.io-api-v2/blob/d91bedd91ea75793512a921bfd9aa83e86a6f0a7/src/PutIO/Engines/PutIO/OauthEngine.php#L52-L69 |
15,258 | blackprism/serializer | src/Blackprism/Serializer/Json/Serialize.php | Serialize.setArray | private function setArray($object): array
{
$data = [];
$configurationObject = $this->configuration->getConfigurationObjectForClass(new ClassName(get_class($object)));
$identifier = $configurationObject->getIdentifier();
if ($identifier !== '') {
$data[$this->configuration->getIdentifierAttribute()] = $identifier;
}
foreach ($configurationObject->getAttributes() as $attribute) {
$type = $configurationObject->getTypeForAttribute($attribute);
$data = $this->processSerializeForType($type, $object, $data, $attribute);
}
return $data;
} | php | private function setArray($object): array
{
$data = [];
$configurationObject = $this->configuration->getConfigurationObjectForClass(new ClassName(get_class($object)));
$identifier = $configurationObject->getIdentifier();
if ($identifier !== '') {
$data[$this->configuration->getIdentifierAttribute()] = $identifier;
}
foreach ($configurationObject->getAttributes() as $attribute) {
$type = $configurationObject->getTypeForAttribute($attribute);
$data = $this->processSerializeForType($type, $object, $data, $attribute);
}
return $data;
} | [
"private",
"function",
"setArray",
"(",
"$",
"object",
")",
":",
"array",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"configurationObject",
"=",
"$",
"this",
"->",
"configuration",
"->",
"getConfigurationObjectForClass",
"(",
"new",
"ClassName",
"(",
"get_class",
"(",
"$",
"object",
")",
")",
")",
";",
"$",
"identifier",
"=",
"$",
"configurationObject",
"->",
"getIdentifier",
"(",
")",
";",
"if",
"(",
"$",
"identifier",
"!==",
"''",
")",
"{",
"$",
"data",
"[",
"$",
"this",
"->",
"configuration",
"->",
"getIdentifierAttribute",
"(",
")",
"]",
"=",
"$",
"identifier",
";",
"}",
"foreach",
"(",
"$",
"configurationObject",
"->",
"getAttributes",
"(",
")",
"as",
"$",
"attribute",
")",
"{",
"$",
"type",
"=",
"$",
"configurationObject",
"->",
"getTypeForAttribute",
"(",
"$",
"attribute",
")",
";",
"$",
"data",
"=",
"$",
"this",
"->",
"processSerializeForType",
"(",
"$",
"type",
",",
"$",
"object",
",",
"$",
"data",
",",
"$",
"attribute",
")",
";",
"}",
"return",
"$",
"data",
";",
"}"
]
| Create array from object
@param object $object
@return mixed[] | [
"Create",
"array",
"from",
"object"
]
| f5bd6ebeec802d2ad747daba7c9211b252ee4776 | https://github.com/blackprism/serializer/blob/f5bd6ebeec802d2ad747daba7c9211b252ee4776/src/Blackprism/Serializer/Json/Serialize.php#L59-L75 |
15,259 | blackprism/serializer | src/Blackprism/Serializer/Json/Serialize.php | Serialize.checkNullForAttribute | protected function checkNullForAttribute($value, $attribute): bool
{
// We don't use $attribute here, we want filter all value with the same behavior
if ($value === null) {
return true;
}
if (is_array($value) === true && $value === []) {
return true;
}
if ($value instanceof \Countable && count($value) === 0) {
return true;
}
return false;
} | php | protected function checkNullForAttribute($value, $attribute): bool
{
// We don't use $attribute here, we want filter all value with the same behavior
if ($value === null) {
return true;
}
if (is_array($value) === true && $value === []) {
return true;
}
if ($value instanceof \Countable && count($value) === 0) {
return true;
}
return false;
} | [
"protected",
"function",
"checkNullForAttribute",
"(",
"$",
"value",
",",
"$",
"attribute",
")",
":",
"bool",
"{",
"// We don't use $attribute here, we want filter all value with the same behavior",
"if",
"(",
"$",
"value",
"===",
"null",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"is_array",
"(",
"$",
"value",
")",
"===",
"true",
"&&",
"$",
"value",
"===",
"[",
"]",
")",
"{",
"return",
"true",
";",
"}",
"if",
"(",
"$",
"value",
"instanceof",
"\\",
"Countable",
"&&",
"count",
"(",
"$",
"value",
")",
"===",
"0",
")",
"{",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Set attribute with value when value is not considered as a null value
@param mixed $value
@param string $attribute
@return bool | [
"Set",
"attribute",
"with",
"value",
"when",
"value",
"is",
"not",
"considered",
"as",
"a",
"null",
"value"
]
| f5bd6ebeec802d2ad747daba7c9211b252ee4776 | https://github.com/blackprism/serializer/blob/f5bd6ebeec802d2ad747daba7c9211b252ee4776/src/Blackprism/Serializer/Json/Serialize.php#L239-L255 |
15,260 | dragosprotung/stc-core | src/Workout/TrackPoint.php | TrackPoint.extension | public function extension($idExtension): ExtensionInterface
{
if ($this->hasExtension($idExtension) !== true) {
throw new \OutOfBoundsException(sprintf('Extension "%s" not found.', $idExtension));
}
return $this->extensions[$idExtension];
} | php | public function extension($idExtension): ExtensionInterface
{
if ($this->hasExtension($idExtension) !== true) {
throw new \OutOfBoundsException(sprintf('Extension "%s" not found.', $idExtension));
}
return $this->extensions[$idExtension];
} | [
"public",
"function",
"extension",
"(",
"$",
"idExtension",
")",
":",
"ExtensionInterface",
"{",
"if",
"(",
"$",
"this",
"->",
"hasExtension",
"(",
"$",
"idExtension",
")",
"!==",
"true",
")",
"{",
"throw",
"new",
"\\",
"OutOfBoundsException",
"(",
"sprintf",
"(",
"'Extension \"%s\" not found.'",
",",
"$",
"idExtension",
")",
")",
";",
"}",
"return",
"$",
"this",
"->",
"extensions",
"[",
"$",
"idExtension",
"]",
";",
"}"
]
| Get an extension by ID.
@param string $idExtension The ID of the extension.
@return ExtensionInterface
@throws \OutOfBoundsException If the extension is not found. | [
"Get",
"an",
"extension",
"by",
"ID",
"."
]
| 9783e3414294f4ee555a1d538d2807269deeb9e7 | https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/TrackPoint.php#L147-L154 |
15,261 | dragosprotung/stc-core | src/Workout/TrackPoint.php | TrackPoint.distanceFromPoint | public function distanceFromPoint(TrackPoint $trackPoint): float
{
$earthRadius = 6371000;
$latFrom = deg2rad($this->latitude());
$lonFrom = deg2rad($this->longitude());
$latTo = deg2rad($trackPoint->latitude());
$lonTo = deg2rad($trackPoint->longitude());
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;
$angle = 2 * asin(
sqrt(
pow(sin($latDelta / 2), 2) +
cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)
)
);
return $angle * $earthRadius;
} | php | public function distanceFromPoint(TrackPoint $trackPoint): float
{
$earthRadius = 6371000;
$latFrom = deg2rad($this->latitude());
$lonFrom = deg2rad($this->longitude());
$latTo = deg2rad($trackPoint->latitude());
$lonTo = deg2rad($trackPoint->longitude());
$latDelta = $latTo - $latFrom;
$lonDelta = $lonTo - $lonFrom;
$angle = 2 * asin(
sqrt(
pow(sin($latDelta / 2), 2) +
cos($latFrom) * cos($latTo) * pow(sin($lonDelta / 2), 2)
)
);
return $angle * $earthRadius;
} | [
"public",
"function",
"distanceFromPoint",
"(",
"TrackPoint",
"$",
"trackPoint",
")",
":",
"float",
"{",
"$",
"earthRadius",
"=",
"6371000",
";",
"$",
"latFrom",
"=",
"deg2rad",
"(",
"$",
"this",
"->",
"latitude",
"(",
")",
")",
";",
"$",
"lonFrom",
"=",
"deg2rad",
"(",
"$",
"this",
"->",
"longitude",
"(",
")",
")",
";",
"$",
"latTo",
"=",
"deg2rad",
"(",
"$",
"trackPoint",
"->",
"latitude",
"(",
")",
")",
";",
"$",
"lonTo",
"=",
"deg2rad",
"(",
"$",
"trackPoint",
"->",
"longitude",
"(",
")",
")",
";",
"$",
"latDelta",
"=",
"$",
"latTo",
"-",
"$",
"latFrom",
";",
"$",
"lonDelta",
"=",
"$",
"lonTo",
"-",
"$",
"lonFrom",
";",
"$",
"angle",
"=",
"2",
"*",
"asin",
"(",
"sqrt",
"(",
"pow",
"(",
"sin",
"(",
"$",
"latDelta",
"/",
"2",
")",
",",
"2",
")",
"+",
"cos",
"(",
"$",
"latFrom",
")",
"*",
"cos",
"(",
"$",
"latTo",
")",
"*",
"pow",
"(",
"sin",
"(",
"$",
"lonDelta",
"/",
"2",
")",
",",
"2",
")",
")",
")",
";",
"return",
"$",
"angle",
"*",
"$",
"earthRadius",
";",
"}"
]
| Get the distance between this point and another point in meters.
@param TrackPoint $trackPoint The other point.
@return float The distance in meters. | [
"Get",
"the",
"distance",
"between",
"this",
"point",
"and",
"another",
"point",
"in",
"meters",
"."
]
| 9783e3414294f4ee555a1d538d2807269deeb9e7 | https://github.com/dragosprotung/stc-core/blob/9783e3414294f4ee555a1d538d2807269deeb9e7/src/Workout/TrackPoint.php#L192-L212 |
15,262 | WebDevTmas/date-repetition | src/DateRepetition/DailyDateRepetition.php | DailyDateRepetition.newFromTimeString | public static function newFromTimeString($timeString)
{
try {
$dateTime = new DateTime($timeString);
} catch(\Exception $e) {
throw new InvalidArgumentException('Time string must be valid, see DateTime for documentation');
}
return new self($dateTime->format('G'), $dateTime->format('i'));
} | php | public static function newFromTimeString($timeString)
{
try {
$dateTime = new DateTime($timeString);
} catch(\Exception $e) {
throw new InvalidArgumentException('Time string must be valid, see DateTime for documentation');
}
return new self($dateTime->format('G'), $dateTime->format('i'));
} | [
"public",
"static",
"function",
"newFromTimeString",
"(",
"$",
"timeString",
")",
"{",
"try",
"{",
"$",
"dateTime",
"=",
"new",
"DateTime",
"(",
"$",
"timeString",
")",
";",
"}",
"catch",
"(",
"\\",
"Exception",
"$",
"e",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Time string must be valid, see DateTime for documentation'",
")",
";",
"}",
"return",
"new",
"self",
"(",
"$",
"dateTime",
"->",
"format",
"(",
"'G'",
")",
",",
"$",
"dateTime",
"->",
"format",
"(",
"'i'",
")",
")",
";",
"}"
]
| Creates new DailyDateRepetition from string readable by DateTime
@param string time string
@return DailyDateRepetition | [
"Creates",
"new",
"DailyDateRepetition",
"from",
"string",
"readable",
"by",
"DateTime"
]
| 3ebd59f4ab3aab4b7497ebd767a57fad08277c6d | https://github.com/WebDevTmas/date-repetition/blob/3ebd59f4ab3aab4b7497ebd767a57fad08277c6d/src/DateRepetition/DailyDateRepetition.php#L34-L42 |
15,263 | WebDevTmas/date-repetition | src/DateRepetition/DailyDateRepetition.php | DailyDateRepetition.setHour | public function setHour($hour)
{
if(! in_array($hour, range(0, 23))) {
throw new InvalidArgumentException('Hour must be between 0 and 23');
}
$this->hour = $hour;
return $this;
} | php | public function setHour($hour)
{
if(! in_array($hour, range(0, 23))) {
throw new InvalidArgumentException('Hour must be between 0 and 23');
}
$this->hour = $hour;
return $this;
} | [
"public",
"function",
"setHour",
"(",
"$",
"hour",
")",
"{",
"if",
"(",
"!",
"in_array",
"(",
"$",
"hour",
",",
"range",
"(",
"0",
",",
"23",
")",
")",
")",
"{",
"throw",
"new",
"InvalidArgumentException",
"(",
"'Hour must be between 0 and 23'",
")",
";",
"}",
"$",
"this",
"->",
"hour",
"=",
"$",
"hour",
";",
"return",
"$",
"this",
";",
"}"
]
| Sets hour of repetition
@param integer hour
@return this | [
"Sets",
"hour",
"of",
"repetition"
]
| 3ebd59f4ab3aab4b7497ebd767a57fad08277c6d | https://github.com/WebDevTmas/date-repetition/blob/3ebd59f4ab3aab4b7497ebd767a57fad08277c6d/src/DateRepetition/DailyDateRepetition.php#L60-L67 |
15,264 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeModels.php | AnalyzeModels.processModuleSorting | protected function processModuleSorting()
{
$this->model['is_listified'] = false;
$this->model['ordered_by'] = [];
// if there can be only 1 entry, it makes no sense to listify or order in any case
if ($this->module['max_entries'] == 1) {
return;
}
// if manually sorted, use listify and do not set sorting columns
if ($this->module['sort_entries_manually']) {
$this->model['is_listified'] = true;
return;
}
// if automatically sorted, check and extract the sorting columns
// listify is disabled by default, but may be overridden (might be useful some day)
$this->model['is_listified'] = false;
$sorting = trim(strtolower($this->module['sort_entries_by']));
if (empty($sorting)) return;
foreach (explode(',', $sorting) as $sortClauseString) {
if ( ! preg_match("#^\s*[`'](.*)[`']\s+(asc|desc)\s*$#i", $sortClauseString, $matches)) {
$this->context->log(
"Could not interpret sorting clause '{$sortClauseString}' for module #{$this->moduleId}",
Generator::LOG_LEVEL_ERROR
);
continue;
}
// store direction per column as key
$this->model['ordered_by'][ $matches[1] ] = $matches[2];
}
} | php | protected function processModuleSorting()
{
$this->model['is_listified'] = false;
$this->model['ordered_by'] = [];
// if there can be only 1 entry, it makes no sense to listify or order in any case
if ($this->module['max_entries'] == 1) {
return;
}
// if manually sorted, use listify and do not set sorting columns
if ($this->module['sort_entries_manually']) {
$this->model['is_listified'] = true;
return;
}
// if automatically sorted, check and extract the sorting columns
// listify is disabled by default, but may be overridden (might be useful some day)
$this->model['is_listified'] = false;
$sorting = trim(strtolower($this->module['sort_entries_by']));
if (empty($sorting)) return;
foreach (explode(',', $sorting) as $sortClauseString) {
if ( ! preg_match("#^\s*[`'](.*)[`']\s+(asc|desc)\s*$#i", $sortClauseString, $matches)) {
$this->context->log(
"Could not interpret sorting clause '{$sortClauseString}' for module #{$this->moduleId}",
Generator::LOG_LEVEL_ERROR
);
continue;
}
// store direction per column as key
$this->model['ordered_by'][ $matches[1] ] = $matches[2];
}
} | [
"protected",
"function",
"processModuleSorting",
"(",
")",
"{",
"$",
"this",
"->",
"model",
"[",
"'is_listified'",
"]",
"=",
"false",
";",
"$",
"this",
"->",
"model",
"[",
"'ordered_by'",
"]",
"=",
"[",
"]",
";",
"// if there can be only 1 entry, it makes no sense to listify or order in any case",
"if",
"(",
"$",
"this",
"->",
"module",
"[",
"'max_entries'",
"]",
"==",
"1",
")",
"{",
"return",
";",
"}",
"// if manually sorted, use listify and do not set sorting columns",
"if",
"(",
"$",
"this",
"->",
"module",
"[",
"'sort_entries_manually'",
"]",
")",
"{",
"$",
"this",
"->",
"model",
"[",
"'is_listified'",
"]",
"=",
"true",
";",
"return",
";",
"}",
"// if automatically sorted, check and extract the sorting columns",
"// listify is disabled by default, but may be overridden (might be useful some day)",
"$",
"this",
"->",
"model",
"[",
"'is_listified'",
"]",
"=",
"false",
";",
"$",
"sorting",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"this",
"->",
"module",
"[",
"'sort_entries_by'",
"]",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"sorting",
")",
")",
"return",
";",
"foreach",
"(",
"explode",
"(",
"','",
",",
"$",
"sorting",
")",
"as",
"$",
"sortClauseString",
")",
"{",
"if",
"(",
"!",
"preg_match",
"(",
"\"#^\\s*[`'](.*)[`']\\s+(asc|desc)\\s*$#i\"",
",",
"$",
"sortClauseString",
",",
"$",
"matches",
")",
")",
"{",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Could not interpret sorting clause '{$sortClauseString}' for module #{$this->moduleId}\"",
",",
"Generator",
"::",
"LOG_LEVEL_ERROR",
")",
";",
"continue",
";",
"}",
"// store direction per column as key",
"$",
"this",
"->",
"model",
"[",
"'ordered_by'",
"]",
"[",
"$",
"matches",
"[",
"1",
"]",
"]",
"=",
"$",
"matches",
"[",
"2",
"]",
";",
"}",
"}"
]
| Determines and stores information about the sorting configuration
found for entries of the module | [
"Determines",
"and",
"stores",
"information",
"about",
"the",
"sorting",
"configuration",
"found",
"for",
"entries",
"of",
"the",
"module"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeModels.php#L181-L218 |
15,265 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeModels.php | AnalyzeModels.prepareModelOverrides | protected function prepareModelOverrides()
{
$this->overrides = $this->getOverrideConfigForModel($this->moduleId);
// determine name to use, handle pluralization and check database table override
if (array_key_exists('name', $this->overrides)) {
$name = $this->overrides['name'];
} else {
$name = array_get($this->module, 'prefixed_name') ?: $this->model['name'];
if (config('pxlcms.generator.models.model_name.singularize_model_names')) {
if ($this->context->dutchMode) {
$name = $this->dutchSingularize($name);
} else {
$name = str_singular($name);
}
}
}
// make sure we force set a table name if it does not follow convention
$tableOverride = null;
if (str_plural($this->normalizeDb($name)) != $this->normalizeDb($this->module['name'])) {
$tableOverride = $this->getModuleTablePrefix($this->moduleId)
. $this->normalizeDb($this->module['name']);
}
// force listified?
$listified = array_key_exists('listify', $this->overrides)
? (bool) $this->overrides['listify']
: $this->model['is_listified'];
// override hidden attributes?
$this->overrideHidden = [];
if ( ! is_null(array_get($this->overrides, 'attributes.hidden'))
&& ! array_get($this->overrides, 'attributes.hidden-empty')
) {
$this->overrideHidden = array_get($this->overrides, 'attributes.hidden');
if ( ! is_array($this->overrideHidden)) $this->overrideHidden = [ (string) $this->overrideHidden ];
}
// apply overrides to model data
$this->model['name'] = $name;
$this->model['table'] = $tableOverride;
$this->model['is_listified'] = $listified;
$this->model['hidden'] = $this->overrideHidden;
$this->model['casts'] = array_get($this->overrides, 'attributes.casts', []);
} | php | protected function prepareModelOverrides()
{
$this->overrides = $this->getOverrideConfigForModel($this->moduleId);
// determine name to use, handle pluralization and check database table override
if (array_key_exists('name', $this->overrides)) {
$name = $this->overrides['name'];
} else {
$name = array_get($this->module, 'prefixed_name') ?: $this->model['name'];
if (config('pxlcms.generator.models.model_name.singularize_model_names')) {
if ($this->context->dutchMode) {
$name = $this->dutchSingularize($name);
} else {
$name = str_singular($name);
}
}
}
// make sure we force set a table name if it does not follow convention
$tableOverride = null;
if (str_plural($this->normalizeDb($name)) != $this->normalizeDb($this->module['name'])) {
$tableOverride = $this->getModuleTablePrefix($this->moduleId)
. $this->normalizeDb($this->module['name']);
}
// force listified?
$listified = array_key_exists('listify', $this->overrides)
? (bool) $this->overrides['listify']
: $this->model['is_listified'];
// override hidden attributes?
$this->overrideHidden = [];
if ( ! is_null(array_get($this->overrides, 'attributes.hidden'))
&& ! array_get($this->overrides, 'attributes.hidden-empty')
) {
$this->overrideHidden = array_get($this->overrides, 'attributes.hidden');
if ( ! is_array($this->overrideHidden)) $this->overrideHidden = [ (string) $this->overrideHidden ];
}
// apply overrides to model data
$this->model['name'] = $name;
$this->model['table'] = $tableOverride;
$this->model['is_listified'] = $listified;
$this->model['hidden'] = $this->overrideHidden;
$this->model['casts'] = array_get($this->overrides, 'attributes.casts', []);
} | [
"protected",
"function",
"prepareModelOverrides",
"(",
")",
"{",
"$",
"this",
"->",
"overrides",
"=",
"$",
"this",
"->",
"getOverrideConfigForModel",
"(",
"$",
"this",
"->",
"moduleId",
")",
";",
"// determine name to use, handle pluralization and check database table override",
"if",
"(",
"array_key_exists",
"(",
"'name'",
",",
"$",
"this",
"->",
"overrides",
")",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"overrides",
"[",
"'name'",
"]",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"array_get",
"(",
"$",
"this",
"->",
"module",
",",
"'prefixed_name'",
")",
"?",
":",
"$",
"this",
"->",
"model",
"[",
"'name'",
"]",
";",
"if",
"(",
"config",
"(",
"'pxlcms.generator.models.model_name.singularize_model_names'",
")",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"context",
"->",
"dutchMode",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"dutchSingularize",
"(",
"$",
"name",
")",
";",
"}",
"else",
"{",
"$",
"name",
"=",
"str_singular",
"(",
"$",
"name",
")",
";",
"}",
"}",
"}",
"// make sure we force set a table name if it does not follow convention",
"$",
"tableOverride",
"=",
"null",
";",
"if",
"(",
"str_plural",
"(",
"$",
"this",
"->",
"normalizeDb",
"(",
"$",
"name",
")",
")",
"!=",
"$",
"this",
"->",
"normalizeDb",
"(",
"$",
"this",
"->",
"module",
"[",
"'name'",
"]",
")",
")",
"{",
"$",
"tableOverride",
"=",
"$",
"this",
"->",
"getModuleTablePrefix",
"(",
"$",
"this",
"->",
"moduleId",
")",
".",
"$",
"this",
"->",
"normalizeDb",
"(",
"$",
"this",
"->",
"module",
"[",
"'name'",
"]",
")",
";",
"}",
"// force listified?",
"$",
"listified",
"=",
"array_key_exists",
"(",
"'listify'",
",",
"$",
"this",
"->",
"overrides",
")",
"?",
"(",
"bool",
")",
"$",
"this",
"->",
"overrides",
"[",
"'listify'",
"]",
":",
"$",
"this",
"->",
"model",
"[",
"'is_listified'",
"]",
";",
"// override hidden attributes?",
"$",
"this",
"->",
"overrideHidden",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"is_null",
"(",
"array_get",
"(",
"$",
"this",
"->",
"overrides",
",",
"'attributes.hidden'",
")",
")",
"&&",
"!",
"array_get",
"(",
"$",
"this",
"->",
"overrides",
",",
"'attributes.hidden-empty'",
")",
")",
"{",
"$",
"this",
"->",
"overrideHidden",
"=",
"array_get",
"(",
"$",
"this",
"->",
"overrides",
",",
"'attributes.hidden'",
")",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"this",
"->",
"overrideHidden",
")",
")",
"$",
"this",
"->",
"overrideHidden",
"=",
"[",
"(",
"string",
")",
"$",
"this",
"->",
"overrideHidden",
"]",
";",
"}",
"// apply overrides to model data",
"$",
"this",
"->",
"model",
"[",
"'name'",
"]",
"=",
"$",
"name",
";",
"$",
"this",
"->",
"model",
"[",
"'table'",
"]",
"=",
"$",
"tableOverride",
";",
"$",
"this",
"->",
"model",
"[",
"'is_listified'",
"]",
"=",
"$",
"listified",
";",
"$",
"this",
"->",
"model",
"[",
"'hidden'",
"]",
"=",
"$",
"this",
"->",
"overrideHidden",
";",
"$",
"this",
"->",
"model",
"[",
"'casts'",
"]",
"=",
"array_get",
"(",
"$",
"this",
"->",
"overrides",
",",
"'attributes.casts'",
",",
"[",
"]",
")",
";",
"}"
]
| Prepares override cache for current model being assembled | [
"Prepares",
"override",
"cache",
"for",
"current",
"model",
"being",
"assembled"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeModels.php#L223-L279 |
15,266 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeModels.php | AnalyzeModels.applyOverridesForRelationships | protected function applyOverridesForRelationships()
{
$overrides = array_get($this->overrides, 'relationships');
if (empty($overrides)) return;
$removeRelations = [];
foreach ($overrides as $overrideName => $override) {
// find the relationship
foreach (['normal', 'image', 'file', 'checkbox'] as $type) {
foreach ($this->model['relationships'][ $type ] as $name => &$relationData) {
if ($name === $overrideName) {
// apply overrides and change the model data
$newName = array_get($override, 'name');
$preventReverse = array_get($override, 'prevent_reverse', false);
$reverseName = array_get($override, 'reverse_name', false);
if ($preventReverse) {
$relationData['prevent_reverse'] = true;
}
if ( ! empty($reverseName)) {
$relationData['reverse_name'] = $reverseName;
}
if ( ! empty($newName)) {
$this->model['relationships'][ $type ][ $newName ] = $relationData;
$removeRelations[] = $type . '.' . $overrideName;
$removeRelations = array_diff($removeRelations, [ $newName ]);
}
$this->context->log(
"Override applied for relationship {$overrideName} on module {$this->moduleId}."
);
break 2;
}
}
}
}
unset($relationData);
// remove now 'moved' relationships
array_forget($this->model['relationships'], $removeRelations);
} | php | protected function applyOverridesForRelationships()
{
$overrides = array_get($this->overrides, 'relationships');
if (empty($overrides)) return;
$removeRelations = [];
foreach ($overrides as $overrideName => $override) {
// find the relationship
foreach (['normal', 'image', 'file', 'checkbox'] as $type) {
foreach ($this->model['relationships'][ $type ] as $name => &$relationData) {
if ($name === $overrideName) {
// apply overrides and change the model data
$newName = array_get($override, 'name');
$preventReverse = array_get($override, 'prevent_reverse', false);
$reverseName = array_get($override, 'reverse_name', false);
if ($preventReverse) {
$relationData['prevent_reverse'] = true;
}
if ( ! empty($reverseName)) {
$relationData['reverse_name'] = $reverseName;
}
if ( ! empty($newName)) {
$this->model['relationships'][ $type ][ $newName ] = $relationData;
$removeRelations[] = $type . '.' . $overrideName;
$removeRelations = array_diff($removeRelations, [ $newName ]);
}
$this->context->log(
"Override applied for relationship {$overrideName} on module {$this->moduleId}."
);
break 2;
}
}
}
}
unset($relationData);
// remove now 'moved' relationships
array_forget($this->model['relationships'], $removeRelations);
} | [
"protected",
"function",
"applyOverridesForRelationships",
"(",
")",
"{",
"$",
"overrides",
"=",
"array_get",
"(",
"$",
"this",
"->",
"overrides",
",",
"'relationships'",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"overrides",
")",
")",
"return",
";",
"$",
"removeRelations",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"overrides",
"as",
"$",
"overrideName",
"=>",
"$",
"override",
")",
"{",
"// find the relationship",
"foreach",
"(",
"[",
"'normal'",
",",
"'image'",
",",
"'file'",
",",
"'checkbox'",
"]",
"as",
"$",
"type",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"model",
"[",
"'relationships'",
"]",
"[",
"$",
"type",
"]",
"as",
"$",
"name",
"=>",
"&",
"$",
"relationData",
")",
"{",
"if",
"(",
"$",
"name",
"===",
"$",
"overrideName",
")",
"{",
"// apply overrides and change the model data",
"$",
"newName",
"=",
"array_get",
"(",
"$",
"override",
",",
"'name'",
")",
";",
"$",
"preventReverse",
"=",
"array_get",
"(",
"$",
"override",
",",
"'prevent_reverse'",
",",
"false",
")",
";",
"$",
"reverseName",
"=",
"array_get",
"(",
"$",
"override",
",",
"'reverse_name'",
",",
"false",
")",
";",
"if",
"(",
"$",
"preventReverse",
")",
"{",
"$",
"relationData",
"[",
"'prevent_reverse'",
"]",
"=",
"true",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"reverseName",
")",
")",
"{",
"$",
"relationData",
"[",
"'reverse_name'",
"]",
"=",
"$",
"reverseName",
";",
"}",
"if",
"(",
"!",
"empty",
"(",
"$",
"newName",
")",
")",
"{",
"$",
"this",
"->",
"model",
"[",
"'relationships'",
"]",
"[",
"$",
"type",
"]",
"[",
"$",
"newName",
"]",
"=",
"$",
"relationData",
";",
"$",
"removeRelations",
"[",
"]",
"=",
"$",
"type",
".",
"'.'",
".",
"$",
"overrideName",
";",
"$",
"removeRelations",
"=",
"array_diff",
"(",
"$",
"removeRelations",
",",
"[",
"$",
"newName",
"]",
")",
";",
"}",
"$",
"this",
"->",
"context",
"->",
"log",
"(",
"\"Override applied for relationship {$overrideName} on module {$this->moduleId}.\"",
")",
";",
"break",
"2",
";",
"}",
"}",
"}",
"}",
"unset",
"(",
"$",
"relationData",
")",
";",
"// remove now 'moved' relationships",
"array_forget",
"(",
"$",
"this",
"->",
"model",
"[",
"'relationships'",
"]",
",",
"$",
"removeRelations",
")",
";",
"}"
]
| Applies overrides set in the config for analyzed relationships | [
"Applies",
"overrides",
"set",
"in",
"the",
"config",
"for",
"analyzed",
"relationships"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeModels.php#L564-L618 |
15,267 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeModels.php | AnalyzeModels.multipleBelongsToRelationsBetweenModels | protected function multipleBelongsToRelationsBetweenModels($fromModuleId, $toModuleId)
{
$count = 0;
foreach ($this->context->output['models'][ $fromModuleId ]['relationships']['normal'] as $relationship) {
if ( $relationship['model'] == $toModuleId
&& $relationship['type'] == Generator::RELATIONSHIP_BELONGS_TO
&& ! array_get($relationship, 'negative')
) {
$count++;
}
}
return ($count > 1);
} | php | protected function multipleBelongsToRelationsBetweenModels($fromModuleId, $toModuleId)
{
$count = 0;
foreach ($this->context->output['models'][ $fromModuleId ]['relationships']['normal'] as $relationship) {
if ( $relationship['model'] == $toModuleId
&& $relationship['type'] == Generator::RELATIONSHIP_BELONGS_TO
&& ! array_get($relationship, 'negative')
) {
$count++;
}
}
return ($count > 1);
} | [
"protected",
"function",
"multipleBelongsToRelationsBetweenModels",
"(",
"$",
"fromModuleId",
",",
"$",
"toModuleId",
")",
"{",
"$",
"count",
"=",
"0",
";",
"foreach",
"(",
"$",
"this",
"->",
"context",
"->",
"output",
"[",
"'models'",
"]",
"[",
"$",
"fromModuleId",
"]",
"[",
"'relationships'",
"]",
"[",
"'normal'",
"]",
"as",
"$",
"relationship",
")",
"{",
"if",
"(",
"$",
"relationship",
"[",
"'model'",
"]",
"==",
"$",
"toModuleId",
"&&",
"$",
"relationship",
"[",
"'type'",
"]",
"==",
"Generator",
"::",
"RELATIONSHIP_BELONGS_TO",
"&&",
"!",
"array_get",
"(",
"$",
"relationship",
",",
"'negative'",
")",
")",
"{",
"$",
"count",
"++",
";",
"}",
"}",
"return",
"(",
"$",
"count",
">",
"1",
")",
";",
"}"
]
| Returns whether there are multiple relationships from one model to the other
@param int $fromModuleId
@param int $toModuleId
@return bool | [
"Returns",
"whether",
"there",
"are",
"multiple",
"relationships",
"from",
"one",
"model",
"to",
"the",
"other"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeModels.php#L783-L798 |
15,268 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeModels.php | AnalyzeModels.getImageResizesForField | protected function getImageResizesForField($fieldId)
{
if ( ! array_key_exists('resizes', $this->data->rawData['fields'][ $fieldId ])
|| ! count($this->data->rawData['fields'][ $fieldId ]['resizes'])
) {
return [];
}
$resizes = [];
foreach ($this->data->rawData['fields'][ $fieldId ]['resizes'] as $resizeId => $resize) {
$resizes[] = [
'resize' => $resizeId,
'prefix' => $resize['prefix'],
'width' => (int) $resize['width'],
'height' => (int) $resize['height'],
];
}
// sort resizes.. by prefix name, or by image size?
uasort($resizes, function ($a, $b) {
//return $a['width'] * $a['height'] - $b['width'] * $b['height'];
return strcmp($a['prefix'], $b['prefix']);
});
return $resizes;
} | php | protected function getImageResizesForField($fieldId)
{
if ( ! array_key_exists('resizes', $this->data->rawData['fields'][ $fieldId ])
|| ! count($this->data->rawData['fields'][ $fieldId ]['resizes'])
) {
return [];
}
$resizes = [];
foreach ($this->data->rawData['fields'][ $fieldId ]['resizes'] as $resizeId => $resize) {
$resizes[] = [
'resize' => $resizeId,
'prefix' => $resize['prefix'],
'width' => (int) $resize['width'],
'height' => (int) $resize['height'],
];
}
// sort resizes.. by prefix name, or by image size?
uasort($resizes, function ($a, $b) {
//return $a['width'] * $a['height'] - $b['width'] * $b['height'];
return strcmp($a['prefix'], $b['prefix']);
});
return $resizes;
} | [
"protected",
"function",
"getImageResizesForField",
"(",
"$",
"fieldId",
")",
"{",
"if",
"(",
"!",
"array_key_exists",
"(",
"'resizes'",
",",
"$",
"this",
"->",
"data",
"->",
"rawData",
"[",
"'fields'",
"]",
"[",
"$",
"fieldId",
"]",
")",
"||",
"!",
"count",
"(",
"$",
"this",
"->",
"data",
"->",
"rawData",
"[",
"'fields'",
"]",
"[",
"$",
"fieldId",
"]",
"[",
"'resizes'",
"]",
")",
")",
"{",
"return",
"[",
"]",
";",
"}",
"$",
"resizes",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"data",
"->",
"rawData",
"[",
"'fields'",
"]",
"[",
"$",
"fieldId",
"]",
"[",
"'resizes'",
"]",
"as",
"$",
"resizeId",
"=>",
"$",
"resize",
")",
"{",
"$",
"resizes",
"[",
"]",
"=",
"[",
"'resize'",
"=>",
"$",
"resizeId",
",",
"'prefix'",
"=>",
"$",
"resize",
"[",
"'prefix'",
"]",
",",
"'width'",
"=>",
"(",
"int",
")",
"$",
"resize",
"[",
"'width'",
"]",
",",
"'height'",
"=>",
"(",
"int",
")",
"$",
"resize",
"[",
"'height'",
"]",
",",
"]",
";",
"}",
"// sort resizes.. by prefix name, or by image size?",
"uasort",
"(",
"$",
"resizes",
",",
"function",
"(",
"$",
"a",
",",
"$",
"b",
")",
"{",
"//return $a['width'] * $a['height'] - $b['width'] * $b['height'];",
"return",
"strcmp",
"(",
"$",
"a",
"[",
"'prefix'",
"]",
",",
"$",
"b",
"[",
"'prefix'",
"]",
")",
";",
"}",
")",
";",
"return",
"$",
"resizes",
";",
"}"
]
| Returns data about resizes for an image field
@param int $fieldId
@return array | [
"Returns",
"data",
"about",
"resizes",
"for",
"an",
"image",
"field"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeModels.php#L806-L833 |
15,269 | czim/laravel-pxlcms | src/Generator/Analyzer/Steps/AnalyzeModels.php | AnalyzeModels.checkForReservedClassName | protected function checkForReservedClassName($name)
{
$name = trim(strtolower($name));
if (in_array($name, config('pxlcms.generator.reserved', []))) {
throw new \InvalidArgumentException("Cannot use {$name} as a module name, it is reserved!");
}
} | php | protected function checkForReservedClassName($name)
{
$name = trim(strtolower($name));
if (in_array($name, config('pxlcms.generator.reserved', []))) {
throw new \InvalidArgumentException("Cannot use {$name} as a module name, it is reserved!");
}
} | [
"protected",
"function",
"checkForReservedClassName",
"(",
"$",
"name",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"strtolower",
"(",
"$",
"name",
")",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"name",
",",
"config",
"(",
"'pxlcms.generator.reserved'",
",",
"[",
"]",
")",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Cannot use {$name} as a module name, it is reserved!\"",
")",
";",
"}",
"}"
]
| Checks whether a given name is on the reserved list
@param string $name | [
"Checks",
"whether",
"a",
"given",
"name",
"is",
"on",
"the",
"reserved",
"list"
]
| 910297d2a3f2db86dde51b0e10fe5aad45f1aa1a | https://github.com/czim/laravel-pxlcms/blob/910297d2a3f2db86dde51b0e10fe5aad45f1aa1a/src/Generator/Analyzer/Steps/AnalyzeModels.php#L840-L847 |
15,270 | ellipsephp/container | src/Container/CompositeServiceFactory.php | CompositeServiceFactory.extended | private function extended(callable $previous = null, callable $current): callable
{
return is_null($previous) ? $current : new Extension($current, $previous);
} | php | private function extended(callable $previous = null, callable $current): callable
{
return is_null($previous) ? $current : new Extension($current, $previous);
} | [
"private",
"function",
"extended",
"(",
"callable",
"$",
"previous",
"=",
"null",
",",
"callable",
"$",
"current",
")",
":",
"callable",
"{",
"return",
"is_null",
"(",
"$",
"previous",
")",
"?",
"$",
"current",
":",
"new",
"Extension",
"(",
"$",
"current",
",",
"$",
"previous",
")",
";",
"}"
]
| Return the previous service factory extended with the current service
factory.
@param callable $previous
@param callable $current
@return callable | [
"Return",
"the",
"previous",
"service",
"factory",
"extended",
"with",
"the",
"current",
"service",
"factory",
"."
]
| ae0836b071fa1751f41b50fc33e3196fcbced6bf | https://github.com/ellipsephp/container/blob/ae0836b071fa1751f41b50fc33e3196fcbced6bf/src/Container/CompositeServiceFactory.php#L47-L50 |
15,271 | bfitech/zapcore | src/Header.php | Header.get_header_string | final public static function get_header_string(int $code) {
if (!isset(self::$header_string[$code]))
$code = 404;
return [
'code' => $code,
'msg' => self::$header_string[$code],
];
} | php | final public static function get_header_string(int $code) {
if (!isset(self::$header_string[$code]))
$code = 404;
return [
'code' => $code,
'msg' => self::$header_string[$code],
];
} | [
"final",
"public",
"static",
"function",
"get_header_string",
"(",
"int",
"$",
"code",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"self",
"::",
"$",
"header_string",
"[",
"$",
"code",
"]",
")",
")",
"$",
"code",
"=",
"404",
";",
"return",
"[",
"'code'",
"=>",
"$",
"code",
",",
"'msg'",
"=>",
"self",
"::",
"$",
"header_string",
"[",
"$",
"code",
"]",
",",
"]",
";",
"}"
]
| Get HTTP code.
@param int $code HTTP code.
@return array A dict containing code and message if
`$code` is valid, 404 dict otherwise. | [
"Get",
"HTTP",
"code",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Header.php#L76-L83 |
15,272 | bfitech/zapcore | src/Header.php | Header.start_header | public static function start_header(
int $code=200, int $cache=0, array $headers=[]
) {
$msg = 'OK';
extract(self::get_header_string($code));
$proto = isset($_SERVER['SERVER_PROTOCOL'])
? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
static::header("$proto $code $msg");
if ($cache) {
$cache = intval($cache);
$expire = time() + $cache;
static::header("Expires: " .
gmdate("D, d M Y H:i:s", $expire)." GMT");
static::header("Cache-Control: must-revalidate");
} else {
static::header("Expires: Mon, 27 Jul 1996 07:00:00 GMT");
static::header(
"Cache-Control: no-store, no-cache, must-revalidate");
static::header("Cache-Control: post-check=0, pre-check=0");
static::header("Pragma: no-cache");
}
static::header("Last-Modified: " .
gmdate("D, d M Y H:i:s")." GMT");
static::header("X-Powered-By: Zap!", true);
if (!$headers)
return;
foreach ($headers as $header)
static::header($header);
} | php | public static function start_header(
int $code=200, int $cache=0, array $headers=[]
) {
$msg = 'OK';
extract(self::get_header_string($code));
$proto = isset($_SERVER['SERVER_PROTOCOL'])
? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.1';
static::header("$proto $code $msg");
if ($cache) {
$cache = intval($cache);
$expire = time() + $cache;
static::header("Expires: " .
gmdate("D, d M Y H:i:s", $expire)." GMT");
static::header("Cache-Control: must-revalidate");
} else {
static::header("Expires: Mon, 27 Jul 1996 07:00:00 GMT");
static::header(
"Cache-Control: no-store, no-cache, must-revalidate");
static::header("Cache-Control: post-check=0, pre-check=0");
static::header("Pragma: no-cache");
}
static::header("Last-Modified: " .
gmdate("D, d M Y H:i:s")." GMT");
static::header("X-Powered-By: Zap!", true);
if (!$headers)
return;
foreach ($headers as $header)
static::header($header);
} | [
"public",
"static",
"function",
"start_header",
"(",
"int",
"$",
"code",
"=",
"200",
",",
"int",
"$",
"cache",
"=",
"0",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"msg",
"=",
"'OK'",
";",
"extract",
"(",
"self",
"::",
"get_header_string",
"(",
"$",
"code",
")",
")",
";",
"$",
"proto",
"=",
"isset",
"(",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
")",
"?",
"$",
"_SERVER",
"[",
"'SERVER_PROTOCOL'",
"]",
":",
"'HTTP/1.1'",
";",
"static",
"::",
"header",
"(",
"\"$proto $code $msg\"",
")",
";",
"if",
"(",
"$",
"cache",
")",
"{",
"$",
"cache",
"=",
"intval",
"(",
"$",
"cache",
")",
";",
"$",
"expire",
"=",
"time",
"(",
")",
"+",
"$",
"cache",
";",
"static",
"::",
"header",
"(",
"\"Expires: \"",
".",
"gmdate",
"(",
"\"D, d M Y H:i:s\"",
",",
"$",
"expire",
")",
".",
"\" GMT\"",
")",
";",
"static",
"::",
"header",
"(",
"\"Cache-Control: must-revalidate\"",
")",
";",
"}",
"else",
"{",
"static",
"::",
"header",
"(",
"\"Expires: Mon, 27 Jul 1996 07:00:00 GMT\"",
")",
";",
"static",
"::",
"header",
"(",
"\"Cache-Control: no-store, no-cache, must-revalidate\"",
")",
";",
"static",
"::",
"header",
"(",
"\"Cache-Control: post-check=0, pre-check=0\"",
")",
";",
"static",
"::",
"header",
"(",
"\"Pragma: no-cache\"",
")",
";",
"}",
"static",
"::",
"header",
"(",
"\"Last-Modified: \"",
".",
"gmdate",
"(",
"\"D, d M Y H:i:s\"",
")",
".",
"\" GMT\"",
")",
";",
"static",
"::",
"header",
"(",
"\"X-Powered-By: Zap!\"",
",",
"true",
")",
";",
"if",
"(",
"!",
"$",
"headers",
")",
"return",
";",
"foreach",
"(",
"$",
"headers",
"as",
"$",
"header",
")",
"static",
"::",
"header",
"(",
"$",
"header",
")",
";",
"}"
]
| Start sending response headers.
@param int $code HTTP code.
@param int $cache Cache age, 0 for no cache.
@param array $headers Additional headers. | [
"Start",
"sending",
"response",
"headers",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Header.php#L144-L174 |
15,273 | bfitech/zapcore | src/Header.php | Header.send_file | public static function send_file(
string $fpath, $disposition=null, int $code=200, int $cache=0,
array $headers=[], bool $xsendfile=null,
callable $callback_notfound=null
) {
if (!file_exists($fpath) || is_dir($fpath)) {
static::start_header(404, 0, $headers);
if (is_callable($callback_notfound)) {
$callback_notfound();
static::halt();
}
return;
}
static::start_header($code, $cache, $headers);
static::header('Content-Length: ' .
filesize($fpath));
static::header("Content-Type: " .
Common::get_mimetype($fpath));
if ($disposition) {
if ($disposition === true)
$disposition = htmlspecialchars(
basename($fpath), ENT_QUOTES);
static::header(sprintf(
'Content-Disposition: attachment; filename="%s"',
$disposition));
}
if (!$xsendfile)
readfile($fpath);
static::halt();
} | php | public static function send_file(
string $fpath, $disposition=null, int $code=200, int $cache=0,
array $headers=[], bool $xsendfile=null,
callable $callback_notfound=null
) {
if (!file_exists($fpath) || is_dir($fpath)) {
static::start_header(404, 0, $headers);
if (is_callable($callback_notfound)) {
$callback_notfound();
static::halt();
}
return;
}
static::start_header($code, $cache, $headers);
static::header('Content-Length: ' .
filesize($fpath));
static::header("Content-Type: " .
Common::get_mimetype($fpath));
if ($disposition) {
if ($disposition === true)
$disposition = htmlspecialchars(
basename($fpath), ENT_QUOTES);
static::header(sprintf(
'Content-Disposition: attachment; filename="%s"',
$disposition));
}
if (!$xsendfile)
readfile($fpath);
static::halt();
} | [
"public",
"static",
"function",
"send_file",
"(",
"string",
"$",
"fpath",
",",
"$",
"disposition",
"=",
"null",
",",
"int",
"$",
"code",
"=",
"200",
",",
"int",
"$",
"cache",
"=",
"0",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
",",
"bool",
"$",
"xsendfile",
"=",
"null",
",",
"callable",
"$",
"callback_notfound",
"=",
"null",
")",
"{",
"if",
"(",
"!",
"file_exists",
"(",
"$",
"fpath",
")",
"||",
"is_dir",
"(",
"$",
"fpath",
")",
")",
"{",
"static",
"::",
"start_header",
"(",
"404",
",",
"0",
",",
"$",
"headers",
")",
";",
"if",
"(",
"is_callable",
"(",
"$",
"callback_notfound",
")",
")",
"{",
"$",
"callback_notfound",
"(",
")",
";",
"static",
"::",
"halt",
"(",
")",
";",
"}",
"return",
";",
"}",
"static",
"::",
"start_header",
"(",
"$",
"code",
",",
"$",
"cache",
",",
"$",
"headers",
")",
";",
"static",
"::",
"header",
"(",
"'Content-Length: '",
".",
"filesize",
"(",
"$",
"fpath",
")",
")",
";",
"static",
"::",
"header",
"(",
"\"Content-Type: \"",
".",
"Common",
"::",
"get_mimetype",
"(",
"$",
"fpath",
")",
")",
";",
"if",
"(",
"$",
"disposition",
")",
"{",
"if",
"(",
"$",
"disposition",
"===",
"true",
")",
"$",
"disposition",
"=",
"htmlspecialchars",
"(",
"basename",
"(",
"$",
"fpath",
")",
",",
"ENT_QUOTES",
")",
";",
"static",
"::",
"header",
"(",
"sprintf",
"(",
"'Content-Disposition: attachment; filename=\"%s\"'",
",",
"$",
"disposition",
")",
")",
";",
"}",
"if",
"(",
"!",
"$",
"xsendfile",
")",
"readfile",
"(",
"$",
"fpath",
")",
";",
"static",
"::",
"halt",
"(",
")",
";",
"}"
]
| Send file.
Using higher-level Route::static_file_default is enough for
standard usage. Wrap this in Route::static_file_custom to make
a more elaborate static file serving instead of calling it
directly.
@param string $fpath Path to file.
@param mixed $disposition If set as string, this will be used
as filename on content disposition. If set to true, content
disposition is inferred from basename. Otherwise, no
content disposition header is sent.
@param int $code HTTP code. Typically it's 200, but this can
be anything since we can serve, e.g. 404 with a text file.
@param int $cache Cache age, 0 for no cache.
@param array $headers Additional headers.
@param bool $xsendfile If true, response is delegated to
web server. Appropriate header must be set via $headers,
e.g.: `X-Accel-Redirect` on Nginx or `X-Sendfile` on
Apache.
@param callable $callback_notfound What to do when the file
is not found. If no callback is provided, the method will
just immediately halt. | [
"Send",
"file",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Header.php#L201-L236 |
15,274 | bfitech/zapcore | src/Header.php | Header.print_json | final public static function print_json(
int $errno=0, $data=null, int $http_code=200, int $cache=0
) {
$json = json_encode(compact('errno', 'data'));
self::start_header($http_code, $cache, [
'Content-Length: ' . strlen($json),
'Content-Type: application/json',
]);
static::halt($json);
} | php | final public static function print_json(
int $errno=0, $data=null, int $http_code=200, int $cache=0
) {
$json = json_encode(compact('errno', 'data'));
self::start_header($http_code, $cache, [
'Content-Length: ' . strlen($json),
'Content-Type: application/json',
]);
static::halt($json);
} | [
"final",
"public",
"static",
"function",
"print_json",
"(",
"int",
"$",
"errno",
"=",
"0",
",",
"$",
"data",
"=",
"null",
",",
"int",
"$",
"http_code",
"=",
"200",
",",
"int",
"$",
"cache",
"=",
"0",
")",
"{",
"$",
"json",
"=",
"json_encode",
"(",
"compact",
"(",
"'errno'",
",",
"'data'",
")",
")",
";",
"self",
"::",
"start_header",
"(",
"$",
"http_code",
",",
"$",
"cache",
",",
"[",
"'Content-Length: '",
".",
"strlen",
"(",
"$",
"json",
")",
",",
"'Content-Type: application/json'",
",",
"]",
")",
";",
"static",
"::",
"halt",
"(",
"$",
"json",
")",
";",
"}"
]
| Convenience method for JSON response.
@param int $errno Error number to return.
@param array $data Data to return.
@param int $http_code Valid HTTP response code.
@param int $cache Cache duration in seconds. 0 for no cache. | [
"Convenience",
"method",
"for",
"JSON",
"response",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Header.php#L246-L255 |
15,275 | bfitech/zapcore | src/Header.php | Header.pj | final public static function pj(
$retval, int $forbidden_code=null, int $cache=0
) {
$http_code = 200;
if (!is_array($retval)) {
$retval = [-1, null];
$forbidden_code = 500;
}
if ($retval[0] !== 0) {
$http_code = 401;
if ($forbidden_code)
$http_code = $forbidden_code;
}
if (!isset($retval[1]))
$retval[1] = null;
self::print_json($retval[0], $retval[1], $http_code, $cache);
} | php | final public static function pj(
$retval, int $forbidden_code=null, int $cache=0
) {
$http_code = 200;
if (!is_array($retval)) {
$retval = [-1, null];
$forbidden_code = 500;
}
if ($retval[0] !== 0) {
$http_code = 401;
if ($forbidden_code)
$http_code = $forbidden_code;
}
if (!isset($retval[1]))
$retval[1] = null;
self::print_json($retval[0], $retval[1], $http_code, $cache);
} | [
"final",
"public",
"static",
"function",
"pj",
"(",
"$",
"retval",
",",
"int",
"$",
"forbidden_code",
"=",
"null",
",",
"int",
"$",
"cache",
"=",
"0",
")",
"{",
"$",
"http_code",
"=",
"200",
";",
"if",
"(",
"!",
"is_array",
"(",
"$",
"retval",
")",
")",
"{",
"$",
"retval",
"=",
"[",
"-",
"1",
",",
"null",
"]",
";",
"$",
"forbidden_code",
"=",
"500",
";",
"}",
"if",
"(",
"$",
"retval",
"[",
"0",
"]",
"!==",
"0",
")",
"{",
"$",
"http_code",
"=",
"401",
";",
"if",
"(",
"$",
"forbidden_code",
")",
"$",
"http_code",
"=",
"$",
"forbidden_code",
";",
"}",
"if",
"(",
"!",
"isset",
"(",
"$",
"retval",
"[",
"1",
"]",
")",
")",
"$",
"retval",
"[",
"1",
"]",
"=",
"null",
";",
"self",
"::",
"print_json",
"(",
"$",
"retval",
"[",
"0",
"]",
",",
"$",
"retval",
"[",
"1",
"]",
",",
"$",
"http_code",
",",
"$",
"cache",
")",
";",
"}"
]
| Even shorter JSON response formatter.
@param array $retval Return value of typical Zap HTTP response.
Invalid format will send 500 HTTP error.
@param int $forbidden_code If `$retval[0] == 0`, HTTP code is
200. Otherwise it defaults to 401 which we can override with
this parameter, e.g. 403.
@param int $cache Cache duration in seconds. 0 for no cache.
@see Header::print_json.
@cond
@SuppressWarnings(PHPMD.ShortMethodName)
@endcond | [
"Even",
"shorter",
"JSON",
"response",
"formatter",
"."
]
| 0ae4cb9370876ab3583556bf272063685ec57948 | https://github.com/bfitech/zapcore/blob/0ae4cb9370876ab3583556bf272063685ec57948/src/Header.php#L272-L288 |
15,276 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.all | public function all()
{
$pluggables = [];
$allPlugs = $this->getAllBaseNames();
foreach ($allPlugs as $plug) {
$pluggables[] = $this->getJsonContents($plug);
}
return new Collection($this->sortByOrder($pluggables));
} | php | public function all()
{
$pluggables = [];
$allPlugs = $this->getAllBaseNames();
foreach ($allPlugs as $plug) {
$pluggables[] = $this->getJsonContents($plug);
}
return new Collection($this->sortByOrder($pluggables));
} | [
"public",
"function",
"all",
"(",
")",
"{",
"$",
"pluggables",
"=",
"[",
"]",
";",
"$",
"allPlugs",
"=",
"$",
"this",
"->",
"getAllBaseNames",
"(",
")",
";",
"foreach",
"(",
"$",
"allPlugs",
"as",
"$",
"plug",
")",
"{",
"$",
"pluggables",
"[",
"]",
"=",
"$",
"this",
"->",
"getJsonContents",
"(",
"$",
"plug",
")",
";",
"}",
"return",
"new",
"Collection",
"(",
"$",
"this",
"->",
"sortByOrder",
"(",
"$",
"pluggables",
")",
")",
";",
"}"
]
| Get all the pluggables.
@return Collection | [
"Get",
"all",
"the",
"pluggables",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L79-L89 |
15,277 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.getAllBaseNames | protected function getAllBaseNames()
{
$pluggables = [];
$path = $this->getPath();
if (!is_dir($path)) {
return $pluggables;
}
$folders = $this->files->directories($path);
foreach ($folders as $plug) {
$pluggables[] = basename($plug);
}
return $pluggables;
} | php | protected function getAllBaseNames()
{
$pluggables = [];
$path = $this->getPath();
if (!is_dir($path)) {
return $pluggables;
}
$folders = $this->files->directories($path);
foreach ($folders as $plug) {
$pluggables[] = basename($plug);
}
return $pluggables;
} | [
"protected",
"function",
"getAllBaseNames",
"(",
")",
"{",
"$",
"pluggables",
"=",
"[",
"]",
";",
"$",
"path",
"=",
"$",
"this",
"->",
"getPath",
"(",
")",
";",
"if",
"(",
"!",
"is_dir",
"(",
"$",
"path",
")",
")",
"{",
"return",
"$",
"pluggables",
";",
"}",
"$",
"folders",
"=",
"$",
"this",
"->",
"files",
"->",
"directories",
"(",
"$",
"path",
")",
";",
"foreach",
"(",
"$",
"folders",
"as",
"$",
"plug",
")",
"{",
"$",
"pluggables",
"[",
"]",
"=",
"basename",
"(",
"$",
"plug",
")",
";",
"}",
"return",
"$",
"pluggables",
";",
"}"
]
| Get all pluggable basenames.
@return array | [
"Get",
"all",
"pluggable",
"basenames",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L96-L113 |
15,278 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.getAllSlugs | protected function getAllSlugs()
{
$pluggables = $this->all();
$slugs = [];
foreach ($pluggables as $plug) {
$slugs[] = $plug['slug'];
}
return $slugs;
} | php | protected function getAllSlugs()
{
$pluggables = $this->all();
$slugs = [];
foreach ($pluggables as $plug) {
$slugs[] = $plug['slug'];
}
return $slugs;
} | [
"protected",
"function",
"getAllSlugs",
"(",
")",
"{",
"$",
"pluggables",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"$",
"slugs",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pluggables",
"as",
"$",
"plug",
")",
"{",
"$",
"slugs",
"[",
"]",
"=",
"$",
"plug",
"[",
"'slug'",
"]",
";",
"}",
"return",
"$",
"slugs",
";",
"}"
]
| Get all pluggable slugs.
@return array | [
"Get",
"all",
"pluggable",
"slugs",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L120-L129 |
15,279 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.pathExists | protected function pathExists($folder)
{
$folder = Str::studly($folder);
return in_array($folder, $this->getAllBaseNames());
} | php | protected function pathExists($folder)
{
$folder = Str::studly($folder);
return in_array($folder, $this->getAllBaseNames());
} | [
"protected",
"function",
"pathExists",
"(",
"$",
"folder",
")",
"{",
"$",
"folder",
"=",
"Str",
"::",
"studly",
"(",
"$",
"folder",
")",
";",
"return",
"in_array",
"(",
"$",
"folder",
",",
"$",
"this",
"->",
"getAllBaseNames",
"(",
")",
")",
";",
"}"
]
| Check if given pluggable path exists.
@param string $folder
@return bool | [
"Check",
"if",
"given",
"pluggable",
"path",
"exists",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L138-L143 |
15,280 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.getPluggablePath | public function getPluggablePath($slug, $allowNotExists = false)
{
$pluggable = Str::studly($slug);
if (!$this->pathExists($pluggable) && $allowNotExists === false) {
return;
}
return $this->getPath()."/{$pluggable}/";
} | php | public function getPluggablePath($slug, $allowNotExists = false)
{
$pluggable = Str::studly($slug);
if (!$this->pathExists($pluggable) && $allowNotExists === false) {
return;
}
return $this->getPath()."/{$pluggable}/";
} | [
"public",
"function",
"getPluggablePath",
"(",
"$",
"slug",
",",
"$",
"allowNotExists",
"=",
"false",
")",
"{",
"$",
"pluggable",
"=",
"Str",
"::",
"studly",
"(",
"$",
"slug",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"pathExists",
"(",
"$",
"pluggable",
")",
"&&",
"$",
"allowNotExists",
"===",
"false",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"getPath",
"(",
")",
".",
"\"/{$pluggable}/\"",
";",
"}"
]
| Get path for the specified pluggable.
@param string $slug
@return string | [
"Get",
"path",
"for",
"the",
"specified",
"pluggable",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L210-L219 |
15,281 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.getProperty | public function getProperty($property, $default = null)
{
list($pluggable, $key) = explode('::', $property);
return array_get($this->getJsonContents($pluggable), $key, $default);
} | php | public function getProperty($property, $default = null)
{
list($pluggable, $key) = explode('::', $property);
return array_get($this->getJsonContents($pluggable), $key, $default);
} | [
"public",
"function",
"getProperty",
"(",
"$",
"property",
",",
"$",
"default",
"=",
"null",
")",
"{",
"list",
"(",
"$",
"pluggable",
",",
"$",
"key",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"property",
")",
";",
"return",
"array_get",
"(",
"$",
"this",
"->",
"getJsonContents",
"(",
"$",
"pluggable",
")",
",",
"$",
"key",
",",
"$",
"default",
")",
";",
"}"
]
| Get a pluggable property value.
@param string $property
@param mixed $default
@return mixed | [
"Get",
"a",
"pluggable",
"property",
"value",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L241-L246 |
15,282 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.setProperty | public function setProperty($property, $value)
{
list($pluggable, $key) = explode('::', $property);
$content = $this->getJsonContents($pluggable);
if (count($content)) {
if (isset($content[$key])) {
unset($content[$key]);
}
$content[$key] = $value;
$this->setJsonContents($pluggable, $content);
return true;
}
return false;
} | php | public function setProperty($property, $value)
{
list($pluggable, $key) = explode('::', $property);
$content = $this->getJsonContents($pluggable);
if (count($content)) {
if (isset($content[$key])) {
unset($content[$key]);
}
$content[$key] = $value;
$this->setJsonContents($pluggable, $content);
return true;
}
return false;
} | [
"public",
"function",
"setProperty",
"(",
"$",
"property",
",",
"$",
"value",
")",
"{",
"list",
"(",
"$",
"pluggable",
",",
"$",
"key",
")",
"=",
"explode",
"(",
"'::'",
",",
"$",
"property",
")",
";",
"$",
"content",
"=",
"$",
"this",
"->",
"getJsonContents",
"(",
"$",
"pluggable",
")",
";",
"if",
"(",
"count",
"(",
"$",
"content",
")",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"content",
"[",
"$",
"key",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"content",
"[",
"$",
"key",
"]",
")",
";",
"}",
"$",
"content",
"[",
"$",
"key",
"]",
"=",
"$",
"value",
";",
"$",
"this",
"->",
"setJsonContents",
"(",
"$",
"pluggable",
",",
"$",
"content",
")",
";",
"return",
"true",
";",
"}",
"return",
"false",
";",
"}"
]
| Set a pluggale property value.
@param string $property
@param mixed $value
@return bool | [
"Set",
"a",
"pluggale",
"property",
"value",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L256-L274 |
15,283 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.getByEnabled | public function getByEnabled($enabled = true)
{
$disabledPluggables = [];
$enabledPluggables = [];
$pluggables = $this->all();
// Iterate through each pluggable
foreach ($pluggables as $pluggable) {
if ($this->isEnabled($pluggable['slug'])) {
$enabledPluggables[] = $pluggable;
} else {
$disabledPluggables[] = $pluggable;
}
}
if ($enabled === true) {
return $this->sortByOrder($enabledPluggables);
}
return $this->sortByOrder($disabledPluggables);
} | php | public function getByEnabled($enabled = true)
{
$disabledPluggables = [];
$enabledPluggables = [];
$pluggables = $this->all();
// Iterate through each pluggable
foreach ($pluggables as $pluggable) {
if ($this->isEnabled($pluggable['slug'])) {
$enabledPluggables[] = $pluggable;
} else {
$disabledPluggables[] = $pluggable;
}
}
if ($enabled === true) {
return $this->sortByOrder($enabledPluggables);
}
return $this->sortByOrder($disabledPluggables);
} | [
"public",
"function",
"getByEnabled",
"(",
"$",
"enabled",
"=",
"true",
")",
"{",
"$",
"disabledPluggables",
"=",
"[",
"]",
";",
"$",
"enabledPluggables",
"=",
"[",
"]",
";",
"$",
"pluggables",
"=",
"$",
"this",
"->",
"all",
"(",
")",
";",
"// Iterate through each pluggable",
"foreach",
"(",
"$",
"pluggables",
"as",
"$",
"pluggable",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isEnabled",
"(",
"$",
"pluggable",
"[",
"'slug'",
"]",
")",
")",
"{",
"$",
"enabledPluggables",
"[",
"]",
"=",
"$",
"pluggable",
";",
"}",
"else",
"{",
"$",
"disabledPluggables",
"[",
"]",
"=",
"$",
"pluggable",
";",
"}",
"}",
"if",
"(",
"$",
"enabled",
"===",
"true",
")",
"{",
"return",
"$",
"this",
"->",
"sortByOrder",
"(",
"$",
"enabledPluggables",
")",
";",
"}",
"return",
"$",
"this",
"->",
"sortByOrder",
"(",
"$",
"disabledPluggables",
")",
";",
"}"
]
| Find a pluggable with enabled status given.
@param bool $enabled
@return array | [
"Find",
"a",
"pluggable",
"with",
"enabled",
"status",
"given",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L283-L304 |
15,284 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.getJsonContents | protected function getJsonContents($pluggable)
{
$pluggable = Str::studly($pluggable);
$default = [];
if (!$this->pathExists($pluggable)) {
return $default;
}
$path = $this->getJsonPath($pluggable);
if ($this->files->exists($path)) {
$contents = $this->files->get($path);
return json_decode($contents, true);
} else {
$message = "Pluggable [{$pluggable}] must have a valid pluggable.json file.";
throw new FileNotFoundException($message);
}
} | php | protected function getJsonContents($pluggable)
{
$pluggable = Str::studly($pluggable);
$default = [];
if (!$this->pathExists($pluggable)) {
return $default;
}
$path = $this->getJsonPath($pluggable);
if ($this->files->exists($path)) {
$contents = $this->files->get($path);
return json_decode($contents, true);
} else {
$message = "Pluggable [{$pluggable}] must have a valid pluggable.json file.";
throw new FileNotFoundException($message);
}
} | [
"protected",
"function",
"getJsonContents",
"(",
"$",
"pluggable",
")",
"{",
"$",
"pluggable",
"=",
"Str",
"::",
"studly",
"(",
"$",
"pluggable",
")",
";",
"$",
"default",
"=",
"[",
"]",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"pathExists",
"(",
"$",
"pluggable",
")",
")",
"{",
"return",
"$",
"default",
";",
"}",
"$",
"path",
"=",
"$",
"this",
"->",
"getJsonPath",
"(",
"$",
"pluggable",
")",
";",
"if",
"(",
"$",
"this",
"->",
"files",
"->",
"exists",
"(",
"$",
"path",
")",
")",
"{",
"$",
"contents",
"=",
"$",
"this",
"->",
"files",
"->",
"get",
"(",
"$",
"path",
")",
";",
"return",
"json_decode",
"(",
"$",
"contents",
",",
"true",
")",
";",
"}",
"else",
"{",
"$",
"message",
"=",
"\"Pluggable [{$pluggable}] must have a valid pluggable.json file.\"",
";",
"throw",
"new",
"FileNotFoundException",
"(",
"$",
"message",
")",
";",
"}",
"}"
]
| Get pluggable JSON content as an array.
@param string $pluggable
@throws FileNotFoundException
@return array|mixed | [
"Get",
"pluggable",
"JSON",
"content",
"as",
"an",
"array",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L383-L403 |
15,285 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.sortByOrder | public function sortByOrder($pluggables)
{
$orderedPluggables = [];
foreach ($pluggables as $pluggable) {
if (!isset($pluggable['order'])) {
$pluggable['order'] = 9001; // It's over 9000!
}
$orderedPluggables[] = $pluggable;
}
if (count($orderedPluggables) > 0) {
$orderedPluggables = $this->arrayOrderBy($orderedPluggables, 'order', SORT_ASC, 'slug', SORT_ASC);
}
return $orderedPluggables;
} | php | public function sortByOrder($pluggables)
{
$orderedPluggables = [];
foreach ($pluggables as $pluggable) {
if (!isset($pluggable['order'])) {
$pluggable['order'] = 9001; // It's over 9000!
}
$orderedPluggables[] = $pluggable;
}
if (count($orderedPluggables) > 0) {
$orderedPluggables = $this->arrayOrderBy($orderedPluggables, 'order', SORT_ASC, 'slug', SORT_ASC);
}
return $orderedPluggables;
} | [
"public",
"function",
"sortByOrder",
"(",
"$",
"pluggables",
")",
"{",
"$",
"orderedPluggables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"pluggables",
"as",
"$",
"pluggable",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"pluggable",
"[",
"'order'",
"]",
")",
")",
"{",
"$",
"pluggable",
"[",
"'order'",
"]",
"=",
"9001",
";",
"// It's over 9000!",
"}",
"$",
"orderedPluggables",
"[",
"]",
"=",
"$",
"pluggable",
";",
"}",
"if",
"(",
"count",
"(",
"$",
"orderedPluggables",
")",
">",
"0",
")",
"{",
"$",
"orderedPluggables",
"=",
"$",
"this",
"->",
"arrayOrderBy",
"(",
"$",
"orderedPluggables",
",",
"'order'",
",",
"SORT_ASC",
",",
"'slug'",
",",
"SORT_ASC",
")",
";",
"}",
"return",
"$",
"orderedPluggables",
";",
"}"
]
| Sort pluggables by order.
@param array $pluggables
@return array | [
"Sort",
"pluggables",
"by",
"order",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L440-L456 |
15,286 | aindong/pluggables | src/Aindong/Pluggables/Pluggables.php | Pluggables.arrayOrderBy | protected function arrayOrderBy()
{
$arguments = func_get_args();
$data = array_shift($arguments);
foreach ($arguments as $argument => $field) {
if (is_string($field)) {
$temp = [];
foreach ($data as $key => $row) {
$temp[$key] = $row[$field];
}
$arguments[$argument] = $temp;
}
}
$arguments[] = &$data;
call_user_func_array('array_multisort', $arguments);
return array_pop($arguments);
} | php | protected function arrayOrderBy()
{
$arguments = func_get_args();
$data = array_shift($arguments);
foreach ($arguments as $argument => $field) {
if (is_string($field)) {
$temp = [];
foreach ($data as $key => $row) {
$temp[$key] = $row[$field];
}
$arguments[$argument] = $temp;
}
}
$arguments[] = &$data;
call_user_func_array('array_multisort', $arguments);
return array_pop($arguments);
} | [
"protected",
"function",
"arrayOrderBy",
"(",
")",
"{",
"$",
"arguments",
"=",
"func_get_args",
"(",
")",
";",
"$",
"data",
"=",
"array_shift",
"(",
"$",
"arguments",
")",
";",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"argument",
"=>",
"$",
"field",
")",
"{",
"if",
"(",
"is_string",
"(",
"$",
"field",
")",
")",
"{",
"$",
"temp",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"data",
"as",
"$",
"key",
"=>",
"$",
"row",
")",
"{",
"$",
"temp",
"[",
"$",
"key",
"]",
"=",
"$",
"row",
"[",
"$",
"field",
"]",
";",
"}",
"$",
"arguments",
"[",
"$",
"argument",
"]",
"=",
"$",
"temp",
";",
"}",
"}",
"$",
"arguments",
"[",
"]",
"=",
"&",
"$",
"data",
";",
"call_user_func_array",
"(",
"'array_multisort'",
",",
"$",
"arguments",
")",
";",
"return",
"array_pop",
"(",
"$",
"arguments",
")",
";",
"}"
]
| Helper method to order multiple values easily.
@return array | [
"Helper",
"method",
"to",
"order",
"multiple",
"values",
"easily",
"."
]
| bf8bab46fb65268043fb4b98db21f8e0338b5e96 | https://github.com/aindong/pluggables/blob/bf8bab46fb65268043fb4b98db21f8e0338b5e96/src/Aindong/Pluggables/Pluggables.php#L463-L480 |
15,287 | verschoof/bunq-api | src/Resource/PaymentResource.php | PaymentResource.listPayments | public function listPayments($userId, $monetaryAccountId)
{
$payments = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId));
foreach ($payments['Response'] as $key => $payment) {
$payments['Response'][$key]['Payment']['amount']['value'] = $this->floatToCents($payment['Payment']['amount']['value']);
}
return $payments;
} | php | public function listPayments($userId, $monetaryAccountId)
{
$payments = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId));
foreach ($payments['Response'] as $key => $payment) {
$payments['Response'][$key]['Payment']['amount']['value'] = $this->floatToCents($payment['Payment']['amount']['value']);
}
return $payments;
} | [
"public",
"function",
"listPayments",
"(",
"$",
"userId",
",",
"$",
"monetaryAccountId",
")",
"{",
"$",
"payments",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"getResourceEndpoint",
"(",
"$",
"userId",
",",
"$",
"monetaryAccountId",
")",
")",
";",
"foreach",
"(",
"$",
"payments",
"[",
"'Response'",
"]",
"as",
"$",
"key",
"=>",
"$",
"payment",
")",
"{",
"$",
"payments",
"[",
"'Response'",
"]",
"[",
"$",
"key",
"]",
"[",
"'Payment'",
"]",
"[",
"'amount'",
"]",
"[",
"'value'",
"]",
"=",
"$",
"this",
"->",
"floatToCents",
"(",
"$",
"payment",
"[",
"'Payment'",
"]",
"[",
"'amount'",
"]",
"[",
"'value'",
"]",
")",
";",
"}",
"return",
"$",
"payments",
";",
"}"
]
| Lists all payments.
@param integer $userId
@param integer $monetaryAccountId
@return array | [
"Lists",
"all",
"payments",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Resource/PaymentResource.php#L30-L38 |
15,288 | verschoof/bunq-api | src/Resource/PaymentResource.php | PaymentResource.getPayment | public function getPayment($userId, $monetaryAccountId, $id)
{
$paymentResponse = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId) . '/' . (int)$id);
$payment = $paymentResponse['Response'][0]['Payment'];
$payment['amount']['value'] = $this->floatToCents($payment['amount']['value']);
return $payment;
} | php | public function getPayment($userId, $monetaryAccountId, $id)
{
$paymentResponse = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId) . '/' . (int)$id);
$payment = $paymentResponse['Response'][0]['Payment'];
$payment['amount']['value'] = $this->floatToCents($payment['amount']['value']);
return $payment;
} | [
"public",
"function",
"getPayment",
"(",
"$",
"userId",
",",
"$",
"monetaryAccountId",
",",
"$",
"id",
")",
"{",
"$",
"paymentResponse",
"=",
"$",
"this",
"->",
"client",
"->",
"get",
"(",
"$",
"this",
"->",
"getResourceEndpoint",
"(",
"$",
"userId",
",",
"$",
"monetaryAccountId",
")",
".",
"'/'",
".",
"(",
"int",
")",
"$",
"id",
")",
";",
"$",
"payment",
"=",
"$",
"paymentResponse",
"[",
"'Response'",
"]",
"[",
"0",
"]",
"[",
"'Payment'",
"]",
";",
"$",
"payment",
"[",
"'amount'",
"]",
"[",
"'value'",
"]",
"=",
"$",
"this",
"->",
"floatToCents",
"(",
"$",
"payment",
"[",
"'amount'",
"]",
"[",
"'value'",
"]",
")",
";",
"return",
"$",
"payment",
";",
"}"
]
| Gets a user its payment information.
@param integer $userId
@param integer $monetaryAccountId
@param integer $id
@return array | [
"Gets",
"a",
"user",
"its",
"payment",
"information",
"."
]
| df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd | https://github.com/verschoof/bunq-api/blob/df9aa19f384275f4f0deb26de0cb5e5f8b45ffcd/src/Resource/PaymentResource.php#L49-L58 |
15,289 | prooph/link-app-core | src/Controller/ConfigurationController.php | ConfigurationController.changeNodeNameAction | public function changeNodeNameAction()
{
$nodeName = $this->bodyParam('node_name');
if (! is_string($nodeName) || strlen($nodeName) < 3) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The node name must be at least 3 characters long')));
}
$this->commandBus->dispatch(ChangeNodeName::to(
NodeName::fromString($nodeName),
ConfigLocation::fromPath(Definition::getSystemConfigDir())
));
return ['success' => true];
} | php | public function changeNodeNameAction()
{
$nodeName = $this->bodyParam('node_name');
if (! is_string($nodeName) || strlen($nodeName) < 3) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The node name must be at least 3 characters long')));
}
$this->commandBus->dispatch(ChangeNodeName::to(
NodeName::fromString($nodeName),
ConfigLocation::fromPath(Definition::getSystemConfigDir())
));
return ['success' => true];
} | [
"public",
"function",
"changeNodeNameAction",
"(",
")",
"{",
"$",
"nodeName",
"=",
"$",
"this",
"->",
"bodyParam",
"(",
"'node_name'",
")",
";",
"if",
"(",
"!",
"is_string",
"(",
"$",
"nodeName",
")",
"||",
"strlen",
"(",
"$",
"nodeName",
")",
"<",
"3",
")",
"{",
"return",
"new",
"ApiProblemResponse",
"(",
"new",
"ApiProblem",
"(",
"422",
",",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'The node name must be at least 3 characters long'",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"commandBus",
"->",
"dispatch",
"(",
"ChangeNodeName",
"::",
"to",
"(",
"NodeName",
"::",
"fromString",
"(",
"$",
"nodeName",
")",
",",
"ConfigLocation",
"::",
"fromPath",
"(",
"Definition",
"::",
"getSystemConfigDir",
"(",
")",
")",
")",
")",
";",
"return",
"[",
"'success'",
"=>",
"true",
"]",
";",
"}"
]
| Handles a POST request that want to change the node name | [
"Handles",
"a",
"POST",
"request",
"that",
"want",
"to",
"change",
"the",
"node",
"name"
]
| 835a5945dfa7be7b2cebfa6e84e757ecfd783357 | https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Controller/ConfigurationController.php#L37-L51 |
15,290 | prooph/link-app-core | src/Controller/ConfigurationController.php | ConfigurationController.configureJavascriptTickerAction | public function configureJavascriptTickerAction()
{
$tickerEnabled = $this->bodyParam('enabled');
$tickerInterval = $this->bodyParam('interval');
if (! is_bool($tickerEnabled)) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The enabled flag should be a boolean value')));
}
if (! is_int($tickerInterval) || $tickerInterval <= 0) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The ticker interval should greater than zero')));
}
$this->commandBus->dispatch(
ConfigureJavascriptTicker::set(
$tickerEnabled,
$tickerInterval,
ConfigLocation::fromPath(Definition::getSystemConfigDir())
)
);
return ['success' => true];
} | php | public function configureJavascriptTickerAction()
{
$tickerEnabled = $this->bodyParam('enabled');
$tickerInterval = $this->bodyParam('interval');
if (! is_bool($tickerEnabled)) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The enabled flag should be a boolean value')));
}
if (! is_int($tickerInterval) || $tickerInterval <= 0) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The ticker interval should greater than zero')));
}
$this->commandBus->dispatch(
ConfigureJavascriptTicker::set(
$tickerEnabled,
$tickerInterval,
ConfigLocation::fromPath(Definition::getSystemConfigDir())
)
);
return ['success' => true];
} | [
"public",
"function",
"configureJavascriptTickerAction",
"(",
")",
"{",
"$",
"tickerEnabled",
"=",
"$",
"this",
"->",
"bodyParam",
"(",
"'enabled'",
")",
";",
"$",
"tickerInterval",
"=",
"$",
"this",
"->",
"bodyParam",
"(",
"'interval'",
")",
";",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"tickerEnabled",
")",
")",
"{",
"return",
"new",
"ApiProblemResponse",
"(",
"new",
"ApiProblem",
"(",
"422",
",",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'The enabled flag should be a boolean value'",
")",
")",
")",
";",
"}",
"if",
"(",
"!",
"is_int",
"(",
"$",
"tickerInterval",
")",
"||",
"$",
"tickerInterval",
"<=",
"0",
")",
"{",
"return",
"new",
"ApiProblemResponse",
"(",
"new",
"ApiProblem",
"(",
"422",
",",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'The ticker interval should greater than zero'",
")",
")",
")",
";",
"}",
"$",
"this",
"->",
"commandBus",
"->",
"dispatch",
"(",
"ConfigureJavascriptTicker",
"::",
"set",
"(",
"$",
"tickerEnabled",
",",
"$",
"tickerInterval",
",",
"ConfigLocation",
"::",
"fromPath",
"(",
"Definition",
"::",
"getSystemConfigDir",
"(",
")",
")",
")",
")",
";",
"return",
"[",
"'success'",
"=>",
"true",
"]",
";",
"}"
]
| Handles a POST request to configure the javascript ticker | [
"Handles",
"a",
"POST",
"request",
"to",
"configure",
"the",
"javascript",
"ticker"
]
| 835a5945dfa7be7b2cebfa6e84e757ecfd783357 | https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Controller/ConfigurationController.php#L56-L78 |
15,291 | prooph/link-app-core | src/Controller/ConfigurationController.php | ConfigurationController.configureWorkflowProcessorMessageQueueAction | public function configureWorkflowProcessorMessageQueueAction()
{
$queueEnabled = $this->bodyParam('enabled');
if (! is_bool($queueEnabled)) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The enabled flag should be a boolean value')));
}
if ($queueEnabled) {
$this->commandBus->dispatch(
EnableWorkflowProcessorMessageQueue::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))
);
} else {
$this->commandBus->dispatch(
DisableWorkflowProcessorMessageQueue::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))
);
}
return ['success' => true];
} | php | public function configureWorkflowProcessorMessageQueueAction()
{
$queueEnabled = $this->bodyParam('enabled');
if (! is_bool($queueEnabled)) {
return new ApiProblemResponse(new ApiProblem(422, $this->translator->translate('The enabled flag should be a boolean value')));
}
if ($queueEnabled) {
$this->commandBus->dispatch(
EnableWorkflowProcessorMessageQueue::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))
);
} else {
$this->commandBus->dispatch(
DisableWorkflowProcessorMessageQueue::in(ConfigLocation::fromPath(Definition::getSystemConfigDir()))
);
}
return ['success' => true];
} | [
"public",
"function",
"configureWorkflowProcessorMessageQueueAction",
"(",
")",
"{",
"$",
"queueEnabled",
"=",
"$",
"this",
"->",
"bodyParam",
"(",
"'enabled'",
")",
";",
"if",
"(",
"!",
"is_bool",
"(",
"$",
"queueEnabled",
")",
")",
"{",
"return",
"new",
"ApiProblemResponse",
"(",
"new",
"ApiProblem",
"(",
"422",
",",
"$",
"this",
"->",
"translator",
"->",
"translate",
"(",
"'The enabled flag should be a boolean value'",
")",
")",
")",
";",
"}",
"if",
"(",
"$",
"queueEnabled",
")",
"{",
"$",
"this",
"->",
"commandBus",
"->",
"dispatch",
"(",
"EnableWorkflowProcessorMessageQueue",
"::",
"in",
"(",
"ConfigLocation",
"::",
"fromPath",
"(",
"Definition",
"::",
"getSystemConfigDir",
"(",
")",
")",
")",
")",
";",
"}",
"else",
"{",
"$",
"this",
"->",
"commandBus",
"->",
"dispatch",
"(",
"DisableWorkflowProcessorMessageQueue",
"::",
"in",
"(",
"ConfigLocation",
"::",
"fromPath",
"(",
"Definition",
"::",
"getSystemConfigDir",
"(",
")",
")",
")",
")",
";",
"}",
"return",
"[",
"'success'",
"=>",
"true",
"]",
";",
"}"
]
| Handles a POST request to enable or disable the workflow processor message queue | [
"Handles",
"a",
"POST",
"request",
"to",
"enable",
"or",
"disable",
"the",
"workflow",
"processor",
"message",
"queue"
]
| 835a5945dfa7be7b2cebfa6e84e757ecfd783357 | https://github.com/prooph/link-app-core/blob/835a5945dfa7be7b2cebfa6e84e757ecfd783357/src/Controller/ConfigurationController.php#L83-L102 |
15,292 | etki/opencart-core-installer | src/DebugPrinter.php | DebugPrinter.log | public static function log($message, $args = null)
{
if (getenv('DEBUG') || getenv('OPENCART_INSTALLER_DEBUG')) {
if ($args) {
if (!is_array($args)) {
$args = array($args);
}
$message = vsprintf($message, $args);
}
echo 'OpencartInstaller: ' . $message . PHP_EOL;
}
} | php | public static function log($message, $args = null)
{
if (getenv('DEBUG') || getenv('OPENCART_INSTALLER_DEBUG')) {
if ($args) {
if (!is_array($args)) {
$args = array($args);
}
$message = vsprintf($message, $args);
}
echo 'OpencartInstaller: ' . $message . PHP_EOL;
}
} | [
"public",
"static",
"function",
"log",
"(",
"$",
"message",
",",
"$",
"args",
"=",
"null",
")",
"{",
"if",
"(",
"getenv",
"(",
"'DEBUG'",
")",
"||",
"getenv",
"(",
"'OPENCART_INSTALLER_DEBUG'",
")",
")",
"{",
"if",
"(",
"$",
"args",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"args",
")",
")",
"{",
"$",
"args",
"=",
"array",
"(",
"$",
"args",
")",
";",
"}",
"$",
"message",
"=",
"vsprintf",
"(",
"$",
"message",
",",
"$",
"args",
")",
";",
"}",
"echo",
"'OpencartInstaller: '",
".",
"$",
"message",
".",
"PHP_EOL",
";",
"}",
"}"
]
| Writes debug message to stdout.
@param string $message Message to be shown.
@param array|string|null $args Additional arguments for message
formatting.
@return void
@since 0.1.0 | [
"Writes",
"debug",
"message",
"to",
"stdout",
"."
]
| e651c94982afe966cd36977bbdc2ff4f7e785475 | https://github.com/etki/opencart-core-installer/blob/e651c94982afe966cd36977bbdc2ff4f7e785475/src/DebugPrinter.php#L24-L35 |
15,293 | ryanwachtl/silverstripe-foundation-forms | code/pagetypes/FoundationFormPage.php | FoundationFormPage_Controller.submitFoundationForm | function submitFoundationForm($data, $form) {
if(isset($data['SecurityID'])) {
unset($data['SecurityID']);
}
Session::set('FoundationForm' . $this->ID, $data);
return $this->redirect($this->Link());
} | php | function submitFoundationForm($data, $form) {
if(isset($data['SecurityID'])) {
unset($data['SecurityID']);
}
Session::set('FoundationForm' . $this->ID, $data);
return $this->redirect($this->Link());
} | [
"function",
"submitFoundationForm",
"(",
"$",
"data",
",",
"$",
"form",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"data",
"[",
"'SecurityID'",
"]",
")",
")",
"{",
"unset",
"(",
"$",
"data",
"[",
"'SecurityID'",
"]",
")",
";",
"}",
"Session",
"::",
"set",
"(",
"'FoundationForm'",
".",
"$",
"this",
"->",
"ID",
",",
"$",
"data",
")",
";",
"return",
"$",
"this",
"->",
"redirect",
"(",
"$",
"this",
"->",
"Link",
"(",
")",
")",
";",
"}"
]
| submit the form and redirect back to the form | [
"submit",
"the",
"form",
"and",
"redirect",
"back",
"to",
"the",
"form"
]
| 9055449fcb895811187124d81e57b7c93948403f | https://github.com/ryanwachtl/silverstripe-foundation-forms/blob/9055449fcb895811187124d81e57b7c93948403f/code/pagetypes/FoundationFormPage.php#L145-L152 |
15,294 | crossjoin/Css | src/Crossjoin/Css/Format/Rule/AtImport/ImportRule.php | ImportRule.parseRuleString | protected function parseRuleString($ruleString)
{
$charset = $this->getCharset();
// Remove at-rule and unnecessary white-spaces
$ruleString = preg_replace('/^[ \r\n\t\f]*@import[ \r\n\t\f]+/i', '', $ruleString);
$ruleString = trim($ruleString, " \r\n\t\f");
// Remove trailing semicolon
$ruleString = rtrim($ruleString, ";");
$isEscaped = false;
$inFunction = false;
$url = "";
$mediaQuery = "";
$currentPart = "";
for ($i = 0, $j = mb_strlen($ruleString, $charset); $i < $j; $i++) {
$char = mb_substr($ruleString, $i, 1, $charset);
if ($char === "\\") {
if ($isEscaped === false) {
$isEscaped = true;
} else {
$isEscaped = false;
}
} else {
if ($char === " ") {
if ($isEscaped === false) {
if ($inFunction == false) {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
if ($url === "") {
$url = trim($currentPart, " \r\n\t\f");
} else {
$mediaQuery .= trim($currentPart, " \r\n\t\f");
$mediaQuery .= $char;
}
$currentPart = "";
}
}
} else {
$currentPart .= $char;
}
} elseif ($isEscaped === false && $char === "(") {
$inFunction = true;
$currentPart .= $char;
} elseif ($isEscaped === false && $char === ")") {
$inFunction = false;
$currentPart .= $char;
} else {
$currentPart .= $char;
}
}
// Reset escaped flag
if ($isEscaped === true && $char !== "\\") {
$isEscaped = false;
}
}
if ($currentPart !== "") {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
if ($url === "") {
$url = trim($currentPart, " \r\n\t\f");
} else {
$mediaQuery .= trim($currentPart, " \r\n\t\f");
}
}
}
// Get URL value
$url = Url::extractUrl($url);
$this->setUrl($url);
// Process media query
$mediaRule = new MediaRule($mediaQuery);
$this->setQueries($mediaRule->getQueries());
} | php | protected function parseRuleString($ruleString)
{
$charset = $this->getCharset();
// Remove at-rule and unnecessary white-spaces
$ruleString = preg_replace('/^[ \r\n\t\f]*@import[ \r\n\t\f]+/i', '', $ruleString);
$ruleString = trim($ruleString, " \r\n\t\f");
// Remove trailing semicolon
$ruleString = rtrim($ruleString, ";");
$isEscaped = false;
$inFunction = false;
$url = "";
$mediaQuery = "";
$currentPart = "";
for ($i = 0, $j = mb_strlen($ruleString, $charset); $i < $j; $i++) {
$char = mb_substr($ruleString, $i, 1, $charset);
if ($char === "\\") {
if ($isEscaped === false) {
$isEscaped = true;
} else {
$isEscaped = false;
}
} else {
if ($char === " ") {
if ($isEscaped === false) {
if ($inFunction == false) {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
if ($url === "") {
$url = trim($currentPart, " \r\n\t\f");
} else {
$mediaQuery .= trim($currentPart, " \r\n\t\f");
$mediaQuery .= $char;
}
$currentPart = "";
}
}
} else {
$currentPart .= $char;
}
} elseif ($isEscaped === false && $char === "(") {
$inFunction = true;
$currentPart .= $char;
} elseif ($isEscaped === false && $char === ")") {
$inFunction = false;
$currentPart .= $char;
} else {
$currentPart .= $char;
}
}
// Reset escaped flag
if ($isEscaped === true && $char !== "\\") {
$isEscaped = false;
}
}
if ($currentPart !== "") {
$currentPart = trim($currentPart, " \r\n\t\f");
if ($currentPart !== "") {
if ($url === "") {
$url = trim($currentPart, " \r\n\t\f");
} else {
$mediaQuery .= trim($currentPart, " \r\n\t\f");
}
}
}
// Get URL value
$url = Url::extractUrl($url);
$this->setUrl($url);
// Process media query
$mediaRule = new MediaRule($mediaQuery);
$this->setQueries($mediaRule->getQueries());
} | [
"protected",
"function",
"parseRuleString",
"(",
"$",
"ruleString",
")",
"{",
"$",
"charset",
"=",
"$",
"this",
"->",
"getCharset",
"(",
")",
";",
"// Remove at-rule and unnecessary white-spaces",
"$",
"ruleString",
"=",
"preg_replace",
"(",
"'/^[ \\r\\n\\t\\f]*@import[ \\r\\n\\t\\f]+/i'",
",",
"''",
",",
"$",
"ruleString",
")",
";",
"$",
"ruleString",
"=",
"trim",
"(",
"$",
"ruleString",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"// Remove trailing semicolon",
"$",
"ruleString",
"=",
"rtrim",
"(",
"$",
"ruleString",
",",
"\";\"",
")",
";",
"$",
"isEscaped",
"=",
"false",
";",
"$",
"inFunction",
"=",
"false",
";",
"$",
"url",
"=",
"\"\"",
";",
"$",
"mediaQuery",
"=",
"\"\"",
";",
"$",
"currentPart",
"=",
"\"\"",
";",
"for",
"(",
"$",
"i",
"=",
"0",
",",
"$",
"j",
"=",
"mb_strlen",
"(",
"$",
"ruleString",
",",
"$",
"charset",
")",
";",
"$",
"i",
"<",
"$",
"j",
";",
"$",
"i",
"++",
")",
"{",
"$",
"char",
"=",
"mb_substr",
"(",
"$",
"ruleString",
",",
"$",
"i",
",",
"1",
",",
"$",
"charset",
")",
";",
"if",
"(",
"$",
"char",
"===",
"\"\\\\\"",
")",
"{",
"if",
"(",
"$",
"isEscaped",
"===",
"false",
")",
"{",
"$",
"isEscaped",
"=",
"true",
";",
"}",
"else",
"{",
"$",
"isEscaped",
"=",
"false",
";",
"}",
"}",
"else",
"{",
"if",
"(",
"$",
"char",
"===",
"\" \"",
")",
"{",
"if",
"(",
"$",
"isEscaped",
"===",
"false",
")",
"{",
"if",
"(",
"$",
"inFunction",
"==",
"false",
")",
"{",
"$",
"currentPart",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"if",
"(",
"$",
"currentPart",
"!==",
"\"\"",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"\"\"",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"}",
"else",
"{",
"$",
"mediaQuery",
".=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"$",
"mediaQuery",
".=",
"$",
"char",
";",
"}",
"$",
"currentPart",
"=",
"\"\"",
";",
"}",
"}",
"}",
"else",
"{",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"}",
"elseif",
"(",
"$",
"isEscaped",
"===",
"false",
"&&",
"$",
"char",
"===",
"\"(\"",
")",
"{",
"$",
"inFunction",
"=",
"true",
";",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"elseif",
"(",
"$",
"isEscaped",
"===",
"false",
"&&",
"$",
"char",
"===",
"\")\"",
")",
"{",
"$",
"inFunction",
"=",
"false",
";",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"else",
"{",
"$",
"currentPart",
".=",
"$",
"char",
";",
"}",
"}",
"// Reset escaped flag",
"if",
"(",
"$",
"isEscaped",
"===",
"true",
"&&",
"$",
"char",
"!==",
"\"\\\\\"",
")",
"{",
"$",
"isEscaped",
"=",
"false",
";",
"}",
"}",
"if",
"(",
"$",
"currentPart",
"!==",
"\"\"",
")",
"{",
"$",
"currentPart",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"if",
"(",
"$",
"currentPart",
"!==",
"\"\"",
")",
"{",
"if",
"(",
"$",
"url",
"===",
"\"\"",
")",
"{",
"$",
"url",
"=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"}",
"else",
"{",
"$",
"mediaQuery",
".=",
"trim",
"(",
"$",
"currentPart",
",",
"\" \\r\\n\\t\\f\"",
")",
";",
"}",
"}",
"}",
"// Get URL value",
"$",
"url",
"=",
"Url",
"::",
"extractUrl",
"(",
"$",
"url",
")",
";",
"$",
"this",
"->",
"setUrl",
"(",
"$",
"url",
")",
";",
"// Process media query",
"$",
"mediaRule",
"=",
"new",
"MediaRule",
"(",
"$",
"mediaQuery",
")",
";",
"$",
"this",
"->",
"setQueries",
"(",
"$",
"mediaRule",
"->",
"getQueries",
"(",
")",
")",
";",
"}"
]
| Parses the import rule.
@param string $ruleString | [
"Parses",
"the",
"import",
"rule",
"."
]
| 7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3 | https://github.com/crossjoin/Css/blob/7b50ca94c4bdad60d01cfa327f00b7a600d6f9f3/src/Crossjoin/Css/Format/Rule/AtImport/ImportRule.php#L109-L186 |
15,295 | shawnsandy/ui-pages | src/Classes/Markdown.php | Markdown.markdown | public function markdown($markdown, $page = null)
{
$file = $markdown . '.md';
if (isset($page)) {
$file = $page . '/' . $markdown . '.md';
}
if (!Storage::disk('markdown')->exists($file)) {
return false;
}
$array = $this->markdownToArray($file);
return $array ;
} | php | public function markdown($markdown, $page = null)
{
$file = $markdown . '.md';
if (isset($page)) {
$file = $page . '/' . $markdown . '.md';
}
if (!Storage::disk('markdown')->exists($file)) {
return false;
}
$array = $this->markdownToArray($file);
return $array ;
} | [
"public",
"function",
"markdown",
"(",
"$",
"markdown",
",",
"$",
"page",
"=",
"null",
")",
"{",
"$",
"file",
"=",
"$",
"markdown",
".",
"'.md'",
";",
"if",
"(",
"isset",
"(",
"$",
"page",
")",
")",
"{",
"$",
"file",
"=",
"$",
"page",
".",
"'/'",
".",
"$",
"markdown",
".",
"'.md'",
";",
"}",
"if",
"(",
"!",
"Storage",
"::",
"disk",
"(",
"'markdown'",
")",
"->",
"exists",
"(",
"$",
"file",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"array",
"=",
"$",
"this",
"->",
"markdownToArray",
"(",
"$",
"file",
")",
";",
"return",
"$",
"array",
";",
"}"
]
| Parses and output a markdown file
@param string $markdown File name
@param null $page File directory
@return string | [
"Parses",
"and",
"output",
"a",
"markdown",
"file"
]
| 11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8 | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Classes/Markdown.php#L44-L60 |
15,296 | shawnsandy/ui-pages | src/Classes/Markdown.php | Markdown.markdownLink | public function markdownLink($file_path, $type = '')
{
$array = explode('/', $file_path);
$dir = $array[0];
$replace = array('-', '_');
$url = trim($dir, '.md');
$display_name = str_replace($replace, ' ', trim($dir, '.md'));
if (count($array) > 1) {
$name = trim($array[1], '.md');
$url = $dir . '?page=' . $name;
$display_name = str_replace($replace, ' ', $name);
}
$link = ($type == 'url') ? '/md/' . $url :
'<a href="/md/' . $url . '" class="markdown-link">' . $display_name .
'</a>';
return $link;
} | php | public function markdownLink($file_path, $type = '')
{
$array = explode('/', $file_path);
$dir = $array[0];
$replace = array('-', '_');
$url = trim($dir, '.md');
$display_name = str_replace($replace, ' ', trim($dir, '.md'));
if (count($array) > 1) {
$name = trim($array[1], '.md');
$url = $dir . '?page=' . $name;
$display_name = str_replace($replace, ' ', $name);
}
$link = ($type == 'url') ? '/md/' . $url :
'<a href="/md/' . $url . '" class="markdown-link">' . $display_name .
'</a>';
return $link;
} | [
"public",
"function",
"markdownLink",
"(",
"$",
"file_path",
",",
"$",
"type",
"=",
"''",
")",
"{",
"$",
"array",
"=",
"explode",
"(",
"'/'",
",",
"$",
"file_path",
")",
";",
"$",
"dir",
"=",
"$",
"array",
"[",
"0",
"]",
";",
"$",
"replace",
"=",
"array",
"(",
"'-'",
",",
"'_'",
")",
";",
"$",
"url",
"=",
"trim",
"(",
"$",
"dir",
",",
"'.md'",
")",
";",
"$",
"display_name",
"=",
"str_replace",
"(",
"$",
"replace",
",",
"' '",
",",
"trim",
"(",
"$",
"dir",
",",
"'.md'",
")",
")",
";",
"if",
"(",
"count",
"(",
"$",
"array",
")",
">",
"1",
")",
"{",
"$",
"name",
"=",
"trim",
"(",
"$",
"array",
"[",
"1",
"]",
",",
"'.md'",
")",
";",
"$",
"url",
"=",
"$",
"dir",
".",
"'?page='",
".",
"$",
"name",
";",
"$",
"display_name",
"=",
"str_replace",
"(",
"$",
"replace",
",",
"' '",
",",
"$",
"name",
")",
";",
"}",
"$",
"link",
"=",
"(",
"$",
"type",
"==",
"'url'",
")",
"?",
"'/md/'",
".",
"$",
"url",
":",
"'<a href=\"/md/'",
".",
"$",
"url",
".",
"'\" class=\"markdown-link\">'",
".",
"$",
"display_name",
".",
"'</a>'",
";",
"return",
"$",
"link",
";",
"}"
]
| Converts a give md file path to a link
@param string $file_path file path
@param string $type url/link
@return mixed | [
"Converts",
"a",
"give",
"md",
"file",
"path",
"to",
"a",
"link"
]
| 11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8 | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Classes/Markdown.php#L94-L116 |
15,297 | shawnsandy/ui-pages | src/Classes/Markdown.php | Markdown.markdownMenu | public function markdownMenu($dir = null)
{
$md_files = $this->markdownFiles($dir);
$links = [];
foreach ($md_files as $file) {
$links[] = $this->markdownLink($file, $this->type);
}
return $links;
} | php | public function markdownMenu($dir = null)
{
$md_files = $this->markdownFiles($dir);
$links = [];
foreach ($md_files as $file) {
$links[] = $this->markdownLink($file, $this->type);
}
return $links;
} | [
"public",
"function",
"markdownMenu",
"(",
"$",
"dir",
"=",
"null",
")",
"{",
"$",
"md_files",
"=",
"$",
"this",
"->",
"markdownFiles",
"(",
"$",
"dir",
")",
";",
"$",
"links",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"md_files",
"as",
"$",
"file",
")",
"{",
"$",
"links",
"[",
"]",
"=",
"$",
"this",
"->",
"markdownLink",
"(",
"$",
"file",
",",
"$",
"this",
"->",
"type",
")",
";",
"}",
"return",
"$",
"links",
";",
"}"
]
| Returns an list or directory of array of markdown files
@param string $dir file dir
@return array | [
"Returns",
"an",
"list",
"or",
"directory",
"of",
"array",
"of",
"markdown",
"files"
]
| 11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8 | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Classes/Markdown.php#L125-L136 |
15,298 | shawnsandy/ui-pages | src/Classes/Markdown.php | Markdown.markdownPosts | public function markdownPosts($dir = null)
{
$source = collect($this->markdownFiles($dir));
if (empty($source)) {
return false;
}
//map files
$files = $source->map(
function ($file) {
$array = $this->markdownToArray($file);
$arr['url'] = $array['url'];
$arr['last_modified'] = $array['last_modified'];
$arr['time_ago'] = $array['time_ago'];
$arr['link'] = $array['link'];
$arr['title'] = $array['title'];
$arr['excerpt'] = $array['excerpt'];
$arr['content'] = $array['content'];
return $arr;
}
);
return $files;
} | php | public function markdownPosts($dir = null)
{
$source = collect($this->markdownFiles($dir));
if (empty($source)) {
return false;
}
//map files
$files = $source->map(
function ($file) {
$array = $this->markdownToArray($file);
$arr['url'] = $array['url'];
$arr['last_modified'] = $array['last_modified'];
$arr['time_ago'] = $array['time_ago'];
$arr['link'] = $array['link'];
$arr['title'] = $array['title'];
$arr['excerpt'] = $array['excerpt'];
$arr['content'] = $array['content'];
return $arr;
}
);
return $files;
} | [
"public",
"function",
"markdownPosts",
"(",
"$",
"dir",
"=",
"null",
")",
"{",
"$",
"source",
"=",
"collect",
"(",
"$",
"this",
"->",
"markdownFiles",
"(",
"$",
"dir",
")",
")",
";",
"if",
"(",
"empty",
"(",
"$",
"source",
")",
")",
"{",
"return",
"false",
";",
"}",
"//map files",
"$",
"files",
"=",
"$",
"source",
"->",
"map",
"(",
"function",
"(",
"$",
"file",
")",
"{",
"$",
"array",
"=",
"$",
"this",
"->",
"markdownToArray",
"(",
"$",
"file",
")",
";",
"$",
"arr",
"[",
"'url'",
"]",
"=",
"$",
"array",
"[",
"'url'",
"]",
";",
"$",
"arr",
"[",
"'last_modified'",
"]",
"=",
"$",
"array",
"[",
"'last_modified'",
"]",
";",
"$",
"arr",
"[",
"'time_ago'",
"]",
"=",
"$",
"array",
"[",
"'time_ago'",
"]",
";",
"$",
"arr",
"[",
"'link'",
"]",
"=",
"$",
"array",
"[",
"'link'",
"]",
";",
"$",
"arr",
"[",
"'title'",
"]",
"=",
"$",
"array",
"[",
"'title'",
"]",
";",
"$",
"arr",
"[",
"'excerpt'",
"]",
"=",
"$",
"array",
"[",
"'excerpt'",
"]",
";",
"$",
"arr",
"[",
"'content'",
"]",
"=",
"$",
"array",
"[",
"'content'",
"]",
";",
"return",
"$",
"arr",
";",
"}",
")",
";",
"return",
"$",
"files",
";",
"}"
]
| Return and array of markdown
@param string $dir location of md directory
@return mixed | [
"Return",
"and",
"array",
"of",
"markdown"
]
| 11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8 | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Classes/Markdown.php#L157-L185 |
15,299 | shawnsandy/ui-pages | src/Classes/Markdown.php | Markdown.markdownToArray | public function markdownToArray($file)
{
$markdown = $this->markdown->transform(
Storage::disk('markdown')
->get($file)
);
$array = explode("\n", $markdown);
$data['url'] = $this->markdownLink($file, 'url');
$data['last_modified'] = date(
'Y-m-d',
Storage::disk('markdown')->lastModified($file)
);
$posted = Carbon::now()->parse($data['last_modified'])->diffForHumans();
$data['time_ago'] = $posted;
$data['link'] = $this->markdownLink($file);
$data['title'] = $array[0];
$data['excerpt'] = $array[2];
$data['content'] = str_replace($data['title'], '', $markdown);
return $data ;
} | php | public function markdownToArray($file)
{
$markdown = $this->markdown->transform(
Storage::disk('markdown')
->get($file)
);
$array = explode("\n", $markdown);
$data['url'] = $this->markdownLink($file, 'url');
$data['last_modified'] = date(
'Y-m-d',
Storage::disk('markdown')->lastModified($file)
);
$posted = Carbon::now()->parse($data['last_modified'])->diffForHumans();
$data['time_ago'] = $posted;
$data['link'] = $this->markdownLink($file);
$data['title'] = $array[0];
$data['excerpt'] = $array[2];
$data['content'] = str_replace($data['title'], '', $markdown);
return $data ;
} | [
"public",
"function",
"markdownToArray",
"(",
"$",
"file",
")",
"{",
"$",
"markdown",
"=",
"$",
"this",
"->",
"markdown",
"->",
"transform",
"(",
"Storage",
"::",
"disk",
"(",
"'markdown'",
")",
"->",
"get",
"(",
"$",
"file",
")",
")",
";",
"$",
"array",
"=",
"explode",
"(",
"\"\\n\"",
",",
"$",
"markdown",
")",
";",
"$",
"data",
"[",
"'url'",
"]",
"=",
"$",
"this",
"->",
"markdownLink",
"(",
"$",
"file",
",",
"'url'",
")",
";",
"$",
"data",
"[",
"'last_modified'",
"]",
"=",
"date",
"(",
"'Y-m-d'",
",",
"Storage",
"::",
"disk",
"(",
"'markdown'",
")",
"->",
"lastModified",
"(",
"$",
"file",
")",
")",
";",
"$",
"posted",
"=",
"Carbon",
"::",
"now",
"(",
")",
"->",
"parse",
"(",
"$",
"data",
"[",
"'last_modified'",
"]",
")",
"->",
"diffForHumans",
"(",
")",
";",
"$",
"data",
"[",
"'time_ago'",
"]",
"=",
"$",
"posted",
";",
"$",
"data",
"[",
"'link'",
"]",
"=",
"$",
"this",
"->",
"markdownLink",
"(",
"$",
"file",
")",
";",
"$",
"data",
"[",
"'title'",
"]",
"=",
"$",
"array",
"[",
"0",
"]",
";",
"$",
"data",
"[",
"'excerpt'",
"]",
"=",
"$",
"array",
"[",
"2",
"]",
";",
"$",
"data",
"[",
"'content'",
"]",
"=",
"str_replace",
"(",
"$",
"data",
"[",
"'title'",
"]",
",",
"''",
",",
"$",
"markdown",
")",
";",
"return",
"$",
"data",
";",
"}"
]
| Takes a markdown and converts it to array
@param string $file
@return array | [
"Takes",
"a",
"markdown",
"and",
"converts",
"it",
"to",
"array"
]
| 11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8 | https://github.com/shawnsandy/ui-pages/blob/11584c12fa3e2b9a5c513f4ec9e2eaf78c206ca8/src/Classes/Markdown.php#L194-L218 |
Subsets and Splits