repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior._getUserId
protected function _getUserId(): ?string { $userId = null; $callback = $this->config('userIdCallback'); if (is_callable($callback)) { $userId = $callback(); } return $userId; }
php
protected function _getUserId(): ?string { $userId = null; $callback = $this->config('userIdCallback'); if (is_callable($callback)) { $userId = $callback(); } return $userId; }
[ "protected", "function", "_getUserId", "(", ")", ":", "?", "string", "{", "$", "userId", "=", "null", ";", "$", "callback", "=", "$", "this", "->", "config", "(", "'userIdCallback'", ")", ";", "if", "(", "is_callable", "(", "$", "callback", ")", ")", ...
Tries to get a userId to use in the history from the given configuration @return string|null
[ "Tries", "to", "get", "a", "userId", "to", "use", "in", "the", "history", "from", "the", "given", "configuration" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L338-L347
train
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getUserNameFields
public function getUserNameFields(bool $withoutModel = false): array { $userNameFields = $this->config('userNameFields'); if ($withoutModel) { foreach ($userNameFields as $key => $value) { $exploded = explode('.', $value); if (count($exploded) === 2) { $userNameFields[$key] = $exploded[1]; } } } return $userNameFields; }
php
public function getUserNameFields(bool $withoutModel = false): array { $userNameFields = $this->config('userNameFields'); if ($withoutModel) { foreach ($userNameFields as $key => $value) { $exploded = explode('.', $value); if (count($exploded) === 2) { $userNameFields[$key] = $exploded[1]; } } } return $userNameFields; }
[ "public", "function", "getUserNameFields", "(", "bool", "$", "withoutModel", "=", "false", ")", ":", "array", "{", "$", "userNameFields", "=", "$", "this", "->", "config", "(", "'userNameFields'", ")", ";", "if", "(", "$", "withoutModel", ")", "{", "foreac...
Get the user fields @param bool $withoutModel set to true to only get the field names without model name @return array
[ "Get", "the", "user", "fields" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L413-L426
train
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getTranslatedFields
public function getTranslatedFields(): array { return Hash::apply($this->config('fields'), '{*}[searchable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data['translation']; } return Hash::sort($formatted, '{s}', 'asc'); }); }
php
public function getTranslatedFields(): array { return Hash::apply($this->config('fields'), '{*}[searchable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data['translation']; } return Hash::sort($formatted, '{s}', 'asc'); }); }
[ "public", "function", "getTranslatedFields", "(", ")", ":", "array", "{", "return", "Hash", "::", "apply", "(", "$", "this", "->", "config", "(", "'fields'", ")", ",", "'{*}[searchable=true]'", ",", "function", "(", "$", "array", ")", "{", "$", "formatted"...
Get translated fields @return array
[ "Get", "translated", "fields" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L467-L477
train
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getSaveableFields
public function getSaveableFields(): array { return Hash::apply($this->config('fields'), '{*}[saveable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data; } return $formatted; }); }
php
public function getSaveableFields(): array { return Hash::apply($this->config('fields'), '{*}[saveable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data; } return $formatted; }); }
[ "public", "function", "getSaveableFields", "(", ")", ":", "array", "{", "return", "Hash", "::", "apply", "(", "$", "this", "->", "config", "(", "'fields'", ")", ",", "'{*}[saveable=true]'", ",", "function", "(", "$", "array", ")", "{", "$", "formatted", ...
Get saveable fields @return array
[ "Get", "saveable", "fields" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L484-L494
train
fab2s/NodalFlow
src/Flows/FlowRegistry.php
FlowRegistry.load
public function load(FlowInterface $flow, array $entry) { $this->registerFlow($flow); $flowId = $flow->getId(); static::$registry[$flowId] = $entry; foreach ($flow->getNodes() as $node) { $this->registerNode($node); } return $this; }
php
public function load(FlowInterface $flow, array $entry) { $this->registerFlow($flow); $flowId = $flow->getId(); static::$registry[$flowId] = $entry; foreach ($flow->getNodes() as $node) { $this->registerNode($node); } return $this; }
[ "public", "function", "load", "(", "FlowInterface", "$", "flow", ",", "array", "$", "entry", ")", "{", "$", "this", "->", "registerFlow", "(", "$", "flow", ")", ";", "$", "flowId", "=", "$", "flow", "->", "getId", "(", ")", ";", "static", "::", "$"...
Used upon FlowMap un-serialization @param FlowInterface $flow @param array $entry @throws NodalFlowException @return $this
[ "Used", "upon", "FlowMap", "un", "-", "serialization" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowRegistry.php#L57-L68
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.insert
public function insert($bucketName, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "INSERT INTO $bucketName (KEY, VALUE) VALUES (UUID(), $data) " . $this->buildReturning([new Expression('META().id AS `_id`')]); }
php
public function insert($bucketName, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "INSERT INTO $bucketName (KEY, VALUE) VALUES (UUID(), $data) " . $this->buildReturning([new Expression('META().id AS `_id`')]); }
[ "public", "function", "insert", "(", "$", "bucketName", ",", "$", "data", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ";", "$", "data", "=", "Json", "::", "encode", "(", "$", "data"...
Creates an INSERT SQL statement. For example, ```php $sql = $queryBuilder->insert('user', [ 'name' => 'Sam', 'age' => 30, ], $params); ``` The method will properly escape the bucket and column names. @param string $bucketName the bucket that new rows will be inserted into. @param array $data the column data (name => value) to be inserted into the bucket or instance They should be bound to the DB command later. @return string the INSERT SQL
[ "Creates", "an", "INSERT", "SQL", "statement", ".", "For", "example" ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L163-L169
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.upsert
public function upsert($bucketName, $id, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $id = $this->db->quoteValue($id); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "UPSERT INTO $bucketName (KEY, VALUE) VALUES ($id, $data) "; }
php
public function upsert($bucketName, $id, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $id = $this->db->quoteValue($id); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "UPSERT INTO $bucketName (KEY, VALUE) VALUES ($id, $data) "; }
[ "public", "function", "upsert", "(", "$", "bucketName", ",", "$", "id", ",", "$", "data", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ";", "$", "id", "=", "$", "this", "->", "db",...
Creates an UPSERT SQL statement. For example, ```php $sql = $queryBuilder->upsert('user', 'my-id', [ 'name' => 'Sam', 'age' => 30, ], $params); ``` The method will properly escape the bucket and column names. @param string $bucketName the bucket that new rows will be inserted into. @param string $id the document id. @param array $data the column data (name => value) to be inserted into the bucket or instance They should be bound to the DB command later. @return string the UPSERT SQL
[ "Creates", "an", "UPSERT", "SQL", "statement", ".", "For", "example" ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L277-L284
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildIndex
public function buildIndex($bucketName, $indexNames) { $indexNames = is_array($indexNames) ? $indexNames : [$indexNames]; foreach ($indexNames as $i => $indexName) { $indexNames[$i] = $this->db->quoteColumnName($indexName); } return 'BUILD INDEX ' . $this->db->quoteBucketName($bucketName) . '(' . implode(', ', $indexNames) . ') USING GSI'; }
php
public function buildIndex($bucketName, $indexNames) { $indexNames = is_array($indexNames) ? $indexNames : [$indexNames]; foreach ($indexNames as $i => $indexName) { $indexNames[$i] = $this->db->quoteColumnName($indexName); } return 'BUILD INDEX ' . $this->db->quoteBucketName($bucketName) . '(' . implode(', ', $indexNames) . ') USING GSI'; }
[ "public", "function", "buildIndex", "(", "$", "bucketName", ",", "$", "indexNames", ")", "{", "$", "indexNames", "=", "is_array", "(", "$", "indexNames", ")", "?", "$", "indexNames", ":", "[", "$", "indexNames", "]", ";", "foreach", "(", "$", "indexNames...
Builds a SQL statement for build index. @param string $bucketName @param string|string[] $indexNames names of index @return string the BUILD INDEX SQL
[ "Builds", "a", "SQL", "statement", "for", "build", "index", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L350-L359
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.createPrimaryIndex
public function createPrimaryIndex($bucketName, $indexName = null, $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); if ($indexName) { $indexName = $this->db->quoteBucketName($indexName); } $sql = "CREATE PRIMARY INDEX $indexName ON $bucketName"; if (!empty($options)) { $sql .= ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); } return $sql; }
php
public function createPrimaryIndex($bucketName, $indexName = null, $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); if ($indexName) { $indexName = $this->db->quoteBucketName($indexName); } $sql = "CREATE PRIMARY INDEX $indexName ON $bucketName"; if (!empty($options)) { $sql .= ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); } return $sql; }
[ "public", "function", "createPrimaryIndex", "(", "$", "bucketName", ",", "$", "indexName", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ...
Builds a SQL statement for creating a new primary index. @param string $bucketName @param string|null $indexName name of primary index (optional) @param array $options @return string the CREATE PRIMARY INDEX SQL
[ "Builds", "a", "SQL", "statement", "for", "creating", "a", "new", "primary", "index", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L370-L385
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.createIndex
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteBucketName($indexName); foreach ($columns as $i => $column) { if ($column instanceof Expression) { $columns[$i] = $column->expression; } else { $columns[$i] = $this->db->quoteColumnName($column); } } $where = $this->buildWhere($condition, $params); $sql = "CREATE INDEX $indexName ON $bucketName (" . implode(', ', $columns) . ")"; $sql = $where === '' ? $sql : $sql . ' ' . $where; $sql = empty($options) ? $sql : $sql . ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return $sql; }
php
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteBucketName($indexName); foreach ($columns as $i => $column) { if ($column instanceof Expression) { $columns[$i] = $column->expression; } else { $columns[$i] = $this->db->quoteColumnName($column); } } $where = $this->buildWhere($condition, $params); $sql = "CREATE INDEX $indexName ON $bucketName (" . implode(', ', $columns) . ")"; $sql = $where === '' ? $sql : $sql . ' ' . $where; $sql = empty($options) ? $sql : $sql . ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return $sql; }
[ "public", "function", "createIndex", "(", "$", "bucketName", ",", "$", "indexName", ",", "$", "columns", ",", "$", "condition", "=", "null", ",", "&", "$", "params", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "bucketName", "=...
Builds a SQL statement for creating a new index. @param string $bucketName @param string $indexName @param array $columns @param array|null $condition @param array $params @param array $options @return string the CREATE INDEX SQL @throws Exception
[ "Builds", "a", "SQL", "statement", "for", "creating", "a", "new", "index", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L414-L435
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.dropIndex
public function dropIndex($bucketName, $indexName) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteColumnName($indexName); return "DROP INDEX $bucketName.$indexName"; }
php
public function dropIndex($bucketName, $indexName) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteColumnName($indexName); return "DROP INDEX $bucketName.$indexName"; }
[ "public", "function", "dropIndex", "(", "$", "bucketName", ",", "$", "indexName", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ";", "$", "indexName", "=", "$", "this", "->", "db", "->"...
Builds a SQL statement for dropping an index. @param string $bucketName @param string $indexName @return string the DROP INDEX SQL
[ "Builds", "a", "SQL", "statement", "for", "dropping", "an", "index", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L445-L451
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.quoteBucketName
private function quoteBucketName($bucketName, &$params) { if (!is_array($bucketName)) { return $this->db->quoteBucketName($bucketName); } foreach ($bucketName as $i => $bucket) { if ($bucket instanceof Query) { list($sql, $params) = $this->build($bucket, $params); $bucketName[$i] = "($sql) " . $this->db->quoteBucketName($i); } elseif (is_string($i)) { if (strpos($bucket, '(') === false) { $bucket = $this->db->quoteBucketName($bucket); } $bucketName[$i] = "$bucket " . $this->db->quoteBucketName($i); } elseif (strpos($bucket, '(') === false) { if (preg_match('/^(.*?)(?i:\s+as|)\s+([^ ]+)$/', $bucket, $matches)) { // with alias $bucketName[$i] = $this->db->quoteBucketName($matches[1]) . ' ' . $this->db->quoteBucketName($matches[2]); } else { $bucketName[$i] = $this->db->quoteBucketName($bucket); } } } return reset($bucketName); }
php
private function quoteBucketName($bucketName, &$params) { if (!is_array($bucketName)) { return $this->db->quoteBucketName($bucketName); } foreach ($bucketName as $i => $bucket) { if ($bucket instanceof Query) { list($sql, $params) = $this->build($bucket, $params); $bucketName[$i] = "($sql) " . $this->db->quoteBucketName($i); } elseif (is_string($i)) { if (strpos($bucket, '(') === false) { $bucket = $this->db->quoteBucketName($bucket); } $bucketName[$i] = "$bucket " . $this->db->quoteBucketName($i); } elseif (strpos($bucket, '(') === false) { if (preg_match('/^(.*?)(?i:\s+as|)\s+([^ ]+)$/', $bucket, $matches)) { // with alias $bucketName[$i] = $this->db->quoteBucketName($matches[1]) . ' ' . $this->db->quoteBucketName($matches[2]); } else { $bucketName[$i] = $this->db->quoteBucketName($bucket); } } } return reset($bucketName); }
[ "private", "function", "quoteBucketName", "(", "$", "bucketName", ",", "&", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "bucketName", ")", ")", "{", "return", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ...
Quotes bucket names passed @param array|string $bucketName @param array $params @return array|string @throws Exception
[ "Quotes", "bucket", "names", "passed" ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L607-L637
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildCondition
public function buildCondition($condition, &$params) { if ($condition instanceof Expression) { foreach ($condition->params as $n => $v) { $params[$n] = $v; } return $condition->expression; } elseif (!is_array($condition)) { return (string) $condition; } elseif (empty($condition)) { return ''; } if (isset($condition[0])) { // operator format: operator, operand 1, operand 2, ... $operator = strtoupper($condition[0]); if (isset($this->conditionBuilders[$operator])) { $method = $this->conditionBuilders[$operator]; } else { $method = 'buildSimpleCondition'; } array_shift($condition); return $this->$method($operator, $condition, $params); } else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ... return $this->buildHashCondition($condition, $params); } }
php
public function buildCondition($condition, &$params) { if ($condition instanceof Expression) { foreach ($condition->params as $n => $v) { $params[$n] = $v; } return $condition->expression; } elseif (!is_array($condition)) { return (string) $condition; } elseif (empty($condition)) { return ''; } if (isset($condition[0])) { // operator format: operator, operand 1, operand 2, ... $operator = strtoupper($condition[0]); if (isset($this->conditionBuilders[$operator])) { $method = $this->conditionBuilders[$operator]; } else { $method = 'buildSimpleCondition'; } array_shift($condition); return $this->$method($operator, $condition, $params); } else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ... return $this->buildHashCondition($condition, $params); } }
[ "public", "function", "buildCondition", "(", "$", "condition", ",", "&", "$", "params", ")", "{", "if", "(", "$", "condition", "instanceof", "Expression", ")", "{", "foreach", "(", "$", "condition", "->", "params", "as", "$", "n", "=>", "$", "v", ")", ...
Parses the condition specification and generates the corresponding SQL expression. @param string|array|Expression $condition the condition specification. Please refer to [[Query::where()]] on how to specify a condition. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws Exception
[ "Parses", "the", "condition", "specification", "and", "generates", "the", "corresponding", "SQL", "expression", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L822-L855
train
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildCompositeInCondition
protected function buildCompositeInCondition($operator, $columns, $values, &$params) { $vss = []; foreach ($values as $value) { $vs = []; foreach ($columns as $column) { if (isset($value[$column])) { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value[$column]; $vs[] = $phName; } else { $vs[] = 'NULL'; } } $vss[] = '(' . implode(', ', $vs) . ')'; } if (empty($vss)) { return $operator === 'IN' ? '0=1' : ''; } $sqlColumns = []; foreach ($columns as $i => $column) { $sqlColumns[] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column; } return '(' . implode(', ', $sqlColumns) . ") $operator (" . implode(', ', $vss) . ')'; }
php
protected function buildCompositeInCondition($operator, $columns, $values, &$params) { $vss = []; foreach ($values as $value) { $vs = []; foreach ($columns as $column) { if (isset($value[$column])) { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value[$column]; $vs[] = $phName; } else { $vs[] = 'NULL'; } } $vss[] = '(' . implode(', ', $vs) . ')'; } if (empty($vss)) { return $operator === 'IN' ? '0=1' : ''; } $sqlColumns = []; foreach ($columns as $i => $column) { $sqlColumns[] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column; } return '(' . implode(', ', $sqlColumns) . ") $operator (" . implode(', ', $vss) . ')'; }
[ "protected", "function", "buildCompositeInCondition", "(", "$", "operator", ",", "$", "columns", ",", "$", "values", ",", "&", "$", "params", ")", "{", "$", "vss", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", ...
Builds SQL for IN condition @param string $operator @param array|\Traversable $columns @param array $values @param array $params @return string SQL
[ "Builds", "SQL", "for", "IN", "condition" ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L1143-L1175
train
baleen/migrations
src/Service/Runner/MigrationRunner.php
MigrationRunner.run
public function run(DeltaInterface $version, OptionsInterface $options) { if (!$this->shouldMigrate($version, $options)) { if ($options->isExceptionOnSkip()) { throw new RunnerException(sprintf( 'Cowardly refusing to run %s() on a delta that is already "%s" (ID: %s).', $options->getDirection(), $options->getDirection(), $version->getId() )); } return false; // skip } // Dispatch MIGRATE_BEFORE $this->getPublisher()->publish(new MigrateBeforeEvent($version, $options, $this->getContext())); $version->migrate($options); // state will be changed // Dispatch MIGRATE_AFTER $event = new MigrateAfterEvent($version, $options, $this->getContext()); $this->getPublisher()->publish($event); return $event; }
php
public function run(DeltaInterface $version, OptionsInterface $options) { if (!$this->shouldMigrate($version, $options)) { if ($options->isExceptionOnSkip()) { throw new RunnerException(sprintf( 'Cowardly refusing to run %s() on a delta that is already "%s" (ID: %s).', $options->getDirection(), $options->getDirection(), $version->getId() )); } return false; // skip } // Dispatch MIGRATE_BEFORE $this->getPublisher()->publish(new MigrateBeforeEvent($version, $options, $this->getContext())); $version->migrate($options); // state will be changed // Dispatch MIGRATE_AFTER $event = new MigrateAfterEvent($version, $options, $this->getContext()); $this->getPublisher()->publish($event); return $event; }
[ "public", "function", "run", "(", "DeltaInterface", "$", "version", ",", "OptionsInterface", "$", "options", ")", "{", "if", "(", "!", "$", "this", "->", "shouldMigrate", "(", "$", "version", ",", "$", "options", ")", ")", "{", "if", "(", "$", "options...
Runs a single version using the specified options @param DeltaInterface $version @param OptionsInterface $options @return false|MigrateAfterEvent @throws RunnerException
[ "Runs", "a", "single", "version", "using", "the", "specified", "options" ]
cfc8c439858cf4f0d4119af9eb67de493da8d95c
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/Runner/MigrationRunner.php#L76-L101
train
baleen/migrations
src/Service/Runner/MigrationRunner.php
MigrationRunner.shouldMigrate
protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options) { return $options->isForced() || ($options->getDirection()->isUp() ^ $version->isMigrated()); // direction is opposite to state }
php
protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options) { return $options->isForced() || ($options->getDirection()->isUp() ^ $version->isMigrated()); // direction is opposite to state }
[ "protected", "function", "shouldMigrate", "(", "DeltaInterface", "$", "version", ",", "OptionsInterface", "$", "options", ")", "{", "return", "$", "options", "->", "isForced", "(", ")", "||", "(", "$", "options", "->", "getDirection", "(", ")", "->", "isUp",...
Returns true if the operation is forced, or if the direction is the opposite to the state of the migration. @param DeltaInterface $version @param OptionsInterface $options @return bool
[ "Returns", "true", "if", "the", "operation", "is", "forced", "or", "if", "the", "direction", "is", "the", "opposite", "to", "the", "state", "of", "the", "migration", "." ]
cfc8c439858cf4f0d4119af9eb67de493da8d95c
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/Runner/MigrationRunner.php#L111-L115
train
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.modelHistoryArea
public function modelHistoryArea(EntityInterface $entity, array $options = []): string { $options = Hash::merge([ 'showCommentBox' => false, 'showFilterBox' => false, 'columnClass' => 'col-md-12', 'includeAssociated' => false ], $options); $page = 1; $limit = TableRegistry::get($entity->source())->getEntriesLimit(); $modelHistory = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistory($entity->source(), $entity->id, $limit, $page, [], $options); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($entity->source(), $entity->id, [], $options); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } return $this->_View->element('ModelHistory.model_history_area', [ 'modelHistory' => $modelHistory, 'showNextEntriesButton' => $showNextEntriesButton, 'showPrevEntriesButton' => $showPrevEntriesButton, 'page' => $page, 'model' => $entity->source(), 'foreignKey' => $entity->id, 'limit' => $limit, 'searchableFields' => TableRegistry::get($entity->source())->getTranslatedFields(), 'showCommentBox' => $options['showCommentBox'], 'showFilterBox' => $options['showFilterBox'], 'columnClass' => $options['columnClass'], 'includeAssociated' => $options['includeAssociated'], 'contexts' => $contexts ]); }
php
public function modelHistoryArea(EntityInterface $entity, array $options = []): string { $options = Hash::merge([ 'showCommentBox' => false, 'showFilterBox' => false, 'columnClass' => 'col-md-12', 'includeAssociated' => false ], $options); $page = 1; $limit = TableRegistry::get($entity->source())->getEntriesLimit(); $modelHistory = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistory($entity->source(), $entity->id, $limit, $page, [], $options); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($entity->source(), $entity->id, [], $options); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } return $this->_View->element('ModelHistory.model_history_area', [ 'modelHistory' => $modelHistory, 'showNextEntriesButton' => $showNextEntriesButton, 'showPrevEntriesButton' => $showPrevEntriesButton, 'page' => $page, 'model' => $entity->source(), 'foreignKey' => $entity->id, 'limit' => $limit, 'searchableFields' => TableRegistry::get($entity->source())->getTranslatedFields(), 'showCommentBox' => $options['showCommentBox'], 'showFilterBox' => $options['showFilterBox'], 'columnClass' => $options['columnClass'], 'includeAssociated' => $options['includeAssociated'], 'contexts' => $contexts ]); }
[ "public", "function", "modelHistoryArea", "(", "EntityInterface", "$", "entity", ",", "array", "$", "options", "=", "[", "]", ")", ":", "string", "{", "$", "options", "=", "Hash", "::", "merge", "(", "[", "'showCommentBox'", "=>", "false", ",", "'showFilte...
Render the model history area where needed @param \Cake\Datasource\EntityInterface $entity One historizable entity @param array $options options array
[ "Render", "the", "model", "history", "area", "where", "needed" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L31-L69
train
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.actionClass
public function actionClass(string $action): string { switch ($action) { case ModelHistory::ACTION_CREATE: $class = 'success'; break; case ModelHistory::ACTION_DELETE: $class = 'danger'; break; case ModelHistory::ACTION_COMMENT: $class = 'active'; break; case ModelHistory::ACTION_UPDATE: default: $class = 'info'; break; } return $class; }
php
public function actionClass(string $action): string { switch ($action) { case ModelHistory::ACTION_CREATE: $class = 'success'; break; case ModelHistory::ACTION_DELETE: $class = 'danger'; break; case ModelHistory::ACTION_COMMENT: $class = 'active'; break; case ModelHistory::ACTION_UPDATE: default: $class = 'info'; break; } return $class; }
[ "public", "function", "actionClass", "(", "string", "$", "action", ")", ":", "string", "{", "switch", "(", "$", "action", ")", "{", "case", "ModelHistory", "::", "ACTION_CREATE", ":", "$", "class", "=", "'success'", ";", "break", ";", "case", "ModelHistory...
Convert action to bootstrap class @param string $action History Action @return string
[ "Convert", "action", "to", "bootstrap", "class" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L77-L96
train
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.historyText
public function historyText(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_CREATE: $action = __d('model_history', 'created'); break; case ModelHistory::ACTION_UPDATE: $action = __d('model_history', 'updated'); break; case ModelHistory::ACTION_DELETE: $action = __d('model_history', 'deleted'); break; case ModelHistory::ACTION_COMMENT: $action = __d('model_history', 'commented'); break; default: } if (empty($history->user_id)) { $username = 'Anonymous'; } else { $userNameFields = TableRegistry::get($history->model)->getUserNameFields(true); $firstname = $history->user->{$userNameFields['firstname']}; $lastname = $history->user->{$userNameFields['lastname']}; $username = $firstname . ' ' . $lastname; } return ucfirst($action) . ' ' . __d('model_history', 'by') . ' ' . $username; }
php
public function historyText(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_CREATE: $action = __d('model_history', 'created'); break; case ModelHistory::ACTION_UPDATE: $action = __d('model_history', 'updated'); break; case ModelHistory::ACTION_DELETE: $action = __d('model_history', 'deleted'); break; case ModelHistory::ACTION_COMMENT: $action = __d('model_history', 'commented'); break; default: } if (empty($history->user_id)) { $username = 'Anonymous'; } else { $userNameFields = TableRegistry::get($history->model)->getUserNameFields(true); $firstname = $history->user->{$userNameFields['firstname']}; $lastname = $history->user->{$userNameFields['lastname']}; $username = $firstname . ' ' . $lastname; } return ucfirst($action) . ' ' . __d('model_history', 'by') . ' ' . $username; }
[ "public", "function", "historyText", "(", "ModelHistory", "$", "history", ")", ":", "string", "{", "$", "action", "=", "''", ";", "switch", "(", "$", "history", "->", "action", ")", "{", "case", "ModelHistory", "::", "ACTION_CREATE", ":", "$", "action", ...
Returns the text displayed in the widget @param ModelHistory $history one ModelHistory entity @return string
[ "Returns", "the", "text", "displayed", "in", "the", "widget" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L104-L132
train
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.historyBadge
public function historyBadge(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_UPDATE: $icon = 'refresh'; break; case ModelHistory::ACTION_DELETE: $icon = 'minus-circle'; break; case ModelHistory::ACTION_COMMENT: $icon = 'comments'; break; default: case ModelHistory::ACTION_CREATE: $icon = 'plus-circle'; break; } return '<i class="fa fa-' . $icon . '"></i>'; }
php
public function historyBadge(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_UPDATE: $icon = 'refresh'; break; case ModelHistory::ACTION_DELETE: $icon = 'minus-circle'; break; case ModelHistory::ACTION_COMMENT: $icon = 'comments'; break; default: case ModelHistory::ACTION_CREATE: $icon = 'plus-circle'; break; } return '<i class="fa fa-' . $icon . '"></i>'; }
[ "public", "function", "historyBadge", "(", "ModelHistory", "$", "history", ")", ":", "string", "{", "$", "action", "=", "''", ";", "switch", "(", "$", "history", "->", "action", ")", "{", "case", "ModelHistory", "::", "ACTION_UPDATE", ":", "$", "icon", "...
Returns the badge displayed in the widget @param ModelHistory $history one ModelHistory entity @return string
[ "Returns", "the", "badge", "displayed", "in", "the", "widget" ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L140-L160
train
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.getLocalizedFieldnames
public function getLocalizedFieldnames(ModelHistory $historyEntry): string { $fields = join(', ', array_map(function ($value) use ($historyEntry) { if (!is_string($value)) { return $value; } // Get pre configured translations and return it if found $fields = TableRegistry::get($historyEntry->model)->getFields(); if (isset($fields[$value]['translation'])) { if (is_callable($fields[$value]['translation'])) { return $fields[$value]['translation'](); } return $fields[$value]['translation']; } // Try to get the generic model.field translation string $localeSlug = strtolower(Inflector::singularize(Inflector::delimit($historyEntry->model))) . '.' . strtolower($value); $translatedString = __($localeSlug); // Return original value when no translation was made if ($localeSlug == $translatedString) { return $value; } return $translatedString; }, array_keys($historyEntry->data))); return $fields; }
php
public function getLocalizedFieldnames(ModelHistory $historyEntry): string { $fields = join(', ', array_map(function ($value) use ($historyEntry) { if (!is_string($value)) { return $value; } // Get pre configured translations and return it if found $fields = TableRegistry::get($historyEntry->model)->getFields(); if (isset($fields[$value]['translation'])) { if (is_callable($fields[$value]['translation'])) { return $fields[$value]['translation'](); } return $fields[$value]['translation']; } // Try to get the generic model.field translation string $localeSlug = strtolower(Inflector::singularize(Inflector::delimit($historyEntry->model))) . '.' . strtolower($value); $translatedString = __($localeSlug); // Return original value when no translation was made if ($localeSlug == $translatedString) { return $value; } return $translatedString; }, array_keys($historyEntry->data))); return $fields; }
[ "public", "function", "getLocalizedFieldnames", "(", "ModelHistory", "$", "historyEntry", ")", ":", "string", "{", "$", "fields", "=", "join", "(", "', '", ",", "array_map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "historyEntry", ")", "{"...
Retrieve field names as localized, comma seperated string. @param ModelHistory $historyEntry A History entry @return string
[ "Retrieve", "field", "names", "as", "localized", "comma", "seperated", "string", "." ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L168-L199
train
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.getLocalizedSlug
public function getLocalizedSlug(ModelHistory $historyEntry): string { $slug = $historyEntry->context_slug; if (!empty($historyEntry->context) && !empty($historyEntry->context['namespace'])) { $class = new $historyEntry->context['namespace']; if (method_exists($class, 'typeDescriptions')) { $typeDescriptions = $class::typeDescriptions(); if (isset($typeDescriptions[$slug])) { $slug = $typeDescriptions[$slug]; } } } return $slug; }
php
public function getLocalizedSlug(ModelHistory $historyEntry): string { $slug = $historyEntry->context_slug; if (!empty($historyEntry->context) && !empty($historyEntry->context['namespace'])) { $class = new $historyEntry->context['namespace']; if (method_exists($class, 'typeDescriptions')) { $typeDescriptions = $class::typeDescriptions(); if (isset($typeDescriptions[$slug])) { $slug = $typeDescriptions[$slug]; } } } return $slug; }
[ "public", "function", "getLocalizedSlug", "(", "ModelHistory", "$", "historyEntry", ")", ":", "string", "{", "$", "slug", "=", "$", "historyEntry", "->", "context_slug", ";", "if", "(", "!", "empty", "(", "$", "historyEntry", "->", "context", ")", "&&", "!...
Retrieve localized slug, when translation is available in type descriptions. @param ModelHistory $historyEntry HistoryEntry entity to get data from @return string
[ "Retrieve", "localized", "slug", "when", "translation", "is", "available", "in", "type", "descriptions", "." ]
4dceac1cc7db0e6d443750dd9d76b960df385931
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L207-L221
train
matrozov/yii2-couchbase
src/Migration.php
Migration.createBucket
public function createBucket($bucketName, $options = []) { $this->beginProfile($token = " > create bucket $bucketName ..."); $this->db->createBucket($bucketName, $options); $this->endProfile($token); }
php
public function createBucket($bucketName, $options = []) { $this->beginProfile($token = " > create bucket $bucketName ..."); $this->db->createBucket($bucketName, $options); $this->endProfile($token); }
[ "public", "function", "createBucket", "(", "$", "bucketName", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > create bucket $bucketName ...\"", ")", ";", "$", "this", "->", "db", "->", "crea...
Creates new bucket with the specified options. @param string $bucketName name of the bucket @param array $options bucket options in format: "name" => "value" @throws Exception @throws \yii\base\InvalidConfigException
[ "Creates", "new", "bucket", "with", "the", "specified", "options", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L63-L70
train
matrozov/yii2-couchbase
src/Migration.php
Migration.dropBucket
public function dropBucket($bucketName) { $this->beginProfile($token = " > drop bucket $bucketName ..."); $this->db->getBucket($bucketName)->drop(); $this->endProfile($token); }
php
public function dropBucket($bucketName) { $this->beginProfile($token = " > drop bucket $bucketName ..."); $this->db->getBucket($bucketName)->drop(); $this->endProfile($token); }
[ "public", "function", "dropBucket", "(", "$", "bucketName", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > drop bucket $bucketName ...\"", ")", ";", "$", "this", "->", "db", "->", "getBucket", "(", "$", "bucketName", ")", "->",...
Drops existing bucket. @param string $bucketName name of the bucket @throws Exception @throws \yii\base\InvalidConfigException
[ "Drops", "existing", "bucket", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L80-L87
train
matrozov/yii2-couchbase
src/Migration.php
Migration.insert
public function insert($bucketName, $data) { $this->beginProfile($token = " > insert into $bucketName ..."); $result = $this->db->insert($bucketName, $data); $this->endProfile($token); return $result; }
php
public function insert($bucketName, $data) { $this->beginProfile($token = " > insert into $bucketName ..."); $result = $this->db->insert($bucketName, $data); $this->endProfile($token); return $result; }
[ "public", "function", "insert", "(", "$", "bucketName", ",", "$", "data", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > insert into $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", "insert", ...
Insert record. @param string $bucketName the bucket that new rows will be inserted into. @param array $data the column data (name => value) to be inserted into the bucket or instance @return int|false inserted id @throws Exception @throws \yii\base\InvalidConfigException
[ "Insert", "record", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L99-L108
train
matrozov/yii2-couchbase
src/Migration.php
Migration.batchInsert
public function batchInsert($bucketName, $rows) { $this->beginProfile($token = " > batch insert into $bucketName ..."); $result = $this->db->batchInsert($bucketName, $rows); $this->endProfile($token); return $result; }
php
public function batchInsert($bucketName, $rows) { $this->beginProfile($token = " > batch insert into $bucketName ..."); $result = $this->db->batchInsert($bucketName, $rows); $this->endProfile($token); return $result; }
[ "public", "function", "batchInsert", "(", "$", "bucketName", ",", "$", "rows", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > batch insert into $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", ...
Batch insert record. @param string $bucketName the bucket that new rows will be inserted into. @param array $rows the rows to be batch inserted into the bucket @return int[]|false inserted ids @throws Exception @throws \yii\base\InvalidConfigException
[ "Batch", "insert", "record", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L120-L129
train
matrozov/yii2-couchbase
src/Migration.php
Migration.buildIndex
public function buildIndex($bucketName, $indexNames) { $this->beginProfile($token = " > build index $bucketName ..."); $result = $this->db->buildIndex($bucketName, $indexNames); $this->endProfile($token); return $result; }
php
public function buildIndex($bucketName, $indexNames) { $this->beginProfile($token = " > build index $bucketName ..."); $result = $this->db->buildIndex($bucketName, $indexNames); $this->endProfile($token); return $result; }
[ "public", "function", "buildIndex", "(", "$", "bucketName", ",", "$", "indexNames", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > build index $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", "...
Build index. @param string $bucketName @param string|string[] $indexNames names of index @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "Build", "index", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L210-L219
train
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.addRepositories
public function addRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } foreach ($repositories as $repo) { $this->addRepository($repo); } }
php
public function addRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } foreach ($repositories as $repo) { $this->addRepository($repo); } }
[ "public", "function", "addRepositories", "(", "$", "repositories", ")", "{", "if", "(", "!", "is_array", "(", "$", "repositories", ")", "&&", "(", "!", "is_object", "(", "$", "repositories", ")", "||", "!", "$", "repositories", "instanceof", "\\", "Travers...
Adds a set of repositories to the stack @param $repositories @throws InvalidArgumentException
[ "Adds", "a", "set", "of", "repositories", "to", "the", "stack" ]
cfc8c439858cf4f0d4119af9eb67de493da8d95c
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L60-L72
train
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.setRepositories
public function setRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } $this->stack = new \SplStack(); $this->addRepositories($repositories); }
php
public function setRepositories($repositories) { if (!is_array($repositories) && (!is_object($repositories) || !$repositories instanceof \Traversable)) { throw new InvalidArgumentException(sprintf( 'Invalid argument provided for $repositories, expecting either an array or Traversable object, but' . ' "%s" given', is_object($repositories) ? get_class($repositories) : gettype($repositories) )); } $this->stack = new \SplStack(); $this->addRepositories($repositories); }
[ "public", "function", "setRepositories", "(", "$", "repositories", ")", "{", "if", "(", "!", "is_array", "(", "$", "repositories", ")", "&&", "(", "!", "is_object", "(", "$", "repositories", ")", "||", "!", "$", "repositories", "instanceof", "\\", "Travers...
Resets the stack to the specified repositories @param array|\Traversable $repositories @throws InvalidArgumentException
[ "Resets", "the", "stack", "to", "the", "specified", "repositories" ]
cfc8c439858cf4f0d4119af9eb67de493da8d95c
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L90-L101
train
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.fetchAll
public function fetchAll() { $collection = new Collection(); foreach ($this->getRepositories() as $repo) { /** @var MigrationRepositoryInterface $repo */ $versions = $repo->fetchAll(); $collection->merge($versions); } return $collection; }
php
public function fetchAll() { $collection = new Collection(); foreach ($this->getRepositories() as $repo) { /** @var MigrationRepositoryInterface $repo */ $versions = $repo->fetchAll(); $collection->merge($versions); } return $collection; }
[ "public", "function", "fetchAll", "(", ")", "{", "$", "collection", "=", "new", "Collection", "(", ")", ";", "foreach", "(", "$", "this", "->", "getRepositories", "(", ")", "as", "$", "repo", ")", "{", "/** @var MigrationRepositoryInterface $repo */", "$", "...
Fetches all versions available to all repositories in the stack and returns them as a Linked collection. The returned collection contains versions groups sequentially into groups that correspond to each sub-repository. Each of those groups is sorted with the repository's own comparator. Therefore, its strongly recommended not to sort or modify the resulting collection. @return Collection
[ "Fetches", "all", "versions", "available", "to", "all", "repositories", "in", "the", "stack", "and", "returns", "them", "as", "a", "Linked", "collection", "." ]
cfc8c439858cf4f0d4119af9eb67de493da8d95c
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L112-L122
train
baleen/migrations
src/Migration/Repository/AggregateMigrationRepository.php
AggregateMigrationRepository.setMigrationFactory
public function setMigrationFactory(FactoryInterface $factory) { foreach ($this->getRepositories() as $repo) { $repo->setMigrationFactory($factory); } }
php
public function setMigrationFactory(FactoryInterface $factory) { foreach ($this->getRepositories() as $repo) { $repo->setMigrationFactory($factory); } }
[ "public", "function", "setMigrationFactory", "(", "FactoryInterface", "$", "factory", ")", "{", "foreach", "(", "$", "this", "->", "getRepositories", "(", ")", "as", "$", "repo", ")", "{", "$", "repo", "->", "setMigrationFactory", "(", "$", "factory", ")", ...
Sets the migration factory for ALL repositories in the stack. @param FactoryInterface $factory
[ "Sets", "the", "migration", "factory", "for", "ALL", "repositories", "in", "the", "stack", "." ]
cfc8c439858cf4f0d4119af9eb67de493da8d95c
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Repository/AggregateMigrationRepository.php#L129-L134
train
budde377/Part
lib/model/page/DefaultPageLibraryImpl.php
DefaultPageLibraryImpl.getPage
public function getPage($id) { return isset($this->pages[$id])?$this->pages[$id]:null; }
php
public function getPage($id) { return isset($this->pages[$id])?$this->pages[$id]:null; }
[ "public", "function", "getPage", "(", "$", "id", ")", "{", "return", "isset", "(", "$", "this", "->", "pages", "[", "$", "id", "]", ")", "?", "$", "this", "->", "pages", "[", "$", "id", "]", ":", "null", ";", "}" ]
Will return a default page given an ID @param string $id The id @return Page | null Instance matching the ID or NULL on no such page
[ "Will", "return", "a", "default", "page", "given", "an", "ID" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/DefaultPageLibraryImpl.php#L112-L115
train
budde377/Part
lib/log/LoggerImpl.php
LoggerImpl.listLog
public function listLog($level = Logger::LOG_LEVEL_ALL, $includeContext = true, $time = 0) { $list = $this->logFile->listLog($level, $time); $result = []; foreach ($list as $entry) { if (isset($entry['dumpfile'])) { if ($includeContext) { /** @var DumpFile $dumpFile */ $dumpFile = $entry['dumpfile']; $entry['context'] = $dumpFile->getUnSerializedContent()[0]; } unset($entry['dumpfile']); } $result[] = $entry; } return $result; }
php
public function listLog($level = Logger::LOG_LEVEL_ALL, $includeContext = true, $time = 0) { $list = $this->logFile->listLog($level, $time); $result = []; foreach ($list as $entry) { if (isset($entry['dumpfile'])) { if ($includeContext) { /** @var DumpFile $dumpFile */ $dumpFile = $entry['dumpfile']; $entry['context'] = $dumpFile->getUnSerializedContent()[0]; } unset($entry['dumpfile']); } $result[] = $entry; } return $result; }
[ "public", "function", "listLog", "(", "$", "level", "=", "Logger", "::", "LOG_LEVEL_ALL", ",", "$", "includeContext", "=", "true", ",", "$", "time", "=", "0", ")", "{", "$", "list", "=", "$", "this", "->", "logFile", "->", "listLog", "(", "$", "level...
Use boolean or to combine which loglevels you whish to list. @param int $level @param bool $includeContext If false context will not be included in result. @param int $time The earliest returned entry will be after this value @return mixed
[ "Use", "boolean", "or", "to", "combine", "which", "loglevels", "you", "whish", "to", "list", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/log/LoggerImpl.php#L165-L188
train
budde377/Part
lib/log/LoggerImpl.php
LoggerImpl.getContextAt
public function getContextAt($time) { $l = $this->listLog(Logger::LOG_LEVEL_ALL, true, $time); if(!count($l) || $l[0]["time"] != $time){ return null; } return $l[0]["context"]; }
php
public function getContextAt($time) { $l = $this->listLog(Logger::LOG_LEVEL_ALL, true, $time); if(!count($l) || $l[0]["time"] != $time){ return null; } return $l[0]["context"]; }
[ "public", "function", "getContextAt", "(", "$", "time", ")", "{", "$", "l", "=", "$", "this", "->", "listLog", "(", "Logger", "::", "LOG_LEVEL_ALL", ",", "true", ",", "$", "time", ")", ";", "if", "(", "!", "count", "(", "$", "l", ")", "||", "$", ...
Returns the context corresponding to the line given. @param int $time @return array
[ "Returns", "the", "context", "corresponding", "to", "the", "line", "given", "." ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/log/LoggerImpl.php#L195-L204
train
yeephp/yeephp
Yee/Http/Request.php
Request.get
public function get($key = null, $default = null) { if (!isset($this->env['yee.request.query_hash'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['QUERY_STRING'], $output); } else { parse_str($this->env['QUERY_STRING'], $output); } $this->env['yee.request.query_hash'] = Util::stripSlashesIfMagicQuotes($output); } if ($key) { if (isset($this->env['yee.request.query_hash'][$key])) { return $this->env['yee.request.query_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.query_hash']; } }
php
public function get($key = null, $default = null) { if (!isset($this->env['yee.request.query_hash'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['QUERY_STRING'], $output); } else { parse_str($this->env['QUERY_STRING'], $output); } $this->env['yee.request.query_hash'] = Util::stripSlashesIfMagicQuotes($output); } if ($key) { if (isset($this->env['yee.request.query_hash'][$key])) { return $this->env['yee.request.query_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.query_hash']; } }
[ "public", "function", "get", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "env", "[", "'yee.request.query_hash'", "]", ")", ")", "{", "$", "output", "=", "array", "(", ...
Fetch GET data This method returns a key-value array of data sent in the HTTP request query string, or the value of the array key if requested; if the array key does not exist, NULL is returned. @param string $key @param mixed $default Default return value when key does not exist @return array|mixed|null
[ "Fetch", "GET", "data" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L217-L237
train
yeephp/yeephp
Yee/Http/Request.php
Request.post
public function post($key = null, $default = null) { if (!isset($this->env['yee.input'])) { throw new \RuntimeException('Missing Yee.input in environment variables'); } if (!isset($this->env['yee.request.form_hash'])) { $this->env['yee.request.form_hash'] = array(); if ($this->isFormData() && is_string($this->env['yee.input'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['yee.input'], $output); } else { parse_str($this->env['yee.input'], $output); } $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output); } else { $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST); } } if ($key) { if (isset($this->env['yee.request.form_hash'][$key])) { return $this->env['yee.request.form_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.form_hash']; } }
php
public function post($key = null, $default = null) { if (!isset($this->env['yee.input'])) { throw new \RuntimeException('Missing Yee.input in environment variables'); } if (!isset($this->env['yee.request.form_hash'])) { $this->env['yee.request.form_hash'] = array(); if ($this->isFormData() && is_string($this->env['yee.input'])) { $output = array(); if (function_exists('mb_parse_str') && !isset($this->env['yee.tests.ignore_multibyte'])) { mb_parse_str($this->env['yee.input'], $output); } else { parse_str($this->env['yee.input'], $output); } $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($output); } else { $this->env['yee.request.form_hash'] = Util::stripSlashesIfMagicQuotes($_POST); } } if ($key) { if (isset($this->env['yee.request.form_hash'][$key])) { return $this->env['yee.request.form_hash'][$key]; } else { return $default; } } else { return $this->env['yee.request.form_hash']; } }
[ "public", "function", "post", "(", "$", "key", "=", "null", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "env", "[", "'yee.input'", "]", ")", ")", "{", "throw", "new", "\\", "RuntimeException", "(", ...
Fetch POST data This method returns a key-value array of data sent in the HTTP request body, or the value of a hash key if requested; if the array key does not exist, NULL is returned. @param string $key @param mixed $default Default return value when key does not exist @return array|mixed|null @throws \RuntimeException If environment input is not available
[ "Fetch", "POST", "data" ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Http/Request.php#L250-L278
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.addRootPrivileges
public function addRootPrivileges() { if ($this->addRootPrivilegeStatement == null) { $this->addRootPrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,1,0,NULL)"); } $this->addRootPrivilegeStatement->execute(array($this->user->getUsername())); $this->rootPrivilege = 1; }
php
public function addRootPrivileges() { if ($this->addRootPrivilegeStatement == null) { $this->addRootPrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,1,0,NULL)"); } $this->addRootPrivilegeStatement->execute(array($this->user->getUsername())); $this->rootPrivilege = 1; }
[ "public", "function", "addRootPrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "addRootPrivilegeStatement", "==", "null", ")", "{", "$", "this", "->", "addRootPrivilegeStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"\n ...
Will add root privileges @return void
[ "Will", "add", "root", "privileges" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L49-L57
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.addSitePrivileges
public function addSitePrivileges() { if ($this->addSitePrivilegeStatement == null) { $this->addSitePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,1,NULL)"); } $this->addSitePrivilegeStatement->execute(array($this->user->getUsername())); $this->sitePrivilege = 1; }
php
public function addSitePrivileges() { if ($this->addSitePrivilegeStatement == null) { $this->addSitePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,1,NULL)"); } $this->addSitePrivilegeStatement->execute(array($this->user->getUsername())); $this->sitePrivilege = 1; }
[ "public", "function", "addSitePrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "addSitePrivilegeStatement", "==", "null", ")", "{", "$", "this", "->", "addSitePrivilegeStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"\n ...
Will add Site privileges @return void
[ "Will", "add", "Site", "privileges" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L63-L71
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.addPagePrivileges
public function addPagePrivileges(Page $page) { if ($this->addPagePrivilegeStatement == null) { $this->addPagePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,0,?)"); } $success = true; try { $this->addPagePrivilegeStatement->execute(array($this->user->getUsername(), $page->getID())); } catch (PDOException $e) { $success = false; } if ($success) { $this->pagePrivilege[$page->getID()] = 1; } }
php
public function addPagePrivileges(Page $page) { if ($this->addPagePrivilegeStatement == null) { $this->addPagePrivilegeStatement = $this->connection->prepare(" INSERT INTO UserPrivileges (username, rootPrivileges, sitePrivileges, pageId) VALUES (?,0,0,?)"); } $success = true; try { $this->addPagePrivilegeStatement->execute(array($this->user->getUsername(), $page->getID())); } catch (PDOException $e) { $success = false; } if ($success) { $this->pagePrivilege[$page->getID()] = 1; } }
[ "public", "function", "addPagePrivileges", "(", "Page", "$", "page", ")", "{", "if", "(", "$", "this", "->", "addPagePrivilegeStatement", "==", "null", ")", "{", "$", "this", "->", "addPagePrivilegeStatement", "=", "$", "this", "->", "connection", "->", "pre...
Will add privileges to given page @param Page $page @return void
[ "Will", "add", "privileges", "to", "given", "page" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L78-L93
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokeRootPrivileges
public function revokeRootPrivileges() { if ($this->revokeRootStatement == null) { $this->revokeRootStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND rootPrivileges = 1"); $u = $this->user->getUsername(); $this->revokeRootStatement->bindParam(1, $u); } $this->revokeRootStatement->execute(); $this->rootPrivilege = false; }
php
public function revokeRootPrivileges() { if ($this->revokeRootStatement == null) { $this->revokeRootStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND rootPrivileges = 1"); $u = $this->user->getUsername(); $this->revokeRootStatement->bindParam(1, $u); } $this->revokeRootStatement->execute(); $this->rootPrivilege = false; }
[ "public", "function", "revokeRootPrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "revokeRootStatement", "==", "null", ")", "{", "$", "this", "->", "revokeRootStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM UserP...
Will revoke Root privileges @return void
[ "Will", "revoke", "Root", "privileges" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L127-L137
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokeSitePrivileges
public function revokeSitePrivileges() { if ($this->revokeSiteStatement == null) { $this->revokeSiteStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND sitePrivileges = 1"); $u = $this->user->getUsername(); $this->revokeSiteStatement->bindParam(1, $u); } $this->revokeSiteStatement->execute(); $this->sitePrivilege = 0; }
php
public function revokeSitePrivileges() { if ($this->revokeSiteStatement == null) { $this->revokeSiteStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND sitePrivileges = 1"); $u = $this->user->getUsername(); $this->revokeSiteStatement->bindParam(1, $u); } $this->revokeSiteStatement->execute(); $this->sitePrivilege = 0; }
[ "public", "function", "revokeSitePrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "revokeSiteStatement", "==", "null", ")", "{", "$", "this", "->", "revokeSiteStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM UserP...
Will revoke Site privileges @return void
[ "Will", "revoke", "Site", "privileges" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L143-L153
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokePagePrivileges
public function revokePagePrivileges(Page $page) { if ($this->revokePageStatement == null) { $this->revokePageStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND pageId = ?"); } $this->revokePageStatement->execute(array($this->user->getUsername(), $page->getID())); unset($this->pagePrivilege[$page->getID()]); }
php
public function revokePagePrivileges(Page $page) { if ($this->revokePageStatement == null) { $this->revokePageStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ? AND pageId = ?"); } $this->revokePageStatement->execute(array($this->user->getUsername(), $page->getID())); unset($this->pagePrivilege[$page->getID()]); }
[ "public", "function", "revokePagePrivileges", "(", "Page", "$", "page", ")", "{", "if", "(", "$", "this", "->", "revokePageStatement", "==", "null", ")", "{", "$", "this", "->", "revokePageStatement", "=", "$", "this", "->", "connection", "->", "prepare", ...
Will revoke privileges from given Page @param Page $page @return void
[ "Will", "revoke", "privileges", "from", "given", "Page" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L160-L168
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.revokeAllPrivileges
public function revokeAllPrivileges() { if ($this->revokeAllStatement == null) { $this->revokeAllStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ?"); $u = $this->user->getUsername(); $this->revokeAllStatement->bindParam(1, $u); } $this->revokeAllStatement->execute(); $this->rootPrivilege = $this->sitePrivilege = 0; $this->pagePrivilege = array(); }
php
public function revokeAllPrivileges() { if ($this->revokeAllStatement == null) { $this->revokeAllStatement = $this->connection->prepare("DELETE FROM UserPrivileges WHERE username = ?"); $u = $this->user->getUsername(); $this->revokeAllStatement->bindParam(1, $u); } $this->revokeAllStatement->execute(); $this->rootPrivilege = $this->sitePrivilege = 0; $this->pagePrivilege = array(); }
[ "public", "function", "revokeAllPrivileges", "(", ")", "{", "if", "(", "$", "this", "->", "revokeAllStatement", "==", "null", ")", "{", "$", "this", "->", "revokeAllStatement", "=", "$", "this", "->", "connection", "->", "prepare", "(", "\"DELETE FROM UserPriv...
This will revoke all privileges @return void
[ "This", "will", "revoke", "all", "privileges" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L174-L185
train
budde377/Part
lib/model/user/UserPrivilegesImpl.php
UserPrivilegesImpl.listPagePrivileges
public function listPagePrivileges(PageOrder $pageOrder = null) { $this->initialize(); if ($this->hasRootPrivileges() || $this->hasSitePrivileges()) { return array(); } $returnArray = array(); foreach ($this->pagePrivilege as $key => $val) { if ($pageOrder instanceof PageOrder) { $returnArray[] = $pageOrder->getPage($key); } else { $returnArray[] = $key; } } return $returnArray; }
php
public function listPagePrivileges(PageOrder $pageOrder = null) { $this->initialize(); if ($this->hasRootPrivileges() || $this->hasSitePrivileges()) { return array(); } $returnArray = array(); foreach ($this->pagePrivilege as $key => $val) { if ($pageOrder instanceof PageOrder) { $returnArray[] = $pageOrder->getPage($key); } else { $returnArray[] = $key; } } return $returnArray; }
[ "public", "function", "listPagePrivileges", "(", "PageOrder", "$", "pageOrder", "=", "null", ")", "{", "$", "this", "->", "initialize", "(", ")", ";", "if", "(", "$", "this", "->", "hasRootPrivileges", "(", ")", "||", "$", "this", "->", "hasSitePrivileges"...
Will return an array of strings containing the sites that are under the users control. If the user has site or root privileges an empty array is returned. If the user has no privileges an empty array is returned. @param PageOrder $pageOrder If order is given it will return array containing instances from the PageOrder @return array
[ "Will", "return", "an", "array", "of", "strings", "containing", "the", "sites", "that", "are", "under", "the", "users", "control", ".", "If", "the", "user", "has", "site", "or", "root", "privileges", "an", "empty", "array", "is", "returned", ".", "If", "...
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/user/UserPrivilegesImpl.php#L212-L228
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.add
public function add(NodeInterface $node) { if ($node instanceof BranchNodeInterface) { // this node is a branch $childFlow = $node->getPayload(); $this->branchFlowCheck($childFlow); $childFlow->setParent($this); } $node->setCarrier($this); $this->flowMap->register($node, $this->nodeIdx); $this->nodes[$this->nodeIdx] = $node; ++$this->nodeIdx; return $this; }
php
public function add(NodeInterface $node) { if ($node instanceof BranchNodeInterface) { // this node is a branch $childFlow = $node->getPayload(); $this->branchFlowCheck($childFlow); $childFlow->setParent($this); } $node->setCarrier($this); $this->flowMap->register($node, $this->nodeIdx); $this->nodes[$this->nodeIdx] = $node; ++$this->nodeIdx; return $this; }
[ "public", "function", "add", "(", "NodeInterface", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "BranchNodeInterface", ")", "{", "// this node is a branch", "$", "childFlow", "=", "$", "node", "->", "getPayload", "(", ")", ";", "$", "this", ...
Adds a Node to the flow @param NodeInterface $node @throws NodalFlowException @return $this
[ "Adds", "a", "Node", "to", "the", "flow" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L61-L78
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.addPayload
public function addPayload(callable $payload, $isAReturningVal, $isATraversable = false) { $node = PayloadNodeFactory::create($payload, $isAReturningVal, $isATraversable); $this->add($node); return $this; }
php
public function addPayload(callable $payload, $isAReturningVal, $isATraversable = false) { $node = PayloadNodeFactory::create($payload, $isAReturningVal, $isATraversable); $this->add($node); return $this; }
[ "public", "function", "addPayload", "(", "callable", "$", "payload", ",", "$", "isAReturningVal", ",", "$", "isATraversable", "=", "false", ")", "{", "$", "node", "=", "PayloadNodeFactory", "::", "create", "(", "$", "payload", ",", "$", "isAReturningVal", ",...
Adds a Payload Node to the Flow @param callable $payload @param mixed $isAReturningVal @param mixed $isATraversable @throws NodalFlowException @return $this
[ "Adds", "a", "Payload", "Node", "to", "the", "Flow" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L91-L98
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.replace
public function replace($nodeIdx, NodeInterface $node) { if (!isset($this->nodes[$nodeIdx])) { throw new NodalFlowException('Argument 1 should be a valid index in nodes', 1, null, [ 'nodeIdx' => $nodeIdx, 'node' => get_class($node), ]); } $node->setCarrier($this); $this->nodes[$nodeIdx] = $node; $this->flowMap->register($node, $nodeIdx, true); return $this; }
php
public function replace($nodeIdx, NodeInterface $node) { if (!isset($this->nodes[$nodeIdx])) { throw new NodalFlowException('Argument 1 should be a valid index in nodes', 1, null, [ 'nodeIdx' => $nodeIdx, 'node' => get_class($node), ]); } $node->setCarrier($this); $this->nodes[$nodeIdx] = $node; $this->flowMap->register($node, $nodeIdx, true); return $this; }
[ "public", "function", "replace", "(", "$", "nodeIdx", ",", "NodeInterface", "$", "node", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "nodes", "[", "$", "nodeIdx", "]", ")", ")", "{", "throw", "new", "NodalFlowException", "(", "'Argument ...
Replaces a node with another one @param int $nodeIdx @param NodeInterface $node @throws NodalFlowException @return $this
[ "Replaces", "a", "node", "with", "another", "one" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L110-L124
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.exec
public function exec($param = null) { try { $result = $this->rewind() ->flowStart() ->recurse($param); // set flowStatus to make sure that we have the proper // value in flowEnd even when overridden without (or when // improperly) calling parent if ($this->flowStatus->isRunning()) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_CLEAN); } $this->flowEnd(); return $result; } catch (\Exception $e) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_EXCEPTION, $e); $this->flowEnd(); if ($e instanceof NodalFlowException) { throw $e; } throw new NodalFlowException('Flow execution failed', 0, $e, [ 'nodeMap' => $this->getNodeMap(), ]); } }
php
public function exec($param = null) { try { $result = $this->rewind() ->flowStart() ->recurse($param); // set flowStatus to make sure that we have the proper // value in flowEnd even when overridden without (or when // improperly) calling parent if ($this->flowStatus->isRunning()) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_CLEAN); } $this->flowEnd(); return $result; } catch (\Exception $e) { $this->flowStatus = new FlowStatus(FlowStatus::FLOW_EXCEPTION, $e); $this->flowEnd(); if ($e instanceof NodalFlowException) { throw $e; } throw new NodalFlowException('Flow execution failed', 0, $e, [ 'nodeMap' => $this->getNodeMap(), ]); } }
[ "public", "function", "exec", "(", "$", "param", "=", "null", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "rewind", "(", ")", "->", "flowStart", "(", ")", "->", "recurse", "(", "$", "param", ")", ";", "// set flowStatus to make sure th...
Execute the flow @param null|mixed $param The eventual init argument to the first node or, in case of a branch, the last relevant argument from upstream Flow @throws NodalFlowException @return mixed the last result of the last returning value node
[ "Execute", "the", "flow" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L161-L189
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.rewind
public function rewind() { $this->nodeCount = count($this->nodes); $this->lastIdx = $this->nodeCount - 1; $this->break = false; $this->continue = false; $this->interruptNodeId = null; return $this; }
php
public function rewind() { $this->nodeCount = count($this->nodes); $this->lastIdx = $this->nodeCount - 1; $this->break = false; $this->continue = false; $this->interruptNodeId = null; return $this; }
[ "public", "function", "rewind", "(", ")", "{", "$", "this", "->", "nodeCount", "=", "count", "(", "$", "this", "->", "nodes", ")", ";", "$", "this", "->", "lastIdx", "=", "$", "this", "->", "nodeCount", "-", "1", ";", "$", "this", "->", "break", ...
Rewinds the Flow @return $this
[ "Rewinds", "the", "Flow" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L196-L205
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.flowStart
protected function flowStart() { $this->flowMap->incrementFlow('num_exec')->flowStart(); $this->listActiveEvent(!$this->hasParent())->triggerEvent(FlowEvent::FLOW_START); // flow started status kicks in after Event start to hint eventual children // this way, root flow is only running when a record hits a branch // and triggers a child flow flowStart() call $this->flowStatus = new FlowStatus(FlowStatus::FLOW_RUNNING); return $this; }
php
protected function flowStart() { $this->flowMap->incrementFlow('num_exec')->flowStart(); $this->listActiveEvent(!$this->hasParent())->triggerEvent(FlowEvent::FLOW_START); // flow started status kicks in after Event start to hint eventual children // this way, root flow is only running when a record hits a branch // and triggers a child flow flowStart() call $this->flowStatus = new FlowStatus(FlowStatus::FLOW_RUNNING); return $this; }
[ "protected", "function", "flowStart", "(", ")", "{", "$", "this", "->", "flowMap", "->", "incrementFlow", "(", "'num_exec'", ")", "->", "flowStart", "(", ")", ";", "$", "this", "->", "listActiveEvent", "(", "!", "$", "this", "->", "hasParent", "(", ")", ...
Triggered just before the flow starts @throws NodalFlowException @return $this
[ "Triggered", "just", "before", "the", "flow", "starts" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L235-L245
train
fab2s/NodalFlow
src/NodalFlow.php
NodalFlow.recurse
protected function recurse($param = null, $nodeIdx = 0) { while ($nodeIdx <= $this->lastIdx) { $node = $this->nodes[$nodeIdx]; $this->nodeIdx = $nodeIdx; $nodeStats = &$this->flowMap->getNodeStat($node->getId()); $returnVal = $node->isReturningVal(); if ($node->isTraversable()) { /** @var TraversableNodeInterface $node */ foreach ($node->getTraversable($param) as $value) { if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeStats['num_iterate']; if (!($nodeStats['num_iterate'] % $this->progressMod)) { $this->triggerEvent(FlowEvent::FLOW_PROGRESS, $node); } $param = $this->recurse($param, $nodeIdx + 1); if ($this->continue) { if ($this->continue = $this->interruptNode($node)) { // since we want to bubble the continue upstream // we break here waiting for next $param if any ++$nodeStats['num_break']; break; } // we drop one iteration ++$nodeStats['num_continue']; continue; } if ($this->break) { // we drop all subsequent iterations ++$nodeStats['num_break']; $this->break = $this->interruptNode($node); break; } } // we reached the end of this Traversable and executed all its downstream Nodes ++$nodeStats['num_exec']; return $param; } /** @var ExecNodeInterface $node */ $value = $node->exec($param); ++$nodeStats['num_exec']; if ($this->continue) { ++$nodeStats['num_continue']; // a continue does not need to bubble up unless // it specifically targets a node in this flow // or targets an upstream flow $this->continue = $this->interruptNode($node); return $param; } if ($this->break) { ++$nodeStats['num_break']; // a break always need to bubble up to the first upstream Traversable if any return $param; } if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeIdx; } // we reached the end of this recursion return $param; }
php
protected function recurse($param = null, $nodeIdx = 0) { while ($nodeIdx <= $this->lastIdx) { $node = $this->nodes[$nodeIdx]; $this->nodeIdx = $nodeIdx; $nodeStats = &$this->flowMap->getNodeStat($node->getId()); $returnVal = $node->isReturningVal(); if ($node->isTraversable()) { /** @var TraversableNodeInterface $node */ foreach ($node->getTraversable($param) as $value) { if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeStats['num_iterate']; if (!($nodeStats['num_iterate'] % $this->progressMod)) { $this->triggerEvent(FlowEvent::FLOW_PROGRESS, $node); } $param = $this->recurse($param, $nodeIdx + 1); if ($this->continue) { if ($this->continue = $this->interruptNode($node)) { // since we want to bubble the continue upstream // we break here waiting for next $param if any ++$nodeStats['num_break']; break; } // we drop one iteration ++$nodeStats['num_continue']; continue; } if ($this->break) { // we drop all subsequent iterations ++$nodeStats['num_break']; $this->break = $this->interruptNode($node); break; } } // we reached the end of this Traversable and executed all its downstream Nodes ++$nodeStats['num_exec']; return $param; } /** @var ExecNodeInterface $node */ $value = $node->exec($param); ++$nodeStats['num_exec']; if ($this->continue) { ++$nodeStats['num_continue']; // a continue does not need to bubble up unless // it specifically targets a node in this flow // or targets an upstream flow $this->continue = $this->interruptNode($node); return $param; } if ($this->break) { ++$nodeStats['num_break']; // a break always need to bubble up to the first upstream Traversable if any return $param; } if ($returnVal) { // pass current $value as next param $param = $value; } ++$nodeIdx; } // we reached the end of this recursion return $param; }
[ "protected", "function", "recurse", "(", "$", "param", "=", "null", ",", "$", "nodeIdx", "=", "0", ")", "{", "while", "(", "$", "nodeIdx", "<=", "$", "this", "->", "lastIdx", ")", "{", "$", "node", "=", "$", "this", "->", "nodes", "[", "$", "node...
Recurse over nodes which may as well be Flows and Traversable ... Welcome to the abysses of recursion or iter-recursion ^^ `recurse` perform kind of an hybrid recursion as the Flow is effectively iterating and recurring over its Nodes, which may as well be seen as over itself Iterating tends to limit the amount of recursion levels: recursion is only triggered when executing a Traversable Node's downstream Nodes while every consecutive exec Nodes are executed within the while loop. The size of the recursion context is kept to a minimum as pretty much everything is done by the iterating instance @param mixed $param @param int $nodeIdx @return mixed the last value returned by the last returning value Node in the flow
[ "Recurse", "over", "nodes", "which", "may", "as", "well", "be", "Flows", "and", "Traversable", "...", "Welcome", "to", "the", "abysses", "of", "recursion", "or", "iter", "-", "recursion", "^^" ]
da5d458ffea3e6e954d7ee734f938f4be5e46728
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/NodalFlow.php#L290-L369
train
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.create
public static function create() { switch (func_num_args()) { case 0: return new File(); case 1: return new File(func_get_arg(0)); case 2: return new File(func_get_arg(0), func_get_arg(1)); case 3: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new File(); case 1: return new File(func_get_arg(0)); case 2: return new File(func_get_arg(0), func_get_arg(1)); case 3: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new File(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "File", "(", ")", ";", "case", "1", ":", "return", "new", "File", "(", "func_get_arg", "(", "0", ")", ")...
Creates new instance of \Google\Protobuf\Compiler\CodeGeneratorResponse\File @throws \InvalidArgumentException @return File
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L59-L83
train
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.reset
public static function reset($object) { if (!($object instanceof File)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse\File.'); } $object->name = NULL; $object->insertionPoint = NULL; $object->content = NULL; }
php
public static function reset($object) { if (!($object instanceof File)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\Compiler\CodeGeneratorResponse\File.'); } $object->name = NULL; $object->insertionPoint = NULL; $object->content = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "File", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Compiler\\Code...
Resets properties of \Google\Protobuf\Compiler\CodeGeneratorResponse\File to default values @param File $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File", "to", "default", "values" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L96-L104
train
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->insertionPoint)) { hash_update($ctx, 'insertionPoint'); hash_update($ctx, (string)$object->insertionPoint); } if (isset($object->content)) { hash_update($ctx, 'content'); hash_update($ctx, (string)$object->content); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->insertionPoint)) { hash_update($ctx, 'insertionPoint'); hash_update($ctx, (string)$object->insertionPoint); } if (isset($object->content)) { hash_update($ctx, 'content'); hash_update($ctx, (string)$object->content); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\Compiler\CodeGeneratorResponse\File @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L116-L144
train
skrz/meta
gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php
FileMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->insertionPoint) && ($filter === null || isset($filter['insertionPoint']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->insertionPoint)); $output .= $object->insertionPoint; } if (isset($object->content) && ($filter === null || isset($filter['content']))) { $output .= "\x7a"; $output .= Binary::encodeVarint(strlen($object->content)); $output .= $object->content; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->insertionPoint) && ($filter === null || isset($filter['insertionPoint']))) { $output .= "\x12"; $output .= Binary::encodeVarint(strlen($object->insertionPoint)); $output .= $object->insertionPoint; } if (isset($object->content) && ($filter === null || isset($filter['content']))) { $output .= "\x7a"; $output .= Binary::encodeVarint(strlen($object->content)); $output .= $object->content; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\Compiler\CodeGeneratorResponse\File to Protocol Buffers message. @param File $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "Compiler", "\\", "CodeGeneratorResponse", "\\", "File", "to", "Protocol", "Buffers", "message", "." ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Compiler/CodeGeneratorResponse/Meta/FileMeta.php#L253-L276
train
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new FileDescriptorProto(); case 1: return new FileDescriptorProto(func_get_arg(0)); case 2: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new FileDescriptorProto(); case 1: return new FileDescriptorProto(func_get_arg(0)); case 2: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new FileDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "FileDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "FileDescriptorProto", "(", "func_get_a...
Creates new instance of \Google\Protobuf\FileDescriptorProto @throws \InvalidArgumentException @return FileDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L68-L92
train
skrz/meta
gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php
FileDescriptorProtoMeta.reset
public static function reset($object) { if (!($object instanceof FileDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileDescriptorProto.'); } $object->name = NULL; $object->package = NULL; $object->dependency = NULL; $object->publicDependency = NULL; $object->weakDependency = NULL; $object->messageType = NULL; $object->enumType = NULL; $object->service = NULL; $object->extension = NULL; $object->options = NULL; $object->sourceCodeInfo = NULL; $object->syntax = NULL; }
php
public static function reset($object) { if (!($object instanceof FileDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\FileDescriptorProto.'); } $object->name = NULL; $object->package = NULL; $object->dependency = NULL; $object->publicDependency = NULL; $object->weakDependency = NULL; $object->messageType = NULL; $object->enumType = NULL; $object->service = NULL; $object->extension = NULL; $object->options = NULL; $object->sourceCodeInfo = NULL; $object->syntax = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "FileDescriptorProto", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\...
Resets properties of \Google\Protobuf\FileDescriptorProto to default values @param FileDescriptorProto $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "FileDescriptorProto", "to", "default", "values" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/FileDescriptorProtoMeta.php#L105-L122
train
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.setValueType
final public function setValueType(&$value, $type) { if ( empty($value) || !in_array(strtolower($type), array("base64", "datetime", "cdata")) ) throw new XmlrpcException("Invalid value type"); $this->special_types[$value] = strtolower($type); return $this; }
php
final public function setValueType(&$value, $type) { if ( empty($value) || !in_array(strtolower($type), array("base64", "datetime", "cdata")) ) throw new XmlrpcException("Invalid value type"); $this->special_types[$value] = strtolower($type); return $this; }
[ "final", "public", "function", "setValueType", "(", "&", "$", "value", ",", "$", "type", ")", "{", "if", "(", "empty", "(", "$", "value", ")", "||", "!", "in_array", "(", "strtolower", "(", "$", "type", ")", ",", "array", "(", "\"base64\"", ",", "\...
Handle base64 and datetime values @param mixed $value The referenced value @param string $type The type of value @return \Comodojo\Xmlrpc\XmlrpcEncoder
[ "Handle", "base64", "and", "datetime", "values" ]
2257167ce94ab657608c2062d485896f95f935a3
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L96-L104
train
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeResponse
public function encodeResponse($data) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodResponse"); $xml->startElement("params"); $xml->startElement("param"); $xml->startElement("value"); try { $this->encodeValue($xml, $data); } catch (XmlrpcException $xe) { throw $xe; } catch (Exception $e) { throw $e; } $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
php
public function encodeResponse($data) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodResponse"); $xml->startElement("params"); $xml->startElement("param"); $xml->startElement("value"); try { $this->encodeValue($xml, $data); } catch (XmlrpcException $xe) { throw $xe; } catch (Exception $e) { throw $e; } $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
[ "public", "function", "encodeResponse", "(", "$", "data", ")", "{", "$", "xml", "=", "new", "XMLWriter", "(", ")", ";", "$", "xml", "->", "openMemory", "(", ")", ";", "$", "xml", "->", "setIndent", "(", "false", ")", ";", "$", "xml", "->", "startDo...
Encode an xmlrpc response It expects a scalar, array or NULL as $data and will try to encode it as a valid xmlrpc response. @param mixed $data @return string xmlrpc formatted response @throws \Comodojo\Exception\XmlrpcException @throws \Exception
[ "Encode", "an", "xmlrpc", "response" ]
2257167ce94ab657608c2062d485896f95f935a3
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L133-L177
train
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeCall
public function encodeCall($method, $data = array()) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodCall"); $xml->writeElement("methodName", trim($method)); $xml->startElement("params"); try { foreach ( $data as $d ) { $xml->startElement("param"); $xml->startElement("value"); $this->encodeValue($xml, $d); $xml->endElement(); $xml->endElement(); } } catch (XmlrpcException $xe) { throw $xe; } $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
php
public function encodeCall($method, $data = array()) { $xml = new XMLWriter(); $xml->openMemory(); $xml->setIndent(false); $xml->startDocument('1.0', $this->encoding); $xml->startElement("methodCall"); $xml->writeElement("methodName", trim($method)); $xml->startElement("params"); try { foreach ( $data as $d ) { $xml->startElement("param"); $xml->startElement("value"); $this->encodeValue($xml, $d); $xml->endElement(); $xml->endElement(); } } catch (XmlrpcException $xe) { throw $xe; } $xml->endElement(); $xml->endElement(); $xml->endDocument(); return trim($xml->outputMemory()); }
[ "public", "function", "encodeCall", "(", "$", "method", ",", "$", "data", "=", "array", "(", ")", ")", "{", "$", "xml", "=", "new", "XMLWriter", "(", ")", ";", "$", "xml", "->", "openMemory", "(", ")", ";", "$", "xml", "->", "setIndent", "(", "fa...
Encode an xmlrpc call It expects an array of values as $data and will try to encode it as a valid xmlrpc call. @param string $method @param array $data @return string xmlrpc formatted call @throws \Comodojo\Exception\XmlrpcException @throws \Exception
[ "Encode", "an", "xmlrpc", "call" ]
2257167ce94ab657608c2062d485896f95f935a3
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L192-L238
train
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeMulticall
public function encodeMulticall($data) { $packed_requests = array(); foreach ( $data as $methodName => $params ) { if ( is_int($methodName) && count($params) == 2 ) { array_push($packed_requests, array( "methodName" => $params[0], "params" => $params[1] )); } else { array_push($packed_requests, array( "methodName" => $methodName, "params" => $params )); } } return $this->encodeCall("system.multicall", array($packed_requests)); }
php
public function encodeMulticall($data) { $packed_requests = array(); foreach ( $data as $methodName => $params ) { if ( is_int($methodName) && count($params) == 2 ) { array_push($packed_requests, array( "methodName" => $params[0], "params" => $params[1] )); } else { array_push($packed_requests, array( "methodName" => $methodName, "params" => $params )); } } return $this->encodeCall("system.multicall", array($packed_requests)); }
[ "public", "function", "encodeMulticall", "(", "$", "data", ")", "{", "$", "packed_requests", "=", "array", "(", ")", ";", "foreach", "(", "$", "data", "as", "$", "methodName", "=>", "$", "params", ")", "{", "if", "(", "is_int", "(", "$", "methodName", ...
Encode an xmlrpc multicall It expects in input a key->val array where key represent the method and val the parameters. @param array $data @return string xmlrpc formatted call @throws \Comodojo\Exception\XmlrpcException @throws \Exception
[ "Encode", "an", "xmlrpc", "multicall" ]
2257167ce94ab657608c2062d485896f95f935a3
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L253-L279
train
comodojo/xmlrpc
src/Comodojo/Xmlrpc/XmlrpcEncoder.php
XmlrpcEncoder.encodeError
public function encodeError($error_code, $error_message) { $payload = '<?xml version="1.0" encoding="'.$this->encoding.'"?>'; $payload .= "<methodResponse>"; $payload .= $this->encodeFault($error_code, $error_message); $payload .= "</methodResponse>"; return $payload; }
php
public function encodeError($error_code, $error_message) { $payload = '<?xml version="1.0" encoding="'.$this->encoding.'"?>'; $payload .= "<methodResponse>"; $payload .= $this->encodeFault($error_code, $error_message); $payload .= "</methodResponse>"; return $payload; }
[ "public", "function", "encodeError", "(", "$", "error_code", ",", "$", "error_message", ")", "{", "$", "payload", "=", "'<?xml version=\"1.0\" encoding=\"'", ".", "$", "this", "->", "encoding", ".", "'\"?>'", ";", "$", "payload", ".=", "\"<methodResponse>\"", ";...
Encode an xmlrpc error @param int $error_code @param string $error_message @return string xmlrpc formatted error
[ "Encode", "an", "xmlrpc", "error" ]
2257167ce94ab657608c2062d485896f95f935a3
https://github.com/comodojo/xmlrpc/blob/2257167ce94ab657608c2062d485896f95f935a3/src/Comodojo/Xmlrpc/XmlrpcEncoder.php#L289-L298
train
matrozov/yii2-couchbase
src/ActiveRecord.php
ActiveRecord.toArrayInternal
private function toArrayInternal($data) { if (is_array($data)) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->toArrayInternal($value); } if (is_object($value)) { $data[$key] = ArrayHelper::toArray($value); } } return $data; } elseif (is_object($data)) { return ArrayHelper::toArray($data); } else { return [$data]; } }
php
private function toArrayInternal($data) { if (is_array($data)) { foreach ($data as $key => $value) { if (is_array($value)) { $data[$key] = $this->toArrayInternal($value); } if (is_object($value)) { $data[$key] = ArrayHelper::toArray($value); } } return $data; } elseif (is_object($data)) { return ArrayHelper::toArray($data); } else { return [$data]; } }
[ "private", "function", "toArrayInternal", "(", "$", "data", ")", "{", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "foreach", "(", "$", "data", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", "...
Converts data to array recursively, converting Couchbase JSON objects to readable values. @param mixed $data the data to be converted into an array. @return array the array representation of the data.
[ "Converts", "data", "to", "array", "recursively", "converting", "Couchbase", "JSON", "objects", "to", "readable", "values", "." ]
07c2e9d18cb90f873c0d88dcacf6bb532e9d648c
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/ActiveRecord.php#L478-L499
train
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.getInfo
public function getInfo($ip = null) { if ($ip == null) { $ip = $this->getIpAdress(); } $url = str_replace('{IP}', $ip, $this->api_adress); $hex = $this->ipToHex($ip); $me = $this; // Check if the IP is in the cache if (Cache::has($hex)) { $this->isCached = true; } // Use the IP info stored in cache or store it $ipInfo = Cache::remember($hex, 10080, function () use ($me, $url) { return $me->fetchInfo($url); }); $ipInfo->geoplugin_cached = $this->isCached; return $ipInfo; }
php
public function getInfo($ip = null) { if ($ip == null) { $ip = $this->getIpAdress(); } $url = str_replace('{IP}', $ip, $this->api_adress); $hex = $this->ipToHex($ip); $me = $this; // Check if the IP is in the cache if (Cache::has($hex)) { $this->isCached = true; } // Use the IP info stored in cache or store it $ipInfo = Cache::remember($hex, 10080, function () use ($me, $url) { return $me->fetchInfo($url); }); $ipInfo->geoplugin_cached = $this->isCached; return $ipInfo; }
[ "public", "function", "getInfo", "(", "$", "ip", "=", "null", ")", "{", "if", "(", "$", "ip", "==", "null", ")", "{", "$", "ip", "=", "$", "this", "->", "getIpAdress", "(", ")", ";", "}", "$", "url", "=", "str_replace", "(", "'{IP}'", ",", "$",...
Return all the information in an array. @param $ip IP to search for @return array Info from the IP parameter
[ "Return", "all", "the", "information", "in", "an", "array", "." ]
b45374b971253aa553b4b4429581bba886237671
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L29-L51
train
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.getIpAdress
public function getIpAdress() { $ip_keys = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR']; foreach ($ip_keys as $key) { if (array_key_exists($key, $_SERVER) === true) { foreach (explode(',', $_SERVER[$key]) as $ip) { $ip = trim($ip); if ($this->validateIp($ip)) { return $ip; } } } } return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false; }
php
public function getIpAdress() { $ip_keys = ['HTTP_CLIENT_IP', 'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED', 'HTTP_X_CLUSTER_CLIENT_IP', 'HTTP_FORWARDED_FOR', 'HTTP_FORWARDED', 'REMOTE_ADDR']; foreach ($ip_keys as $key) { if (array_key_exists($key, $_SERVER) === true) { foreach (explode(',', $_SERVER[$key]) as $ip) { $ip = trim($ip); if ($this->validateIp($ip)) { return $ip; } } } } return isset($_SERVER['REMOTE_ADDR']) ? $_SERVER['REMOTE_ADDR'] : false; }
[ "public", "function", "getIpAdress", "(", ")", "{", "$", "ip_keys", "=", "[", "'HTTP_CLIENT_IP'", ",", "'HTTP_X_FORWARDED_FOR'", ",", "'HTTP_X_FORWARDED'", ",", "'HTTP_X_CLUSTER_CLIENT_IP'", ",", "'HTTP_FORWARDED_FOR'", ",", "'HTTP_FORWARDED'", ",", "'REMOTE_ADDR'", "]"...
Get the IP adress. @link https://gist.github.com/cballou/2201933 @return bool|string
[ "Get", "the", "IP", "adress", "." ]
b45374b971253aa553b4b4429581bba886237671
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L60-L75
train
Fuhrmann/larageo-plugin
src/Fuhrmann/LarageoPlugin/LarageoPlugin.php
LarageoPlugin.fetchInfo
public function fetchInfo($url) { $response = null; if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'LarageoPlugin Package v1.0'); $response = curl_exec($ch); curl_close($ch); } elseif (ini_get('allow_url_fopen')) { $response = file_get_contents($url, 'r'); } else { throw new \Exception('LarageoPlugin requires the CURL PHP extension or allow_url_fopen set to 1!'); } $response = json_decode($response); if (empty($response)) { throw new \Exception('Ops! The data is empty! Is '.$url.' acessible?'); } if (isset($response->geoplugin_status) && $response->geoplugin_status == 404) { throw new \Exception('Ops! Your request returned a 404 error! Is '.$url.' acessible?'); } return $response; }
php
public function fetchInfo($url) { $response = null; if (function_exists('curl_init')) { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, 'LarageoPlugin Package v1.0'); $response = curl_exec($ch); curl_close($ch); } elseif (ini_get('allow_url_fopen')) { $response = file_get_contents($url, 'r'); } else { throw new \Exception('LarageoPlugin requires the CURL PHP extension or allow_url_fopen set to 1!'); } $response = json_decode($response); if (empty($response)) { throw new \Exception('Ops! The data is empty! Is '.$url.' acessible?'); } if (isset($response->geoplugin_status) && $response->geoplugin_status == 404) { throw new \Exception('Ops! Your request returned a 404 error! Is '.$url.' acessible?'); } return $response; }
[ "public", "function", "fetchInfo", "(", "$", "url", ")", "{", "$", "response", "=", "null", ";", "if", "(", "function_exists", "(", "'curl_init'", ")", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT...
Fetch the info from IP using CURL or file_get_contents. @param $url @throws \Exception @return mixed
[ "Fetch", "the", "info", "from", "IP", "using", "CURL", "or", "file_get_contents", "." ]
b45374b971253aa553b4b4429581bba886237671
https://github.com/Fuhrmann/larageo-plugin/blob/b45374b971253aa553b4b4429581bba886237671/src/Fuhrmann/LarageoPlugin/LarageoPlugin.php#L99-L128
train
vcarreira/wordsapi
src/Word.php
Word.make
private function make($verb, $fetchDetails = null) { if (isset($this->cache[$verb])) { return $this->cache[$verb]; } $data = $this->service->fetch( $this->word, $verb, is_null($fetchDetails) ? $this->prefetchDetails : (bool) $fetchDetails ); if ($data === false) { return false; } $this->cache = array_merge($this->cache, $data); return $this->cache[$verb]; }
php
private function make($verb, $fetchDetails = null) { if (isset($this->cache[$verb])) { return $this->cache[$verb]; } $data = $this->service->fetch( $this->word, $verb, is_null($fetchDetails) ? $this->prefetchDetails : (bool) $fetchDetails ); if ($data === false) { return false; } $this->cache = array_merge($this->cache, $data); return $this->cache[$verb]; }
[ "private", "function", "make", "(", "$", "verb", ",", "$", "fetchDetails", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "cache", "[", "$", "verb", "]", ")", ")", "{", "return", "$", "this", "->", "cache", "[", "$", "verb", ...
Checks if the result is cached. Otherwise it invokes the service method to retrieve the results. Results are cached on a word basis to optimize the number of API calls.
[ "Checks", "if", "the", "result", "is", "cached", ".", "Otherwise", "it", "invokes", "the", "service", "method", "to", "retrieve", "the", "results", ".", "Results", "are", "cached", "on", "a", "word", "basis", "to", "optimize", "the", "number", "of", "API",...
60ca55823ffdf8c422e6bbed614161dc8d6af394
https://github.com/vcarreira/wordsapi/blob/60ca55823ffdf8c422e6bbed614161dc8d6af394/src/Word.php#L326-L344
train
louvian/pururin-crawler
src/Pururin/PururinCrawler.php
PururinCrawler.getCover
private function getCover() { $get = new Cover($this); $get->action(); $get->build(); $this->buildContext($this->result = $get->get(), "cover"); $this->tmpContainer['content_crawler'] = new Content($this); $this->tmpContainer['content_crawler']->setOffsetPoint($this->offset); }
php
private function getCover() { $get = new Cover($this); $get->action(); $get->build(); $this->buildContext($this->result = $get->get(), "cover"); $this->tmpContainer['content_crawler'] = new Content($this); $this->tmpContainer['content_crawler']->setOffsetPoint($this->offset); }
[ "private", "function", "getCover", "(", ")", "{", "$", "get", "=", "new", "Cover", "(", "$", "this", ")", ";", "$", "get", "->", "action", "(", ")", ";", "$", "get", "->", "build", "(", ")", ";", "$", "this", "->", "buildContext", "(", "$", "th...
Get gallery cover.
[ "Get", "gallery", "cover", "." ]
1a8e5d606fc9e0f494aaceaf192d08265e8b8d26
https://github.com/louvian/pururin-crawler/blob/1a8e5d606fc9e0f494aaceaf192d08265e8b8d26/src/Pururin/PururinCrawler.php#L141-L149
train
wardrobecms/core-archived
src/Wardrobe/Core/WardrobeServiceProvider.php
WardrobeServiceProvider.bindRepositories
protected function bindRepositories() { $this->app->singleton('Wardrobe\Core\Repositories\PostRepositoryInterface', 'Wardrobe\Core\Repositories\DbPostRepository'); $this->app->singleton('Wardrobe\Core\Repositories\UserRepositoryInterface', 'Wardrobe\Core\Repositories\DbUserRepository'); $this->app->bind('Wardrobe', function() { return new \Wardrobe\Core\Facades\Wardrobe(new Repositories\DbPostRepository); }); }
php
protected function bindRepositories() { $this->app->singleton('Wardrobe\Core\Repositories\PostRepositoryInterface', 'Wardrobe\Core\Repositories\DbPostRepository'); $this->app->singleton('Wardrobe\Core\Repositories\UserRepositoryInterface', 'Wardrobe\Core\Repositories\DbUserRepository'); $this->app->bind('Wardrobe', function() { return new \Wardrobe\Core\Facades\Wardrobe(new Repositories\DbPostRepository); }); }
[ "protected", "function", "bindRepositories", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'Wardrobe\\Core\\Repositories\\PostRepositoryInterface'", ",", "'Wardrobe\\Core\\Repositories\\DbPostRepository'", ")", ";", "$", "this", "->", "app", "->", "s...
Bind repositories. @return void
[ "Bind", "repositories", "." ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/WardrobeServiceProvider.php#L37-L47
train
wardrobecms/core-archived
src/Wardrobe/Core/WardrobeServiceProvider.php
WardrobeServiceProvider.setConnection
public function setConnection() { $connection = Config::get('core::database.default'); if ($connection !== 'default') { $wardrobeConfig = Config::get('core::database.connections.'.$connection); } else { $connection = Config::get('database.default'); $wardrobeConfig = Config::get('database.connections.'.$connection); } Config::set('database.connections.wardrobe', $wardrobeConfig); }
php
public function setConnection() { $connection = Config::get('core::database.default'); if ($connection !== 'default') { $wardrobeConfig = Config::get('core::database.connections.'.$connection); } else { $connection = Config::get('database.default'); $wardrobeConfig = Config::get('database.connections.'.$connection); } Config::set('database.connections.wardrobe', $wardrobeConfig); }
[ "public", "function", "setConnection", "(", ")", "{", "$", "connection", "=", "Config", "::", "get", "(", "'core::database.default'", ")", ";", "if", "(", "$", "connection", "!==", "'default'", ")", "{", "$", "wardrobeConfig", "=", "Config", "::", "get", "...
Set up the db connection @return void
[ "Set", "up", "the", "db", "connection" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/WardrobeServiceProvider.php#L91-L106
train
skrz/meta
gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php
EnumDescriptorProtoMeta.create
public static function create() { switch (func_num_args()) { case 0: return new EnumDescriptorProto(); case 1: return new EnumDescriptorProto(func_get_arg(0)); case 2: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new EnumDescriptorProto(); case 1: return new EnumDescriptorProto(func_get_arg(0)); case 2: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1)); case 3: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new EnumDescriptorProto(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "EnumDescriptorProto", "(", ")", ";", "case", "1", ":", "return", "new", "EnumDescriptorProto", "(", "func_get_a...
Creates new instance of \Google\Protobuf\EnumDescriptorProto @throws \InvalidArgumentException @return EnumDescriptorProto
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumDescriptorProto" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php#L59-L83
train
skrz/meta
gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php
EnumDescriptorProtoMeta.reset
public static function reset($object) { if (!($object instanceof EnumDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumDescriptorProto.'); } $object->name = NULL; $object->value = NULL; $object->options = NULL; }
php
public static function reset($object) { if (!($object instanceof EnumDescriptorProto)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\EnumDescriptorProto.'); } $object->name = NULL; $object->value = NULL; $object->options = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "EnumDescriptorProto", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\...
Resets properties of \Google\Protobuf\EnumDescriptorProto to default values @param EnumDescriptorProto $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumDescriptorProto", "to", "default", "values" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php#L96-L104
train
skrz/meta
gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php
EnumDescriptorProtoMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->value)) { hash_update($ctx, 'value'); foreach ($object->value instanceof \Traversable ? $object->value : (array)$object->value as $v0) { EnumValueDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->options)) { hash_update($ctx, 'options'); EnumOptionsMeta::hash($object->options, $ctx); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->name)) { hash_update($ctx, 'name'); hash_update($ctx, (string)$object->name); } if (isset($object->value)) { hash_update($ctx, 'value'); foreach ($object->value instanceof \Traversable ? $object->value : (array)$object->value as $v0) { EnumValueDescriptorProtoMeta::hash($v0, $ctx); } } if (isset($object->options)) { hash_update($ctx, 'options'); EnumOptionsMeta::hash($object->options, $ctx); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\EnumDescriptorProto @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "EnumDescriptorProto" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php#L116-L146
train
skrz/meta
gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php
EnumDescriptorProtoMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->value) && ($filter === null || isset($filter['value']))) { foreach ($object->value instanceof \Traversable ? $object->value : (array)$object->value as $k => $v) { $output .= "\x12"; $buffer = EnumValueDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['value']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x1a"; $buffer = EnumOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->name) && ($filter === null || isset($filter['name']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->name)); $output .= $object->name; } if (isset($object->value) && ($filter === null || isset($filter['value']))) { foreach ($object->value instanceof \Traversable ? $object->value : (array)$object->value as $k => $v) { $output .= "\x12"; $buffer = EnumValueDescriptorProtoMeta::toProtobuf($v, $filter === null ? null : $filter['value']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } } if (isset($object->options) && ($filter === null || isset($filter['options']))) { $output .= "\x1a"; $buffer = EnumOptionsMeta::toProtobuf($object->options, $filter === null ? null : $filter['options']); $output .= Binary::encodeVarint(strlen($buffer)); $output .= $buffer; } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "name", ")", "&&", "(", "$", "filter", "===", "null", "||", ...
Serialized \Google\Protobuf\EnumDescriptorProto to Protocol Buffers message. @param EnumDescriptorProto $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "EnumDescriptorProto", "to", "Protocol", "Buffers", "message", "." ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/Meta/EnumDescriptorProtoMeta.php#L256-L283
train
jkphl/dom-factory
src/Domfactory/Ports/Dom.php
Dom.createFromUri
public static function createFromUri($url, array $options = []) { return extension_loaded('curl') ? self::createViaHttpClient($url, $options) : self::createViaStreamWrapper($url, $options); }
php
public static function createFromUri($url, array $options = []) { return extension_loaded('curl') ? self::createViaHttpClient($url, $options) : self::createViaStreamWrapper($url, $options); }
[ "public", "static", "function", "createFromUri", "(", "$", "url", ",", "array", "$", "options", "=", "[", "]", ")", "{", "return", "extension_loaded", "(", "'curl'", ")", "?", "self", "::", "createViaHttpClient", "(", "$", "url", ",", "$", "options", ")"...
Create a DOM document from a URI @param string $url HTTP / HTTPS URL @param array $options Connection options @return \DOMDocument DOM document @api
[ "Create", "a", "DOM", "document", "from", "a", "URI" ]
460595b73b214510b29f483d61358296d2825143
https://github.com/jkphl/dom-factory/blob/460595b73b214510b29f483d61358296d2825143/src/Domfactory/Ports/Dom.php#L57-L61
train
jkphl/dom-factory
src/Domfactory/Ports/Dom.php
Dom.createFromFile
public static function createFromFile($file) { // If the file is not readable if (!is_readable($file)) { throw new InvalidArgumentException( sprintf(InvalidArgumentException::INVALID_FILE_STR, $file), InvalidArgumentException::INVALID_FILE ); } return self::createFromString(file_get_contents($file)); }
php
public static function createFromFile($file) { // If the file is not readable if (!is_readable($file)) { throw new InvalidArgumentException( sprintf(InvalidArgumentException::INVALID_FILE_STR, $file), InvalidArgumentException::INVALID_FILE ); } return self::createFromString(file_get_contents($file)); }
[ "public", "static", "function", "createFromFile", "(", "$", "file", ")", "{", "// If the file is not readable", "if", "(", "!", "is_readable", "(", "$", "file", ")", ")", "{", "throw", "new", "InvalidArgumentException", "(", "sprintf", "(", "InvalidArgumentExcepti...
Create a DOM document from a file @param string $file File @return \DOMDocument DOM document @throws InvalidArgumentException If the file is not readable @api
[ "Create", "a", "DOM", "document", "from", "a", "file" ]
460595b73b214510b29f483d61358296d2825143
https://github.com/jkphl/dom-factory/blob/460595b73b214510b29f483d61358296d2825143/src/Domfactory/Ports/Dom.php#L71-L82
train
budde377/Part
lib/model/page/CurrentPageStrategyImpl.php
CurrentPageStrategyImpl.getCurrentPagePath
public function getCurrentPagePath() { if ($this->currentPagePath != null) { return $this->currentPagePath; } $pageOrderArray = $this->pageOrder->getPageOrder(); $path = $this->GETValueOfIndexIfSetElseDefault('page', false); if (!empty($path) && !empty($pagePath = $this->getPathArrayFromString($path, $pageOrderArray))) { return $this->currentPagePath = $pagePath; } if (!empty($pageOrderArray) && empty($path)) { return $this->currentPagePath = [array_shift($pageOrderArray)]; } return $this->currentPagePath = [new NotFoundPageImpl($this->container)]; }
php
public function getCurrentPagePath() { if ($this->currentPagePath != null) { return $this->currentPagePath; } $pageOrderArray = $this->pageOrder->getPageOrder(); $path = $this->GETValueOfIndexIfSetElseDefault('page', false); if (!empty($path) && !empty($pagePath = $this->getPathArrayFromString($path, $pageOrderArray))) { return $this->currentPagePath = $pagePath; } if (!empty($pageOrderArray) && empty($path)) { return $this->currentPagePath = [array_shift($pageOrderArray)]; } return $this->currentPagePath = [new NotFoundPageImpl($this->container)]; }
[ "public", "function", "getCurrentPagePath", "(", ")", "{", "if", "(", "$", "this", "->", "currentPagePath", "!=", "null", ")", "{", "return", "$", "this", "->", "currentPagePath", ";", "}", "$", "pageOrderArray", "=", "$", "this", "->", "pageOrder", "->", ...
Will return the path to the current page as an array of Page's @return array
[ "Will", "return", "the", "path", "to", "the", "current", "page", "as", "an", "array", "of", "Page", "s" ]
9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/model/page/CurrentPageStrategyImpl.php#L36-L57
train
yeephp/yeephp
Yee/Views/Twig.php
Twig.getInstance
public function getInstance() { if (!$this->parserInstance) { /** * Check if Twig_Autoloader class exists * otherwise include it. */ if (!class_exists('\Twig_Autoloader')) { require_once $this->parserDirectory . '/Autoloader.php'; } \Twig_Autoloader::register(); $loader = new \Twig_Loader_Filesystem($this->getTemplateDirs()); $this->parserInstance = new \Twig_Environment( $loader, $this->parserOptions ); foreach ($this->parserExtensions as $ext) { $extension = is_object($ext) ? $ext : new $ext; $this->parserInstance->addExtension($extension); } } return $this->parserInstance; }
php
public function getInstance() { if (!$this->parserInstance) { /** * Check if Twig_Autoloader class exists * otherwise include it. */ if (!class_exists('\Twig_Autoloader')) { require_once $this->parserDirectory . '/Autoloader.php'; } \Twig_Autoloader::register(); $loader = new \Twig_Loader_Filesystem($this->getTemplateDirs()); $this->parserInstance = new \Twig_Environment( $loader, $this->parserOptions ); foreach ($this->parserExtensions as $ext) { $extension = is_object($ext) ? $ext : new $ext; $this->parserInstance->addExtension($extension); } } return $this->parserInstance; }
[ "public", "function", "getInstance", "(", ")", "{", "if", "(", "!", "$", "this", "->", "parserInstance", ")", "{", "/**\n * Check if Twig_Autoloader class exists\n * otherwise include it.\n */", "if", "(", "!", "class_exists", "(", "'\\Tw...
Creates new TwigEnvironment if it doesn't already exist, and returns it. @return \Twig_Environment
[ "Creates", "new", "TwigEnvironment", "if", "it", "doesn", "t", "already", "exist", "and", "returns", "it", "." ]
6107f60ceaf0811a6550872bd669580ac282cb1f
https://github.com/yeephp/yeephp/blob/6107f60ceaf0811a6550872bd669580ac282cb1f/Yee/Views/Twig.php#L109-L135
train
joetannenbaum/phpushbullet
src/Request/PushFile.php
PushFile.getFileType
protected function getFileType($file_url) { $file_info = (new Client())->head($file_url); $file_type = $file_info->getHeader('content-type'); if (is_array($file_type)) { return reset($file_type); } return $file_type; }
php
protected function getFileType($file_url) { $file_info = (new Client())->head($file_url); $file_type = $file_info->getHeader('content-type'); if (is_array($file_type)) { return reset($file_type); } return $file_type; }
[ "protected", "function", "getFileType", "(", "$", "file_url", ")", "{", "$", "file_info", "=", "(", "new", "Client", "(", ")", ")", "->", "head", "(", "$", "file_url", ")", ";", "$", "file_type", "=", "$", "file_info", "->", "getHeader", "(", "'content...
Get the file type based on the file url @param string $file_url @return string
[ "Get", "the", "file", "type", "based", "on", "the", "file", "url" ]
df138ebb3adebcddade282be478c0d2d6ebffb3e
https://github.com/joetannenbaum/phpushbullet/blob/df138ebb3adebcddade282be478c0d2d6ebffb3e/src/Request/PushFile.php#L33-L43
train
kss-php/kss-php
lib/Modifier.php
Modifier.getExtendedClassName
public function getExtendedClassName() { if ($this->getExtendedClass() === null) { return ''; } $name = str_replace('%', ' ', $this->getExtendedClass()); $name = str_replace('.', ' ', $name); $name = str_replace(':', ' pseudo-class-', $name); return trim($name); }
php
public function getExtendedClassName() { if ($this->getExtendedClass() === null) { return ''; } $name = str_replace('%', ' ', $this->getExtendedClass()); $name = str_replace('.', ' ', $name); $name = str_replace(':', ' pseudo-class-', $name); return trim($name); }
[ "public", "function", "getExtendedClassName", "(", ")", "{", "if", "(", "$", "this", "->", "getExtendedClass", "(", ")", "===", "null", ")", "{", "return", "''", ";", "}", "$", "name", "=", "str_replace", "(", "'%'", ",", "' '", ",", "$", "this", "->...
Returns the class name for the extended class @return string
[ "Returns", "the", "class", "name", "for", "the", "extended", "class" ]
5431bfb3c3708cfedb6a95fc3413181287d1f776
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Modifier.php#L176-L186
train
kss-php/kss-php
lib/Modifier.php
Modifier.getClassName
public function getClassName() { $name = str_replace('.', ' ', $this->name); $name = str_replace(':', ' pseudo-class-', $name); return trim($name); }
php
public function getClassName() { $name = str_replace('.', ' ', $this->name); $name = str_replace(':', ' pseudo-class-', $name); return trim($name); }
[ "public", "function", "getClassName", "(", ")", "{", "$", "name", "=", "str_replace", "(", "'.'", ",", "' '", ",", "$", "this", "->", "name", ")", ";", "$", "name", "=", "str_replace", "(", "':'", ",", "' pseudo-class-'", ",", "$", "name", ")", ";", ...
Returns the class name for the modifier @return string
[ "Returns", "the", "class", "name", "for", "the", "modifier" ]
5431bfb3c3708cfedb6a95fc3413181287d1f776
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Modifier.php#L193-L198
train
kss-php/kss-php
lib/Modifier.php
Modifier.getExampleHtml
public function getExampleHtml($html = null) { if ($html === null) { if ($this->getMarkup() === null) { return ''; } $html = $this->getMarkup(); } if ($this->isExtender()) { $html = str_replace('$modifierClass', '', $html); // Use a positive lookbehind and lookahead to ensure we don't // replace anything more than just the targeted class name // for example an element name that is the same as the extended // class name (e.g. button) $pattern = sprintf('/(?<="| )%s(?="| )/', $this->getExtendedClassName()); $html = preg_replace( $pattern, $this->getClassName(), $html ); } $html = str_replace('$modifierClass', $this->getClassName(), $html); return $html; }
php
public function getExampleHtml($html = null) { if ($html === null) { if ($this->getMarkup() === null) { return ''; } $html = $this->getMarkup(); } if ($this->isExtender()) { $html = str_replace('$modifierClass', '', $html); // Use a positive lookbehind and lookahead to ensure we don't // replace anything more than just the targeted class name // for example an element name that is the same as the extended // class name (e.g. button) $pattern = sprintf('/(?<="| )%s(?="| )/', $this->getExtendedClassName()); $html = preg_replace( $pattern, $this->getClassName(), $html ); } $html = str_replace('$modifierClass', $this->getClassName(), $html); return $html; }
[ "public", "function", "getExampleHtml", "(", "$", "html", "=", "null", ")", "{", "if", "(", "$", "html", "===", "null", ")", "{", "if", "(", "$", "this", "->", "getMarkup", "(", ")", "===", "null", ")", "{", "return", "''", ";", "}", "$", "html",...
Returns a string of specified html with inserted class names in the correct places for modifiers and extenders. @param string $html OPTIONAL @return string $html
[ "Returns", "a", "string", "of", "specified", "html", "with", "inserted", "class", "names", "in", "the", "correct", "places", "for", "modifiers", "and", "extenders", "." ]
5431bfb3c3708cfedb6a95fc3413181287d1f776
https://github.com/kss-php/kss-php/blob/5431bfb3c3708cfedb6a95fc3413181287d1f776/lib/Modifier.php#L208-L235
train
skrz/meta
gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php
NamePartMeta.create
public static function create() { switch (func_num_args()) { case 0: return new NamePart(); case 1: return new NamePart(func_get_arg(0)); case 2: return new NamePart(func_get_arg(0), func_get_arg(1)); case 3: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new NamePart(); case 1: return new NamePart(func_get_arg(0)); case 2: return new NamePart(func_get_arg(0), func_get_arg(1)); case 3: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new NamePart(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "NamePart", "(", ")", ";", "case", "1", ":", "return", "new", "NamePart", "(", "func_get_arg", "(", "0", "...
Creates new instance of \Google\Protobuf\UninterpretedOption\NamePart @throws \InvalidArgumentException @return NamePart
[ "Creates", "new", "instance", "of", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "\\", "NamePart" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php#L58-L82
train
skrz/meta
gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php
NamePartMeta.reset
public static function reset($object) { if (!($object instanceof NamePart)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\UninterpretedOption\NamePart.'); } $object->namePart = NULL; $object->isExtension = NULL; }
php
public static function reset($object) { if (!($object instanceof NamePart)) { throw new \InvalidArgumentException('You have to pass object of class Google\Protobuf\UninterpretedOption\NamePart.'); } $object->namePart = NULL; $object->isExtension = NULL; }
[ "public", "static", "function", "reset", "(", "$", "object", ")", "{", "if", "(", "!", "(", "$", "object", "instanceof", "NamePart", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'You have to pass object of class Google\\Protobuf\\Uninterpre...
Resets properties of \Google\Protobuf\UninterpretedOption\NamePart to default values @param NamePart $object @throws \InvalidArgumentException @return void
[ "Resets", "properties", "of", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "\\", "NamePart", "to", "default", "values" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php#L95-L102
train
skrz/meta
gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php
NamePartMeta.hash
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->namePart)) { hash_update($ctx, 'namePart'); hash_update($ctx, (string)$object->namePart); } if (isset($object->isExtension)) { hash_update($ctx, 'isExtension'); hash_update($ctx, (string)$object->isExtension); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
php
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE) { if (is_string($algoOrCtx)) { $ctx = hash_init($algoOrCtx); } else { $ctx = $algoOrCtx; } if (isset($object->namePart)) { hash_update($ctx, 'namePart'); hash_update($ctx, (string)$object->namePart); } if (isset($object->isExtension)) { hash_update($ctx, 'isExtension'); hash_update($ctx, (string)$object->isExtension); } if (is_string($algoOrCtx)) { return hash_final($ctx, $raw); } else { return null; } }
[ "public", "static", "function", "hash", "(", "$", "object", ",", "$", "algoOrCtx", "=", "'md5'", ",", "$", "raw", "=", "FALSE", ")", "{", "if", "(", "is_string", "(", "$", "algoOrCtx", ")", ")", "{", "$", "ctx", "=", "hash_init", "(", "$", "algoOrC...
Computes hash of \Google\Protobuf\UninterpretedOption\NamePart @param object $object @param string|resource $algoOrCtx @param bool $raw @return string|void
[ "Computes", "hash", "of", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "\\", "NamePart" ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php#L114-L137
train
skrz/meta
gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php
NamePartMeta.fromProtobuf
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new NamePart(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->namePart = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->isExtension = (bool)Binary::decodeVarint($input, $start); break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
php
public static function fromProtobuf($input, $object = NULL, &$start = 0, $end = NULL) { if ($object === null) { $object = new NamePart(); } if ($end === null) { $end = strlen($input); } while ($start < $end) { $tag = Binary::decodeVarint($input, $start); $wireType = $tag & 0x7; $number = $tag >> 3; switch ($number) { case 1: if ($wireType !== 2) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 2.', $number); } $length = Binary::decodeVarint($input, $start); $expectedStart = $start + $length; if ($expectedStart > $end) { throw new ProtobufException('Not enough data.'); } $object->namePart = substr($input, $start, $length); $start += $length; if ($start !== $expectedStart) { throw new ProtobufException('Unexpected start. Expected ' . $expectedStart . ', got ' . $start . '.', $number); } break; case 2: if ($wireType !== 0) { throw new ProtobufException('Unexpected wire type ' . $wireType . ', expected 0.', $number); } $object->isExtension = (bool)Binary::decodeVarint($input, $start); break; default: switch ($wireType) { case 0: Binary::decodeVarint($input, $start); break; case 1: $start += 8; break; case 2: $start += Binary::decodeVarint($input, $start); break; case 5: $start += 4; break; default: throw new ProtobufException('Unexpected wire type ' . $wireType . '.', $number); } } } return $object; }
[ "public", "static", "function", "fromProtobuf", "(", "$", "input", ",", "$", "object", "=", "NULL", ",", "&", "$", "start", "=", "0", ",", "$", "end", "=", "NULL", ")", "{", "if", "(", "$", "object", "===", "null", ")", "{", "$", "object", "=", ...
Creates \Google\Protobuf\UninterpretedOption\NamePart object from serialized Protocol Buffers message. @param string $input @param NamePart $object @param int $start @param int $end @throws \Exception @return NamePart
[ "Creates", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "\\", "NamePart", "object", "from", "serialized", "Protocol", "Buffers", "message", "." ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php#L152-L209
train
skrz/meta
gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php
NamePartMeta.toProtobuf
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->namePart) && ($filter === null || isset($filter['namePart']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->namePart)); $output .= $object->namePart; } if (isset($object->isExtension) && ($filter === null || isset($filter['isExtension']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->isExtension); } return $output; }
php
public static function toProtobuf($object, $filter = NULL) { $output = ''; if (isset($object->namePart) && ($filter === null || isset($filter['namePart']))) { $output .= "\x0a"; $output .= Binary::encodeVarint(strlen($object->namePart)); $output .= $object->namePart; } if (isset($object->isExtension) && ($filter === null || isset($filter['isExtension']))) { $output .= "\x10"; $output .= Binary::encodeVarint((int)$object->isExtension); } return $output; }
[ "public", "static", "function", "toProtobuf", "(", "$", "object", ",", "$", "filter", "=", "NULL", ")", "{", "$", "output", "=", "''", ";", "if", "(", "isset", "(", "$", "object", "->", "namePart", ")", "&&", "(", "$", "filter", "===", "null", "||"...
Serialized \Google\Protobuf\UninterpretedOption\NamePart to Protocol Buffers message. @param NamePart $object @param array $filter @throws \Exception @return string
[ "Serialized", "\\", "Google", "\\", "Protobuf", "\\", "UninterpretedOption", "\\", "NamePart", "to", "Protocol", "Buffers", "message", "." ]
013af6435d3885ab5b2e91fb8ebb051d0f874ab2
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Google/Protobuf/UninterpretedOption/Meta/NamePartMeta.php#L222-L238
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.active
public function active($per_page) { $per_page = is_numeric($per_page) ? $per_page : 5; return Post::with(array('tags', 'user')) ->where('active', 1) ->where('publish_date', '<=', new DateTime) ->orderBy('publish_date', 'desc') ->paginate($per_page); }
php
public function active($per_page) { $per_page = is_numeric($per_page) ? $per_page : 5; return Post::with(array('tags', 'user')) ->where('active', 1) ->where('publish_date', '<=', new DateTime) ->orderBy('publish_date', 'desc') ->paginate($per_page); }
[ "public", "function", "active", "(", "$", "per_page", ")", "{", "$", "per_page", "=", "is_numeric", "(", "$", "per_page", ")", "?", "$", "per_page", ":", "5", ";", "return", "Post", "::", "with", "(", "array", "(", "'tags'", ",", "'user'", ")", ")", ...
Get all of the active posts. @param int $per_page @return array
[ "Get", "all", "of", "the", "active", "posts", "." ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L26-L35
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.findBySlug
public function findBySlug($slug) { return Post::with(array('tags', 'user')) ->where('active', 1) ->where('publish_date', '<=', new DateTime) ->where('slug', $slug)->first(); }
php
public function findBySlug($slug) { return Post::with(array('tags', 'user')) ->where('active', 1) ->where('publish_date', '<=', new DateTime) ->where('slug', $slug)->first(); }
[ "public", "function", "findBySlug", "(", "$", "slug", ")", "{", "return", "Post", "::", "with", "(", "array", "(", "'tags'", ",", "'user'", ")", ")", "->", "where", "(", "'active'", ",", "1", ")", "->", "where", "(", "'publish_date'", ",", "'<='", ",...
Get a Post by its slug @param string $slug @return Post
[ "Get", "a", "Post", "by", "its", "slug" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L54-L60
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.activeByTag
public function activeByTag($tag, $per_page) { $per_page = is_numeric($per_page) ? $per_page : 5; return Post::with(array('tags', 'user')) ->select('posts.*') ->join('tags', 'posts.id', '=', 'tags.post_id') ->where('tags.tag', '=', $tag) ->orderBy('posts.publish_date', 'desc') ->where('posts.active', 1) ->where('posts.publish_date', '<=', new DateTime) ->distinct() ->paginate($per_page); }
php
public function activeByTag($tag, $per_page) { $per_page = is_numeric($per_page) ? $per_page : 5; return Post::with(array('tags', 'user')) ->select('posts.*') ->join('tags', 'posts.id', '=', 'tags.post_id') ->where('tags.tag', '=', $tag) ->orderBy('posts.publish_date', 'desc') ->where('posts.active', 1) ->where('posts.publish_date', '<=', new DateTime) ->distinct() ->paginate($per_page); }
[ "public", "function", "activeByTag", "(", "$", "tag", ",", "$", "per_page", ")", "{", "$", "per_page", "=", "is_numeric", "(", "$", "per_page", ")", "?", "$", "per_page", ":", "5", ";", "return", "Post", "::", "with", "(", "array", "(", "'tags'", ","...
Get all posts with a tag @param string $tag @param int $per_page @return array
[ "Get", "all", "posts", "with", "a", "tag" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L69-L82
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.search
public function search($search, $per_page) { $per_page = is_numeric($per_page) ? $per_page : 5; return Post::with(array('tags', 'user')) ->select('posts.*') ->join('tags', 'posts.id', '=', 'tags.post_id') ->where(function($query) use ($search) { $query->orWhere('title', 'like', '%'.$search.'%') ->orWhere('content', 'like', '%'.$search.'%'); }) ->orderBy('posts.publish_date', 'desc') ->where('posts.active', '=', 1) ->where('posts.publish_date', '<=', new DateTime) ->groupBy('id') ->distinct() ->paginate($per_page); }
php
public function search($search, $per_page) { $per_page = is_numeric($per_page) ? $per_page : 5; return Post::with(array('tags', 'user')) ->select('posts.*') ->join('tags', 'posts.id', '=', 'tags.post_id') ->where(function($query) use ($search) { $query->orWhere('title', 'like', '%'.$search.'%') ->orWhere('content', 'like', '%'.$search.'%'); }) ->orderBy('posts.publish_date', 'desc') ->where('posts.active', '=', 1) ->where('posts.publish_date', '<=', new DateTime) ->groupBy('id') ->distinct() ->paginate($per_page); }
[ "public", "function", "search", "(", "$", "search", ",", "$", "per_page", ")", "{", "$", "per_page", "=", "is_numeric", "(", "$", "per_page", ")", "?", "$", "per_page", ":", "5", ";", "return", "Post", "::", "with", "(", "array", "(", "'tags'", ",", ...
Search all active posts @param string $tag @param int $per_page @return array
[ "Search", "all", "active", "posts" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L91-L109
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.facadeSearch
public function facadeSearch(array $params) { $search = isset($params['q']) ? $params['q'] : null; $tag = isset($params['tag']) ? $params['tag'] : null; $limit = isset($params['limit']) ? (int) $params['limit'] : 1; $post = Post::with(array('tags', 'user')) ->select('posts.*') ->join('tags', 'posts.id', '=', 'tags.post_id') ->orderBy('posts.publish_date', 'desc') ->where('posts.active', 1) ->where('posts.publish_date', '<=', new DateTime) ->distinct(); if ($search) { $post->where(function($query) use ($search) { $query->orWhere('title', 'like', '%'.$search.'%') ->orWhere('content', 'like', '%'.$search.'%'); }); } if ($tag) { $post->where('tags.tag', '=', $tag); } return $post->skip(0)->take($limit)->get(); }
php
public function facadeSearch(array $params) { $search = isset($params['q']) ? $params['q'] : null; $tag = isset($params['tag']) ? $params['tag'] : null; $limit = isset($params['limit']) ? (int) $params['limit'] : 1; $post = Post::with(array('tags', 'user')) ->select('posts.*') ->join('tags', 'posts.id', '=', 'tags.post_id') ->orderBy('posts.publish_date', 'desc') ->where('posts.active', 1) ->where('posts.publish_date', '<=', new DateTime) ->distinct(); if ($search) { $post->where(function($query) use ($search) { $query->orWhere('title', 'like', '%'.$search.'%') ->orWhere('content', 'like', '%'.$search.'%'); }); } if ($tag) { $post->where('tags.tag', '=', $tag); } return $post->skip(0)->take($limit)->get(); }
[ "public", "function", "facadeSearch", "(", "array", "$", "params", ")", "{", "$", "search", "=", "isset", "(", "$", "params", "[", "'q'", "]", ")", "?", "$", "params", "[", "'q'", "]", ":", "null", ";", "$", "tag", "=", "isset", "(", "$", "params...
Search from the wardrobe facet @param array $params @return array
[ "Search", "from", "the", "wardrobe", "facet" ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L117-L146
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.create
public function create($title, $content, $slug, array $tags, $active, $user_id, DateTime $publish_date) { $post = Post::create(compact('title', 'content', 'slug', 'active', 'user_id', 'publish_date')); $post->tags()->delete(); $post->tags()->createMany($this->prepareTags($tags)); return $post; }
php
public function create($title, $content, $slug, array $tags, $active, $user_id, DateTime $publish_date) { $post = Post::create(compact('title', 'content', 'slug', 'active', 'user_id', 'publish_date')); $post->tags()->delete(); $post->tags()->createMany($this->prepareTags($tags)); return $post; }
[ "public", "function", "create", "(", "$", "title", ",", "$", "content", ",", "$", "slug", ",", "array", "$", "tags", ",", "$", "active", ",", "$", "user_id", ",", "DateTime", "$", "publish_date", ")", "{", "$", "post", "=", "Post", "::", "create", ...
Create a new post. @param string $title @param string $content @param string $slug @param array $tags @param bool $active @param int $user_id @param DateTime $publish_date @return Post
[ "Create", "a", "new", "post", "." ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L160-L169
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.update
public function update($id, $title, $content, $slug, array $tags, $active, $user_id, DateTime $publish_date) { $post = $this->find($id); // Forget the old cache if (Config::get('wardrobe.cache')) { Cache::forget('post-'.$post->id); } $post->fill(compact('title', 'content', 'slug', 'active', 'user_id', 'publish_date'))->save(); $post->tags()->delete(); $post->tags()->createMany($this->prepareTags($tags)); return $post; }
php
public function update($id, $title, $content, $slug, array $tags, $active, $user_id, DateTime $publish_date) { $post = $this->find($id); // Forget the old cache if (Config::get('wardrobe.cache')) { Cache::forget('post-'.$post->id); } $post->fill(compact('title', 'content', 'slug', 'active', 'user_id', 'publish_date'))->save(); $post->tags()->delete(); $post->tags()->createMany($this->prepareTags($tags)); return $post; }
[ "public", "function", "update", "(", "$", "id", ",", "$", "title", ",", "$", "content", ",", "$", "slug", ",", "array", "$", "tags", ",", "$", "active", ",", "$", "user_id", ",", "DateTime", "$", "publish_date", ")", "{", "$", "post", "=", "$", "...
Update a post's title and content. @param int $id @param string $title @param string $content @param string $slug @param array $tags @param string $active @param int $user_id @param \DateTime $publish_date @return Post
[ "Update", "a", "post", "s", "title", "and", "content", "." ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L185-L202
train
wardrobecms/core-archived
src/Wardrobe/Core/Repositories/DbPostRepository.php
DbPostRepository.validatePost
protected function validatePost($title, $slug, $id = null) { $rules = array( 'title' => 'required', 'slug' => 'required|unique:posts,slug', ); if ($id) { $rules['slug'] .= ','.$id; } with($validator = Validator::make(compact('title', 'slug'), $rules))->fails(); return $validator->errors(); }
php
protected function validatePost($title, $slug, $id = null) { $rules = array( 'title' => 'required', 'slug' => 'required|unique:posts,slug', ); if ($id) { $rules['slug'] .= ','.$id; } with($validator = Validator::make(compact('title', 'slug'), $rules))->fails(); return $validator->errors(); }
[ "protected", "function", "validatePost", "(", "$", "title", ",", "$", "slug", ",", "$", "id", "=", "null", ")", "{", "$", "rules", "=", "array", "(", "'title'", "=>", "'required'", ",", "'slug'", "=>", "'required|unique:posts,slug'", ",", ")", ";", "if",...
Determine if the given post is valid. @param string $title @param string $slug @param int $id @return \Illuminate\Support\MessageBag
[ "Determine", "if", "the", "given", "post", "is", "valid", "." ]
5c0836ea2e6885a428c852dc392073f2a2541c71
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Repositories/DbPostRepository.php#L276-L291
train
MW-Peachy/Peachy
Includes/Peachy.php
Peachy.newWiki
public static function newWiki( $config_name = null, $pgUsername = null, $password = null, $base_url = 'http://en.wikipedia.org/w/api.php', $classname = 'Wiki' ) { pecho( "Loading Peachy (version " . PEACHYVERSION . ")...\n\n", PECHO_NORMAL ); /*$updater = new AutoUpdate(); $Uptodate = $updater->Checkforupdate(); if( !$Uptodate ) $updater->updatePeachy();*/ if( !is_null( $config_name ) ) { $config_params = self::parse_config( $config_name ); } else { $config_params = array( 'username' => $pgUsername, 'password' => $password, 'baseurl' => $base_url, 'method' => 'legacy' ); } if( is_null( $config_params['baseurl'] ) || !isset( $config_params['baseurl'] ) ) { throw new LoginError( array( "MissingParam", "The baseurl parameter was not set." ) ); } if( !isset( $config_params['username'] ) ) { $config_params['nologin'] = true; } if( !isset( $config_params['password'] ) && isset( $config_params['method'] ) && $config_params['method'] == "legacy" ) { $config_params['nologin'] = true; } list( $version, $extensions ) = self::wikiChecks( $config_params['baseurl'] ); Hooks::runHook( 'StartLogin', array( &$config_params, &$extensions ) ); $w = new $classname( $config_params, $extensions, false, null ); $w->mwversion = $version; return $w; }
php
public static function newWiki( $config_name = null, $pgUsername = null, $password = null, $base_url = 'http://en.wikipedia.org/w/api.php', $classname = 'Wiki' ) { pecho( "Loading Peachy (version " . PEACHYVERSION . ")...\n\n", PECHO_NORMAL ); /*$updater = new AutoUpdate(); $Uptodate = $updater->Checkforupdate(); if( !$Uptodate ) $updater->updatePeachy();*/ if( !is_null( $config_name ) ) { $config_params = self::parse_config( $config_name ); } else { $config_params = array( 'username' => $pgUsername, 'password' => $password, 'baseurl' => $base_url, 'method' => 'legacy' ); } if( is_null( $config_params['baseurl'] ) || !isset( $config_params['baseurl'] ) ) { throw new LoginError( array( "MissingParam", "The baseurl parameter was not set." ) ); } if( !isset( $config_params['username'] ) ) { $config_params['nologin'] = true; } if( !isset( $config_params['password'] ) && isset( $config_params['method'] ) && $config_params['method'] == "legacy" ) { $config_params['nologin'] = true; } list( $version, $extensions ) = self::wikiChecks( $config_params['baseurl'] ); Hooks::runHook( 'StartLogin', array( &$config_params, &$extensions ) ); $w = new $classname( $config_params, $extensions, false, null ); $w->mwversion = $version; return $w; }
[ "public", "static", "function", "newWiki", "(", "$", "config_name", "=", "null", ",", "$", "pgUsername", "=", "null", ",", "$", "password", "=", "null", ",", "$", "base_url", "=", "'http://en.wikipedia.org/w/api.php'", ",", "$", "classname", "=", "'Wiki'", "...
Initializes Peachy, logs in with a either the configuration file or a given username and password @static @access public @param string $config_name Name of the config file stored in the Configs directory, minus the .cfg extension. Default null @param string $pgUsername Username to log in if no config file specified. Default null @param string $password Password to log in with if no config file specified. Default null @param string $base_url URL to api.php if no config file specified. Defaults to English Wikipedia's API. @param string $classname @throws LoginError @return Wiki Instance of the Wiki class, where most functions are stored
[ "Initializes", "Peachy", "logs", "in", "with", "a", "either", "the", "configuration", "file", "or", "a", "given", "username", "and", "password" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Peachy.php#L23-L61
train
MW-Peachy/Peachy
Includes/Peachy.php
Peachy.parse_config
private static function parse_config( $config_name ) { global $pgIP; if( !is_file( $config_name ) ) { if( !is_file( $pgIP . 'Configs/' . $config_name . '.cfg' ) ) { throw new BadEntryError( "BadConfig", "A non-existent configuration file was specified." ); } else { $config_name = $pgIP . 'Configs/' . $config_name . '.cfg'; } } $config_params = parse_ini_file( $config_name ); if( isset( $config_params['useconfig'] ) ) { $config_params = $config_params + self::parse_config( $config_params['useconfig'] ); } return $config_params; }
php
private static function parse_config( $config_name ) { global $pgIP; if( !is_file( $config_name ) ) { if( !is_file( $pgIP . 'Configs/' . $config_name . '.cfg' ) ) { throw new BadEntryError( "BadConfig", "A non-existent configuration file was specified." ); } else { $config_name = $pgIP . 'Configs/' . $config_name . '.cfg'; } } $config_params = parse_ini_file( $config_name ); if( isset( $config_params['useconfig'] ) ) { $config_params = $config_params + self::parse_config( $config_params['useconfig'] ); } return $config_params; }
[ "private", "static", "function", "parse_config", "(", "$", "config_name", ")", "{", "global", "$", "pgIP", ";", "if", "(", "!", "is_file", "(", "$", "config_name", ")", ")", "{", "if", "(", "!", "is_file", "(", "$", "pgIP", ".", "'Configs/'", ".", "$...
Checks for config files, parses them. @access private @static @param string $config_name Name of config file @throws BadEntryError @return array Config params
[ "Checks", "for", "config", "files", "parses", "them", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Peachy.php#L122-L139
train
MW-Peachy/Peachy
Includes/Peachy.php
Peachy.deprecatedWarn
public static function deprecatedWarn($method, $newFunction, $message = null) { if( is_null( $message ) ) { $message = "Warning: $method is deprecated. Please use $newFunction instead."; } $message = "[$message|YELLOW_BAR]\n\n"; pecho( $message, PECHO_WARN, 'cecho' ); }
php
public static function deprecatedWarn($method, $newFunction, $message = null) { if( is_null( $message ) ) { $message = "Warning: $method is deprecated. Please use $newFunction instead."; } $message = "[$message|YELLOW_BAR]\n\n"; pecho( $message, PECHO_WARN, 'cecho' ); }
[ "public", "static", "function", "deprecatedWarn", "(", "$", "method", ",", "$", "newFunction", ",", "$", "message", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "message", ")", ")", "{", "$", "message", "=", "\"Warning: $method is deprecated. Pleas...
Function that displays an error message when an End-User attempts to use a function no longer included in Peachy @param null|string $method @param null|string $newFunction @param string $message
[ "Function", "that", "displays", "an", "error", "message", "when", "an", "End", "-", "User", "attempts", "to", "use", "a", "function", "no", "longer", "included", "in", "Peachy" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Peachy.php#L148-L157
train
MW-Peachy/Peachy
Includes/Peachy.php
Peachy.getSvnInfo
public static function getSvnInfo() { global $pgIP; // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html $entries = $pgIP . '/.svn/entries'; if( !file_exists( $entries ) ) { return false; } $lines = file( $entries ); if( !count( $lines ) ) { return false; } // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4) if( preg_match( '/^<\?xml/', $lines[0] ) ) { return false; } // Subversion is release 1.4 or above. if( count( $lines ) < 11 ) { return false; } $info = array( 'checkout-rev' => intval( trim( $lines[3] ) ), 'url' => trim( $lines[4] ), 'repo-url' => trim( $lines[5] ), 'directory-rev' => intval( trim( $lines[10] ) ) ); return $info; }
php
public static function getSvnInfo() { global $pgIP; // http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html $entries = $pgIP . '/.svn/entries'; if( !file_exists( $entries ) ) { return false; } $lines = file( $entries ); if( !count( $lines ) ) { return false; } // check if file is xml (subversion release <= 1.3) or not (subversion release = 1.4) if( preg_match( '/^<\?xml/', $lines[0] ) ) { return false; } // Subversion is release 1.4 or above. if( count( $lines ) < 11 ) { return false; } $info = array( 'checkout-rev' => intval( trim( $lines[3] ) ), 'url' => trim( $lines[4] ), 'repo-url' => trim( $lines[5] ), 'directory-rev' => intval( trim( $lines[10] ) ) ); return $info; }
[ "public", "static", "function", "getSvnInfo", "(", ")", "{", "global", "$", "pgIP", ";", "// http://svnbook.red-bean.com/nightly/en/svn.developer.insidewc.html", "$", "entries", "=", "$", "pgIP", ".", "'/.svn/entries'", ";", "if", "(", "!", "file_exists", "(", "$", ...
Checks for and returns an SVN repository version. @return array|bool
[ "Checks", "for", "and", "returns", "an", "SVN", "repository", "version", "." ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/Peachy.php#L164-L197
train
MW-Peachy/Peachy
Plugins/AbuseFilter.php
AbuseFilter.abuselog
public function abuselog( $filter = null, $user = null, $title = null, $limit = null, $start = null, $end = null, $dir = 'older', $prop = array( 'ids', 'filter', 'user', 'ip', 'title', 'action', 'details', 'result', 'timestamp' ) ) { $tArray = array( 'prop' => $prop, '_code' => 'afl', 'afldir' => $dir, '_limit' => $limit, 'list' => 'abuselog', ); if( !is_null( $filter ) ) $tArray['aflfilter'] = $filter; if( !is_null( $user ) ) $tArray['afluser'] = $user; if( !is_null( $title ) ) $tArray['afltitle'] = $title; if( !is_null( $start ) ) $tArray['aflstart'] = $start; if( !is_null( $end ) ) $tArray['aflend'] = $end; pecho( "Getting abuse log...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $tArray ); }
php
public function abuselog( $filter = null, $user = null, $title = null, $limit = null, $start = null, $end = null, $dir = 'older', $prop = array( 'ids', 'filter', 'user', 'ip', 'title', 'action', 'details', 'result', 'timestamp' ) ) { $tArray = array( 'prop' => $prop, '_code' => 'afl', 'afldir' => $dir, '_limit' => $limit, 'list' => 'abuselog', ); if( !is_null( $filter ) ) $tArray['aflfilter'] = $filter; if( !is_null( $user ) ) $tArray['afluser'] = $user; if( !is_null( $title ) ) $tArray['afltitle'] = $title; if( !is_null( $start ) ) $tArray['aflstart'] = $start; if( !is_null( $end ) ) $tArray['aflend'] = $end; pecho( "Getting abuse log...\n\n", PECHO_NORMAL ); return $this->wiki->listHandler( $tArray ); }
[ "public", "function", "abuselog", "(", "$", "filter", "=", "null", ",", "$", "user", "=", "null", ",", "$", "title", "=", "null", ",", "$", "limit", "=", "null", ",", "$", "start", "=", "null", ",", "$", "end", "=", "null", ",", "$", "dir", "="...
Returns the abuse filter log @access public @param int $filter Filter ID. Default null @param string $user Show entries by this user. Default null @param string $title Show entries to this title. Default null @param int $limit Number of entries to retrieve. Defautl null @param string $start Timestamp to start at. Default null @param string $end Timestamp to end at. Default null @param string $dir Direction to list. Default older @param array $prop Properties to retrieve. Default array( 'ids', 'filter', 'user', 'ip', 'title', 'action', 'details', 'result', 'timestamp' ) @return array
[ "Returns", "the", "abuse", "filter", "log" ]
2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Plugins/AbuseFilter.php#L60-L81
train