id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
sequence
docstring
stringlengths
3
47.2k
docstring_tokens
sequence
sha
stringlengths
40
40
url
stringlengths
91
247
1,300
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.getFromWhere
public function getFromWhere($from, $where=NULL, $where_values=array(), $order=NULL, $limit=NULL, $offset=NULL){ $res= FALSE; try{ //Armo partes de la consulta if($order != NULL){$order= " ORDER BY " . $order;} if($limit != NULL){ $limit= " LIMIT " . $limit; if($offset != NULL){$limit.= ' OFFSET ' . $offset;} } //Armo y preparo la consulta $query= $this->prepareSelect($this->select, $from, $where, '', '', $order, $limit); //Ejecuto la consulta $query->execute($where_values); //Controlo que este todo bien if($this->isOk($query)){ $res= $query; } //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
php
public function getFromWhere($from, $where=NULL, $where_values=array(), $order=NULL, $limit=NULL, $offset=NULL){ $res= FALSE; try{ //Armo partes de la consulta if($order != NULL){$order= " ORDER BY " . $order;} if($limit != NULL){ $limit= " LIMIT " . $limit; if($offset != NULL){$limit.= ' OFFSET ' . $offset;} } //Armo y preparo la consulta $query= $this->prepareSelect($this->select, $from, $where, '', '', $order, $limit); //Ejecuto la consulta $query->execute($where_values); //Controlo que este todo bien if($this->isOk($query)){ $res= $query; } //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
[ "public", "function", "getFromWhere", "(", "$", "from", ",", "$", "where", "=", "NULL", ",", "$", "where_values", "=", "array", "(", ")", ",", "$", "order", "=", "NULL", ",", "$", "limit", "=", "NULL", ",", "$", "offset", "=", "NULL", ")", "{", "$", "res", "=", "FALSE", ";", "try", "{", "//Armo partes de la consulta", "if", "(", "$", "order", "!=", "NULL", ")", "{", "$", "order", "=", "\" ORDER BY \"", ".", "$", "order", ";", "}", "if", "(", "$", "limit", "!=", "NULL", ")", "{", "$", "limit", "=", "\" LIMIT \"", ".", "$", "limit", ";", "if", "(", "$", "offset", "!=", "NULL", ")", "{", "$", "limit", ".=", "' OFFSET '", ".", "$", "offset", ";", "}", "}", "//Armo y preparo la consulta", "$", "query", "=", "$", "this", "->", "prepareSelect", "(", "$", "this", "->", "select", ",", "$", "from", ",", "$", "where", ",", "''", ",", "''", ",", "$", "order", ",", "$", "limit", ")", ";", "//Ejecuto la consulta", "$", "query", "->", "execute", "(", "$", "where_values", ")", ";", "//Controlo que este todo bien", "if", "(", "$", "this", "->", "isOk", "(", "$", "query", ")", ")", "{", "$", "res", "=", "$", "query", ";", "}", "//Limpio las variables del AR", "$", "this", "->", "cleanVars", "(", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "this", "->", "cleanVars", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "res", ";", "}" ]
Devuelve el resultado de la consulta armada en base a los parametros @param string $from @param string $where @param array $where_values @param string $order @param type $limit @param type $offset @return \PDOStatement o FALSE @throws \PDOStatement
[ "Devuelve", "el", "resultado", "de", "la", "consulta", "armada", "en", "base", "a", "los", "parametros" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L389-L413
1,301
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.insert
public function insert($table, array $values){ try{ //Armo y preparo la consulta $query= $this->prepareInsert($table, $values); //Ejecuto la consulta $query->execute($values); //Retorno si salio todo bien o no return $this->isOk($query); } catch (\PDOException $e) { throw $e; } }
php
public function insert($table, array $values){ try{ //Armo y preparo la consulta $query= $this->prepareInsert($table, $values); //Ejecuto la consulta $query->execute($values); //Retorno si salio todo bien o no return $this->isOk($query); } catch (\PDOException $e) { throw $e; } }
[ "public", "function", "insert", "(", "$", "table", ",", "array", "$", "values", ")", "{", "try", "{", "//Armo y preparo la consulta", "$", "query", "=", "$", "this", "->", "prepareInsert", "(", "$", "table", ",", "$", "values", ")", ";", "//Ejecuto la consulta", "$", "query", "->", "execute", "(", "$", "values", ")", ";", "//Retorno si salio todo bien o no", "return", "$", "this", "->", "isOk", "(", "$", "query", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Inserta en una tabla los valores indicados @param string $table @param array $values @return boolean @throws \PDOException
[ "Inserta", "en", "una", "tabla", "los", "valores", "indicados" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L421-L432
1,302
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.insertMany
public function insertMany($table, array $manyValues){ try{ reset($manyValues); if(current($manyValues) != FALSE){ //Armo y preparo la consulta $query= $this->prepareInsert($table, $manyValues[0]); } $ok= true; while(current($manyValues) != FALSE && $ok){ //Ejecuto la consulta $query->execute(current($manyValues)); //Retorno si salio todo bien o no $ok= $this->isOk($query); //Paso al proximo next($manyValues); } return $ok; } catch (\PDOException $e) { throw $e; } }
php
public function insertMany($table, array $manyValues){ try{ reset($manyValues); if(current($manyValues) != FALSE){ //Armo y preparo la consulta $query= $this->prepareInsert($table, $manyValues[0]); } $ok= true; while(current($manyValues) != FALSE && $ok){ //Ejecuto la consulta $query->execute(current($manyValues)); //Retorno si salio todo bien o no $ok= $this->isOk($query); //Paso al proximo next($manyValues); } return $ok; } catch (\PDOException $e) { throw $e; } }
[ "public", "function", "insertMany", "(", "$", "table", ",", "array", "$", "manyValues", ")", "{", "try", "{", "reset", "(", "$", "manyValues", ")", ";", "if", "(", "current", "(", "$", "manyValues", ")", "!=", "FALSE", ")", "{", "//Armo y preparo la consulta", "$", "query", "=", "$", "this", "->", "prepareInsert", "(", "$", "table", ",", "$", "manyValues", "[", "0", "]", ")", ";", "}", "$", "ok", "=", "true", ";", "while", "(", "current", "(", "$", "manyValues", ")", "!=", "FALSE", "&&", "$", "ok", ")", "{", "//Ejecuto la consulta", "$", "query", "->", "execute", "(", "current", "(", "$", "manyValues", ")", ")", ";", "//Retorno si salio todo bien o no", "$", "ok", "=", "$", "this", "->", "isOk", "(", "$", "query", ")", ";", "//Paso al proximo", "next", "(", "$", "manyValues", ")", ";", "}", "return", "$", "ok", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "}" ]
Inserta en una tabla un conjunto de valores indicados. Cada elemento del vector guardado debe tener la misma estructura @param string $table @param array[array] $manyValues @return boolean @throws \PDOException
[ "Inserta", "en", "una", "tabla", "un", "conjunto", "de", "valores", "indicados", ".", "Cada", "elemento", "del", "vector", "guardado", "debe", "tener", "la", "misma", "estructura" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L440-L460
1,303
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.update
public function update($table, array $values){ $res= FALSE; try{ $query= $this->prepareUpdate($table, $values, $this->where); //Uno los values pasados y los del where $values= array_merge($values, $this->where_values); //Ejecuto la consulta $query->execute($values); //Veo si salio todo bien $res= $this->isOk($query); //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
php
public function update($table, array $values){ $res= FALSE; try{ $query= $this->prepareUpdate($table, $values, $this->where); //Uno los values pasados y los del where $values= array_merge($values, $this->where_values); //Ejecuto la consulta $query->execute($values); //Veo si salio todo bien $res= $this->isOk($query); //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
[ "public", "function", "update", "(", "$", "table", ",", "array", "$", "values", ")", "{", "$", "res", "=", "FALSE", ";", "try", "{", "$", "query", "=", "$", "this", "->", "prepareUpdate", "(", "$", "table", ",", "$", "values", ",", "$", "this", "->", "where", ")", ";", "//Uno los values pasados y los del where", "$", "values", "=", "array_merge", "(", "$", "values", ",", "$", "this", "->", "where_values", ")", ";", "//Ejecuto la consulta", "$", "query", "->", "execute", "(", "$", "values", ")", ";", "//Veo si salio todo bien", "$", "res", "=", "$", "this", "->", "isOk", "(", "$", "query", ")", ";", "//Limpio las variables del AR", "$", "this", "->", "cleanVars", "(", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "this", "->", "cleanVars", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "res", ";", "}" ]
Actualiza una tabla en base a los datos indicados y la consulta armada al estilo Active Record @param string $table @param array $values @return boolean @throws \PDOException
[ "Actualiza", "una", "tabla", "en", "base", "a", "los", "datos", "indicados", "y", "la", "consulta", "armada", "al", "estilo", "Active", "Record" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L468-L485
1,304
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.delete
public function delete($table){ $res= FALSE; try{ //Armo y preparo la consulta $query= $this->prepareDelete($table, $this->where); //Ejecuto la consulta $query->execute($this->where_values); //Veo si salio todo bien $res= $this->isOk($query); //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
php
public function delete($table){ $res= FALSE; try{ //Armo y preparo la consulta $query= $this->prepareDelete($table, $this->where); //Ejecuto la consulta $query->execute($this->where_values); //Veo si salio todo bien $res= $this->isOk($query); //Limpio las variables del AR $this->cleanVars(); } catch (\PDOException $e) { $this->cleanVars(); throw $e; } return $res; }
[ "public", "function", "delete", "(", "$", "table", ")", "{", "$", "res", "=", "FALSE", ";", "try", "{", "//Armo y preparo la consulta", "$", "query", "=", "$", "this", "->", "prepareDelete", "(", "$", "table", ",", "$", "this", "->", "where", ")", ";", "//Ejecuto la consulta", "$", "query", "->", "execute", "(", "$", "this", "->", "where_values", ")", ";", "//Veo si salio todo bien", "$", "res", "=", "$", "this", "->", "isOk", "(", "$", "query", ")", ";", "//Limpio las variables del AR", "$", "this", "->", "cleanVars", "(", ")", ";", "}", "catch", "(", "\\", "PDOException", "$", "e", ")", "{", "$", "this", "->", "cleanVars", "(", ")", ";", "throw", "$", "e", ";", "}", "return", "$", "res", ";", "}" ]
Elimina tuplas de una tabla en base a la consulta armada de la forma Active Record @param string $table @return boolean @throws \PDOException
[ "Elimina", "tuplas", "de", "una", "tabla", "en", "base", "a", "la", "consulta", "armada", "de", "la", "forma", "Active", "Record" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L492-L508
1,305
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.isOk
protected function isOk(\PDOStatement $query){ $error= $query->errorInfo(); if($error[0] == '00000'){ return TRUE; }else{ $this->catchError($error); return FALSE; } }
php
protected function isOk(\PDOStatement $query){ $error= $query->errorInfo(); if($error[0] == '00000'){ return TRUE; }else{ $this->catchError($error); return FALSE; } }
[ "protected", "function", "isOk", "(", "\\", "PDOStatement", "$", "query", ")", "{", "$", "error", "=", "$", "query", "->", "errorInfo", "(", ")", ";", "if", "(", "$", "error", "[", "0", "]", "==", "'00000'", ")", "{", "return", "TRUE", ";", "}", "else", "{", "$", "this", "->", "catchError", "(", "$", "error", ")", ";", "return", "FALSE", ";", "}", "}" ]
Retorna si la consulta se realizao con exito, si no ocurrio ningun error. @param \PDOStatement $query @return boolean
[ "Retorna", "si", "la", "consulta", "se", "realizao", "con", "exito", "si", "no", "ocurrio", "ningun", "error", "." ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L517-L525
1,306
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.cleanVars
protected function cleanVars(){ $this->select= "*"; $this->from= ''; $this->where= ''; $this->where_values= array(); $this->group= ''; $this->having= ''; $this->order= ''; $this->limit= ''; }
php
protected function cleanVars(){ $this->select= "*"; $this->from= ''; $this->where= ''; $this->where_values= array(); $this->group= ''; $this->having= ''; $this->order= ''; $this->limit= ''; }
[ "protected", "function", "cleanVars", "(", ")", "{", "$", "this", "->", "select", "=", "\"*\"", ";", "$", "this", "->", "from", "=", "''", ";", "$", "this", "->", "where", "=", "''", ";", "$", "this", "->", "where_values", "=", "array", "(", ")", ";", "$", "this", "->", "group", "=", "''", ";", "$", "this", "->", "having", "=", "''", ";", "$", "this", "->", "order", "=", "''", ";", "$", "this", "->", "limit", "=", "''", ";", "}" ]
Limpia las variables de instancia del ActiveRecord
[ "Limpia", "las", "variables", "de", "instancia", "del", "ActiveRecord" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L527-L536
1,307
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.prepareSelect
protected function prepareSelect($select, $from, $where='', $group='', $having='', $order='', $limit=''){ $sql= "SELECT " . $select; $sql.= " FROM " . $from; if($where != '' && $where != NULL){$sql.= " WHERE " . $where;} $sql.= $group; if($having != '' && $having != NULL){$sql.= " HAVING " . $having;} $sql.= $order; $sql.= $limit; //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
php
protected function prepareSelect($select, $from, $where='', $group='', $having='', $order='', $limit=''){ $sql= "SELECT " . $select; $sql.= " FROM " . $from; if($where != '' && $where != NULL){$sql.= " WHERE " . $where;} $sql.= $group; if($having != '' && $having != NULL){$sql.= " HAVING " . $having;} $sql.= $order; $sql.= $limit; //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
[ "protected", "function", "prepareSelect", "(", "$", "select", ",", "$", "from", ",", "$", "where", "=", "''", ",", "$", "group", "=", "''", ",", "$", "having", "=", "''", ",", "$", "order", "=", "''", ",", "$", "limit", "=", "''", ")", "{", "$", "sql", "=", "\"SELECT \"", ".", "$", "select", ";", "$", "sql", ".=", "\" FROM \"", ".", "$", "from", ";", "if", "(", "$", "where", "!=", "''", "&&", "$", "where", "!=", "NULL", ")", "{", "$", "sql", ".=", "\" WHERE \"", ".", "$", "where", ";", "}", "$", "sql", ".=", "$", "group", ";", "if", "(", "$", "having", "!=", "''", "&&", "$", "having", "!=", "NULL", ")", "{", "$", "sql", ".=", "\" HAVING \"", ".", "$", "having", ";", "}", "$", "sql", ".=", "$", "order", ";", "$", "sql", ".=", "$", "limit", ";", "//Preparo la consulta y la retorno", "return", "$", "this", "->", "connection", "->", "prepare", "(", "$", "sql", ")", ";", "}" ]
Retorna un PDOStatement SELECT armado en base a los parametros pasados @param string $select @param string $from @param string $where @param string $group @param string $having @param string $order @param string $limit return PDOStatement
[ "Retorna", "un", "PDOStatement", "SELECT", "armado", "en", "base", "a", "los", "parametros", "pasados" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L560-L570
1,308
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.prepareInsert
protected function prepareInsert($table, $values){ $sql= 'INSERT INTO ' . $table . ' ('; $value= 'values('; foreach ($values as $key => $val) { $sql.= $key . ','; $value.= ':' . $key . ','; } $sql = trim($sql, ','); $value = trim($value, ','); $sql .= ') ' . $value . ')'; //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
php
protected function prepareInsert($table, $values){ $sql= 'INSERT INTO ' . $table . ' ('; $value= 'values('; foreach ($values as $key => $val) { $sql.= $key . ','; $value.= ':' . $key . ','; } $sql = trim($sql, ','); $value = trim($value, ','); $sql .= ') ' . $value . ')'; //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
[ "protected", "function", "prepareInsert", "(", "$", "table", ",", "$", "values", ")", "{", "$", "sql", "=", "'INSERT INTO '", ".", "$", "table", ".", "' ('", ";", "$", "value", "=", "'values('", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "val", ")", "{", "$", "sql", ".=", "$", "key", ".", "','", ";", "$", "value", ".=", "':'", ".", "$", "key", ".", "','", ";", "}", "$", "sql", "=", "trim", "(", "$", "sql", ",", "','", ")", ";", "$", "value", "=", "trim", "(", "$", "value", ",", "','", ")", ";", "$", "sql", ".=", "') '", ".", "$", "value", ".", "')'", ";", "//Preparo la consulta y la retorno", "return", "$", "this", "->", "connection", "->", "prepare", "(", "$", "sql", ")", ";", "}" ]
Retorna un PDOStatement INSERT armado en base a los parametros pasados @param string $table @param array $values @return PDOStatement
[ "Retorna", "un", "PDOStatement", "INSERT", "armado", "en", "base", "a", "los", "parametros", "pasados" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L577-L589
1,309
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.prepareUpdate
protected function prepareUpdate($table, $values, $where){ $sql= 'UPDATE ' . $table . ' SET '; foreach ($values as $key => $value) { $sql .= $key . '=:' . $key . ','; } $sql = trim($sql, ','); if($where != ''){$sql.= " WHERE " . $where;} //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
php
protected function prepareUpdate($table, $values, $where){ $sql= 'UPDATE ' . $table . ' SET '; foreach ($values as $key => $value) { $sql .= $key . '=:' . $key . ','; } $sql = trim($sql, ','); if($where != ''){$sql.= " WHERE " . $where;} //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
[ "protected", "function", "prepareUpdate", "(", "$", "table", ",", "$", "values", ",", "$", "where", ")", "{", "$", "sql", "=", "'UPDATE '", ".", "$", "table", ".", "' SET '", ";", "foreach", "(", "$", "values", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "sql", ".=", "$", "key", ".", "'=:'", ".", "$", "key", ".", "','", ";", "}", "$", "sql", "=", "trim", "(", "$", "sql", ",", "','", ")", ";", "if", "(", "$", "where", "!=", "''", ")", "{", "$", "sql", ".=", "\" WHERE \"", ".", "$", "where", ";", "}", "//Preparo la consulta y la retorno", "return", "$", "this", "->", "connection", "->", "prepare", "(", "$", "sql", ")", ";", "}" ]
Retorna un PDOStatement UPDATE armado en base a los parametros pasados @param string $table @param array $values @param string $where @return PDOStatement
[ "Retorna", "un", "PDOStatement", "UPDATE", "armado", "en", "base", "a", "los", "parametros", "pasados" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L597-L606
1,310
edunola13/core-modules
src/DataBaseAR.php
DataBaseAR.prepareDelete
protected function prepareDelete($table, $where){ $sql= 'DELETE FROM ' . $table . ' '; if($where != ''){$sql.= " WHERE " . $where;} //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
php
protected function prepareDelete($table, $where){ $sql= 'DELETE FROM ' . $table . ' '; if($where != ''){$sql.= " WHERE " . $where;} //Preparo la consulta y la retorno return $this->connection->prepare($sql); }
[ "protected", "function", "prepareDelete", "(", "$", "table", ",", "$", "where", ")", "{", "$", "sql", "=", "'DELETE FROM '", ".", "$", "table", ".", "' '", ";", "if", "(", "$", "where", "!=", "''", ")", "{", "$", "sql", ".=", "\" WHERE \"", ".", "$", "where", ";", "}", "//Preparo la consulta y la retorno", "return", "$", "this", "->", "connection", "->", "prepare", "(", "$", "sql", ")", ";", "}" ]
Retorna un PDOStatement DELETE armado en base a los parametros pasados @param string $table @param string $where @return PDOStatement
[ "Retorna", "un", "PDOStatement", "DELETE", "armado", "en", "base", "a", "los", "parametros", "pasados" ]
2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364
https://github.com/edunola13/core-modules/blob/2a2e9b89bb61cc28e548412e1d6c9bbb44bc5364/src/DataBaseAR.php#L613-L618
1,311
nattreid/security
src/Control/tryUser/TryUser.php
TryUser.set
public function set(int $id): bool { if (!$this->isAllowed()) { return false; } $hash = $this->hasher->hash($id); $uniqid = uniqid(); $this->session->setExpiration('5 minutes'); $this->session->$uniqid = $hash; $this->id = $uniqid; $this->presenter->redirect($this->redirect); return true; }
php
public function set(int $id): bool { if (!$this->isAllowed()) { return false; } $hash = $this->hasher->hash($id); $uniqid = uniqid(); $this->session->setExpiration('5 minutes'); $this->session->$uniqid = $hash; $this->id = $uniqid; $this->presenter->redirect($this->redirect); return true; }
[ "public", "function", "set", "(", "int", "$", "id", ")", ":", "bool", "{", "if", "(", "!", "$", "this", "->", "isAllowed", "(", ")", ")", "{", "return", "false", ";", "}", "$", "hash", "=", "$", "this", "->", "hasher", "->", "hash", "(", "$", "id", ")", ";", "$", "uniqid", "=", "uniqid", "(", ")", ";", "$", "this", "->", "session", "->", "setExpiration", "(", "'5 minutes'", ")", ";", "$", "this", "->", "session", "->", "$", "uniqid", "=", "$", "hash", ";", "$", "this", "->", "id", "=", "$", "uniqid", ";", "$", "this", "->", "presenter", "->", "redirect", "(", "$", "this", "->", "redirect", ")", ";", "return", "true", ";", "}" ]
Nastavi testovaci ucet a presmeruje @param int $id @return bool pokud uzivatel nema prava k teto metode, vrati false @throws AbortException
[ "Nastavi", "testovaci", "ucet", "a", "presmeruje" ]
ed649e5bdf453cea2d5352e643dbf201193de01d
https://github.com/nattreid/security/blob/ed649e5bdf453cea2d5352e643dbf201193de01d/src/Control/tryUser/TryUser.php#L104-L116
1,312
emaphp/eMapper
lib/eMapper/Result/Mapper/ComplexMapper.php
ComplexMapper.validateIndex
protected function validateIndex($index, $indexType) { if (is_null($this->resultMap)) { //find index column on given result if (!array_key_exists($index, $this->columnTypes)) { if (is_numeric($index) && array_key_exists(intval($index), $this->columnTypes)) $index = intval($index); else throw new \UnexpectedValueException("Index column '$index' not found"); } //get index type $indexColumn = $index; $indexType = is_null($indexType) ? $this->columnTypes[$index] : $indexType; //obtain index type handler $indexTypeHandler = $this->typeManager->getTypeHandler($indexType); if ($indexTypeHandler === false) throw new \UnexpectedValueException("Unknown type '$indexType' defined for index '$index'"); } else { //find index property if (!array_key_exists($index, $this->properties)) throw new \UnexpectedValueException("Index property '$index' was not found in result map"); //obtain index column and type handler $indexColumn = $this->properties[$index]->getColumn(); $indexTypeHandler = $this->typeHandlers[$index]; } return [$indexColumn, $indexTypeHandler]; }
php
protected function validateIndex($index, $indexType) { if (is_null($this->resultMap)) { //find index column on given result if (!array_key_exists($index, $this->columnTypes)) { if (is_numeric($index) && array_key_exists(intval($index), $this->columnTypes)) $index = intval($index); else throw new \UnexpectedValueException("Index column '$index' not found"); } //get index type $indexColumn = $index; $indexType = is_null($indexType) ? $this->columnTypes[$index] : $indexType; //obtain index type handler $indexTypeHandler = $this->typeManager->getTypeHandler($indexType); if ($indexTypeHandler === false) throw new \UnexpectedValueException("Unknown type '$indexType' defined for index '$index'"); } else { //find index property if (!array_key_exists($index, $this->properties)) throw new \UnexpectedValueException("Index property '$index' was not found in result map"); //obtain index column and type handler $indexColumn = $this->properties[$index]->getColumn(); $indexTypeHandler = $this->typeHandlers[$index]; } return [$indexColumn, $indexTypeHandler]; }
[ "protected", "function", "validateIndex", "(", "$", "index", ",", "$", "indexType", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "resultMap", ")", ")", "{", "//find index column on given result", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "columnTypes", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "index", ")", "&&", "array_key_exists", "(", "intval", "(", "$", "index", ")", ",", "$", "this", "->", "columnTypes", ")", ")", "$", "index", "=", "intval", "(", "$", "index", ")", ";", "else", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Index column '$index' not found\"", ")", ";", "}", "//get index type", "$", "indexColumn", "=", "$", "index", ";", "$", "indexType", "=", "is_null", "(", "$", "indexType", ")", "?", "$", "this", "->", "columnTypes", "[", "$", "index", "]", ":", "$", "indexType", ";", "//obtain index type handler", "$", "indexTypeHandler", "=", "$", "this", "->", "typeManager", "->", "getTypeHandler", "(", "$", "indexType", ")", ";", "if", "(", "$", "indexTypeHandler", "===", "false", ")", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Unknown type '$indexType' defined for index '$index'\"", ")", ";", "}", "else", "{", "//find index property", "if", "(", "!", "array_key_exists", "(", "$", "index", ",", "$", "this", "->", "properties", ")", ")", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Index property '$index' was not found in result map\"", ")", ";", "//obtain index column and type handler", "$", "indexColumn", "=", "$", "this", "->", "properties", "[", "$", "index", "]", "->", "getColumn", "(", ")", ";", "$", "indexTypeHandler", "=", "$", "this", "->", "typeHandlers", "[", "$", "index", "]", ";", "}", "return", "[", "$", "indexColumn", ",", "$", "indexTypeHandler", "]", ";", "}" ]
Validates a user defined index againts current result @param string $index @param string $indexType @throws \UnexpectedValueException @return array
[ "Validates", "a", "user", "defined", "index", "againts", "current", "result" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Result/Mapper/ComplexMapper.php#L79-L110
1,313
emaphp/eMapper
lib/eMapper/Result/Mapper/ComplexMapper.php
ComplexMapper.validateGroup
protected function validateGroup($group, $groupType) { if (is_null($this->resultMap)) { //find group column if (!array_key_exists($group, $this->columnTypes)) { if (is_numeric($group) && array_key_exists(intval($group), $this->columnTypes)) $group = intval($group); else throw new \UnexpectedValueException("Group column '$group' not found"); } //get group type $groupType = is_null($groupType) ? $this->columnTypes[$group] : $groupType; $groupColumn = $group; //obtain group type handler $groupTypeHandler = $this->typeManager->getTypeHandler($groupType); if ($groupTypeHandler === false) throw new \UnexpectedValueException("Unknown type '$groupType' defined for group '$group'"); } else { //find group property if (!array_key_exists($group, $this->properties)) throw new \UnexpectedValueException("Group property '$group' was not found in result map"); //obtain group column and type handler $groupColumn = $this->properties[$group]->getColumn(); $groupTypeHandler = $this->typeHandlers[$group]; } return [$groupColumn, $groupTypeHandler]; }
php
protected function validateGroup($group, $groupType) { if (is_null($this->resultMap)) { //find group column if (!array_key_exists($group, $this->columnTypes)) { if (is_numeric($group) && array_key_exists(intval($group), $this->columnTypes)) $group = intval($group); else throw new \UnexpectedValueException("Group column '$group' not found"); } //get group type $groupType = is_null($groupType) ? $this->columnTypes[$group] : $groupType; $groupColumn = $group; //obtain group type handler $groupTypeHandler = $this->typeManager->getTypeHandler($groupType); if ($groupTypeHandler === false) throw new \UnexpectedValueException("Unknown type '$groupType' defined for group '$group'"); } else { //find group property if (!array_key_exists($group, $this->properties)) throw new \UnexpectedValueException("Group property '$group' was not found in result map"); //obtain group column and type handler $groupColumn = $this->properties[$group]->getColumn(); $groupTypeHandler = $this->typeHandlers[$group]; } return [$groupColumn, $groupTypeHandler]; }
[ "protected", "function", "validateGroup", "(", "$", "group", ",", "$", "groupType", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "resultMap", ")", ")", "{", "//find group column", "if", "(", "!", "array_key_exists", "(", "$", "group", ",", "$", "this", "->", "columnTypes", ")", ")", "{", "if", "(", "is_numeric", "(", "$", "group", ")", "&&", "array_key_exists", "(", "intval", "(", "$", "group", ")", ",", "$", "this", "->", "columnTypes", ")", ")", "$", "group", "=", "intval", "(", "$", "group", ")", ";", "else", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Group column '$group' not found\"", ")", ";", "}", "//get group type", "$", "groupType", "=", "is_null", "(", "$", "groupType", ")", "?", "$", "this", "->", "columnTypes", "[", "$", "group", "]", ":", "$", "groupType", ";", "$", "groupColumn", "=", "$", "group", ";", "//obtain group type handler", "$", "groupTypeHandler", "=", "$", "this", "->", "typeManager", "->", "getTypeHandler", "(", "$", "groupType", ")", ";", "if", "(", "$", "groupTypeHandler", "===", "false", ")", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Unknown type '$groupType' defined for group '$group'\"", ")", ";", "}", "else", "{", "//find group property", "if", "(", "!", "array_key_exists", "(", "$", "group", ",", "$", "this", "->", "properties", ")", ")", "throw", "new", "\\", "UnexpectedValueException", "(", "\"Group property '$group' was not found in result map\"", ")", ";", "//obtain group column and type handler", "$", "groupColumn", "=", "$", "this", "->", "properties", "[", "$", "group", "]", "->", "getColumn", "(", ")", ";", "$", "groupTypeHandler", "=", "$", "this", "->", "typeHandlers", "[", "$", "group", "]", ";", "}", "return", "[", "$", "groupColumn", ",", "$", "groupTypeHandler", "]", ";", "}" ]
Validates a user defined group against current result @param string $group @param string $groupType @throws \UnexpectedValueException @return array
[ "Validates", "a", "user", "defined", "group", "against", "current", "result" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Result/Mapper/ComplexMapper.php#L119-L150
1,314
emaphp/eMapper
lib/eMapper/Result/Mapper/ComplexMapper.php
ComplexMapper.buildTypeHandlerList
protected function buildTypeHandlerList() { foreach ($this->properties as $name => $propertyProfile) { $column = $propertyProfile->getColumn(); if (!array_key_exists($column, $this->columnTypes)) continue; $this->availableColumns[$name] = $column; $type = $propertyProfile->getType(); if (isset($type)) { $typeHandler = $this->typeManager->getTypeHandler($type); if ($typeHandler == false) throw new \UnexpectedValueException("No typehandler assigned to type '$type' defined at property $name"); $this->typeHandlers[$name] = $typeHandler; } else { $type = $this->columnTypes[$column]; $this->typeHandlers[$name] = $this->typeManager->getTypeHandler($type); } } }
php
protected function buildTypeHandlerList() { foreach ($this->properties as $name => $propertyProfile) { $column = $propertyProfile->getColumn(); if (!array_key_exists($column, $this->columnTypes)) continue; $this->availableColumns[$name] = $column; $type = $propertyProfile->getType(); if (isset($type)) { $typeHandler = $this->typeManager->getTypeHandler($type); if ($typeHandler == false) throw new \UnexpectedValueException("No typehandler assigned to type '$type' defined at property $name"); $this->typeHandlers[$name] = $typeHandler; } else { $type = $this->columnTypes[$column]; $this->typeHandlers[$name] = $this->typeManager->getTypeHandler($type); } } }
[ "protected", "function", "buildTypeHandlerList", "(", ")", "{", "foreach", "(", "$", "this", "->", "properties", "as", "$", "name", "=>", "$", "propertyProfile", ")", "{", "$", "column", "=", "$", "propertyProfile", "->", "getColumn", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "column", ",", "$", "this", "->", "columnTypes", ")", ")", "continue", ";", "$", "this", "->", "availableColumns", "[", "$", "name", "]", "=", "$", "column", ";", "$", "type", "=", "$", "propertyProfile", "->", "getType", "(", ")", ";", "if", "(", "isset", "(", "$", "type", ")", ")", "{", "$", "typeHandler", "=", "$", "this", "->", "typeManager", "->", "getTypeHandler", "(", "$", "type", ")", ";", "if", "(", "$", "typeHandler", "==", "false", ")", "throw", "new", "\\", "UnexpectedValueException", "(", "\"No typehandler assigned to type '$type' defined at property $name\"", ")", ";", "$", "this", "->", "typeHandlers", "[", "$", "name", "]", "=", "$", "typeHandler", ";", "}", "else", "{", "$", "type", "=", "$", "this", "->", "columnTypes", "[", "$", "column", "]", ";", "$", "this", "->", "typeHandlers", "[", "$", "name", "]", "=", "$", "this", "->", "typeManager", "->", "getTypeHandler", "(", "$", "type", ")", ";", "}", "}", "}" ]
Builds a list of type handlers for the available columns @throws \UnexpectedValueException
[ "Builds", "a", "list", "of", "type", "handlers", "for", "the", "available", "columns" ]
df7100e601d2a1363d07028a786b6ceb22271829
https://github.com/emaphp/eMapper/blob/df7100e601d2a1363d07028a786b6ceb22271829/lib/eMapper/Result/Mapper/ComplexMapper.php#L180-L203
1,315
easy-system/es-error
src/Strategy/AbstractErrorStrategy.php
AbstractErrorStrategy.processResponse
public function processResponse(ResponseInterface $response, SystemEvent $event) { if ($event->getName() === SystemEvent::FINISH) { $event->stopPropagation(true); $server = $this->getServer(); $emitter = $server->getEmitter(); $emitter->emit($response); return; } $events = $this->getEvents(); $event->setResult(SystemEvent::FINISH, $response); $events->trigger($event(SystemEvent::FINISH)); }
php
public function processResponse(ResponseInterface $response, SystemEvent $event) { if ($event->getName() === SystemEvent::FINISH) { $event->stopPropagation(true); $server = $this->getServer(); $emitter = $server->getEmitter(); $emitter->emit($response); return; } $events = $this->getEvents(); $event->setResult(SystemEvent::FINISH, $response); $events->trigger($event(SystemEvent::FINISH)); }
[ "public", "function", "processResponse", "(", "ResponseInterface", "$", "response", ",", "SystemEvent", "$", "event", ")", "{", "if", "(", "$", "event", "->", "getName", "(", ")", "===", "SystemEvent", "::", "FINISH", ")", "{", "$", "event", "->", "stopPropagation", "(", "true", ")", ";", "$", "server", "=", "$", "this", "->", "getServer", "(", ")", ";", "$", "emitter", "=", "$", "server", "->", "getEmitter", "(", ")", ";", "$", "emitter", "->", "emit", "(", "$", "response", ")", ";", "return", ";", "}", "$", "events", "=", "$", "this", "->", "getEvents", "(", ")", ";", "$", "event", "->", "setResult", "(", "SystemEvent", "::", "FINISH", ",", "$", "response", ")", ";", "$", "events", "->", "trigger", "(", "$", "event", "(", "SystemEvent", "::", "FINISH", ")", ")", ";", "}" ]
Processes the response. @param \Psr\Http\Message\ResponseInterface $response The response @param \Es\System\SystemEvent $event The system event
[ "Processes", "the", "response", "." ]
5248c52f2992acc9ddf3542092ad7bbbb440e621
https://github.com/easy-system/es-error/blob/5248c52f2992acc9ddf3542092ad7bbbb440e621/src/Strategy/AbstractErrorStrategy.php#L61-L74
1,316
vphantom/pyritephp
src/Pyrite/AuditTrail.php
AuditTrail.add
public static function add($objectType, $objectId = null, $action = null, $fieldName = null, $oldValue = null, $newValue = null, $userId = 0, $content = '') { global $PPHP; $db = $PPHP['db']; $ip = '127.0.0.1'; $req = grab('request'); if (isset($req['remote_addr'])) { $ip = $req['remote_addr']; }; // First argument could contain named arguments if (is_array($objectType)) { if (isset($objectType['objectId'])) $objectId = $objectType['objectId']; if (isset($objectType['action'])) $action = $objectType['action']; if (isset($objectType['fieldName'])) $fieldName = $objectType['fieldName']; if (isset($objectType['oldValue'])) $oldValue = $objectType['oldValue']; if (isset($objectType['newValue'])) $newValue = $objectType['newValue']; if (isset($objectType['userId'])) $userId = $objectType['userId']; if (isset($objectType['content'])) $content = $objectType['content']; if (isset($objectType['objectType'])) { $objectType = $objectType['objectType']; } else { $objectType = null; }; }; if ($objectType === null && $objectId === null && $PPHP['contextType'] !== null && $PPHP['contextId'] !== null) { $objectType = $PPHP['contextType']; $objectId = $PPHP['contextId']; }; if (isset($_SESSION['user']['id'])) { $actingUserId = $_SESSION['user']['id']; if ($userId === 0) { $userId = $actingUserId; }; }; // Enforce size limit on field values $oldValue = substr($oldValue, 0, 250); $newValue = substr($newValue, 0, 250); $db->exec( " INSERT INTO transactions (actingUserId, userId, ip, objectType, objectId, action, fieldName, oldValue, newValue, content) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ", array( $actingUserId, $userId, $ip, $objectType, $objectId, $action, $fieldName, $oldValue, $newValue, $content ) ); }
php
public static function add($objectType, $objectId = null, $action = null, $fieldName = null, $oldValue = null, $newValue = null, $userId = 0, $content = '') { global $PPHP; $db = $PPHP['db']; $ip = '127.0.0.1'; $req = grab('request'); if (isset($req['remote_addr'])) { $ip = $req['remote_addr']; }; // First argument could contain named arguments if (is_array($objectType)) { if (isset($objectType['objectId'])) $objectId = $objectType['objectId']; if (isset($objectType['action'])) $action = $objectType['action']; if (isset($objectType['fieldName'])) $fieldName = $objectType['fieldName']; if (isset($objectType['oldValue'])) $oldValue = $objectType['oldValue']; if (isset($objectType['newValue'])) $newValue = $objectType['newValue']; if (isset($objectType['userId'])) $userId = $objectType['userId']; if (isset($objectType['content'])) $content = $objectType['content']; if (isset($objectType['objectType'])) { $objectType = $objectType['objectType']; } else { $objectType = null; }; }; if ($objectType === null && $objectId === null && $PPHP['contextType'] !== null && $PPHP['contextId'] !== null) { $objectType = $PPHP['contextType']; $objectId = $PPHP['contextId']; }; if (isset($_SESSION['user']['id'])) { $actingUserId = $_SESSION['user']['id']; if ($userId === 0) { $userId = $actingUserId; }; }; // Enforce size limit on field values $oldValue = substr($oldValue, 0, 250); $newValue = substr($newValue, 0, 250); $db->exec( " INSERT INTO transactions (actingUserId, userId, ip, objectType, objectId, action, fieldName, oldValue, newValue, content) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) ", array( $actingUserId, $userId, $ip, $objectType, $objectId, $action, $fieldName, $oldValue, $newValue, $content ) ); }
[ "public", "static", "function", "add", "(", "$", "objectType", ",", "$", "objectId", "=", "null", ",", "$", "action", "=", "null", ",", "$", "fieldName", "=", "null", ",", "$", "oldValue", "=", "null", ",", "$", "newValue", "=", "null", ",", "$", "userId", "=", "0", ",", "$", "content", "=", "''", ")", "{", "global", "$", "PPHP", ";", "$", "db", "=", "$", "PPHP", "[", "'db'", "]", ";", "$", "ip", "=", "'127.0.0.1'", ";", "$", "req", "=", "grab", "(", "'request'", ")", ";", "if", "(", "isset", "(", "$", "req", "[", "'remote_addr'", "]", ")", ")", "{", "$", "ip", "=", "$", "req", "[", "'remote_addr'", "]", ";", "}", ";", "// First argument could contain named arguments", "if", "(", "is_array", "(", "$", "objectType", ")", ")", "{", "if", "(", "isset", "(", "$", "objectType", "[", "'objectId'", "]", ")", ")", "$", "objectId", "=", "$", "objectType", "[", "'objectId'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'action'", "]", ")", ")", "$", "action", "=", "$", "objectType", "[", "'action'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'fieldName'", "]", ")", ")", "$", "fieldName", "=", "$", "objectType", "[", "'fieldName'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'oldValue'", "]", ")", ")", "$", "oldValue", "=", "$", "objectType", "[", "'oldValue'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'newValue'", "]", ")", ")", "$", "newValue", "=", "$", "objectType", "[", "'newValue'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'userId'", "]", ")", ")", "$", "userId", "=", "$", "objectType", "[", "'userId'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'content'", "]", ")", ")", "$", "content", "=", "$", "objectType", "[", "'content'", "]", ";", "if", "(", "isset", "(", "$", "objectType", "[", "'objectType'", "]", ")", ")", "{", "$", "objectType", "=", "$", "objectType", "[", "'objectType'", "]", ";", "}", "else", "{", "$", "objectType", "=", "null", ";", "}", ";", "}", ";", "if", "(", "$", "objectType", "===", "null", "&&", "$", "objectId", "===", "null", "&&", "$", "PPHP", "[", "'contextType'", "]", "!==", "null", "&&", "$", "PPHP", "[", "'contextId'", "]", "!==", "null", ")", "{", "$", "objectType", "=", "$", "PPHP", "[", "'contextType'", "]", ";", "$", "objectId", "=", "$", "PPHP", "[", "'contextId'", "]", ";", "}", ";", "if", "(", "isset", "(", "$", "_SESSION", "[", "'user'", "]", "[", "'id'", "]", ")", ")", "{", "$", "actingUserId", "=", "$", "_SESSION", "[", "'user'", "]", "[", "'id'", "]", ";", "if", "(", "$", "userId", "===", "0", ")", "{", "$", "userId", "=", "$", "actingUserId", ";", "}", ";", "}", ";", "// Enforce size limit on field values", "$", "oldValue", "=", "substr", "(", "$", "oldValue", ",", "0", ",", "250", ")", ";", "$", "newValue", "=", "substr", "(", "$", "newValue", ",", "0", ",", "250", ")", ";", "$", "db", "->", "exec", "(", "\"\n INSERT INTO transactions\n (actingUserId, userId, ip, objectType, objectId, action, fieldName, oldValue, newValue, content)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)\n \"", ",", "array", "(", "$", "actingUserId", ",", "$", "userId", ",", "$", "ip", ",", "$", "objectType", ",", "$", "objectId", ",", "$", "action", ",", "$", "fieldName", ",", "$", "oldValue", ",", "$", "newValue", ",", "$", "content", ")", ")", ";", "}" ]
Add a new transaction to the audit trail Suggested minimum set of actions: created modified deleted You can either use these positional arguments or specify a single associative array argument with only the keys you need defined. At least an action should be specified (i.e. 'rebooted', perhaps) and typically also objectType and objectId. The rest is accessory. @param array|string $objectType Class of object this applies to (*or args, see above) @param string|int|null $objectId Specific instance acted upon @param string $action Type of action performed @param string|null $fieldName Specific field affected @param string|int|null $oldValue Previous value for affected field @param string|int|null $newValue New value for affected field @param string|int|null $userId Over-ride session userId with this one @param string|null $content Additional text to store in the entry @return null
[ "Add", "a", "new", "transaction", "to", "the", "audit", "trail" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/AuditTrail.php#L105-L166
1,317
vphantom/pyritephp
src/Pyrite/AuditTrail.php
AuditTrail.getLastLogin
public static function getLastLogin($userId) { global $PPHP; $db = $PPHP['db']; $last = $db->selectSingleArray( " SELECT timestamp, ip, datetime(timestamp, 'localtime') AS localtimestamp FROM transactions WHERE objectType='user' AND objectId=? AND action='login' ORDER BY id DESC LIMIT 1 ", array( $userId ) ); return $last !== false ? $last : array('timestamp' => null, 'ip' => null); }
php
public static function getLastLogin($userId) { global $PPHP; $db = $PPHP['db']; $last = $db->selectSingleArray( " SELECT timestamp, ip, datetime(timestamp, 'localtime') AS localtimestamp FROM transactions WHERE objectType='user' AND objectId=? AND action='login' ORDER BY id DESC LIMIT 1 ", array( $userId ) ); return $last !== false ? $last : array('timestamp' => null, 'ip' => null); }
[ "public", "static", "function", "getLastLogin", "(", "$", "userId", ")", "{", "global", "$", "PPHP", ";", "$", "db", "=", "$", "PPHP", "[", "'db'", "]", ";", "$", "last", "=", "$", "db", "->", "selectSingleArray", "(", "\"\n SELECT timestamp, ip, datetime(timestamp, 'localtime') AS localtimestamp\n FROM transactions\n WHERE objectType='user' AND objectId=? AND action='login'\n ORDER BY id DESC\n LIMIT 1\n \"", ",", "array", "(", "$", "userId", ")", ")", ";", "return", "$", "last", "!==", "false", "?", "$", "last", ":", "array", "(", "'timestamp'", "=>", "null", ",", "'ip'", "=>", "null", ")", ";", "}" ]
Get user's last login details The last login is an associative array with the following keys: timestamp - UTC localtimestamp - Local time zone ip - IP address @param int $userId User ID @return array Last login, if any
[ "Get", "user", "s", "last", "login", "details" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/AuditTrail.php#L293-L310
1,318
vphantom/pyritephp
src/Pyrite/AuditTrail.php
AuditTrail.getObjectIds
public static function getObjectIds($objectType, $begin = null, $end = null) { global $PPHP; $db = $PPHP['db']; $q = $db->query("SELECT DISTINCT(objectId) FROM transactions WHERE objectType=?", $objectType); if ($begin !== null && $end !== null) { $q->and("timestamp BETWEEN date(?) AND date(?, '+1 day')", array($begin, $end)); } elseif ($begin !== null) { $q->and("timestamp >= date(?)", $begin); } elseif ($end !== null) { $q->and("timestamp <= date(?, '+1 day')", $end); }; $q->order_by('objectId ASC'); return $db->selectList($q); }
php
public static function getObjectIds($objectType, $begin = null, $end = null) { global $PPHP; $db = $PPHP['db']; $q = $db->query("SELECT DISTINCT(objectId) FROM transactions WHERE objectType=?", $objectType); if ($begin !== null && $end !== null) { $q->and("timestamp BETWEEN date(?) AND date(?, '+1 day')", array($begin, $end)); } elseif ($begin !== null) { $q->and("timestamp >= date(?)", $begin); } elseif ($end !== null) { $q->and("timestamp <= date(?, '+1 day')", $end); }; $q->order_by('objectId ASC'); return $db->selectList($q); }
[ "public", "static", "function", "getObjectIds", "(", "$", "objectType", ",", "$", "begin", "=", "null", ",", "$", "end", "=", "null", ")", "{", "global", "$", "PPHP", ";", "$", "db", "=", "$", "PPHP", "[", "'db'", "]", ";", "$", "q", "=", "$", "db", "->", "query", "(", "\"SELECT DISTINCT(objectId) FROM transactions WHERE objectType=?\"", ",", "$", "objectType", ")", ";", "if", "(", "$", "begin", "!==", "null", "&&", "$", "end", "!==", "null", ")", "{", "$", "q", "->", "and", "(", "\"timestamp BETWEEN date(?) AND date(?, '+1 day')\"", ",", "array", "(", "$", "begin", ",", "$", "end", ")", ")", ";", "}", "elseif", "(", "$", "begin", "!==", "null", ")", "{", "$", "q", "->", "and", "(", "\"timestamp >= date(?)\"", ",", "$", "begin", ")", ";", "}", "elseif", "(", "$", "end", "!==", "null", ")", "{", "$", "q", "->", "and", "(", "\"timestamp <= date(?, '+1 day')\"", ",", "$", "end", ")", ";", "}", ";", "$", "q", "->", "order_by", "(", "'objectId ASC'", ")", ";", "return", "$", "db", "->", "selectList", "(", "$", "q", ")", ";", "}" ]
Get IDs with activity present Get all objectIds of $objectType for which there is activity. If $begin is specified, search period is restricted to transactions on and after that date. If $end is also specified, search period is further restricted to end on that date, inclusively. @param string $objectType Type of object to search for @param string|null $begin ('YYYY-MM-DD') Earliest date to match @param string|null $end ('YYYY-MM-DD') Last date to match @return array List of objectIds found
[ "Get", "IDs", "with", "activity", "present" ]
e609daa714298a254bf5a945a1d6985c9d4d539d
https://github.com/vphantom/pyritephp/blob/e609daa714298a254bf5a945a1d6985c9d4d539d/src/Pyrite/AuditTrail.php#L326-L342
1,319
fortifi/sdk
api/Foundation/Responses/FortifiApiResponse.php
FortifiApiResponse.prepareForTransport
public function prepareForTransport() { foreach($this as $k => $v) { if($v instanceof FortifiApiResponse) { $v->prepareForTransport(); } else if(is_array($v)) { foreach($v as $vi => $vv) { if($vv instanceof FortifiApiResponse) { $vv->prepareForTransport(); } } } } }
php
public function prepareForTransport() { foreach($this as $k => $v) { if($v instanceof FortifiApiResponse) { $v->prepareForTransport(); } else if(is_array($v)) { foreach($v as $vi => $vv) { if($vv instanceof FortifiApiResponse) { $vv->prepareForTransport(); } } } } }
[ "public", "function", "prepareForTransport", "(", ")", "{", "foreach", "(", "$", "this", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(", "$", "v", "instanceof", "FortifiApiResponse", ")", "{", "$", "v", "->", "prepareForTransport", "(", ")", ";", "}", "else", "if", "(", "is_array", "(", "$", "v", ")", ")", "{", "foreach", "(", "$", "v", "as", "$", "vi", "=>", "$", "vv", ")", "{", "if", "(", "$", "vv", "instanceof", "FortifiApiResponse", ")", "{", "$", "vv", "->", "prepareForTransport", "(", ")", ";", "}", "}", "}", "}", "}" ]
Executed before sending the response
[ "Executed", "before", "sending", "the", "response" ]
4d0471c72c7954271c692d32265fd42f698392e4
https://github.com/fortifi/sdk/blob/4d0471c72c7954271c692d32265fd42f698392e4/api/Foundation/Responses/FortifiApiResponse.php#L36-L55
1,320
webriq/core
module/Core/src/Grid/Core/Model/Settings/StructureAbstract.php
StructureAbstract.setSetting
public function setSetting( $name, $value ) { $old = isset( $this->settings[$name] ) ? $this->settings[$name] : null; if ( $old instanceof self || $value instanceof self ) { if ( $old instanceof self && $value instanceof self ) { $old->setSettings( $value->settings ); } else if ( $old instanceof self ) { if ( $value instanceof Traversable ) { $value = ArrayUtils::iteratorToArray( $value ); } $old->setSettings( (array) $value ); } else { $this->settings[$name] = $value; } } else { $method = array( $this, 'update' . ucfirst( $name ) ); if ( is_callable( $method ) && ( ( isset( $value ) && isset( $this->settings[$name] ) && $value != $this->settings[$name] ) || ( isset( $value ) && ! isset( $this->settings[$name] ) ) || ( ! isset( $value ) && isset( $this->settings[$name] ) ) ) ) { $value = $method( $value, $old ); } if ( null === $value ) { unset( $this->settings[$name] ); } else { $this->settings[$name] = $value; } } return $this; }
php
public function setSetting( $name, $value ) { $old = isset( $this->settings[$name] ) ? $this->settings[$name] : null; if ( $old instanceof self || $value instanceof self ) { if ( $old instanceof self && $value instanceof self ) { $old->setSettings( $value->settings ); } else if ( $old instanceof self ) { if ( $value instanceof Traversable ) { $value = ArrayUtils::iteratorToArray( $value ); } $old->setSettings( (array) $value ); } else { $this->settings[$name] = $value; } } else { $method = array( $this, 'update' . ucfirst( $name ) ); if ( is_callable( $method ) && ( ( isset( $value ) && isset( $this->settings[$name] ) && $value != $this->settings[$name] ) || ( isset( $value ) && ! isset( $this->settings[$name] ) ) || ( ! isset( $value ) && isset( $this->settings[$name] ) ) ) ) { $value = $method( $value, $old ); } if ( null === $value ) { unset( $this->settings[$name] ); } else { $this->settings[$name] = $value; } } return $this; }
[ "public", "function", "setSetting", "(", "$", "name", ",", "$", "value", ")", "{", "$", "old", "=", "isset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", "?", "$", "this", "->", "settings", "[", "$", "name", "]", ":", "null", ";", "if", "(", "$", "old", "instanceof", "self", "||", "$", "value", "instanceof", "self", ")", "{", "if", "(", "$", "old", "instanceof", "self", "&&", "$", "value", "instanceof", "self", ")", "{", "$", "old", "->", "setSettings", "(", "$", "value", "->", "settings", ")", ";", "}", "else", "if", "(", "$", "old", "instanceof", "self", ")", "{", "if", "(", "$", "value", "instanceof", "Traversable", ")", "{", "$", "value", "=", "ArrayUtils", "::", "iteratorToArray", "(", "$", "value", ")", ";", "}", "$", "old", "->", "setSettings", "(", "(", "array", ")", "$", "value", ")", ";", "}", "else", "{", "$", "this", "->", "settings", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "else", "{", "$", "method", "=", "array", "(", "$", "this", ",", "'update'", ".", "ucfirst", "(", "$", "name", ")", ")", ";", "if", "(", "is_callable", "(", "$", "method", ")", "&&", "(", "(", "isset", "(", "$", "value", ")", "&&", "isset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", "&&", "$", "value", "!=", "$", "this", "->", "settings", "[", "$", "name", "]", ")", "||", "(", "isset", "(", "$", "value", ")", "&&", "!", "isset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", ")", "||", "(", "!", "isset", "(", "$", "value", ")", "&&", "isset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", ")", ")", ")", "{", "$", "value", "=", "$", "method", "(", "$", "value", ",", "$", "old", ")", ";", "}", "if", "(", "null", "===", "$", "value", ")", "{", "unset", "(", "$", "this", "->", "settings", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "this", "->", "settings", "[", "$", "name", "]", "=", "$", "value", ";", "}", "}", "return", "$", "this", ";", "}" ]
Set a setting by name @param string $name @param string|\StructureAbstract $value @return \Core\Model\Settings\Structure
[ "Set", "a", "setting", "by", "name" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Core/src/Grid/Core/Model/Settings/StructureAbstract.php#L102-L152
1,321
neat-php/http
classes/Upload.php
Upload.capture
public static function capture($files = null) { $files = $files ?? $_FILES; if (!is_array($files)) { return null; } $keys = array_keys($files); sort($keys); $multi = $keys !== ['error', 'name', 'size', 'tmp_name', 'type']; if (!$multi && is_array($files['name'])) { $multi = true; $files = array_map(function ($index) use ($files) { return array_combine(array_keys($files), array_column($files, $index)); }, array_keys($files['name'])); } if ($multi) { return array_filter(array_map([static::class, 'capture'], $files)); } return new static($files['tmp_name'], $files['name'], $files['type'], $files['error']); }
php
public static function capture($files = null) { $files = $files ?? $_FILES; if (!is_array($files)) { return null; } $keys = array_keys($files); sort($keys); $multi = $keys !== ['error', 'name', 'size', 'tmp_name', 'type']; if (!$multi && is_array($files['name'])) { $multi = true; $files = array_map(function ($index) use ($files) { return array_combine(array_keys($files), array_column($files, $index)); }, array_keys($files['name'])); } if ($multi) { return array_filter(array_map([static::class, 'capture'], $files)); } return new static($files['tmp_name'], $files['name'], $files['type'], $files['error']); }
[ "public", "static", "function", "capture", "(", "$", "files", "=", "null", ")", "{", "$", "files", "=", "$", "files", "??", "$", "_FILES", ";", "if", "(", "!", "is_array", "(", "$", "files", ")", ")", "{", "return", "null", ";", "}", "$", "keys", "=", "array_keys", "(", "$", "files", ")", ";", "sort", "(", "$", "keys", ")", ";", "$", "multi", "=", "$", "keys", "!==", "[", "'error'", ",", "'name'", ",", "'size'", ",", "'tmp_name'", ",", "'type'", "]", ";", "if", "(", "!", "$", "multi", "&&", "is_array", "(", "$", "files", "[", "'name'", "]", ")", ")", "{", "$", "multi", "=", "true", ";", "$", "files", "=", "array_map", "(", "function", "(", "$", "index", ")", "use", "(", "$", "files", ")", "{", "return", "array_combine", "(", "array_keys", "(", "$", "files", ")", ",", "array_column", "(", "$", "files", ",", "$", "index", ")", ")", ";", "}", ",", "array_keys", "(", "$", "files", "[", "'name'", "]", ")", ")", ";", "}", "if", "(", "$", "multi", ")", "{", "return", "array_filter", "(", "array_map", "(", "[", "static", "::", "class", ",", "'capture'", "]", ",", "$", "files", ")", ")", ";", "}", "return", "new", "static", "(", "$", "files", "[", "'tmp_name'", "]", ",", "$", "files", "[", "'name'", "]", ",", "$", "files", "[", "'type'", "]", ",", "$", "files", "[", "'error'", "]", ")", ";", "}" ]
Capture uploaded files @param array $files @return null|Upload|Upload[]|Upload[][]|...
[ "Capture", "uploaded", "files" ]
5d4781a8481c1f708fd642292e44244435a8369c
https://github.com/neat-php/http/blob/5d4781a8481c1f708fd642292e44244435a8369c/classes/Upload.php#L165-L187
1,322
marc1706/otp-authenticate
lib/OTPHelper.php
OTPHelper.generateKeyURI
public function generateKeyURI($type, $secret, $account, $issuer = '', $counter = 0, $algorithm = '', $digits = '', $period = '') { // Check if type is supported $this->validateType($type); $this->validateAlgorithm($algorithm); // Format label string $this->formatLabel($issuer, 'issuer'); $this->formatLabel($account, 'account'); // Set additional parameters $this->setCounter($type, $counter); $this->setParameter($algorithm, 'algorithm'); $this->setParameter($digits, 'digits'); $this->setParameter($period, 'period'); return 'otpauth://' . $type . '/' . $this->label . '?secret=' . $secret . $this->issuer . $this->parameters; }
php
public function generateKeyURI($type, $secret, $account, $issuer = '', $counter = 0, $algorithm = '', $digits = '', $period = '') { // Check if type is supported $this->validateType($type); $this->validateAlgorithm($algorithm); // Format label string $this->formatLabel($issuer, 'issuer'); $this->formatLabel($account, 'account'); // Set additional parameters $this->setCounter($type, $counter); $this->setParameter($algorithm, 'algorithm'); $this->setParameter($digits, 'digits'); $this->setParameter($period, 'period'); return 'otpauth://' . $type . '/' . $this->label . '?secret=' . $secret . $this->issuer . $this->parameters; }
[ "public", "function", "generateKeyURI", "(", "$", "type", ",", "$", "secret", ",", "$", "account", ",", "$", "issuer", "=", "''", ",", "$", "counter", "=", "0", ",", "$", "algorithm", "=", "''", ",", "$", "digits", "=", "''", ",", "$", "period", "=", "''", ")", "{", "// Check if type is supported", "$", "this", "->", "validateType", "(", "$", "type", ")", ";", "$", "this", "->", "validateAlgorithm", "(", "$", "algorithm", ")", ";", "// Format label string", "$", "this", "->", "formatLabel", "(", "$", "issuer", ",", "'issuer'", ")", ";", "$", "this", "->", "formatLabel", "(", "$", "account", ",", "'account'", ")", ";", "// Set additional parameters", "$", "this", "->", "setCounter", "(", "$", "type", ",", "$", "counter", ")", ";", "$", "this", "->", "setParameter", "(", "$", "algorithm", ",", "'algorithm'", ")", ";", "$", "this", "->", "setParameter", "(", "$", "digits", ",", "'digits'", ")", ";", "$", "this", "->", "setParameter", "(", "$", "period", ",", "'period'", ")", ";", "return", "'otpauth://'", ".", "$", "type", ".", "'/'", ".", "$", "this", "->", "label", ".", "'?secret='", ".", "$", "secret", ".", "$", "this", "->", "issuer", ".", "$", "this", "->", "parameters", ";", "}" ]
Generate OTP key URI @param string $type OTP type @param string $secret Base32 encoded secret @param string $account Account name @param string $issuer Issuer name (optional) @param int $counter Counter for HOTP (optional) @param string $algorithm Algorithm name (optional) @param string $digits Number of digits for code (optional) @param string $period Period for TOTP codes (optional) @return string OTP key URI
[ "Generate", "OTP", "key", "URI" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPHelper.php#L52-L69
1,323
marc1706/otp-authenticate
lib/OTPHelper.php
OTPHelper.formatLabel
protected function formatLabel($string, $part) { $string = trim($string); if ($part === 'account') { $this->setAccount($string); } else if ($part === 'issuer') { $this->setIssuer($string); } }
php
protected function formatLabel($string, $part) { $string = trim($string); if ($part === 'account') { $this->setAccount($string); } else if ($part === 'issuer') { $this->setIssuer($string); } }
[ "protected", "function", "formatLabel", "(", "$", "string", ",", "$", "part", ")", "{", "$", "string", "=", "trim", "(", "$", "string", ")", ";", "if", "(", "$", "part", "===", "'account'", ")", "{", "$", "this", "->", "setAccount", "(", "$", "string", ")", ";", "}", "else", "if", "(", "$", "part", "===", "'issuer'", ")", "{", "$", "this", "->", "setIssuer", "(", "$", "string", ")", ";", "}", "}" ]
Format label string according to expected urlencoded standards. @param string $string The label string @param string $part Part of label
[ "Format", "label", "string", "according", "to", "expected", "urlencoded", "standards", "." ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPHelper.php#L107-L119
1,324
marc1706/otp-authenticate
lib/OTPHelper.php
OTPHelper.setAccount
protected function setAccount($account) { if (empty($account)) { throw new \InvalidArgumentException("Label can't contain empty strings"); } $this->label .= str_replace('%40', '@', rawurlencode($account)); }
php
protected function setAccount($account) { if (empty($account)) { throw new \InvalidArgumentException("Label can't contain empty strings"); } $this->label .= str_replace('%40', '@', rawurlencode($account)); }
[ "protected", "function", "setAccount", "(", "$", "account", ")", "{", "if", "(", "empty", "(", "$", "account", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Label can't contain empty strings\"", ")", ";", "}", "$", "this", "->", "label", ".=", "str_replace", "(", "'%40'", ",", "'@'", ",", "rawurlencode", "(", "$", "account", ")", ")", ";", "}" ]
Format and and set account name @param string $account Account name @throws \InvalidArgumentException When given account name is an empty string
[ "Format", "and", "and", "set", "account", "name" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPHelper.php#L128-L136
1,325
marc1706/otp-authenticate
lib/OTPHelper.php
OTPHelper.setIssuer
protected function setIssuer($issuer) { if (!empty($issuer)) { $this->label = rawurlencode($issuer) . ':'; $this->issuer = '&issuer=' . rawurlencode($issuer); } }
php
protected function setIssuer($issuer) { if (!empty($issuer)) { $this->label = rawurlencode($issuer) . ':'; $this->issuer = '&issuer=' . rawurlencode($issuer); } }
[ "protected", "function", "setIssuer", "(", "$", "issuer", ")", "{", "if", "(", "!", "empty", "(", "$", "issuer", ")", ")", "{", "$", "this", "->", "label", "=", "rawurlencode", "(", "$", "issuer", ")", ".", "':'", ";", "$", "this", "->", "issuer", "=", "'&issuer='", ".", "rawurlencode", "(", "$", "issuer", ")", ";", "}", "}" ]
Format and set issuer @param string $issuer Issuer name
[ "Format", "and", "set", "issuer" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPHelper.php#L143-L150
1,326
marc1706/otp-authenticate
lib/OTPHelper.php
OTPHelper.setCounter
protected function setCounter($type, $counter) { if ($type === 'hotp') { if ($counter !== 0 && empty($counter)) { throw new \InvalidArgumentException("Counter can't be empty if HOTP is being used"); } $this->parameters .= "&counter=$counter"; } }
php
protected function setCounter($type, $counter) { if ($type === 'hotp') { if ($counter !== 0 && empty($counter)) { throw new \InvalidArgumentException("Counter can't be empty if HOTP is being used"); } $this->parameters .= "&counter=$counter"; } }
[ "protected", "function", "setCounter", "(", "$", "type", ",", "$", "counter", ")", "{", "if", "(", "$", "type", "===", "'hotp'", ")", "{", "if", "(", "$", "counter", "!==", "0", "&&", "empty", "(", "$", "counter", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "\"Counter can't be empty if HOTP is being used\"", ")", ";", "}", "$", "this", "->", "parameters", ".=", "\"&counter=$counter\"", ";", "}", "}" ]
Set counter value if hotp is being used @param string $type Type of OTP auth, either HOTP or TOTP @param int $counter Counter value @throws \InvalidArgumentException If counter is empty while using HOTP
[ "Set", "counter", "value", "if", "hotp", "is", "being", "used" ]
a2ea1ed3a958fe6bfafc5866a07f204d9d30c588
https://github.com/marc1706/otp-authenticate/blob/a2ea1ed3a958fe6bfafc5866a07f204d9d30c588/lib/OTPHelper.php#L174-L185
1,327
novuso/system
src/Utility/ClassName.php
ClassName.full
public static function full($object): string { if (is_string($object)) { return str_replace('.', '\\', $object); } if (is_object($object)) { return trim(get_class($object), '\\'); } $message = sprintf( '%s expects $object to be an object or string; received (%s) %s', __METHOD__, gettype($object), VarPrinter::toString($object) ); throw new TypeException($message); }
php
public static function full($object): string { if (is_string($object)) { return str_replace('.', '\\', $object); } if (is_object($object)) { return trim(get_class($object), '\\'); } $message = sprintf( '%s expects $object to be an object or string; received (%s) %s', __METHOD__, gettype($object), VarPrinter::toString($object) ); throw new TypeException($message); }
[ "public", "static", "function", "full", "(", "$", "object", ")", ":", "string", "{", "if", "(", "is_string", "(", "$", "object", ")", ")", "{", "return", "str_replace", "(", "'.'", ",", "'\\\\'", ",", "$", "object", ")", ";", "}", "if", "(", "is_object", "(", "$", "object", ")", ")", "{", "return", "trim", "(", "get_class", "(", "$", "object", ")", ",", "'\\\\'", ")", ";", "}", "$", "message", "=", "sprintf", "(", "'%s expects $object to be an object or string; received (%s) %s'", ",", "__METHOD__", ",", "gettype", "(", "$", "object", ")", ",", "VarPrinter", "::", "toString", "(", "$", "object", ")", ")", ";", "throw", "new", "TypeException", "(", "$", "message", ")", ";", "}" ]
Retrieves the fully qualified class name of an object @param object|string $object An object, fully qualified class name, or canonical class name @return string @throws TypeException When $object is not a string or object
[ "Retrieves", "the", "fully", "qualified", "class", "name", "of", "an", "object" ]
e34038b391826edc68d0b5fccfba96642de9d6f0
https://github.com/novuso/system/blob/e34038b391826edc68d0b5fccfba96642de9d6f0/src/Utility/ClassName.php#L29-L46
1,328
a2c/BaconGeneratorBundle
Manipulator/BaconRoutingManipulator.php
BaconRoutingManipulator.addAnnotationController
public function addAnnotationController($bundle, $controller) { $current = ''; if (file_exists($this->file)) { $current = file_get_contents($this->file); } elseif (!is_dir($dir = dirname($this->file))) { mkdir($dir, 0777, true); } $code = sprintf("%s:\n", Container::underscore(substr($bundle, 0, -6)).'_'.Container::underscore($controller)); if($this->controllerFolder) { $controller = $this->controllerFolder . '/' . $controller; } $code .= sprintf(" resource: \"@%s/Controller/%sController.php\"\n type: annotation\n", $bundle, $controller); $code .= "\n"; $code .= $current; return false !== file_put_contents($this->file, $code); }
php
public function addAnnotationController($bundle, $controller) { $current = ''; if (file_exists($this->file)) { $current = file_get_contents($this->file); } elseif (!is_dir($dir = dirname($this->file))) { mkdir($dir, 0777, true); } $code = sprintf("%s:\n", Container::underscore(substr($bundle, 0, -6)).'_'.Container::underscore($controller)); if($this->controllerFolder) { $controller = $this->controllerFolder . '/' . $controller; } $code .= sprintf(" resource: \"@%s/Controller/%sController.php\"\n type: annotation\n", $bundle, $controller); $code .= "\n"; $code .= $current; return false !== file_put_contents($this->file, $code); }
[ "public", "function", "addAnnotationController", "(", "$", "bundle", ",", "$", "controller", ")", "{", "$", "current", "=", "''", ";", "if", "(", "file_exists", "(", "$", "this", "->", "file", ")", ")", "{", "$", "current", "=", "file_get_contents", "(", "$", "this", "->", "file", ")", ";", "}", "elseif", "(", "!", "is_dir", "(", "$", "dir", "=", "dirname", "(", "$", "this", "->", "file", ")", ")", ")", "{", "mkdir", "(", "$", "dir", ",", "0777", ",", "true", ")", ";", "}", "$", "code", "=", "sprintf", "(", "\"%s:\\n\"", ",", "Container", "::", "underscore", "(", "substr", "(", "$", "bundle", ",", "0", ",", "-", "6", ")", ")", ".", "'_'", ".", "Container", "::", "underscore", "(", "$", "controller", ")", ")", ";", "if", "(", "$", "this", "->", "controllerFolder", ")", "{", "$", "controller", "=", "$", "this", "->", "controllerFolder", ".", "'/'", ".", "$", "controller", ";", "}", "$", "code", ".=", "sprintf", "(", "\" resource: \\\"@%s/Controller/%sController.php\\\"\\n type: annotation\\n\"", ",", "$", "bundle", ",", "$", "controller", ")", ";", "$", "code", ".=", "\"\\n\"", ";", "$", "code", ".=", "$", "current", ";", "return", "false", "!==", "file_put_contents", "(", "$", "this", "->", "file", ",", "$", "code", ")", ";", "}" ]
Add an annotation controller resource. @param string $bundle @param string $controller @return bool
[ "Add", "an", "annotation", "controller", "resource", "." ]
af862548b136a7d5c4c7cf1845c4211c9e32d100
https://github.com/a2c/BaconGeneratorBundle/blob/af862548b136a7d5c4c7cf1845c4211c9e32d100/Manipulator/BaconRoutingManipulator.php#L57-L79
1,329
avoo/FrameworkGeneratorBundle
Command/CreateResourceCommand.php
CreateResourceCommand.createProgressBar
protected function createProgressBar(OutputInterface $output, $length = 10) { $progress = $this->getHelper('progress'); $progress->setBarCharacter('<info>|</info>'); $progress->setEmptyBarCharacter(' '); $progress->setProgressCharacter('|'); $progress->start($output, $length); return $progress; }
php
protected function createProgressBar(OutputInterface $output, $length = 10) { $progress = $this->getHelper('progress'); $progress->setBarCharacter('<info>|</info>'); $progress->setEmptyBarCharacter(' '); $progress->setProgressCharacter('|'); $progress->start($output, $length); return $progress; }
[ "protected", "function", "createProgressBar", "(", "OutputInterface", "$", "output", ",", "$", "length", "=", "10", ")", "{", "$", "progress", "=", "$", "this", "->", "getHelper", "(", "'progress'", ")", ";", "$", "progress", "->", "setBarCharacter", "(", "'<info>|</info>'", ")", ";", "$", "progress", "->", "setEmptyBarCharacter", "(", "' '", ")", ";", "$", "progress", "->", "setProgressCharacter", "(", "'|'", ")", ";", "$", "progress", "->", "start", "(", "$", "output", ",", "$", "length", ")", ";", "return", "$", "progress", ";", "}" ]
Create progress bar @param OutputInterface $output @param int $length @return ProgressHelper
[ "Create", "progress", "bar" ]
3178268b9e58e6c60c27e0b9ea976944c1f61a48
https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Command/CreateResourceCommand.php#L268-L278
1,330
avoo/FrameworkGeneratorBundle
Command/CreateResourceCommand.php
CreateResourceCommand.validateTemplate
private function validateTemplate($template, $templateList) { if (empty($template)) { throw new \Exception('The template name is required.'); } if (!in_array($template, $templateList)) { throw new \InvalidArgumentException( sprintf('The template "%s" does not exist, use: %s', $template, implode(', ', $templateList)) ); } }
php
private function validateTemplate($template, $templateList) { if (empty($template)) { throw new \Exception('The template name is required.'); } if (!in_array($template, $templateList)) { throw new \InvalidArgumentException( sprintf('The template "%s" does not exist, use: %s', $template, implode(', ', $templateList)) ); } }
[ "private", "function", "validateTemplate", "(", "$", "template", ",", "$", "templateList", ")", "{", "if", "(", "empty", "(", "$", "template", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'The template name is required.'", ")", ";", "}", "if", "(", "!", "in_array", "(", "$", "template", ",", "$", "templateList", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The template \"%s\" does not exist, use: %s'", ",", "$", "template", ",", "implode", "(", "', '", ",", "$", "templateList", ")", ")", ")", ";", "}", "}" ]
Validate template name @param string $template @param array $templateList @throws \Exception
[ "Validate", "template", "name" ]
3178268b9e58e6c60c27e0b9ea976944c1f61a48
https://github.com/avoo/FrameworkGeneratorBundle/blob/3178268b9e58e6c60c27e0b9ea976944c1f61a48/Command/CreateResourceCommand.php#L306-L317
1,331
FlexPress/component-routing
src/FlexPress/Components/Routing/Route.php
Route.setCallable
public function setCallable($callableExpression) { if (strpos("@", $callableExpression) === false) { $callableExpression .= "@indexAction"; } list($controllerName, $action) = explode("@", $callableExpression); $controller = $this->pimple[$controllerName]; $callable = array( $controller, $action ); if (!is_callable($callable)) { $message = "The callable you have provided is not callable, if you did not provide a action then "; $message .= "indexAction will be called on your given controller"; throw new \InvalidArgumentException($message); } $this->callable = $callable; }
php
public function setCallable($callableExpression) { if (strpos("@", $callableExpression) === false) { $callableExpression .= "@indexAction"; } list($controllerName, $action) = explode("@", $callableExpression); $controller = $this->pimple[$controllerName]; $callable = array( $controller, $action ); if (!is_callable($callable)) { $message = "The callable you have provided is not callable, if you did not provide a action then "; $message .= "indexAction will be called on your given controller"; throw new \InvalidArgumentException($message); } $this->callable = $callable; }
[ "public", "function", "setCallable", "(", "$", "callableExpression", ")", "{", "if", "(", "strpos", "(", "\"@\"", ",", "$", "callableExpression", ")", "===", "false", ")", "{", "$", "callableExpression", ".=", "\"@indexAction\"", ";", "}", "list", "(", "$", "controllerName", ",", "$", "action", ")", "=", "explode", "(", "\"@\"", ",", "$", "callableExpression", ")", ";", "$", "controller", "=", "$", "this", "->", "pimple", "[", "$", "controllerName", "]", ";", "$", "callable", "=", "array", "(", "$", "controller", ",", "$", "action", ")", ";", "if", "(", "!", "is_callable", "(", "$", "callable", ")", ")", "{", "$", "message", "=", "\"The callable you have provided is not callable, if you did not provide a action then \"", ";", "$", "message", ".=", "\"indexAction will be called on your given controller\"", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "message", ")", ";", "}", "$", "this", "->", "callable", "=", "$", "callable", ";", "}" ]
Sets the controller and action @param $callableExpression - A string in the format 'controller@action' @throws \InvalidArgumentException @author Tim Perry
[ "Sets", "the", "controller", "and", "action" ]
c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56
https://github.com/FlexPress/component-routing/blob/c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56/src/FlexPress/Components/Routing/Route.php#L49-L74
1,332
FlexPress/component-routing
src/FlexPress/Components/Routing/Route.php
Route.addConditionsFromArray
public function addConditionsFromArray(array $conditions) { foreach ($conditions as $condition) { if (!is_callable($condition)) { $message = "One or more of the conditions you provided are not callable, "; $message .= "please pass an array of callable functions."; throw new \InvalidArgumentException($message); } $this->conditions->enqueue($condition); } }
php
public function addConditionsFromArray(array $conditions) { foreach ($conditions as $condition) { if (!is_callable($condition)) { $message = "One or more of the conditions you provided are not callable, "; $message .= "please pass an array of callable functions."; throw new \InvalidArgumentException($message); } $this->conditions->enqueue($condition); } }
[ "public", "function", "addConditionsFromArray", "(", "array", "$", "conditions", ")", "{", "foreach", "(", "$", "conditions", "as", "$", "condition", ")", "{", "if", "(", "!", "is_callable", "(", "$", "condition", ")", ")", "{", "$", "message", "=", "\"One or more of the conditions you provided are not callable, \"", ";", "$", "message", ".=", "\"please pass an array of callable functions.\"", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "$", "message", ")", ";", "}", "$", "this", "->", "conditions", "->", "enqueue", "(", "$", "condition", ")", ";", "}", "}" ]
Adds conditions to the route from the given array @param array $conditions - an array of conditions @throws \InvalidArgumentException @author Tim Perry
[ "Adds", "conditions", "to", "the", "route", "from", "the", "given", "array" ]
c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56
https://github.com/FlexPress/component-routing/blob/c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56/src/FlexPress/Components/Routing/Route.php#L84-L99
1,333
FlexPress/component-routing
src/FlexPress/Components/Routing/Route.php
Route.run
public function run() { if (!isset($this->conditions) || !isset($this->callable) ) { $message = "You have called the run function but have not provided both a array of conditions"; $message .= " and a callable function, which will be called if all the given conditions are met."; throw new \RuntimeException($message); } $this->conditions->rewind(); while ($this->conditions->valid()) { $condition = $this->conditions->current(); if (!call_user_func($condition)) { return false; } $this->conditions->next(); } call_user_func($this->callable, $this->request); return true; }
php
public function run() { if (!isset($this->conditions) || !isset($this->callable) ) { $message = "You have called the run function but have not provided both a array of conditions"; $message .= " and a callable function, which will be called if all the given conditions are met."; throw new \RuntimeException($message); } $this->conditions->rewind(); while ($this->conditions->valid()) { $condition = $this->conditions->current(); if (!call_user_func($condition)) { return false; } $this->conditions->next(); } call_user_func($this->callable, $this->request); return true; }
[ "public", "function", "run", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "conditions", ")", "||", "!", "isset", "(", "$", "this", "->", "callable", ")", ")", "{", "$", "message", "=", "\"You have called the run function but have not provided both a array of conditions\"", ";", "$", "message", ".=", "\" and a callable function, which will be called if all the given conditions are met.\"", ";", "throw", "new", "\\", "RuntimeException", "(", "$", "message", ")", ";", "}", "$", "this", "->", "conditions", "->", "rewind", "(", ")", ";", "while", "(", "$", "this", "->", "conditions", "->", "valid", "(", ")", ")", "{", "$", "condition", "=", "$", "this", "->", "conditions", "->", "current", "(", ")", ";", "if", "(", "!", "call_user_func", "(", "$", "condition", ")", ")", "{", "return", "false", ";", "}", "$", "this", "->", "conditions", "->", "next", "(", ")", ";", "}", "call_user_func", "(", "$", "this", "->", "callable", ",", "$", "this", "->", "request", ")", ";", "return", "true", ";", "}" ]
Runs through all the callable functions provided, if all are met call the given callable @author Tim Perry
[ "Runs", "through", "all", "the", "callable", "functions", "provided", "if", "all", "are", "met", "call", "the", "given", "callable" ]
c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56
https://github.com/FlexPress/component-routing/blob/c1a0c6f1f4522a54e21ee18a8b24adfc1cc28f56/src/FlexPress/Components/Routing/Route.php#L105-L132
1,334
simple-php-mvc/installer-module
src/InstallerModule/Generator/ModelGenerator.php
ModelGenerator.generateBody
protected function generateBody($modelName, array $properties) { $linesProperties = array(""); $linesMethods = array(""); foreach ($properties as $field) { foreach ($field as $property) { $linesProperties[] = " /**"; $linesProperties[] = " * " . $property['columnName']; $linesProperties[] = " * "; $linesProperties[] = " * @var $property[type] $$property[fieldName]"; $linesProperties[] = " */"; $linesProperties[] = " protected $$property[fieldName];"; $linesProperties[] = ""; # Getter Property $linesMethods[] = str_replace(array( '<description>', '<fieldName>', '<variableType>', '<methodName>', '<spaces>' ), array( 'Get ' . $property['columnName'], $property['fieldName'], $property['type'], 'get' . ucwords($property['fieldName']), " " ), self::$getMethodTemplate); $linesMethods[] = ""; # Setter Property $linesMethods[] = str_replace(array( '<description>', '<fieldName>', '<variableType>', '<variableName>', '<modelClass>', '<methodName>', '<spaces>' ), array( 'Set ' . $property['columnName'], $property['fieldName'], $property['type'], $property['fieldName'], $modelName, 'set' . ucwords($property['fieldName']), " " ), self::$setMethodTemplate); $linesMethods[] = ""; } } return implode("\n", $linesProperties) . implode("\n", $linesMethods); }
php
protected function generateBody($modelName, array $properties) { $linesProperties = array(""); $linesMethods = array(""); foreach ($properties as $field) { foreach ($field as $property) { $linesProperties[] = " /**"; $linesProperties[] = " * " . $property['columnName']; $linesProperties[] = " * "; $linesProperties[] = " * @var $property[type] $$property[fieldName]"; $linesProperties[] = " */"; $linesProperties[] = " protected $$property[fieldName];"; $linesProperties[] = ""; # Getter Property $linesMethods[] = str_replace(array( '<description>', '<fieldName>', '<variableType>', '<methodName>', '<spaces>' ), array( 'Get ' . $property['columnName'], $property['fieldName'], $property['type'], 'get' . ucwords($property['fieldName']), " " ), self::$getMethodTemplate); $linesMethods[] = ""; # Setter Property $linesMethods[] = str_replace(array( '<description>', '<fieldName>', '<variableType>', '<variableName>', '<modelClass>', '<methodName>', '<spaces>' ), array( 'Set ' . $property['columnName'], $property['fieldName'], $property['type'], $property['fieldName'], $modelName, 'set' . ucwords($property['fieldName']), " " ), self::$setMethodTemplate); $linesMethods[] = ""; } } return implode("\n", $linesProperties) . implode("\n", $linesMethods); }
[ "protected", "function", "generateBody", "(", "$", "modelName", ",", "array", "$", "properties", ")", "{", "$", "linesProperties", "=", "array", "(", "\"\"", ")", ";", "$", "linesMethods", "=", "array", "(", "\"\"", ")", ";", "foreach", "(", "$", "properties", "as", "$", "field", ")", "{", "foreach", "(", "$", "field", "as", "$", "property", ")", "{", "$", "linesProperties", "[", "]", "=", "\" /**\"", ";", "$", "linesProperties", "[", "]", "=", "\" * \"", ".", "$", "property", "[", "'columnName'", "]", ";", "$", "linesProperties", "[", "]", "=", "\" * \"", ";", "$", "linesProperties", "[", "]", "=", "\" * @var $property[type] $$property[fieldName]\"", ";", "$", "linesProperties", "[", "]", "=", "\" */\"", ";", "$", "linesProperties", "[", "]", "=", "\" protected $$property[fieldName];\"", ";", "$", "linesProperties", "[", "]", "=", "\"\"", ";", "# Getter Property", "$", "linesMethods", "[", "]", "=", "str_replace", "(", "array", "(", "'<description>'", ",", "'<fieldName>'", ",", "'<variableType>'", ",", "'<methodName>'", ",", "'<spaces>'", ")", ",", "array", "(", "'Get '", ".", "$", "property", "[", "'columnName'", "]", ",", "$", "property", "[", "'fieldName'", "]", ",", "$", "property", "[", "'type'", "]", ",", "'get'", ".", "ucwords", "(", "$", "property", "[", "'fieldName'", "]", ")", ",", "\" \"", ")", ",", "self", "::", "$", "getMethodTemplate", ")", ";", "$", "linesMethods", "[", "]", "=", "\"\"", ";", "# Setter Property", "$", "linesMethods", "[", "]", "=", "str_replace", "(", "array", "(", "'<description>'", ",", "'<fieldName>'", ",", "'<variableType>'", ",", "'<variableName>'", ",", "'<modelClass>'", ",", "'<methodName>'", ",", "'<spaces>'", ")", ",", "array", "(", "'Set '", ".", "$", "property", "[", "'columnName'", "]", ",", "$", "property", "[", "'fieldName'", "]", ",", "$", "property", "[", "'type'", "]", ",", "$", "property", "[", "'fieldName'", "]", ",", "$", "modelName", ",", "'set'", ".", "ucwords", "(", "$", "property", "[", "'fieldName'", "]", ")", ",", "\" \"", ")", ",", "self", "::", "$", "setMethodTemplate", ")", ";", "$", "linesMethods", "[", "]", "=", "\"\"", ";", "}", "}", "return", "implode", "(", "\"\\n\"", ",", "$", "linesProperties", ")", ".", "implode", "(", "\"\\n\"", ",", "$", "linesMethods", ")", ";", "}" ]
Generate array properties, getters and setters @param string $modelName @param array $properties @return string
[ "Generate", "array", "properties", "getters", "and", "setters" ]
62bd5bac05418b5f712dfcead1edc75ef14d60e3
https://github.com/simple-php-mvc/installer-module/blob/62bd5bac05418b5f712dfcead1edc75ef14d60e3/src/InstallerModule/Generator/ModelGenerator.php#L51-L104
1,335
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.panelHeader
public function panelHeader($title, $h = 'h1') { $panelTitle = parent::tag($h, $title, ['class' => 'panel-title']); return parent::tag("div", $panelTitle, ['class' => 'panel-heading']); }
php
public function panelHeader($title, $h = 'h1') { $panelTitle = parent::tag($h, $title, ['class' => 'panel-title']); return parent::tag("div", $panelTitle, ['class' => 'panel-heading']); }
[ "public", "function", "panelHeader", "(", "$", "title", ",", "$", "h", "=", "'h1'", ")", "{", "$", "panelTitle", "=", "parent", "::", "tag", "(", "$", "h", ",", "$", "title", ",", "[", "'class'", "=>", "'panel-title'", "]", ")", ";", "return", "parent", "::", "tag", "(", "\"div\"", ",", "$", "panelTitle", ",", "[", "'class'", "=>", "'panel-heading'", "]", ")", ";", "}" ]
Returns a panel header @param string $title @param string $h @return string
[ "Returns", "a", "panel", "header" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L53-L57
1,336
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.modalHeader
public function modalHeader($title, $h = 'h4') { $modalTitle = parent::tag($h, $title, ['class' => 'modal-title']); return parent::tag("div", $modalTitle, ["class" => 'modal-header']); }
php
public function modalHeader($title, $h = 'h4') { $modalTitle = parent::tag($h, $title, ['class' => 'modal-title']); return parent::tag("div", $modalTitle, ["class" => 'modal-header']); }
[ "public", "function", "modalHeader", "(", "$", "title", ",", "$", "h", "=", "'h4'", ")", "{", "$", "modalTitle", "=", "parent", "::", "tag", "(", "$", "h", ",", "$", "title", ",", "[", "'class'", "=>", "'modal-title'", "]", ")", ";", "return", "parent", "::", "tag", "(", "\"div\"", ",", "$", "modalTitle", ",", "[", "\"class\"", "=>", "'modal-header'", "]", ")", ";", "}" ]
Returns a modal header @param string $title @param string $h @return string
[ "Returns", "a", "modal", "header" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L66-L70
1,337
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.descriptionList
public function descriptionList($data, $options = [], $dtOpts = [], $ddOpts = []) { if (empty($data) || !is_array($data)) { return false; } $out = []; $dtOptions = parent::_parseAttributes($dtOpts); $ddOptions = parent::_parseAttributes($ddOpts); foreach ($data as $descr => $value) { $out[] = sprintf($this->_tags['dt'], $dtOptions, $descr); $out[] = sprintf($this->_tags['dd'], $ddOptions, $value); } $dl = sprintf($this->_tags['dl'], parent::_parseAttributes($options), implode("\n", $out)); return $dl; }
php
public function descriptionList($data, $options = [], $dtOpts = [], $ddOpts = []) { if (empty($data) || !is_array($data)) { return false; } $out = []; $dtOptions = parent::_parseAttributes($dtOpts); $ddOptions = parent::_parseAttributes($ddOpts); foreach ($data as $descr => $value) { $out[] = sprintf($this->_tags['dt'], $dtOptions, $descr); $out[] = sprintf($this->_tags['dd'], $ddOptions, $value); } $dl = sprintf($this->_tags['dl'], parent::_parseAttributes($options), implode("\n", $out)); return $dl; }
[ "public", "function", "descriptionList", "(", "$", "data", ",", "$", "options", "=", "[", "]", ",", "$", "dtOpts", "=", "[", "]", ",", "$", "ddOpts", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "data", ")", "||", "!", "is_array", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "$", "out", "=", "[", "]", ";", "$", "dtOptions", "=", "parent", "::", "_parseAttributes", "(", "$", "dtOpts", ")", ";", "$", "ddOptions", "=", "parent", "::", "_parseAttributes", "(", "$", "ddOpts", ")", ";", "foreach", "(", "$", "data", "as", "$", "descr", "=>", "$", "value", ")", "{", "$", "out", "[", "]", "=", "sprintf", "(", "$", "this", "->", "_tags", "[", "'dt'", "]", ",", "$", "dtOptions", ",", "$", "descr", ")", ";", "$", "out", "[", "]", "=", "sprintf", "(", "$", "this", "->", "_tags", "[", "'dd'", "]", ",", "$", "ddOptions", ",", "$", "value", ")", ";", "}", "$", "dl", "=", "sprintf", "(", "$", "this", "->", "_tags", "[", "'dl'", "]", ",", "parent", "::", "_parseAttributes", "(", "$", "options", ")", ",", "implode", "(", "\"\\n\"", ",", "$", "out", ")", ")", ";", "return", "$", "dl", ";", "}" ]
returns a dl element @param string $data @param array $options @param array $dtOpts @param array $ddOpts @return string
[ "returns", "a", "dl", "element" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L81-L97
1,338
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.well
public function well($text, $size = null, $options = []) { $options = ['class' => 'well']; if (!empty($size)) { switch ($size) { case 'lg': case 'large': $options = parent::addClass($options, 'well-lg'); break; case 'sm': case 'small': $options = parent::addClass($options, 'well-sm'); break; } } return parent::tag('div', $text, $options); }
php
public function well($text, $size = null, $options = []) { $options = ['class' => 'well']; if (!empty($size)) { switch ($size) { case 'lg': case 'large': $options = parent::addClass($options, 'well-lg'); break; case 'sm': case 'small': $options = parent::addClass($options, 'well-sm'); break; } } return parent::tag('div', $text, $options); }
[ "public", "function", "well", "(", "$", "text", ",", "$", "size", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "[", "'class'", "=>", "'well'", "]", ";", "if", "(", "!", "empty", "(", "$", "size", ")", ")", "{", "switch", "(", "$", "size", ")", "{", "case", "'lg'", ":", "case", "'large'", ":", "$", "options", "=", "parent", "::", "addClass", "(", "$", "options", ",", "'well-lg'", ")", ";", "break", ";", "case", "'sm'", ":", "case", "'small'", ":", "$", "options", "=", "parent", "::", "addClass", "(", "$", "options", ",", "'well-sm'", ")", ";", "break", ";", "}", "}", "return", "parent", "::", "tag", "(", "'div'", ",", "$", "text", ",", "$", "options", ")", ";", "}" ]
creates a div with well properties @param string $text @param string $size @param array $options @return string
[ "creates", "a", "div", "with", "well", "properties" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L107-L124
1,339
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.lead
public function lead($content, $options = []) { $options = array_merge(['class' => 'lead'], $options); return parent::tag('p', $content, $options); }
php
public function lead($content, $options = []) { $options = array_merge(['class' => 'lead'], $options); return parent::tag('p', $content, $options); }
[ "public", "function", "lead", "(", "$", "content", ",", "$", "options", "=", "[", "]", ")", "{", "$", "options", "=", "array_merge", "(", "[", "'class'", "=>", "'lead'", "]", ",", "$", "options", ")", ";", "return", "parent", "::", "tag", "(", "'p'", ",", "$", "content", ",", "$", "options", ")", ";", "}" ]
Creates a paragraph with lead class @param string $content @param array $options @return string
[ "Creates", "a", "paragraph", "with", "lead", "class" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L133-L137
1,340
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper._generateListGroupText
protected function _generateListGroupText($title) { if (is_array($title)) { $text = ''; if (!empty($title['header'])) { $text .= $this->tag('h4', $title['header'], ['class' => 'list-group-item-heading']); } if (!empty($title['text'])) { $text .= $this->para('list-group-item-text', $title['text']); } } else { $text = $title; } return $text; }
php
protected function _generateListGroupText($title) { if (is_array($title)) { $text = ''; if (!empty($title['header'])) { $text .= $this->tag('h4', $title['header'], ['class' => 'list-group-item-heading']); } if (!empty($title['text'])) { $text .= $this->para('list-group-item-text', $title['text']); } } else { $text = $title; } return $text; }
[ "protected", "function", "_generateListGroupText", "(", "$", "title", ")", "{", "if", "(", "is_array", "(", "$", "title", ")", ")", "{", "$", "text", "=", "''", ";", "if", "(", "!", "empty", "(", "$", "title", "[", "'header'", "]", ")", ")", "{", "$", "text", ".=", "$", "this", "->", "tag", "(", "'h4'", ",", "$", "title", "[", "'header'", "]", ",", "[", "'class'", "=>", "'list-group-item-heading'", "]", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "title", "[", "'text'", "]", ")", ")", "{", "$", "text", ".=", "$", "this", "->", "para", "(", "'list-group-item-text'", ",", "$", "title", "[", "'text'", "]", ")", ";", "}", "}", "else", "{", "$", "text", "=", "$", "title", ";", "}", "return", "$", "text", ";", "}" ]
_generateListGroupText Generates the text for the list group item @param string $title @return string
[ "_generateListGroupText", "Generates", "the", "text", "for", "the", "list", "group", "item" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L253-L267
1,341
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.badge
public function badge($text, $options = []) { $defaults = array_merge(['class' => 'badge'], $options); return parent::tag('span', $text, $defaults); }
php
public function badge($text, $options = []) { $defaults = array_merge(['class' => 'badge'], $options); return parent::tag('span', $text, $defaults); }
[ "public", "function", "badge", "(", "$", "text", ",", "$", "options", "=", "[", "]", ")", "{", "$", "defaults", "=", "array_merge", "(", "[", "'class'", "=>", "'badge'", "]", ",", "$", "options", ")", ";", "return", "parent", "::", "tag", "(", "'span'", ",", "$", "text", ",", "$", "defaults", ")", ";", "}" ]
return a badge @param string $text @param array $options @return string
[ "return", "a", "badge" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L299-L303
1,342
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.status
public function status($value, $url = []) { $icon = $value == true ? 'check' : 'times'; $contextual = $value == true ? 'success' : 'danger'; return $this->label('', $contextual, ['icon' => $icon]); }
php
public function status($value, $url = []) { $icon = $value == true ? 'check' : 'times'; $contextual = $value == true ? 'success' : 'danger'; return $this->label('', $contextual, ['icon' => $icon]); }
[ "public", "function", "status", "(", "$", "value", ",", "$", "url", "=", "[", "]", ")", "{", "$", "icon", "=", "$", "value", "==", "true", "?", "'check'", ":", "'times'", ";", "$", "contextual", "=", "$", "value", "==", "true", "?", "'success'", ":", "'danger'", ";", "return", "$", "this", "->", "label", "(", "''", ",", "$", "contextual", ",", "[", "'icon'", "=>", "$", "icon", "]", ")", ";", "}" ]
Returns a well formatted check. Used special for booleans @param string $value @param array $url @return string
[ "Returns", "a", "well", "formatted", "check", ".", "Used", "special", "for", "booleans" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L333-L338
1,343
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper.icon
public function icon($type, $text = '', array $options = []) { $icon = $this->iconPrefix; $class = "$icon $icon-$type"; if (isset($options['class']) && !empty($class)) { $options['class'] = $class . ' ' . $options['class']; } else { $options['class'] = $class; } $tag = parent::tag('i', '', $options); return trim($tag . ' ' . $text); }
php
public function icon($type, $text = '', array $options = []) { $icon = $this->iconPrefix; $class = "$icon $icon-$type"; if (isset($options['class']) && !empty($class)) { $options['class'] = $class . ' ' . $options['class']; } else { $options['class'] = $class; } $tag = parent::tag('i', '', $options); return trim($tag . ' ' . $text); }
[ "public", "function", "icon", "(", "$", "type", ",", "$", "text", "=", "''", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "icon", "=", "$", "this", "->", "iconPrefix", ";", "$", "class", "=", "\"$icon $icon-$type\"", ";", "if", "(", "isset", "(", "$", "options", "[", "'class'", "]", ")", "&&", "!", "empty", "(", "$", "class", ")", ")", "{", "$", "options", "[", "'class'", "]", "=", "$", "class", ".", "' '", ".", "$", "options", "[", "'class'", "]", ";", "}", "else", "{", "$", "options", "[", "'class'", "]", "=", "$", "class", ";", "}", "$", "tag", "=", "parent", "::", "tag", "(", "'i'", ",", "''", ",", "$", "options", ")", ";", "return", "trim", "(", "$", "tag", ".", "' '", ".", "$", "text", ")", ";", "}" ]
Returns an icon element followed by a text @example `<i class="fa fa-search"></i> Text` @param string $type @param string $text @param array $options @return string
[ "Returns", "an", "icon", "element", "followed", "by", "a", "text" ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L349-L361
1,344
cakeoven/CakeTwitterBootstrap
View/Helper/BootstrapHtmlHelper.php
BootstrapHtmlHelper._icon
protected function _icon($title, array $options = []) { if (empty($options) || !isset($options['icon'])) { return $title; } $options = $options['icon']; if (is_array($options)) { if (!isset($options['class']) || empty($options['class'])) { return $title; } } if (is_string($options)) { if (empty($options)) { return $title; } $icon = $this->iconPrefix; $options = ["class" => "$icon $icon-$options"]; } $tag = parent::tag('i', '', $options); return trim($tag . ' ' . $title); }
php
protected function _icon($title, array $options = []) { if (empty($options) || !isset($options['icon'])) { return $title; } $options = $options['icon']; if (is_array($options)) { if (!isset($options['class']) || empty($options['class'])) { return $title; } } if (is_string($options)) { if (empty($options)) { return $title; } $icon = $this->iconPrefix; $options = ["class" => "$icon $icon-$options"]; } $tag = parent::tag('i', '', $options); return trim($tag . ' ' . $title); }
[ "protected", "function", "_icon", "(", "$", "title", ",", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "options", ")", "||", "!", "isset", "(", "$", "options", "[", "'icon'", "]", ")", ")", "{", "return", "$", "title", ";", "}", "$", "options", "=", "$", "options", "[", "'icon'", "]", ";", "if", "(", "is_array", "(", "$", "options", ")", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'class'", "]", ")", "||", "empty", "(", "$", "options", "[", "'class'", "]", ")", ")", "{", "return", "$", "title", ";", "}", "}", "if", "(", "is_string", "(", "$", "options", ")", ")", "{", "if", "(", "empty", "(", "$", "options", ")", ")", "{", "return", "$", "title", ";", "}", "$", "icon", "=", "$", "this", "->", "iconPrefix", ";", "$", "options", "=", "[", "\"class\"", "=>", "\"$icon $icon-$options\"", "]", ";", "}", "$", "tag", "=", "parent", "::", "tag", "(", "'i'", ",", "''", ",", "$", "options", ")", ";", "return", "trim", "(", "$", "tag", ".", "' '", ".", "$", "title", ")", ";", "}" ]
Returns an icon element followed by a text. This function is used for generating an icon for internal functions inside this helper. @param string $title @param string|array $options @return string todo We need to refactor this function in order to load an array of icon class with no prefix on the class
[ "Returns", "an", "icon", "element", "followed", "by", "a", "text", ".", "This", "function", "is", "used", "for", "generating", "an", "icon", "for", "internal", "functions", "inside", "this", "helper", "." ]
99b7304a9c8715cb9c989afd5d57dc24d7f95b43
https://github.com/cakeoven/CakeTwitterBootstrap/blob/99b7304a9c8715cb9c989afd5d57dc24d7f95b43/View/Helper/BootstrapHtmlHelper.php#L373-L394
1,345
synapsestudios/synapse-base
src/Synapse/Mapper/InserterTrait.php
InserterTrait.insertRow
protected function insertRow(AbstractEntity $entity) { $values = $entity->getDbValues(); $columns = array_keys($values); if ($this->autoIncrementColumn && ! array_key_exists($this->autoIncrementColumn, $values)) { throw new LogicException('auto_increment column ' . $this->autoIncrementColumn . ' not found'); } $query = $this->getSqlObject() ->insert() ->columns($columns) ->values($values); $statement = $this->getSqlObject()->prepareStatementForSqlObject($query); $result = $statement->execute(); if ($this->autoIncrementColumn && ! $values[$this->autoIncrementColumn]) { $entity->exchangeArray([ $this->autoIncrementColumn => $result->getGeneratedValue() ]); } }
php
protected function insertRow(AbstractEntity $entity) { $values = $entity->getDbValues(); $columns = array_keys($values); if ($this->autoIncrementColumn && ! array_key_exists($this->autoIncrementColumn, $values)) { throw new LogicException('auto_increment column ' . $this->autoIncrementColumn . ' not found'); } $query = $this->getSqlObject() ->insert() ->columns($columns) ->values($values); $statement = $this->getSqlObject()->prepareStatementForSqlObject($query); $result = $statement->execute(); if ($this->autoIncrementColumn && ! $values[$this->autoIncrementColumn]) { $entity->exchangeArray([ $this->autoIncrementColumn => $result->getGeneratedValue() ]); } }
[ "protected", "function", "insertRow", "(", "AbstractEntity", "$", "entity", ")", "{", "$", "values", "=", "$", "entity", "->", "getDbValues", "(", ")", ";", "$", "columns", "=", "array_keys", "(", "$", "values", ")", ";", "if", "(", "$", "this", "->", "autoIncrementColumn", "&&", "!", "array_key_exists", "(", "$", "this", "->", "autoIncrementColumn", ",", "$", "values", ")", ")", "{", "throw", "new", "LogicException", "(", "'auto_increment column '", ".", "$", "this", "->", "autoIncrementColumn", ".", "' not found'", ")", ";", "}", "$", "query", "=", "$", "this", "->", "getSqlObject", "(", ")", "->", "insert", "(", ")", "->", "columns", "(", "$", "columns", ")", "->", "values", "(", "$", "values", ")", ";", "$", "statement", "=", "$", "this", "->", "getSqlObject", "(", ")", "->", "prepareStatementForSqlObject", "(", "$", "query", ")", ";", "$", "result", "=", "$", "statement", "->", "execute", "(", ")", ";", "if", "(", "$", "this", "->", "autoIncrementColumn", "&&", "!", "$", "values", "[", "$", "this", "->", "autoIncrementColumn", "]", ")", "{", "$", "entity", "->", "exchangeArray", "(", "[", "$", "this", "->", "autoIncrementColumn", "=>", "$", "result", "->", "getGeneratedValue", "(", ")", "]", ")", ";", "}", "}" ]
Insert an entity's DB row using the given values. Set the ID on the entity from the query result. @param AbstractEntity $entity
[ "Insert", "an", "entity", "s", "DB", "row", "using", "the", "given", "values", ".", "Set", "the", "ID", "on", "the", "entity", "from", "the", "query", "result", "." ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Mapper/InserterTrait.php#L45-L67
1,346
calgamo/di
src/Compiler/Compiler.php
Compiler.compile
public function compile(CompilerConfig $config) : Compiler { $cache_dir = $config->getCacheDir(); if (!$cache_dir){ throw new CacheDirectoryConfigurationException($cache_dir); } // cehck cache dir $cache_dir = new File($cache_dir); if (!$cache_dir->exists() || !$cache_dir->isDirectory()){ throw new CacheDirectoryNotFoundException($cache_dir); } if (!$cache_dir->canWrite()){ throw new CacheDirectoryNotWritableException($cache_dir); } // check bootstrap $cache_filename = $config->getCacheFilename(); $bootstrap_file = new File($cache_filename . '.php', $cache_dir); if (!$bootstrap_file->exists()){ // compile bootstrap code $contents = $this->generateBootstrapCode($config); $bootstrap_file->putContents($contents); } return $this; }
php
public function compile(CompilerConfig $config) : Compiler { $cache_dir = $config->getCacheDir(); if (!$cache_dir){ throw new CacheDirectoryConfigurationException($cache_dir); } // cehck cache dir $cache_dir = new File($cache_dir); if (!$cache_dir->exists() || !$cache_dir->isDirectory()){ throw new CacheDirectoryNotFoundException($cache_dir); } if (!$cache_dir->canWrite()){ throw new CacheDirectoryNotWritableException($cache_dir); } // check bootstrap $cache_filename = $config->getCacheFilename(); $bootstrap_file = new File($cache_filename . '.php', $cache_dir); if (!$bootstrap_file->exists()){ // compile bootstrap code $contents = $this->generateBootstrapCode($config); $bootstrap_file->putContents($contents); } return $this; }
[ "public", "function", "compile", "(", "CompilerConfig", "$", "config", ")", ":", "Compiler", "{", "$", "cache_dir", "=", "$", "config", "->", "getCacheDir", "(", ")", ";", "if", "(", "!", "$", "cache_dir", ")", "{", "throw", "new", "CacheDirectoryConfigurationException", "(", "$", "cache_dir", ")", ";", "}", "// cehck cache dir", "$", "cache_dir", "=", "new", "File", "(", "$", "cache_dir", ")", ";", "if", "(", "!", "$", "cache_dir", "->", "exists", "(", ")", "||", "!", "$", "cache_dir", "->", "isDirectory", "(", ")", ")", "{", "throw", "new", "CacheDirectoryNotFoundException", "(", "$", "cache_dir", ")", ";", "}", "if", "(", "!", "$", "cache_dir", "->", "canWrite", "(", ")", ")", "{", "throw", "new", "CacheDirectoryNotWritableException", "(", "$", "cache_dir", ")", ";", "}", "// check bootstrap", "$", "cache_filename", "=", "$", "config", "->", "getCacheFilename", "(", ")", ";", "$", "bootstrap_file", "=", "new", "File", "(", "$", "cache_filename", ".", "'.php'", ",", "$", "cache_dir", ")", ";", "if", "(", "!", "$", "bootstrap_file", "->", "exists", "(", ")", ")", "{", "// compile bootstrap code", "$", "contents", "=", "$", "this", "->", "generateBootstrapCode", "(", "$", "config", ")", ";", "$", "bootstrap_file", "->", "putContents", "(", "$", "contents", ")", ";", "}", "return", "$", "this", ";", "}" ]
Compile setup code @param CompilerConfig $config @return Compiler @throws CacheDirectoryConfigurationException @throws CacheDirectoryNotFoundException @throws CacheDirectoryNotWritableException @throws FileOutputException @throws SlotIdNotDefinedException @throws InvalidSlotRestrictionException @throws ComponentIdNotDefinedException @throws ComponentValueNotDefinedException @throws TypeCheckFunctionNotFoundException @throws ComponentValueTypeMismatchException @throws ComponentClassNameNotDefinedException @throws InvalidComponentTypeException @throws BootstrapTemplateFileNotFoundException @throws BootstrapTemplateFileNotReadableException @throws CompileErrorException
[ "Compile", "setup", "code" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L71-L100
1,347
calgamo/di
src/Compiler/Compiler.php
Compiler.constructor
private function constructor(string $class_name, array $params = null) { $this->state->category = CompilerState::CATEGORY_CONSTRUCTOR; $this->state->name = ''; $params_str = ''; if (is_array($params)){ $params_str = $this->decorateParamsForMethodCall($params); } return $class_name . '(' . $params_str . ')'; }
php
private function constructor(string $class_name, array $params = null) { $this->state->category = CompilerState::CATEGORY_CONSTRUCTOR; $this->state->name = ''; $params_str = ''; if (is_array($params)){ $params_str = $this->decorateParamsForMethodCall($params); } return $class_name . '(' . $params_str . ')'; }
[ "private", "function", "constructor", "(", "string", "$", "class_name", ",", "array", "$", "params", "=", "null", ")", "{", "$", "this", "->", "state", "->", "category", "=", "CompilerState", "::", "CATEGORY_CONSTRUCTOR", ";", "$", "this", "->", "state", "->", "name", "=", "''", ";", "$", "params_str", "=", "''", ";", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "params_str", "=", "$", "this", "->", "decorateParamsForMethodCall", "(", "$", "params", ")", ";", "}", "return", "$", "class_name", ".", "'('", ".", "$", "params_str", ".", "')'", ";", "}" ]
Make constructor code @param string $class_name @param array $params @return string @throws CompileErrorException
[ "Make", "constructor", "code" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L330-L339
1,348
calgamo/di
src/Compiler/Compiler.php
Compiler.methodCallList
private function methodCallList(array $method_injections) { $this->state->category = CompilerState::CATEGORY_METHOD; $ret = ''; foreach($method_injections as $injection){ $method_name = $injection['method'] ?? null; $params = $injection['params'] ?? null; $this->state->name = $method_name; $params_str = ''; if (is_array($params)){ $params_str = $this->decorateParamsForMethodCall($params); } $ret .= " \$component->{$method_name}(" . $params_str . ");\n"; } return $ret; }
php
private function methodCallList(array $method_injections) { $this->state->category = CompilerState::CATEGORY_METHOD; $ret = ''; foreach($method_injections as $injection){ $method_name = $injection['method'] ?? null; $params = $injection['params'] ?? null; $this->state->name = $method_name; $params_str = ''; if (is_array($params)){ $params_str = $this->decorateParamsForMethodCall($params); } $ret .= " \$component->{$method_name}(" . $params_str . ");\n"; } return $ret; }
[ "private", "function", "methodCallList", "(", "array", "$", "method_injections", ")", "{", "$", "this", "->", "state", "->", "category", "=", "CompilerState", "::", "CATEGORY_METHOD", ";", "$", "ret", "=", "''", ";", "foreach", "(", "$", "method_injections", "as", "$", "injection", ")", "{", "$", "method_name", "=", "$", "injection", "[", "'method'", "]", "??", "null", ";", "$", "params", "=", "$", "injection", "[", "'params'", "]", "??", "null", ";", "$", "this", "->", "state", "->", "name", "=", "$", "method_name", ";", "$", "params_str", "=", "''", ";", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "params_str", "=", "$", "this", "->", "decorateParamsForMethodCall", "(", "$", "params", ")", ";", "}", "$", "ret", ".=", "\" \\$component->{$method_name}(\"", ".", "$", "params_str", ".", "\");\\n\"", ";", "}", "return", "$", "ret", ";", "}" ]
Make method call code @param array $method_injections @return string @throws CompileErrorException
[ "Make", "method", "call", "code" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L350-L368
1,349
calgamo/di
src/Compiler/Compiler.php
Compiler.propertySetList
private function propertySetList(array $property_injections) { $this->state->category = CompilerState::CATEGORY_PROPERTY; $ret = ''; foreach($property_injections as $injection){ $property_name = $injection['property'] ?? null; $value = $injection['value'] ?? null; $this->state->name = $property_name; if (is_null($value)){ $value = 'null'; } elseif (is_string($value)){ $value = $this->decorateStringValue($value); } elseif (is_array($value)){ $value = $this->decorateArrayValue($value); } $ret .= " \$component->{$property_name} = {$value};\n"; } return $ret; }
php
private function propertySetList(array $property_injections) { $this->state->category = CompilerState::CATEGORY_PROPERTY; $ret = ''; foreach($property_injections as $injection){ $property_name = $injection['property'] ?? null; $value = $injection['value'] ?? null; $this->state->name = $property_name; if (is_null($value)){ $value = 'null'; } elseif (is_string($value)){ $value = $this->decorateStringValue($value); } elseif (is_array($value)){ $value = $this->decorateArrayValue($value); } $ret .= " \$component->{$property_name} = {$value};\n"; } return $ret; }
[ "private", "function", "propertySetList", "(", "array", "$", "property_injections", ")", "{", "$", "this", "->", "state", "->", "category", "=", "CompilerState", "::", "CATEGORY_PROPERTY", ";", "$", "ret", "=", "''", ";", "foreach", "(", "$", "property_injections", "as", "$", "injection", ")", "{", "$", "property_name", "=", "$", "injection", "[", "'property'", "]", "??", "null", ";", "$", "value", "=", "$", "injection", "[", "'value'", "]", "??", "null", ";", "$", "this", "->", "state", "->", "name", "=", "$", "property_name", ";", "if", "(", "is_null", "(", "$", "value", ")", ")", "{", "$", "value", "=", "'null'", ";", "}", "elseif", "(", "is_string", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "decorateStringValue", "(", "$", "value", ")", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "value", "=", "$", "this", "->", "decorateArrayValue", "(", "$", "value", ")", ";", "}", "$", "ret", ".=", "\" \\$component->{$property_name} = {$value};\\n\"", ";", "}", "return", "$", "ret", ";", "}" ]
Make property set code @param array $property_injections @return string @throws CompileErrorException
[ "Make", "property", "set", "code" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L379-L402
1,350
calgamo/di
src/Compiler/Compiler.php
Compiler.findPropertyInjections
private function findPropertyInjections(array $injections) { $ret = []; if (is_array($injections)) { foreach ($injections as $injection) { if (!isset($injection['property'])){ continue; } $ret[] = $injection; } } return $ret; }
php
private function findPropertyInjections(array $injections) { $ret = []; if (is_array($injections)) { foreach ($injections as $injection) { if (!isset($injection['property'])){ continue; } $ret[] = $injection; } } return $ret; }
[ "private", "function", "findPropertyInjections", "(", "array", "$", "injections", ")", "{", "$", "ret", "=", "[", "]", ";", "if", "(", "is_array", "(", "$", "injections", ")", ")", "{", "foreach", "(", "$", "injections", "as", "$", "injection", ")", "{", "if", "(", "!", "isset", "(", "$", "injection", "[", "'property'", "]", ")", ")", "{", "continue", ";", "}", "$", "ret", "[", "]", "=", "$", "injection", ";", "}", "}", "return", "$", "ret", ";", "}" ]
find property injection @param array $injections @return array
[ "find", "property", "injection" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L482-L494
1,351
calgamo/di
src/Compiler/Compiler.php
Compiler.decorateParamsForMethodCall
private function decorateParamsForMethodCall(array $params) : string { $params_out = []; foreach($params as $param) { $params_out[] = $this->decorateValue($param); } return implode(',',$params_out); }
php
private function decorateParamsForMethodCall(array $params) : string { $params_out = []; foreach($params as $param) { $params_out[] = $this->decorateValue($param); } return implode(',',$params_out); }
[ "private", "function", "decorateParamsForMethodCall", "(", "array", "$", "params", ")", ":", "string", "{", "$", "params_out", "=", "[", "]", ";", "foreach", "(", "$", "params", "as", "$", "param", ")", "{", "$", "params_out", "[", "]", "=", "$", "this", "->", "decorateValue", "(", "$", "param", ")", ";", "}", "return", "implode", "(", "','", ",", "$", "params_out", ")", ";", "}" ]
Modify param array for method call @param array $params @return string @throws CompileErrorException
[ "Modify", "param", "array", "for", "method", "call" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L505-L512
1,352
calgamo/di
src/Compiler/Compiler.php
Compiler.decorateValue
private function decorateValue($value) : string { $ret = 'null'; switch(gettype($value)){ case 'string': $ret = $this->decorateStringValue($value); break; case 'integer': case 'double': $ret = $value; break; case 'boolean': $ret = $value ? 'true' : 'false'; break; case 'array': $ret = $this->decorateArrayValue($value); break; } return $ret; }
php
private function decorateValue($value) : string { $ret = 'null'; switch(gettype($value)){ case 'string': $ret = $this->decorateStringValue($value); break; case 'integer': case 'double': $ret = $value; break; case 'boolean': $ret = $value ? 'true' : 'false'; break; case 'array': $ret = $this->decorateArrayValue($value); break; } return $ret; }
[ "private", "function", "decorateValue", "(", "$", "value", ")", ":", "string", "{", "$", "ret", "=", "'null'", ";", "switch", "(", "gettype", "(", "$", "value", ")", ")", "{", "case", "'string'", ":", "$", "ret", "=", "$", "this", "->", "decorateStringValue", "(", "$", "value", ")", ";", "break", ";", "case", "'integer'", ":", "case", "'double'", ":", "$", "ret", "=", "$", "value", ";", "break", ";", "case", "'boolean'", ":", "$", "ret", "=", "$", "value", "?", "'true'", ":", "'false'", ";", "break", ";", "case", "'array'", ":", "$", "ret", "=", "$", "this", "->", "decorateArrayValue", "(", "$", "value", ")", ";", "break", ";", "}", "return", "$", "ret", ";", "}" ]
Modify value for function call or setting property @param mixed $value @return string @throws CompileErrorException
[ "Modify", "value", "for", "function", "call", "or", "setting", "property" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L546-L565
1,353
calgamo/di
src/Compiler/Compiler.php
Compiler.decorateStringValue
private function decorateStringValue(string $value) : string { if ($value === '@this'){ return "\$c"; } if (preg_match('/^@id:(.*)$/s',$value,$matches)){ $id = trim($matches[1]); return "\$c['" . self::escapeSingleQuote($id) . "']"; } if (preg_match('/^@resolve:(.*)$/s',$value,$matches)){ $target = trim($matches[1]); return "\$c[\$c->resolve('" . self::escapeSingleQuote($target) . "')]"; } if (preg_match('/^@func:(.*)$/s',$value,$matches)){ $func = trim($matches[1]); $this->validateCallable($func); return $func; } if (preg_match('/^@int:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateInteger($value); return $this->decorateValue($value); } if (preg_match('/^@float:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateFloat($value); return $this->decorateValue($value); } if (preg_match('/^@bool:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateBool($value); return $this->decorateValue($value); } if (preg_match('/^@json:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateJson($value); return $this->decorateValue($value); } if (preg_match('/^@env:(.*)$/s',$value,$matches)){ $id = trim($matches[1]); return "(\$_ENV['" . self::escapeSingleQuote($id) . "'] ?? null)"; } return "'" . self::escapeSingleQuote($value) . "'"; }
php
private function decorateStringValue(string $value) : string { if ($value === '@this'){ return "\$c"; } if (preg_match('/^@id:(.*)$/s',$value,$matches)){ $id = trim($matches[1]); return "\$c['" . self::escapeSingleQuote($id) . "']"; } if (preg_match('/^@resolve:(.*)$/s',$value,$matches)){ $target = trim($matches[1]); return "\$c[\$c->resolve('" . self::escapeSingleQuote($target) . "')]"; } if (preg_match('/^@func:(.*)$/s',$value,$matches)){ $func = trim($matches[1]); $this->validateCallable($func); return $func; } if (preg_match('/^@int:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateInteger($value); return $this->decorateValue($value); } if (preg_match('/^@float:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateFloat($value); return $this->decorateValue($value); } if (preg_match('/^@bool:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateBool($value); return $this->decorateValue($value); } if (preg_match('/^@json:(.*)$/s',$value,$matches)){ $value = trim($matches[1]); $value = $this->validateJson($value); return $this->decorateValue($value); } if (preg_match('/^@env:(.*)$/s',$value,$matches)){ $id = trim($matches[1]); return "(\$_ENV['" . self::escapeSingleQuote($id) . "'] ?? null)"; } return "'" . self::escapeSingleQuote($value) . "'"; }
[ "private", "function", "decorateStringValue", "(", "string", "$", "value", ")", ":", "string", "{", "if", "(", "$", "value", "===", "'@this'", ")", "{", "return", "\"\\$c\"", ";", "}", "if", "(", "preg_match", "(", "'/^@id:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "id", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "return", "\"\\$c['\"", ".", "self", "::", "escapeSingleQuote", "(", "$", "id", ")", ".", "\"']\"", ";", "}", "if", "(", "preg_match", "(", "'/^@resolve:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "target", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "return", "\"\\$c[\\$c->resolve('\"", ".", "self", "::", "escapeSingleQuote", "(", "$", "target", ")", ".", "\"')]\"", ";", "}", "if", "(", "preg_match", "(", "'/^@func:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "func", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "this", "->", "validateCallable", "(", "$", "func", ")", ";", "return", "$", "func", ";", "}", "if", "(", "preg_match", "(", "'/^@int:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "value", "=", "$", "this", "->", "validateInteger", "(", "$", "value", ")", ";", "return", "$", "this", "->", "decorateValue", "(", "$", "value", ")", ";", "}", "if", "(", "preg_match", "(", "'/^@float:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "value", "=", "$", "this", "->", "validateFloat", "(", "$", "value", ")", ";", "return", "$", "this", "->", "decorateValue", "(", "$", "value", ")", ";", "}", "if", "(", "preg_match", "(", "'/^@bool:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "value", "=", "$", "this", "->", "validateBool", "(", "$", "value", ")", ";", "return", "$", "this", "->", "decorateValue", "(", "$", "value", ")", ";", "}", "if", "(", "preg_match", "(", "'/^@json:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "value", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "$", "value", "=", "$", "this", "->", "validateJson", "(", "$", "value", ")", ";", "return", "$", "this", "->", "decorateValue", "(", "$", "value", ")", ";", "}", "if", "(", "preg_match", "(", "'/^@env:(.*)$/s'", ",", "$", "value", ",", "$", "matches", ")", ")", "{", "$", "id", "=", "trim", "(", "$", "matches", "[", "1", "]", ")", ";", "return", "\"(\\$_ENV['\"", ".", "self", "::", "escapeSingleQuote", "(", "$", "id", ")", ".", "\"'] ?? null)\"", ";", "}", "return", "\"'\"", ".", "self", "::", "escapeSingleQuote", "(", "$", "value", ")", ".", "\"'\"", ";", "}" ]
Modify string value for function call or setting property @param string $value @return string @throws CompileErrorException
[ "Modify", "string", "value", "for", "function", "call", "or", "setting", "property" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L576-L628
1,354
calgamo/di
src/Compiler/Compiler.php
Compiler.validateCallable
private function validateCallable(string $str) { ob_start(); try{ $_ = @eval('return '.$str.';'); if (!is_callable($_)){ throw new ValidateCallableException($str); } } catch(\Throwable $e){ ob_end_clean(); throw new CompileErrorException($e->getMessage(), $this->state); } ob_end_clean(); }
php
private function validateCallable(string $str) { ob_start(); try{ $_ = @eval('return '.$str.';'); if (!is_callable($_)){ throw new ValidateCallableException($str); } } catch(\Throwable $e){ ob_end_clean(); throw new CompileErrorException($e->getMessage(), $this->state); } ob_end_clean(); }
[ "private", "function", "validateCallable", "(", "string", "$", "str", ")", "{", "ob_start", "(", ")", ";", "try", "{", "$", "_", "=", "@", "eval", "(", "'return '", ".", "$", "str", ".", "';'", ")", ";", "if", "(", "!", "is_callable", "(", "$", "_", ")", ")", "{", "throw", "new", "ValidateCallableException", "(", "$", "str", ")", ";", "}", "}", "catch", "(", "\\", "Throwable", "$", "e", ")", "{", "ob_end_clean", "(", ")", ";", "throw", "new", "CompileErrorException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "this", "->", "state", ")", ";", "}", "ob_end_clean", "(", ")", ";", "}" ]
Validate if expression is callable @param string $str @throws CompileErrorException
[ "Validate", "if", "expression", "is", "callable" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L649-L663
1,355
calgamo/di
src/Compiler/Compiler.php
Compiler.validateInteger
private function validateInteger(string $str) : int { $ret = filter_var($str,FILTER_VALIDATE_INT); if ($ret === false){ throw new CompileErrorException('invalid integer value', $this->state); } return $ret; }
php
private function validateInteger(string $str) : int { $ret = filter_var($str,FILTER_VALIDATE_INT); if ($ret === false){ throw new CompileErrorException('invalid integer value', $this->state); } return $ret; }
[ "private", "function", "validateInteger", "(", "string", "$", "str", ")", ":", "int", "{", "$", "ret", "=", "filter_var", "(", "$", "str", ",", "FILTER_VALIDATE_INT", ")", ";", "if", "(", "$", "ret", "===", "false", ")", "{", "throw", "new", "CompileErrorException", "(", "'invalid integer value'", ",", "$", "this", "->", "state", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Validate if expression is integer value @param string $str @return int @throws CompileErrorException
[ "Validate", "if", "expression", "is", "integer", "value" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L674-L681
1,356
calgamo/di
src/Compiler/Compiler.php
Compiler.validateJson
private function validateJson(string $str) : array { $ret = json_decode($str,true); if ($ret === null){ throw new CompileErrorException('invalid json value:' . json_last_error_msg(), $this->state); } if (!is_array($ret)){ throw new CompileErrorException('@json immediate must be array value.', $this->state); } return $ret; }
php
private function validateJson(string $str) : array { $ret = json_decode($str,true); if ($ret === null){ throw new CompileErrorException('invalid json value:' . json_last_error_msg(), $this->state); } if (!is_array($ret)){ throw new CompileErrorException('@json immediate must be array value.', $this->state); } return $ret; }
[ "private", "function", "validateJson", "(", "string", "$", "str", ")", ":", "array", "{", "$", "ret", "=", "json_decode", "(", "$", "str", ",", "true", ")", ";", "if", "(", "$", "ret", "===", "null", ")", "{", "throw", "new", "CompileErrorException", "(", "'invalid json value:'", ".", "json_last_error_msg", "(", ")", ",", "$", "this", "->", "state", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "ret", ")", ")", "{", "throw", "new", "CompileErrorException", "(", "'@json immediate must be array value.'", ",", "$", "this", "->", "state", ")", ";", "}", "return", "$", "ret", ";", "}" ]
Validate if expression is json value @param string $str @return array @throws CompileErrorException
[ "Validate", "if", "expression", "is", "json", "value" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L728-L738
1,357
calgamo/di
src/Compiler/Compiler.php
Compiler.findSlotById
private function findSlotById(string $id, array $slots) { $slot = null; foreach($slots as $s){ $slot_id = $s['id'] ?? null; if ($slot_id == $id){ $slot = $s; break; } } return $slot; }
php
private function findSlotById(string $id, array $slots) { $slot = null; foreach($slots as $s){ $slot_id = $s['id'] ?? null; if ($slot_id == $id){ $slot = $s; break; } } return $slot; }
[ "private", "function", "findSlotById", "(", "string", "$", "id", ",", "array", "$", "slots", ")", "{", "$", "slot", "=", "null", ";", "foreach", "(", "$", "slots", "as", "$", "s", ")", "{", "$", "slot_id", "=", "$", "s", "[", "'id'", "]", "??", "null", ";", "if", "(", "$", "slot_id", "==", "$", "id", ")", "{", "$", "slot", "=", "$", "s", ";", "break", ";", "}", "}", "return", "$", "slot", ";", "}" ]
Find slot by id @param string $id @param array $slots @return array|null
[ "Find", "slot", "by", "id" ]
d7630628a1d6f385839a9d0a8de41aadbea657a9
https://github.com/calgamo/di/blob/d7630628a1d6f385839a9d0a8de41aadbea657a9/src/Compiler/Compiler.php#L748-L759
1,358
infusephp/rest-api
src/Serializer/ModelSerializer.php
ModelSerializer.toArray
public function toArray(Model $model) { // start with the base representation of the model if (method_exists($model, 'withoutArrayHook')) { $model->withoutArrayHook(); } $result = $model->toArray(); // apply namespacing to excluded properties $namedExc = []; foreach ($this->exclude as $k) { array_set($namedExc, $k, true); } // apply namespacing to included properties $namedInc = []; foreach ($this->include as $k) { array_set($namedInc, $k, true); } // apply namespacing to expanded properties $namedExp = []; foreach ($this->expand as $k) { array_set($namedExp, $k, true); } // remove excluded properties foreach (array_keys($result) as $k) { if (isset($namedExc[$k]) && !is_array($namedExc[$k])) { unset($result[$k]); } } // add included properties foreach (array_keys($namedInc) as $k) { if (!isset($result[$k]) && isset($namedInc[$k])) { $result[$k] = $model->$k; if ($result[$k] instanceof Model) { $subExc = array_value($namedExc, $k); $subInc = array_value($namedInc, $k); $subExp = array_value($namedExp, $k); // convert exclude, include, and expand into dot notation // then take the keys for a flattened dot notation $flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : []; $flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : []; $flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : []; $serializer = new self($this->request); $serializer->setExclude($flatExc) ->setInclude($flatInc) ->setExpand($flatExp); $result[$k] = $serializer->toArray($result[$k]); } } } // expand any relational model properties $result = $this->expand($model, $result, $namedExc, $namedInc, $namedExp); // apply hooks, if available if (method_exists($model, 'toArrayHook')) { $model->toArrayHook($result, $namedExc, $namedInc, $namedExp); } // order the properties array by name for consistency // since it is constructed in a random order ksort($result); return $result; }
php
public function toArray(Model $model) { // start with the base representation of the model if (method_exists($model, 'withoutArrayHook')) { $model->withoutArrayHook(); } $result = $model->toArray(); // apply namespacing to excluded properties $namedExc = []; foreach ($this->exclude as $k) { array_set($namedExc, $k, true); } // apply namespacing to included properties $namedInc = []; foreach ($this->include as $k) { array_set($namedInc, $k, true); } // apply namespacing to expanded properties $namedExp = []; foreach ($this->expand as $k) { array_set($namedExp, $k, true); } // remove excluded properties foreach (array_keys($result) as $k) { if (isset($namedExc[$k]) && !is_array($namedExc[$k])) { unset($result[$k]); } } // add included properties foreach (array_keys($namedInc) as $k) { if (!isset($result[$k]) && isset($namedInc[$k])) { $result[$k] = $model->$k; if ($result[$k] instanceof Model) { $subExc = array_value($namedExc, $k); $subInc = array_value($namedInc, $k); $subExp = array_value($namedExp, $k); // convert exclude, include, and expand into dot notation // then take the keys for a flattened dot notation $flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : []; $flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : []; $flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : []; $serializer = new self($this->request); $serializer->setExclude($flatExc) ->setInclude($flatInc) ->setExpand($flatExp); $result[$k] = $serializer->toArray($result[$k]); } } } // expand any relational model properties $result = $this->expand($model, $result, $namedExc, $namedInc, $namedExp); // apply hooks, if available if (method_exists($model, 'toArrayHook')) { $model->toArrayHook($result, $namedExc, $namedInc, $namedExp); } // order the properties array by name for consistency // since it is constructed in a random order ksort($result); return $result; }
[ "public", "function", "toArray", "(", "Model", "$", "model", ")", "{", "// start with the base representation of the model", "if", "(", "method_exists", "(", "$", "model", ",", "'withoutArrayHook'", ")", ")", "{", "$", "model", "->", "withoutArrayHook", "(", ")", ";", "}", "$", "result", "=", "$", "model", "->", "toArray", "(", ")", ";", "// apply namespacing to excluded properties", "$", "namedExc", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "exclude", "as", "$", "k", ")", "{", "array_set", "(", "$", "namedExc", ",", "$", "k", ",", "true", ")", ";", "}", "// apply namespacing to included properties", "$", "namedInc", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "include", "as", "$", "k", ")", "{", "array_set", "(", "$", "namedInc", ",", "$", "k", ",", "true", ")", ";", "}", "// apply namespacing to expanded properties", "$", "namedExp", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "expand", "as", "$", "k", ")", "{", "array_set", "(", "$", "namedExp", ",", "$", "k", ",", "true", ")", ";", "}", "// remove excluded properties", "foreach", "(", "array_keys", "(", "$", "result", ")", "as", "$", "k", ")", "{", "if", "(", "isset", "(", "$", "namedExc", "[", "$", "k", "]", ")", "&&", "!", "is_array", "(", "$", "namedExc", "[", "$", "k", "]", ")", ")", "{", "unset", "(", "$", "result", "[", "$", "k", "]", ")", ";", "}", "}", "// add included properties", "foreach", "(", "array_keys", "(", "$", "namedInc", ")", "as", "$", "k", ")", "{", "if", "(", "!", "isset", "(", "$", "result", "[", "$", "k", "]", ")", "&&", "isset", "(", "$", "namedInc", "[", "$", "k", "]", ")", ")", "{", "$", "result", "[", "$", "k", "]", "=", "$", "model", "->", "$", "k", ";", "if", "(", "$", "result", "[", "$", "k", "]", "instanceof", "Model", ")", "{", "$", "subExc", "=", "array_value", "(", "$", "namedExc", ",", "$", "k", ")", ";", "$", "subInc", "=", "array_value", "(", "$", "namedInc", ",", "$", "k", ")", ";", "$", "subExp", "=", "array_value", "(", "$", "namedExp", ",", "$", "k", ")", ";", "// convert exclude, include, and expand into dot notation", "// then take the keys for a flattened dot notation", "$", "flatExc", "=", "is_array", "(", "$", "subExc", ")", "?", "array_keys", "(", "array_dot", "(", "$", "subExc", ")", ")", ":", "[", "]", ";", "$", "flatInc", "=", "is_array", "(", "$", "subInc", ")", "?", "array_keys", "(", "array_dot", "(", "$", "subInc", ")", ")", ":", "[", "]", ";", "$", "flatExp", "=", "is_array", "(", "$", "subExp", ")", "?", "array_keys", "(", "array_dot", "(", "$", "subExp", ")", ")", ":", "[", "]", ";", "$", "serializer", "=", "new", "self", "(", "$", "this", "->", "request", ")", ";", "$", "serializer", "->", "setExclude", "(", "$", "flatExc", ")", "->", "setInclude", "(", "$", "flatInc", ")", "->", "setExpand", "(", "$", "flatExp", ")", ";", "$", "result", "[", "$", "k", "]", "=", "$", "serializer", "->", "toArray", "(", "$", "result", "[", "$", "k", "]", ")", ";", "}", "}", "}", "// expand any relational model properties", "$", "result", "=", "$", "this", "->", "expand", "(", "$", "model", ",", "$", "result", ",", "$", "namedExc", ",", "$", "namedInc", ",", "$", "namedExp", ")", ";", "// apply hooks, if available", "if", "(", "method_exists", "(", "$", "model", ",", "'toArrayHook'", ")", ")", "{", "$", "model", "->", "toArrayHook", "(", "$", "result", ",", "$", "namedExc", ",", "$", "namedInc", ",", "$", "namedExp", ")", ";", "}", "// order the properties array by name for consistency", "// since it is constructed in a random order", "ksort", "(", "$", "result", ")", ";", "return", "$", "result", ";", "}" ]
Serializes a model to an array. @param Model $model model to be serialized @return array properties
[ "Serializes", "a", "model", "to", "an", "array", "." ]
3a02152048ea38ec5f0adaed3f10a17730086ec7
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Serializer/ModelSerializer.php#L148-L219
1,359
infusephp/rest-api
src/Serializer/ModelSerializer.php
ModelSerializer.expand
private function expand(Model $model, array $result, array $namedExc, array $namedInc, array $namedExp) { foreach ($namedExp as $k => $subExp) { $value = array_value($result, $k); if (!$this->isExpandable($model, $k, $value)) { continue; } $subExc = array_value($namedExc, $k); $subInc = array_value($namedInc, $k); // convert exclude, include, and expand into dot notation // then take the keys for a flattened dot notation $flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : []; $flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : []; $flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : []; $relation = $model->relation($k); $serializer = new self($this->request); $serializer->setExclude($flatExc) ->setInclude($flatInc) ->setExpand($flatExp); if ($relation instanceof Model) { $result[$k] = $serializer->toArray($relation); } else { $result[$k] = $relation; } } return $result; }
php
private function expand(Model $model, array $result, array $namedExc, array $namedInc, array $namedExp) { foreach ($namedExp as $k => $subExp) { $value = array_value($result, $k); if (!$this->isExpandable($model, $k, $value)) { continue; } $subExc = array_value($namedExc, $k); $subInc = array_value($namedInc, $k); // convert exclude, include, and expand into dot notation // then take the keys for a flattened dot notation $flatExc = is_array($subExc) ? array_keys(array_dot($subExc)) : []; $flatInc = is_array($subInc) ? array_keys(array_dot($subInc)) : []; $flatExp = is_array($subExp) ? array_keys(array_dot($subExp)) : []; $relation = $model->relation($k); $serializer = new self($this->request); $serializer->setExclude($flatExc) ->setInclude($flatInc) ->setExpand($flatExp); if ($relation instanceof Model) { $result[$k] = $serializer->toArray($relation); } else { $result[$k] = $relation; } } return $result; }
[ "private", "function", "expand", "(", "Model", "$", "model", ",", "array", "$", "result", ",", "array", "$", "namedExc", ",", "array", "$", "namedInc", ",", "array", "$", "namedExp", ")", "{", "foreach", "(", "$", "namedExp", "as", "$", "k", "=>", "$", "subExp", ")", "{", "$", "value", "=", "array_value", "(", "$", "result", ",", "$", "k", ")", ";", "if", "(", "!", "$", "this", "->", "isExpandable", "(", "$", "model", ",", "$", "k", ",", "$", "value", ")", ")", "{", "continue", ";", "}", "$", "subExc", "=", "array_value", "(", "$", "namedExc", ",", "$", "k", ")", ";", "$", "subInc", "=", "array_value", "(", "$", "namedInc", ",", "$", "k", ")", ";", "// convert exclude, include, and expand into dot notation", "// then take the keys for a flattened dot notation", "$", "flatExc", "=", "is_array", "(", "$", "subExc", ")", "?", "array_keys", "(", "array_dot", "(", "$", "subExc", ")", ")", ":", "[", "]", ";", "$", "flatInc", "=", "is_array", "(", "$", "subInc", ")", "?", "array_keys", "(", "array_dot", "(", "$", "subInc", ")", ")", ":", "[", "]", ";", "$", "flatExp", "=", "is_array", "(", "$", "subExp", ")", "?", "array_keys", "(", "array_dot", "(", "$", "subExp", ")", ")", ":", "[", "]", ";", "$", "relation", "=", "$", "model", "->", "relation", "(", "$", "k", ")", ";", "$", "serializer", "=", "new", "self", "(", "$", "this", "->", "request", ")", ";", "$", "serializer", "->", "setExclude", "(", "$", "flatExc", ")", "->", "setInclude", "(", "$", "flatInc", ")", "->", "setExpand", "(", "$", "flatExp", ")", ";", "if", "(", "$", "relation", "instanceof", "Model", ")", "{", "$", "result", "[", "$", "k", "]", "=", "$", "serializer", "->", "toArray", "(", "$", "relation", ")", ";", "}", "else", "{", "$", "result", "[", "$", "k", "]", "=", "$", "relation", ";", "}", "}", "return", "$", "result", ";", "}" ]
Expands any relational properties within a result. @param array $model @param array $result @param array $namedExc @param array $namedInc @param array $namedExp @return array
[ "Expands", "any", "relational", "properties", "within", "a", "result", "." ]
3a02152048ea38ec5f0adaed3f10a17730086ec7
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Serializer/ModelSerializer.php#L232-L263
1,360
infusephp/rest-api
src/Serializer/ModelSerializer.php
ModelSerializer.isExpandable
private function isExpandable(Model $model, $k, $value) { // if the value is falsey then do not expand it // could be null, excluded, or not included if (!$value) { return false; } // if not a property or no relationship model specified // then do not expand $property = $model::getProperty($k); if (!$property || !isset($property['relation'])) { return false; } return true; }
php
private function isExpandable(Model $model, $k, $value) { // if the value is falsey then do not expand it // could be null, excluded, or not included if (!$value) { return false; } // if not a property or no relationship model specified // then do not expand $property = $model::getProperty($k); if (!$property || !isset($property['relation'])) { return false; } return true; }
[ "private", "function", "isExpandable", "(", "Model", "$", "model", ",", "$", "k", ",", "$", "value", ")", "{", "// if the value is falsey then do not expand it", "// could be null, excluded, or not included", "if", "(", "!", "$", "value", ")", "{", "return", "false", ";", "}", "// if not a property or no relationship model specified", "// then do not expand", "$", "property", "=", "$", "model", "::", "getProperty", "(", "$", "k", ")", ";", "if", "(", "!", "$", "property", "||", "!", "isset", "(", "$", "property", "[", "'relation'", "]", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Expands a model. @param Model $model @param string $k @param mixed $value @return bool
[ "Expands", "a", "model", "." ]
3a02152048ea38ec5f0adaed3f10a17730086ec7
https://github.com/infusephp/rest-api/blob/3a02152048ea38ec5f0adaed3f10a17730086ec7/src/Serializer/ModelSerializer.php#L274-L290
1,361
znframework/package-security
NastyCode.php
NastyCode.encode
public static function encode(String $string, $badWords = NULL, $changeChar = '[badchars]') : String { if( empty($badWords) ) { $secnc = Properties::$ncEncode; $badWords = $secnc['badChars']; $changeChar = $secnc['changeBadChars']; } $regex = Singleton::class('ZN\Regex'); if( ! is_array($badWords) ) { return $string = $regex->replace($badWords, $changeChar, $string, 'xi'); } $ch = ''; $i = 0; foreach( $badWords as $value ) { if( ! is_array($changeChar) ) { $ch = $changeChar; } else { if( isset($changeChar[$i]) ) { $ch = $changeChar[$i]; $i++; } } $string = $regex->replace($value, $ch, $string, 'xi'); } return $string; }
php
public static function encode(String $string, $badWords = NULL, $changeChar = '[badchars]') : String { if( empty($badWords) ) { $secnc = Properties::$ncEncode; $badWords = $secnc['badChars']; $changeChar = $secnc['changeBadChars']; } $regex = Singleton::class('ZN\Regex'); if( ! is_array($badWords) ) { return $string = $regex->replace($badWords, $changeChar, $string, 'xi'); } $ch = ''; $i = 0; foreach( $badWords as $value ) { if( ! is_array($changeChar) ) { $ch = $changeChar; } else { if( isset($changeChar[$i]) ) { $ch = $changeChar[$i]; $i++; } } $string = $regex->replace($value, $ch, $string, 'xi'); } return $string; }
[ "public", "static", "function", "encode", "(", "String", "$", "string", ",", "$", "badWords", "=", "NULL", ",", "$", "changeChar", "=", "'[badchars]'", ")", ":", "String", "{", "if", "(", "empty", "(", "$", "badWords", ")", ")", "{", "$", "secnc", "=", "Properties", "::", "$", "ncEncode", ";", "$", "badWords", "=", "$", "secnc", "[", "'badChars'", "]", ";", "$", "changeChar", "=", "$", "secnc", "[", "'changeBadChars'", "]", ";", "}", "$", "regex", "=", "Singleton", "::", "class", "(", "'ZN\\Regex'", ")", ";", "if", "(", "!", "is_array", "(", "$", "badWords", ")", ")", "{", "return", "$", "string", "=", "$", "regex", "->", "replace", "(", "$", "badWords", ",", "$", "changeChar", ",", "$", "string", ",", "'xi'", ")", ";", "}", "$", "ch", "=", "''", ";", "$", "i", "=", "0", ";", "foreach", "(", "$", "badWords", "as", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "changeChar", ")", ")", "{", "$", "ch", "=", "$", "changeChar", ";", "}", "else", "{", "if", "(", "isset", "(", "$", "changeChar", "[", "$", "i", "]", ")", ")", "{", "$", "ch", "=", "$", "changeChar", "[", "$", "i", "]", ";", "$", "i", "++", ";", "}", "}", "$", "string", "=", "$", "regex", "->", "replace", "(", "$", "value", ",", "$", "ch", ",", "$", "string", ",", "'xi'", ")", ";", "}", "return", "$", "string", ";", "}" ]
Encode Nasty Code @param string $string @param mixed $badWords = NULL @param mixed $changeChar = '[badchars]' @return string
[ "Encode", "Nasty", "Code" ]
dfced60e243ab9f52a1b5bbdb695bfc39b26cac0
https://github.com/znframework/package-security/blob/dfced60e243ab9f52a1b5bbdb695bfc39b26cac0/NastyCode.php#L25-L63
1,362
jhorlima/wp-mocabonita
src/tools/MbException.php
MbException.getData
public function getData() { if ($this->data instanceof Arrayable) { $this->data = $this->data->toArray(); } if (!is_array($this->data)) { $this->data = null; } return $this->data; }
php
public function getData() { if ($this->data instanceof Arrayable) { $this->data = $this->data->toArray(); } if (!is_array($this->data)) { $this->data = null; } return $this->data; }
[ "public", "function", "getData", "(", ")", "{", "if", "(", "$", "this", "->", "data", "instanceof", "Arrayable", ")", "{", "$", "this", "->", "data", "=", "$", "this", "->", "data", "->", "toArray", "(", ")", ";", "}", "if", "(", "!", "is_array", "(", "$", "this", "->", "data", ")", ")", "{", "$", "this", "->", "data", "=", "null", ";", "}", "return", "$", "this", "->", "data", ";", "}" ]
Get exception data @return array|string
[ "Get", "exception", "data" ]
a864b40d5452bc9b892f02a6bb28c02639f25fa8
https://github.com/jhorlima/wp-mocabonita/blob/a864b40d5452bc9b892f02a6bb28c02639f25fa8/src/tools/MbException.php#L45-L56
1,363
jivoo/core
src/Log/StreamHandler.php
StreamHandler.format
public static function format(array $record) { $seconds = (int) $record['time']; $millis = floor(($record['time'] - $seconds) * 1000); $timestamp = date('Y-m-d H:i:s', $seconds); $timestamp .= sprintf('.%03d ', $millis); $timestamp .= date('P'); $level = '[' . $record['level'] . ']'; $message = ''; $message .= Logger::interpolate($record['message'], $record['context']); if (isset($record['context']['file'])) { $message .= ' in ' . $record['context']['file']; } if (isset($record['context']['line'])) { $message .= ' on line ' . $record['context']['line']; } return $timestamp . ' ' . $level . ' ' . $message . PHP_EOL; }
php
public static function format(array $record) { $seconds = (int) $record['time']; $millis = floor(($record['time'] - $seconds) * 1000); $timestamp = date('Y-m-d H:i:s', $seconds); $timestamp .= sprintf('.%03d ', $millis); $timestamp .= date('P'); $level = '[' . $record['level'] . ']'; $message = ''; $message .= Logger::interpolate($record['message'], $record['context']); if (isset($record['context']['file'])) { $message .= ' in ' . $record['context']['file']; } if (isset($record['context']['line'])) { $message .= ' on line ' . $record['context']['line']; } return $timestamp . ' ' . $level . ' ' . $message . PHP_EOL; }
[ "public", "static", "function", "format", "(", "array", "$", "record", ")", "{", "$", "seconds", "=", "(", "int", ")", "$", "record", "[", "'time'", "]", ";", "$", "millis", "=", "floor", "(", "(", "$", "record", "[", "'time'", "]", "-", "$", "seconds", ")", "*", "1000", ")", ";", "$", "timestamp", "=", "date", "(", "'Y-m-d H:i:s'", ",", "$", "seconds", ")", ";", "$", "timestamp", ".=", "sprintf", "(", "'.%03d '", ",", "$", "millis", ")", ";", "$", "timestamp", ".=", "date", "(", "'P'", ")", ";", "$", "level", "=", "'['", ".", "$", "record", "[", "'level'", "]", ".", "']'", ";", "$", "message", "=", "''", ";", "$", "message", ".=", "Logger", "::", "interpolate", "(", "$", "record", "[", "'message'", "]", ",", "$", "record", "[", "'context'", "]", ")", ";", "if", "(", "isset", "(", "$", "record", "[", "'context'", "]", "[", "'file'", "]", ")", ")", "{", "$", "message", ".=", "' in '", ".", "$", "record", "[", "'context'", "]", "[", "'file'", "]", ";", "}", "if", "(", "isset", "(", "$", "record", "[", "'context'", "]", "[", "'line'", "]", ")", ")", "{", "$", "message", ".=", "' on line '", ".", "$", "record", "[", "'context'", "]", "[", "'line'", "]", ";", "}", "return", "$", "timestamp", ".", "' '", ".", "$", "level", ".", "' '", ".", "$", "message", ".", "PHP_EOL", ";", "}" ]
Format a log message for a log file. @param array $record Log message array. @return string Formatted log message followed by a line break.
[ "Format", "a", "log", "message", "for", "a", "log", "file", "." ]
4ef3445068f0ff9c0a6512cb741831a847013b76
https://github.com/jivoo/core/blob/4ef3445068f0ff9c0a6512cb741831a847013b76/src/Log/StreamHandler.php#L87-L104
1,364
SergioMadness/framework
framework/basic/db/QueryBuilder.php
QueryBuilder.select
public static function select() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\SelectBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\SelectBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
php
public static function select() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\SelectBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\SelectBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
[ "public", "static", "function", "select", "(", ")", "{", "$", "result", "=", "null", ";", "switch", "(", "static", "::", "getDriver", "(", ")", ")", "{", "case", "self", "::", "DRIVER_MYSQL", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "MySQL", "\\", "SelectBuilder", "(", ")", ";", "break", ";", "case", "self", "::", "DRIVER_PG", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "PostgreSQL", "\\", "SelectBuilder", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'Wrong query builder driver'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get query builder @return \pwf\components\querybuilder\interfaces\SelectBuilder @throws \Exception
[ "Get", "query", "builder" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/db/QueryBuilder.php#L50-L66
1,365
SergioMadness/framework
framework/basic/db/QueryBuilder.php
QueryBuilder.insert
public static function insert() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\InsertBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\InsertBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
php
public static function insert() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\InsertBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\InsertBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
[ "public", "static", "function", "insert", "(", ")", "{", "$", "result", "=", "null", ";", "switch", "(", "static", "::", "getDriver", "(", ")", ")", "{", "case", "self", "::", "DRIVER_MYSQL", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "MySQL", "\\", "InsertBuilder", "(", ")", ";", "break", ";", "case", "self", "::", "DRIVER_PG", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "PostgreSQL", "\\", "InsertBuilder", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'Wrong query builder driver'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get insert builder @return \pwf\components\querybuilder\interfaces\InsertBuilder @throws \Exception
[ "Get", "insert", "builder" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/db/QueryBuilder.php#L74-L90
1,366
SergioMadness/framework
framework/basic/db/QueryBuilder.php
QueryBuilder.update
public static function update() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\UpdateBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\UpdateBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
php
public static function update() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\UpdateBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\UpdateBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
[ "public", "static", "function", "update", "(", ")", "{", "$", "result", "=", "null", ";", "switch", "(", "static", "::", "getDriver", "(", ")", ")", "{", "case", "self", "::", "DRIVER_MYSQL", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "MySQL", "\\", "UpdateBuilder", "(", ")", ";", "break", ";", "case", "self", "::", "DRIVER_PG", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "PostgreSQL", "\\", "UpdateBuilder", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'Wrong query builder driver'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get update builder @return \pwf\components\querybuilder\interfaces\UpdateBuilder @throws \Exception
[ "Get", "update", "builder" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/db/QueryBuilder.php#L98-L114
1,367
SergioMadness/framework
framework/basic/db/QueryBuilder.php
QueryBuilder.delete
public static function delete() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\DeleteBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\DeleteBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
php
public static function delete() { $result = null; switch (static::getDriver()) { case self::DRIVER_MYSQL: $result = new \pwf\components\querybuilder\adapters\MySQL\DeleteBuilder(); break; case self::DRIVER_PG: $result = new \pwf\components\querybuilder\adapters\PostgreSQL\DeleteBuilder(); break; default: throw new \Exception('Wrong query builder driver'); } return $result; }
[ "public", "static", "function", "delete", "(", ")", "{", "$", "result", "=", "null", ";", "switch", "(", "static", "::", "getDriver", "(", ")", ")", "{", "case", "self", "::", "DRIVER_MYSQL", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "MySQL", "\\", "DeleteBuilder", "(", ")", ";", "break", ";", "case", "self", "::", "DRIVER_PG", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "PostgreSQL", "\\", "DeleteBuilder", "(", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "Exception", "(", "'Wrong query builder driver'", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get delete builder @return \pwf\components\querybuilder\interfaces\DeleteBuilder @throws \Exception
[ "Get", "delete", "builder" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/db/QueryBuilder.php#L122-L138
1,368
SergioMadness/framework
framework/basic/db/QueryBuilder.php
QueryBuilder.getConditionBuilder
public static function getConditionBuilder() { $result = null; switch (static::getDriver()) { default: $result = new \pwf\components\querybuilder\adapters\SQL\ConditionBuilder(); } return $result; }
php
public static function getConditionBuilder() { $result = null; switch (static::getDriver()) { default: $result = new \pwf\components\querybuilder\adapters\SQL\ConditionBuilder(); } return $result; }
[ "public", "static", "function", "getConditionBuilder", "(", ")", "{", "$", "result", "=", "null", ";", "switch", "(", "static", "::", "getDriver", "(", ")", ")", "{", "default", ":", "$", "result", "=", "new", "\\", "pwf", "\\", "components", "\\", "querybuilder", "\\", "adapters", "\\", "SQL", "\\", "ConditionBuilder", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Get condition builder @return \pwf\components\querybuilder\adapters\SQL\ConditionBuilder
[ "Get", "condition", "builder" ]
a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e
https://github.com/SergioMadness/framework/blob/a5038eb926a5038b9a331d0cb6a68d7fc3cf1f1e/framework/basic/db/QueryBuilder.php#L145-L155
1,369
liftkit/database
src/Connection/MsSql.php
MsSql.primaryKey
public function primaryKey ($tableName) { if (! isset($this->primaryKeys[$tableName])) { $sql = "SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name WHERE tc.CONSTRAINT_TYPE = 'Primary Key' AND tc.TABLE_NAME = " . $this->quote($tableName); $keyResult = $this->query($sql); $key = $keyResult->fetchRow(); $this->primaryKeys[$tableName] = $key['COLUMN_NAME']; } return $this->primaryKeys[$tableName]; }
php
public function primaryKey ($tableName) { if (! isset($this->primaryKeys[$tableName])) { $sql = "SELECT * FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name WHERE tc.CONSTRAINT_TYPE = 'Primary Key' AND tc.TABLE_NAME = " . $this->quote($tableName); $keyResult = $this->query($sql); $key = $keyResult->fetchRow(); $this->primaryKeys[$tableName] = $key['COLUMN_NAME']; } return $this->primaryKeys[$tableName]; }
[ "public", "function", "primaryKey", "(", "$", "tableName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "primaryKeys", "[", "$", "tableName", "]", ")", ")", "{", "$", "sql", "=", "\"SELECT *\n\t\t\t\t\t FROM INFORMATION_SCHEMA.TABLE_CONSTRAINTS tc\n\t\t\t\t\t JOIN INFORMATION_SCHEMA.CONSTRAINT_COLUMN_USAGE ccu ON tc.CONSTRAINT_NAME = ccu.Constraint_name\n\t\t\t\t\t WHERE tc.CONSTRAINT_TYPE = 'Primary Key'\n\t\t\t\t\t AND tc.TABLE_NAME = \"", ".", "$", "this", "->", "quote", "(", "$", "tableName", ")", ";", "$", "keyResult", "=", "$", "this", "->", "query", "(", "$", "sql", ")", ";", "$", "key", "=", "$", "keyResult", "->", "fetchRow", "(", ")", ";", "$", "this", "->", "primaryKeys", "[", "$", "tableName", "]", "=", "$", "key", "[", "'COLUMN_NAME'", "]", ";", "}", "return", "$", "this", "->", "primaryKeys", "[", "$", "tableName", "]", ";", "}" ]
primaryKey function. @access public @param string $tableName @return string
[ "primaryKey", "function", "." ]
752099ef8c71be0c187c9d6eea172b9afd723629
https://github.com/liftkit/database/blob/752099ef8c71be0c187c9d6eea172b9afd723629/src/Connection/MsSql.php#L82-L97
1,370
theD1360/ArrayHelper
src/Utilities/Arr.php
Arr.isEmpty
public function isEmpty($key = null) { if ($key === null) { return empty($this->data); } return empty($this->data[$key]); }
php
public function isEmpty($key = null) { if ($key === null) { return empty($this->data); } return empty($this->data[$key]); }
[ "public", "function", "isEmpty", "(", "$", "key", "=", "null", ")", "{", "if", "(", "$", "key", "===", "null", ")", "{", "return", "empty", "(", "$", "this", "->", "data", ")", ";", "}", "return", "empty", "(", "$", "this", "->", "data", "[", "$", "key", "]", ")", ";", "}" ]
is empty will return if the specified key is empty if no key provided it will check itself.
[ "is", "empty", "will", "return", "if", "the", "specified", "key", "is", "empty", "if", "no", "key", "provided", "it", "will", "check", "itself", "." ]
1b637bb56002de2b4c70f5359f009eebc4557a1f
https://github.com/theD1360/ArrayHelper/blob/1b637bb56002de2b4c70f5359f009eebc4557a1f/src/Utilities/Arr.php#L82-L88
1,371
theD1360/ArrayHelper
src/Utilities/Arr.php
Arr.merge
public function merge($arr = []) { $newData = array_merge($this->toArray(), $arr); return $this->reset($newData); }
php
public function merge($arr = []) { $newData = array_merge($this->toArray(), $arr); return $this->reset($newData); }
[ "public", "function", "merge", "(", "$", "arr", "=", "[", "]", ")", "{", "$", "newData", "=", "array_merge", "(", "$", "this", "->", "toArray", "(", ")", ",", "$", "arr", ")", ";", "return", "$", "this", "->", "reset", "(", "$", "newData", ")", ";", "}" ]
array then rebuilds the data array. Returns itself
[ "array", "then", "rebuilds", "the", "data", "array", ".", "Returns", "itself" ]
1b637bb56002de2b4c70f5359f009eebc4557a1f
https://github.com/theD1360/ArrayHelper/blob/1b637bb56002de2b4c70f5359f009eebc4557a1f/src/Utilities/Arr.php#L283-L287
1,372
mvqn/ucrm-module-rest
src/UCRM/REST/Endpoints/Helpers/ClientHelper.php
ClientHelper.resetAllInvoiceOptions
public function resetAllInvoiceOptions(): Client { $this->sendInvoiceByPost = null; $this->invoiceMaturityDays = null; $this->stopServiceDue = null; $this->stopServiceDueDays = null; // TODO: Add 'Late fee delay' to list of resets when made available! /** @var Client $this */ return $this; }
php
public function resetAllInvoiceOptions(): Client { $this->sendInvoiceByPost = null; $this->invoiceMaturityDays = null; $this->stopServiceDue = null; $this->stopServiceDueDays = null; // TODO: Add 'Late fee delay' to list of resets when made available! /** @var Client $this */ return $this; }
[ "public", "function", "resetAllInvoiceOptions", "(", ")", ":", "Client", "{", "$", "this", "->", "sendInvoiceByPost", "=", "null", ";", "$", "this", "->", "invoiceMaturityDays", "=", "null", ";", "$", "this", "->", "stopServiceDue", "=", "null", ";", "$", "this", "->", "stopServiceDueDays", "=", "null", ";", "// TODO: Add 'Late fee delay' to list of resets when made available!", "/** @var Client $this */", "return", "$", "this", ";", "}" ]
Resets all Invoice Options for this Client. @return Client Returns the current Client, for method chaining purposes.
[ "Resets", "all", "Invoice", "Options", "for", "this", "Client", "." ]
b5df714b5697ea12005ffbae84e13f3f15900322
https://github.com/mvqn/ucrm-module-rest/blob/b5df714b5697ea12005ffbae84e13f3f15900322/src/UCRM/REST/Endpoints/Helpers/ClientHelper.php#L41-L51
1,373
mvqn/ucrm-module-rest
src/UCRM/REST/Endpoints/Helpers/ClientHelper.php
ClientHelper.createResidential
public static function createResidential(string $firstName, string $lastName): Client { $organization = Organization::getByDefault(); $client = new Client([ "clientType" => Client::CLIENT_TYPE_RESIDENTIAL, "isLead" => false, "invoiceAddressSameAsContact" => true, "organizationId" => $organization->getId(), "registrationDate" => (new \DateTime())->format("c"), "firstName" => $firstName, "lastName" => $lastName ]); return $client; }
php
public static function createResidential(string $firstName, string $lastName): Client { $organization = Organization::getByDefault(); $client = new Client([ "clientType" => Client::CLIENT_TYPE_RESIDENTIAL, "isLead" => false, "invoiceAddressSameAsContact" => true, "organizationId" => $organization->getId(), "registrationDate" => (new \DateTime())->format("c"), "firstName" => $firstName, "lastName" => $lastName ]); return $client; }
[ "public", "static", "function", "createResidential", "(", "string", "$", "firstName", ",", "string", "$", "lastName", ")", ":", "Client", "{", "$", "organization", "=", "Organization", "::", "getByDefault", "(", ")", ";", "$", "client", "=", "new", "Client", "(", "[", "\"clientType\"", "=>", "Client", "::", "CLIENT_TYPE_RESIDENTIAL", ",", "\"isLead\"", "=>", "false", ",", "\"invoiceAddressSameAsContact\"", "=>", "true", ",", "\"organizationId\"", "=>", "$", "organization", "->", "getId", "(", ")", ",", "\"registrationDate\"", "=>", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "format", "(", "\"c\"", ")", ",", "\"firstName\"", "=>", "$", "firstName", ",", "\"lastName\"", "=>", "$", "lastName", "]", ")", ";", "return", "$", "client", ";", "}" ]
Creates the minimal Residential Client to be used as a starting point for a new Client. @param string $firstName The Client's first name. @param string $lastName The Client's last name. @return Client Returns a partially generated Client for further use before insertion. @throws \Exception
[ "Creates", "the", "minimal", "Residential", "Client", "to", "be", "used", "as", "a", "starting", "point", "for", "a", "new", "Client", "." ]
b5df714b5697ea12005ffbae84e13f3f15900322
https://github.com/mvqn/ucrm-module-rest/blob/b5df714b5697ea12005ffbae84e13f3f15900322/src/UCRM/REST/Endpoints/Helpers/ClientHelper.php#L118-L133
1,374
mvqn/ucrm-module-rest
src/UCRM/REST/Endpoints/Helpers/ClientHelper.php
ClientHelper.createCommercial
public static function createCommercial(string $companyName): Client { $organization = Organization::getByDefault(); $client = new Client([ "clientType" => Client::CLIENT_TYPE_COMMERCIAL, "isLead" => false, "invoiceAddressSameAsContact" => true, "organizationId" => $organization->getId(), "registrationDate" => (new \DateTime())->format("c"), "companyName" => $companyName ]); return $client; }
php
public static function createCommercial(string $companyName): Client { $organization = Organization::getByDefault(); $client = new Client([ "clientType" => Client::CLIENT_TYPE_COMMERCIAL, "isLead" => false, "invoiceAddressSameAsContact" => true, "organizationId" => $organization->getId(), "registrationDate" => (new \DateTime())->format("c"), "companyName" => $companyName ]); return $client; }
[ "public", "static", "function", "createCommercial", "(", "string", "$", "companyName", ")", ":", "Client", "{", "$", "organization", "=", "Organization", "::", "getByDefault", "(", ")", ";", "$", "client", "=", "new", "Client", "(", "[", "\"clientType\"", "=>", "Client", "::", "CLIENT_TYPE_COMMERCIAL", ",", "\"isLead\"", "=>", "false", ",", "\"invoiceAddressSameAsContact\"", "=>", "true", ",", "\"organizationId\"", "=>", "$", "organization", "->", "getId", "(", ")", ",", "\"registrationDate\"", "=>", "(", "new", "\\", "DateTime", "(", ")", ")", "->", "format", "(", "\"c\"", ")", ",", "\"companyName\"", "=>", "$", "companyName", "]", ")", ";", "return", "$", "client", ";", "}" ]
Creates the minimal Commericial Client to be used as a starting point for a new Client. @param string $companyName The company name of this Commercial Client. @return Client Returns a partially generated Client for further use before insertion. @throws \Exception
[ "Creates", "the", "minimal", "Commericial", "Client", "to", "be", "used", "as", "a", "starting", "point", "for", "a", "new", "Client", "." ]
b5df714b5697ea12005ffbae84e13f3f15900322
https://github.com/mvqn/ucrm-module-rest/blob/b5df714b5697ea12005ffbae84e13f3f15900322/src/UCRM/REST/Endpoints/Helpers/ClientHelper.php#L171-L185
1,375
mvqn/ucrm-module-rest
src/UCRM/REST/Endpoints/Helpers/ClientHelper.php
ClientHelper.getByUserIdent
public static function getByUserIdent(string $userIdent): ?Client { /** @var Client $client */ $client = Client::get("", [], [ "userIdent" => $userIdent ])->first(); // Custom ID is Unique, so return the only result or null! return $client; }
php
public static function getByUserIdent(string $userIdent): ?Client { /** @var Client $client */ $client = Client::get("", [], [ "userIdent" => $userIdent ])->first(); // Custom ID is Unique, so return the only result or null! return $client; }
[ "public", "static", "function", "getByUserIdent", "(", "string", "$", "userIdent", ")", ":", "?", "Client", "{", "/** @var Client $client */", "$", "client", "=", "Client", "::", "get", "(", "\"\"", ",", "[", "]", ",", "[", "\"userIdent\"", "=>", "$", "userIdent", "]", ")", "->", "first", "(", ")", ";", "// Custom ID is Unique, so return the only result or null!", "return", "$", "client", ";", "}" ]
Sends an HTTP GET Request using the calling class's annotated information, for an object, given the Custom ID. @param string $userIdent The Custom ID of the Client for which to retrieve. @return Client|null Returns the matching Client or NULL, if none was found. @throws \Exception
[ "Sends", "an", "HTTP", "GET", "Request", "using", "the", "calling", "class", "s", "annotated", "information", "for", "an", "object", "given", "the", "Custom", "ID", "." ]
b5df714b5697ea12005ffbae84e13f3f15900322
https://github.com/mvqn/ucrm-module-rest/blob/b5df714b5697ea12005ffbae84e13f3f15900322/src/UCRM/REST/Endpoints/Helpers/ClientHelper.php#L223-L230
1,376
mvqn/ucrm-module-rest
src/UCRM/REST/Endpoints/Helpers/ClientHelper.php
ClientHelper.getByCustomAttribute
public static function getByCustomAttribute(string $key, string $value): ClientCollection { // TODO: Determine if this is ALWAYS the case! $key = lcfirst($key); /** @var ClientCollection $clients */ $clients = Client::get("", [], [ "customAttributeKey" => $key, "customAttributeValue" => $value ]); return new ClientCollection($clients->elements()); }
php
public static function getByCustomAttribute(string $key, string $value): ClientCollection { // TODO: Determine if this is ALWAYS the case! $key = lcfirst($key); /** @var ClientCollection $clients */ $clients = Client::get("", [], [ "customAttributeKey" => $key, "customAttributeValue" => $value ]); return new ClientCollection($clients->elements()); }
[ "public", "static", "function", "getByCustomAttribute", "(", "string", "$", "key", ",", "string", "$", "value", ")", ":", "ClientCollection", "{", "// TODO: Determine if this is ALWAYS the case!", "$", "key", "=", "lcfirst", "(", "$", "key", ")", ";", "/** @var ClientCollection $clients */", "$", "clients", "=", "Client", "::", "get", "(", "\"\"", ",", "[", "]", ",", "[", "\"customAttributeKey\"", "=>", "$", "key", ",", "\"customAttributeValue\"", "=>", "$", "value", "]", ")", ";", "return", "new", "ClientCollection", "(", "$", "clients", "->", "elements", "(", ")", ")", ";", "}" ]
Sends an HTTP GET Request using the calling class's annotated information, for objects, given an Attribute pair. @param string $key The Custom Attribute Key for which to search, will be converted to camel case as needed. @param string $value The Custom Attribute Value for which to search. @return ClientCollection Returns a collection of Clients matching the given criteria. @throws \Exception
[ "Sends", "an", "HTTP", "GET", "Request", "using", "the", "calling", "class", "s", "annotated", "information", "for", "objects", "given", "an", "Attribute", "pair", "." ]
b5df714b5697ea12005ffbae84e13f3f15900322
https://github.com/mvqn/ucrm-module-rest/blob/b5df714b5697ea12005ffbae84e13f3f15900322/src/UCRM/REST/Endpoints/Helpers/ClientHelper.php#L241-L249
1,377
codezero-be/utilities
src/UrlHelper.php
UrlHelper.joinSlugs
public function joinSlugs(array $urlParts) { $urlParts = array_map(function($urlPart){ return trim($urlPart, '/'); }, $urlParts); return implode('/', $urlParts); }
php
public function joinSlugs(array $urlParts) { $urlParts = array_map(function($urlPart){ return trim($urlPart, '/'); }, $urlParts); return implode('/', $urlParts); }
[ "public", "function", "joinSlugs", "(", "array", "$", "urlParts", ")", "{", "$", "urlParts", "=", "array_map", "(", "function", "(", "$", "urlPart", ")", "{", "return", "trim", "(", "$", "urlPart", ",", "'/'", ")", ";", "}", ",", "$", "urlParts", ")", ";", "return", "implode", "(", "'/'", ",", "$", "urlParts", ")", ";", "}" ]
Join URL parts without double slashes @param array $urlParts @return string
[ "Join", "URL", "parts", "without", "double", "slashes" ]
798b4c3a7f27fdae1dc3eccb7bb4c59f62622db2
https://github.com/codezero-be/utilities/blob/798b4c3a7f27fdae1dc3eccb7bb4c59f62622db2/src/UrlHelper.php#L12-L19
1,378
railsphp/framework
src/Rails/ActiveRecord/Base/Methods/AssociationsMethodsTrait.php
AssociationsMethodsTrait.getAssociation
public function getAssociation($name, $autoLoad = true) { if (isset($this->loadedAssociations[$name])) { return $this->loadedAssociations[$name]; } elseif ($autoLoad && $this->getAssociations()->exists($name)) { $this->loadedAssociations[$name] = $this->getAssociations()->load($this, $name); return $this->loadedAssociations[$name]; } return null; }
php
public function getAssociation($name, $autoLoad = true) { if (isset($this->loadedAssociations[$name])) { return $this->loadedAssociations[$name]; } elseif ($autoLoad && $this->getAssociations()->exists($name)) { $this->loadedAssociations[$name] = $this->getAssociations()->load($this, $name); return $this->loadedAssociations[$name]; } return null; }
[ "public", "function", "getAssociation", "(", "$", "name", ",", "$", "autoLoad", "=", "true", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "loadedAssociations", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "loadedAssociations", "[", "$", "name", "]", ";", "}", "elseif", "(", "$", "autoLoad", "&&", "$", "this", "->", "getAssociations", "(", ")", "->", "exists", "(", "$", "name", ")", ")", "{", "$", "this", "->", "loadedAssociations", "[", "$", "name", "]", "=", "$", "this", "->", "getAssociations", "(", ")", "->", "load", "(", "$", "this", ",", "$", "name", ")", ";", "return", "$", "this", "->", "loadedAssociations", "[", "$", "name", "]", ";", "}", "return", "null", ";", "}" ]
If the association isn't yet loaded, it is loaded and returned. If the association doesn't exist, `null` is returned. Note that unset one-to-one associations return `false`. return null|false|object
[ "If", "the", "association", "isn", "t", "yet", "loaded", "it", "is", "loaded", "and", "returned", ".", "If", "the", "association", "doesn", "t", "exist", "null", "is", "returned", ".", "Note", "that", "unset", "one", "-", "to", "-", "one", "associations", "return", "false", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Base/Methods/AssociationsMethodsTrait.php#L27-L37
1,379
railsphp/framework
src/Rails/ActiveRecord/Base/Methods/AssociationsMethodsTrait.php
AssociationsMethodsTrait.setAssociation
public function setAssociation($name, $value, $raw = false) { if ($raw) { $this->loadedAssociations[$name] = $value; } else { return (new Setter())->set($this, $name, $value); } }
php
public function setAssociation($name, $value, $raw = false) { if ($raw) { $this->loadedAssociations[$name] = $value; } else { return (new Setter())->set($this, $name, $value); } }
[ "public", "function", "setAssociation", "(", "$", "name", ",", "$", "value", ",", "$", "raw", "=", "false", ")", "{", "if", "(", "$", "raw", ")", "{", "$", "this", "->", "loadedAssociations", "[", "$", "name", "]", "=", "$", "value", ";", "}", "else", "{", "return", "(", "new", "Setter", "(", ")", ")", "->", "set", "(", "$", "this", ",", "$", "name", ",", "$", "value", ")", ";", "}", "}" ]
Associates an object to a one-to-one association. Other associations are done in CollectionProxy.
[ "Associates", "an", "object", "to", "a", "one", "-", "to", "-", "one", "association", ".", "Other", "associations", "are", "done", "in", "CollectionProxy", "." ]
2ac9d3e493035dcc68f3c3812423327127327cd5
https://github.com/railsphp/framework/blob/2ac9d3e493035dcc68f3c3812423327127327cd5/src/Rails/ActiveRecord/Base/Methods/AssociationsMethodsTrait.php#L43-L50
1,380
phapi/di
src/Phapi/Di/Container.php
Container.make
public function make($key) { // Check if set if (!isset($this->keys[$key])) { throw new \InvalidArgumentException('Identifier "'. $key .'" is not defined.'); } // Check if it is a simple value (string, int etc) that // should be returned if ( !is_object($this->raw[$key]) || !method_exists($this->raw[$key], '__invoke') ) { return $this->raw[$key]; } if ($this->types[$key] === self::TYPE_SINGLETON) { if (isset($this->resolved[$key])) { return $this->resolved[$key]; } $this->locked[$key] = true; return $this->resolved[$key] = $this->raw[$key]($this); } // Return multiton return $this->raw[$key]($this); }
php
public function make($key) { // Check if set if (!isset($this->keys[$key])) { throw new \InvalidArgumentException('Identifier "'. $key .'" is not defined.'); } // Check if it is a simple value (string, int etc) that // should be returned if ( !is_object($this->raw[$key]) || !method_exists($this->raw[$key], '__invoke') ) { return $this->raw[$key]; } if ($this->types[$key] === self::TYPE_SINGLETON) { if (isset($this->resolved[$key])) { return $this->resolved[$key]; } $this->locked[$key] = true; return $this->resolved[$key] = $this->raw[$key]($this); } // Return multiton return $this->raw[$key]($this); }
[ "public", "function", "make", "(", "$", "key", ")", "{", "// Check if set", "if", "(", "!", "isset", "(", "$", "this", "->", "keys", "[", "$", "key", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Identifier \"'", ".", "$", "key", ".", "'\" is not defined.'", ")", ";", "}", "// Check if it is a simple value (string, int etc) that", "// should be returned", "if", "(", "!", "is_object", "(", "$", "this", "->", "raw", "[", "$", "key", "]", ")", "||", "!", "method_exists", "(", "$", "this", "->", "raw", "[", "$", "key", "]", ",", "'__invoke'", ")", ")", "{", "return", "$", "this", "->", "raw", "[", "$", "key", "]", ";", "}", "if", "(", "$", "this", "->", "types", "[", "$", "key", "]", "===", "self", "::", "TYPE_SINGLETON", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "resolved", "[", "$", "key", "]", ")", ")", "{", "return", "$", "this", "->", "resolved", "[", "$", "key", "]", ";", "}", "$", "this", "->", "locked", "[", "$", "key", "]", "=", "true", ";", "return", "$", "this", "->", "resolved", "[", "$", "key", "]", "=", "$", "this", "->", "raw", "[", "$", "key", "]", "(", "$", "this", ")", ";", "}", "// Return multiton", "return", "$", "this", "->", "raw", "[", "$", "key", "]", "(", "$", "this", ")", ";", "}" ]
Get something from the container @param $key string Identifier @return mixed
[ "Get", "something", "from", "the", "container" ]
869f0f0245540f167192ddf72a195adb70aae5a9
https://github.com/phapi/di/blob/869f0f0245540f167192ddf72a195adb70aae5a9/src/Phapi/Di/Container.php#L112-L139
1,381
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.addVisitAction
public function addVisitAction(\BlackForest\PiwikBundle\Entity\PiwikVisitAction $visitAction) { $this->visitAction[] = $visitAction; return $this; }
php
public function addVisitAction(\BlackForest\PiwikBundle\Entity\PiwikVisitAction $visitAction) { $this->visitAction[] = $visitAction; return $this; }
[ "public", "function", "addVisitAction", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikVisitAction", "$", "visitAction", ")", "{", "$", "this", "->", "visitAction", "[", "]", "=", "$", "visitAction", ";", "return", "$", "this", ";", "}" ]
Add visitAction. @param \BlackForest\PiwikBundle\Entity\PiwikVisitAction $visitAction @return PiwikVisit
[ "Add", "visitAction", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L826-L831
1,382
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.removeVisitAction
public function removeVisitAction(\BlackForest\PiwikBundle\Entity\PiwikVisitAction $visitAction) { return $this->visitAction->removeElement($visitAction); }
php
public function removeVisitAction(\BlackForest\PiwikBundle\Entity\PiwikVisitAction $visitAction) { return $this->visitAction->removeElement($visitAction); }
[ "public", "function", "removeVisitAction", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikVisitAction", "$", "visitAction", ")", "{", "return", "$", "this", "->", "visitAction", "->", "removeElement", "(", "$", "visitAction", ")", ";", "}" ]
Remove visitAction. @param \BlackForest\PiwikBundle\Entity\PiwikVisitAction $visitAction @return boolean TRUE if this collection contained the specified element, FALSE otherwise.
[ "Remove", "visitAction", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L840-L843
1,383
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setVisitor
public function setVisitor(\BlackForest\PiwikBundle\Entity\PiwikVisitor $visitor = null) { $this->visitor = $visitor; return $this; }
php
public function setVisitor(\BlackForest\PiwikBundle\Entity\PiwikVisitor $visitor = null) { $this->visitor = $visitor; return $this; }
[ "public", "function", "setVisitor", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikVisitor", "$", "visitor", "=", "null", ")", "{", "$", "this", "->", "visitor", "=", "$", "visitor", ";", "return", "$", "this", ";", "}" ]
Set visitor. @param \BlackForest\PiwikBundle\Entity\PiwikVisitor|null $visitor @return PiwikVisit
[ "Set", "visitor", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L910-L915
1,384
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setSearchEngine
public function setSearchEngine(\BlackForest\PiwikBundle\Entity\PiwikSearchEngine $searchEngine = null) { $this->searchEngine = $searchEngine; return $this; }
php
public function setSearchEngine(\BlackForest\PiwikBundle\Entity\PiwikSearchEngine $searchEngine = null) { $this->searchEngine = $searchEngine; return $this; }
[ "public", "function", "setSearchEngine", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikSearchEngine", "$", "searchEngine", "=", "null", ")", "{", "$", "this", "->", "searchEngine", "=", "$", "searchEngine", ";", "return", "$", "this", ";", "}" ]
Set searchEngine. @param \BlackForest\PiwikBundle\Entity\PiwikSearchEngine|null $searchEngine @return PiwikVisit
[ "Set", "searchEngine", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1006-L1011
1,385
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setDevice
public function setDevice(\BlackForest\PiwikBundle\Entity\PiwikDevice $device = null) { $this->device = $device; return $this; }
php
public function setDevice(\BlackForest\PiwikBundle\Entity\PiwikDevice $device = null) { $this->device = $device; return $this; }
[ "public", "function", "setDevice", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikDevice", "$", "device", "=", "null", ")", "{", "$", "this", "->", "device", "=", "$", "device", ";", "return", "$", "this", ";", "}" ]
Set device. @param \BlackForest\PiwikBundle\Entity\PiwikDevice|null $device @return PiwikVisit
[ "Set", "device", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1054-L1059
1,386
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setOperatingSystem
public function setOperatingSystem(\BlackForest\PiwikBundle\Entity\PiwikOperatingSystem $operatingSystem = null) { $this->operatingSystem = $operatingSystem; return $this; }
php
public function setOperatingSystem(\BlackForest\PiwikBundle\Entity\PiwikOperatingSystem $operatingSystem = null) { $this->operatingSystem = $operatingSystem; return $this; }
[ "public", "function", "setOperatingSystem", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikOperatingSystem", "$", "operatingSystem", "=", "null", ")", "{", "$", "this", "->", "operatingSystem", "=", "$", "operatingSystem", ";", "return", "$", "this", ";", "}" ]
Set operatingSystem. @param \BlackForest\PiwikBundle\Entity\PiwikOperatingSystem|null $operatingSystem @return PiwikVisit
[ "Set", "operatingSystem", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1078-L1083
1,387
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setBrowser
public function setBrowser(\BlackForest\PiwikBundle\Entity\PiwikBrowser $browser = null) { $this->browser = $browser; return $this; }
php
public function setBrowser(\BlackForest\PiwikBundle\Entity\PiwikBrowser $browser = null) { $this->browser = $browser; return $this; }
[ "public", "function", "setBrowser", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikBrowser", "$", "browser", "=", "null", ")", "{", "$", "this", "->", "browser", "=", "$", "browser", ";", "return", "$", "this", ";", "}" ]
Set browser. @param \BlackForest\PiwikBundle\Entity\PiwikBrowser|null $browser @return PiwikVisit
[ "Set", "browser", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1102-L1107
1,388
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setLocation
public function setLocation(\BlackForest\PiwikBundle\Entity\PiwikLocation $location = null) { $this->location = $location; return $this; }
php
public function setLocation(\BlackForest\PiwikBundle\Entity\PiwikLocation $location = null) { $this->location = $location; return $this; }
[ "public", "function", "setLocation", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikLocation", "$", "location", "=", "null", ")", "{", "$", "this", "->", "location", "=", "$", "location", ";", "return", "$", "this", ";", "}" ]
Set location. @param \BlackForest\PiwikBundle\Entity\PiwikLocation|null $location @return PiwikVisit
[ "Set", "location", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1150-L1155
1,389
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setResolution
public function setResolution(\BlackForest\PiwikBundle\Entity\PiwikResolution $resolution = null) { $this->resolution = $resolution; return $this; }
php
public function setResolution(\BlackForest\PiwikBundle\Entity\PiwikResolution $resolution = null) { $this->resolution = $resolution; return $this; }
[ "public", "function", "setResolution", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikResolution", "$", "resolution", "=", "null", ")", "{", "$", "this", "->", "resolution", "=", "$", "resolution", ";", "return", "$", "this", ";", "}" ]
Set resolution. @param \BlackForest\PiwikBundle\Entity\PiwikResolution|null $resolution @return PiwikVisit
[ "Set", "resolution", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1174-L1179
1,390
black-forest/piwik-bundle
src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php
PiwikVisit.setPlugin
public function setPlugin(\BlackForest\PiwikBundle\Entity\PiwikVisitPlugin $plugin = null) { $this->plugin = $plugin; return $this; }
php
public function setPlugin(\BlackForest\PiwikBundle\Entity\PiwikVisitPlugin $plugin = null) { $this->plugin = $plugin; return $this; }
[ "public", "function", "setPlugin", "(", "\\", "BlackForest", "\\", "PiwikBundle", "\\", "Entity", "\\", "PiwikVisitPlugin", "$", "plugin", "=", "null", ")", "{", "$", "this", "->", "plugin", "=", "$", "plugin", ";", "return", "$", "this", ";", "}" ]
Set plugin. @param \BlackForest\PiwikBundle\Entity\PiwikVisitPlugin|null $plugin @return PiwikVisit
[ "Set", "plugin", "." ]
be1000f898f9583bb4ecbe4ca1933ab7b7e0e785
https://github.com/black-forest/piwik-bundle/blob/be1000f898f9583bb4ecbe4ca1933ab7b7e0e785/src/Resources/doctrine/BlackForest/PiwikBundle/Entity/PiwikVisit.php#L1198-L1203
1,391
leodido/conversio
library/Adapter/AbstractOptionsEnabledAdapter.php
AbstractOptionsEnabledAdapter.setOptions
public function setOptions(AbstractOptions $options) { $optionsClass = Conversion::getOptionsFullQualifiedClassName($this); $inputOptionsClass = get_class($options); if ($inputOptionsClass !== $optionsClass) { throw new Exception\DomainException(sprintf( '"%s" expects that options set are an array or a valid "%s" instance; received "%s"', __METHOD__, $optionsClass, $inputOptionsClass )); } $this->options = $options; return $this; }
php
public function setOptions(AbstractOptions $options) { $optionsClass = Conversion::getOptionsFullQualifiedClassName($this); $inputOptionsClass = get_class($options); if ($inputOptionsClass !== $optionsClass) { throw new Exception\DomainException(sprintf( '"%s" expects that options set are an array or a valid "%s" instance; received "%s"', __METHOD__, $optionsClass, $inputOptionsClass )); } $this->options = $options; return $this; }
[ "public", "function", "setOptions", "(", "AbstractOptions", "$", "options", ")", "{", "$", "optionsClass", "=", "Conversion", "::", "getOptionsFullQualifiedClassName", "(", "$", "this", ")", ";", "$", "inputOptionsClass", "=", "get_class", "(", "$", "options", ")", ";", "if", "(", "$", "inputOptionsClass", "!==", "$", "optionsClass", ")", "{", "throw", "new", "Exception", "\\", "DomainException", "(", "sprintf", "(", "'\"%s\" expects that options set are an array or a valid \"%s\" instance; received \"%s\"'", ",", "__METHOD__", ",", "$", "optionsClass", ",", "$", "inputOptionsClass", ")", ")", ";", "}", "$", "this", "->", "options", "=", "$", "options", ";", "return", "$", "this", ";", "}" ]
Set the adapter options instance @param AbstractOptions $options @return $this
[ "Set", "the", "adapter", "options", "instance" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Adapter/AbstractOptionsEnabledAdapter.php#L32-L46
1,392
leodido/conversio
library/Adapter/AbstractOptionsEnabledAdapter.php
AbstractOptionsEnabledAdapter.getOptions
public function getOptions() { if (!$this->options) { throw new Exception\RuntimeException(sprintf( 'No options instance set for the adapter "%s"', get_class($this) )); } return $this->options; }
php
public function getOptions() { if (!$this->options) { throw new Exception\RuntimeException(sprintf( 'No options instance set for the adapter "%s"', get_class($this) )); } return $this->options; }
[ "public", "function", "getOptions", "(", ")", "{", "if", "(", "!", "$", "this", "->", "options", ")", "{", "throw", "new", "Exception", "\\", "RuntimeException", "(", "sprintf", "(", "'No options instance set for the adapter \"%s\"'", ",", "get_class", "(", "$", "this", ")", ")", ")", ";", "}", "return", "$", "this", "->", "options", ";", "}" ]
Retrieve the adapter options instance @return AbstractOptions
[ "Retrieve", "the", "adapter", "options", "instance" ]
ebbb626b0cf2a44729af6d46d753b5a4b06d9835
https://github.com/leodido/conversio/blob/ebbb626b0cf2a44729af6d46d753b5a4b06d9835/library/Adapter/AbstractOptionsEnabledAdapter.php#L53-L62
1,393
webriq/core
module/Paragraph/src/Grid/Paragraph/Controller/Plugin/ParagraphLayout.php
ParagraphLayout.setMiddleParagraphLayoutId
public function setMiddleParagraphLayoutId( $layoutParagraphId = null ) { $middleLayout = $this->middleLayoutModel ->findMiddleParagraphLayoutById( $layoutParagraphId ); if ( ! empty( $middleLayout ) ) { $controller = $this->getController(); if ( ! method_exists( $controller, 'plugin' ) ) { throw new Exception\LogicException( 'Controller used with paragraphLayout plugin must be pluggable' ); } $controller->plugin( 'layout' ) ->setMiddleLayout( $middleLayout ); } return $this; }
php
public function setMiddleParagraphLayoutId( $layoutParagraphId = null ) { $middleLayout = $this->middleLayoutModel ->findMiddleParagraphLayoutById( $layoutParagraphId ); if ( ! empty( $middleLayout ) ) { $controller = $this->getController(); if ( ! method_exists( $controller, 'plugin' ) ) { throw new Exception\LogicException( 'Controller used with paragraphLayout plugin must be pluggable' ); } $controller->plugin( 'layout' ) ->setMiddleLayout( $middleLayout ); } return $this; }
[ "public", "function", "setMiddleParagraphLayoutId", "(", "$", "layoutParagraphId", "=", "null", ")", "{", "$", "middleLayout", "=", "$", "this", "->", "middleLayoutModel", "->", "findMiddleParagraphLayoutById", "(", "$", "layoutParagraphId", ")", ";", "if", "(", "!", "empty", "(", "$", "middleLayout", ")", ")", "{", "$", "controller", "=", "$", "this", "->", "getController", "(", ")", ";", "if", "(", "!", "method_exists", "(", "$", "controller", ",", "'plugin'", ")", ")", "{", "throw", "new", "Exception", "\\", "LogicException", "(", "'Controller used with paragraphLayout plugin must be pluggable'", ")", ";", "}", "$", "controller", "->", "plugin", "(", "'layout'", ")", "->", "setMiddleLayout", "(", "$", "middleLayout", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set middle-layout for paragraph-layout @param int|null $layoutParagraphId @return \Paragraph\Controller\Plugin\ParagraphLayout @throws \Zend\Mvc\Exception\LogicException if controller not pluggable
[ "Set", "middle", "-", "layout", "for", "paragraph", "-", "layout" ]
cfeb6e8a4732561c2215ec94e736c07f9b8bc990
https://github.com/webriq/core/blob/cfeb6e8a4732561c2215ec94e736c07f9b8bc990/module/Paragraph/src/Grid/Paragraph/Controller/Plugin/ParagraphLayout.php#L39-L62
1,394
Dhii/state-machine-abstract
src/TransitionAwareTrait.php
TransitionAwareTrait._setTransition
protected function _setTransition($transition) { if ($transition !== null && !is_string($transition) && !($transition instanceof Stringable)) { throw $this->_createInvalidArgumentException( $this->__('Argument is not a valid transition'), null, null, $transition ); } $this->transition = $transition; }
php
protected function _setTransition($transition) { if ($transition !== null && !is_string($transition) && !($transition instanceof Stringable)) { throw $this->_createInvalidArgumentException( $this->__('Argument is not a valid transition'), null, null, $transition ); } $this->transition = $transition; }
[ "protected", "function", "_setTransition", "(", "$", "transition", ")", "{", "if", "(", "$", "transition", "!==", "null", "&&", "!", "is_string", "(", "$", "transition", ")", "&&", "!", "(", "$", "transition", "instanceof", "Stringable", ")", ")", "{", "throw", "$", "this", "->", "_createInvalidArgumentException", "(", "$", "this", "->", "__", "(", "'Argument is not a valid transition'", ")", ",", "null", ",", "null", ",", "$", "transition", ")", ";", "}", "$", "this", "->", "transition", "=", "$", "transition", ";", "}" ]
Sets the transition for this instance. @since [*next-version*] @param string|Stringable|null $transition The transition, or null.
[ "Sets", "the", "transition", "for", "this", "instance", "." ]
cb5f706edd74d1c747f09f505b859255b13a5b27
https://github.com/Dhii/state-machine-abstract/blob/cb5f706edd74d1c747f09f505b859255b13a5b27/src/TransitionAwareTrait.php#L44-L56
1,395
konservs/brilliant.framework
libraries/BFactory.php
BFactory.getDBO
public static function getDBO() { if (!empty(self::$db)) { return self::$db; } BLog::addToLog('[BFactory] Connecting to the database "' . MYSQL_DB_HOST . '"...'); self::$db = BMySQL::getInstanceAndConnect(); if (empty(self::$db)) { BLog::addToLog('[BFactory] Could not connect to the MySQL database!', LL_ERROR); return NULL; } return self::$db; }
php
public static function getDBO() { if (!empty(self::$db)) { return self::$db; } BLog::addToLog('[BFactory] Connecting to the database "' . MYSQL_DB_HOST . '"...'); self::$db = BMySQL::getInstanceAndConnect(); if (empty(self::$db)) { BLog::addToLog('[BFactory] Could not connect to the MySQL database!', LL_ERROR); return NULL; } return self::$db; }
[ "public", "static", "function", "getDBO", "(", ")", "{", "if", "(", "!", "empty", "(", "self", "::", "$", "db", ")", ")", "{", "return", "self", "::", "$", "db", ";", "}", "BLog", "::", "addToLog", "(", "'[BFactory] Connecting to the database \"'", ".", "MYSQL_DB_HOST", ".", "'\"...'", ")", ";", "self", "::", "$", "db", "=", "BMySQL", "::", "getInstanceAndConnect", "(", ")", ";", "if", "(", "empty", "(", "self", "::", "$", "db", ")", ")", "{", "BLog", "::", "addToLog", "(", "'[BFactory] Could not connect to the MySQL database!'", ",", "LL_ERROR", ")", ";", "return", "NULL", ";", "}", "return", "self", "::", "$", "db", ";", "}" ]
Get BMySQL instance @return BMySQL|null
[ "Get", "BMySQL", "instance" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/BFactory.php#L23-L34
1,396
konservs/brilliant.framework
libraries/BFactory.php
BFactory.getTempFn
public static function getTempFn() { $tempFileName = BROOTPATH . 'temp' . DIRECTORY_SEPARATOR; $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); for ($i = 0; $i < 15; $i++) { $tempFileName .= $characters[rand(0, $charactersLength - 1)]; } $tempFileName .= '.tmp'; return $tempFileName; }
php
public static function getTempFn() { $tempFileName = BROOTPATH . 'temp' . DIRECTORY_SEPARATOR; $characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $charactersLength = strlen($characters); for ($i = 0; $i < 15; $i++) { $tempFileName .= $characters[rand(0, $charactersLength - 1)]; } $tempFileName .= '.tmp'; return $tempFileName; }
[ "public", "static", "function", "getTempFn", "(", ")", "{", "$", "tempFileName", "=", "BROOTPATH", ".", "'temp'", ".", "DIRECTORY_SEPARATOR", ";", "$", "characters", "=", "'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'", ";", "$", "charactersLength", "=", "strlen", "(", "$", "characters", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "15", ";", "$", "i", "++", ")", "{", "$", "tempFileName", ".=", "$", "characters", "[", "rand", "(", "0", ",", "$", "charactersLength", "-", "1", ")", "]", ";", "}", "$", "tempFileName", ".=", "'.tmp'", ";", "return", "$", "tempFileName", ";", "}" ]
Get temporary filename @return string
[ "Get", "temporary", "filename" ]
95f03f1917f746fee98bea8a906ba0588c87762d
https://github.com/konservs/brilliant.framework/blob/95f03f1917f746fee98bea8a906ba0588c87762d/libraries/BFactory.php#L53-L62
1,397
funkeye/console
src/Console.php
Console.getInstance
public static function getInstance() { if( is_null(self::$_oInstance) ) { $c = __CLASS__; self::$_oInstance = new $c; } return self::$_oInstance; }
php
public static function getInstance() { if( is_null(self::$_oInstance) ) { $c = __CLASS__; self::$_oInstance = new $c; } return self::$_oInstance; }
[ "public", "static", "function", "getInstance", "(", ")", "{", "if", "(", "is_null", "(", "self", "::", "$", "_oInstance", ")", ")", "{", "$", "c", "=", "__CLASS__", ";", "self", "::", "$", "_oInstance", "=", "new", "$", "c", ";", "}", "return", "self", "::", "$", "_oInstance", ";", "}" ]
get a valid instance of this class @return object
[ "get", "a", "valid", "instance", "of", "this", "class" ]
e613c0472004156a68ef6171590c93a71d5b8f9c
https://github.com/funkeye/console/blob/e613c0472004156a68ef6171590c93a71d5b8f9c/src/Console.php#L54-L60
1,398
synapsestudios/synapse-base
src/Synapse/Validator/Constraints/BelongsToEntityValidator.php
BelongsToEntityValidator.addViolation
protected function addViolation($value, Constraint $constraint) { $this->context->addViolation( $constraint->message, [ '{{ id_field }}' => $constraint->getIdField(), '{{ value }}' => $value ], $value ); }
php
protected function addViolation($value, Constraint $constraint) { $this->context->addViolation( $constraint->message, [ '{{ id_field }}' => $constraint->getIdField(), '{{ value }}' => $value ], $value ); }
[ "protected", "function", "addViolation", "(", "$", "value", ",", "Constraint", "$", "constraint", ")", "{", "$", "this", "->", "context", "->", "addViolation", "(", "$", "constraint", "->", "message", ",", "[", "'{{ id_field }}'", "=>", "$", "constraint", "->", "getIdField", "(", ")", ",", "'{{ value }}'", "=>", "$", "value", "]", ",", "$", "value", ")", ";", "}" ]
Add violation with error message @param $value
[ "Add", "violation", "with", "error", "message" ]
60c830550491742a077ab063f924e2f0b63825da
https://github.com/synapsestudios/synapse-base/blob/60c830550491742a077ab063f924e2f0b63825da/src/Synapse/Validator/Constraints/BelongsToEntityValidator.php#L47-L57
1,399
Webiny/BackupService
src/Webiny/BackupService/Lib/Compress.php
Compress.addSources
public function addSources(array $sources) { foreach ($sources as $s) { if (!file_exists($s)) { throw new \Exception(sprintf('Unable to compress %s because the destination doesn\'t exist.', $s)); } $this->sources[] = $s; } }
php
public function addSources(array $sources) { foreach ($sources as $s) { if (!file_exists($s)) { throw new \Exception(sprintf('Unable to compress %s because the destination doesn\'t exist.', $s)); } $this->sources[] = $s; } }
[ "public", "function", "addSources", "(", "array", "$", "sources", ")", "{", "foreach", "(", "$", "sources", "as", "$", "s", ")", "{", "if", "(", "!", "file_exists", "(", "$", "s", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "sprintf", "(", "'Unable to compress %s because the destination doesn\\'t exist.'", ",", "$", "s", ")", ")", ";", "}", "$", "this", "->", "sources", "[", "]", "=", "$", "s", ";", "}", "}" ]
Add one or more file or folders to the archive. @param array $sources @throws \Exception
[ "Add", "one", "or", "more", "file", "or", "folders", "to", "the", "archive", "." ]
9728ddaa67e5703ac7898a6f69a0ad14ac37a256
https://github.com/Webiny/BackupService/blob/9728ddaa67e5703ac7898a6f69a0ad14ac37a256/src/Webiny/BackupService/Lib/Compress.php#L64-L72