id
int32
0
241k
repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
222,900
meysampg/intldate
IntlDateTrait.php
IntlDateTrait.parseDateTime
private function parseDateTime($datetimeArray) { $finalDatetimeArray = []; if (!is_array($datetimeArray)) { throw new Exception('DateTime information must be an array in [year, month, day, hours, minutes, seconds] format.'); } $finalDatetimeArray[0] = isset($datetimeArray[0]) ? (int) $datetimeArray[0] : (isset($datetimeArray['year']) ? (int) $datetimeArray['year'] : 1970); $finalDatetimeArray[1] = isset($datetimeArray[1]) ? (int) $datetimeArray[1] - 1 : (isset($datetimeArray['mon']) ? (int) $datetimeArray['mon'] - 1 : 0); $finalDatetimeArray[2] = isset($datetimeArray[2]) ? (int) $datetimeArray[2] : (isset($datetimeArray['mday']) ? (int) $datetimeArray['mday'] : 1); $finalDatetimeArray[3] = isset($datetimeArray[3]) ? (int) $datetimeArray[3] : (isset($datetimeArray['hours']) ? (int) $datetimeArray['hours'] : 0); $finalDatetimeArray[4] = isset($datetimeArray[4]) ? (int) $datetimeArray[4] : (isset($datetimeArray['minutes']) ? (int) $datetimeArray['minutes'] : 0); $finalDatetimeArray[5] = isset($datetimeArray[5]) ? (int) $datetimeArray[5] : (isset($datetimeArray['seconds']) ? (int) $datetimeArray['seconds'] : 0); return $finalDatetimeArray; }
php
private function parseDateTime($datetimeArray) { $finalDatetimeArray = []; if (!is_array($datetimeArray)) { throw new Exception('DateTime information must be an array in [year, month, day, hours, minutes, seconds] format.'); } $finalDatetimeArray[0] = isset($datetimeArray[0]) ? (int) $datetimeArray[0] : (isset($datetimeArray['year']) ? (int) $datetimeArray['year'] : 1970); $finalDatetimeArray[1] = isset($datetimeArray[1]) ? (int) $datetimeArray[1] - 1 : (isset($datetimeArray['mon']) ? (int) $datetimeArray['mon'] - 1 : 0); $finalDatetimeArray[2] = isset($datetimeArray[2]) ? (int) $datetimeArray[2] : (isset($datetimeArray['mday']) ? (int) $datetimeArray['mday'] : 1); $finalDatetimeArray[3] = isset($datetimeArray[3]) ? (int) $datetimeArray[3] : (isset($datetimeArray['hours']) ? (int) $datetimeArray['hours'] : 0); $finalDatetimeArray[4] = isset($datetimeArray[4]) ? (int) $datetimeArray[4] : (isset($datetimeArray['minutes']) ? (int) $datetimeArray['minutes'] : 0); $finalDatetimeArray[5] = isset($datetimeArray[5]) ? (int) $datetimeArray[5] : (isset($datetimeArray['seconds']) ? (int) $datetimeArray['seconds'] : 0); return $finalDatetimeArray; }
[ "private", "function", "parseDateTime", "(", "$", "datetimeArray", ")", "{", "$", "finalDatetimeArray", "=", "[", "]", ";", "if", "(", "!", "is_array", "(", "$", "datetimeArray", ")", ")", "{", "throw", "new", "Exception", "(", "'DateTime information must be an array in [year, month, day, hours, minutes, seconds] format.'", ")", ";", "}", "$", "finalDatetimeArray", "[", "0", "]", "=", "isset", "(", "$", "datetimeArray", "[", "0", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "0", "]", ":", "(", "isset", "(", "$", "datetimeArray", "[", "'year'", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "'year'", "]", ":", "1970", ")", ";", "$", "finalDatetimeArray", "[", "1", "]", "=", "isset", "(", "$", "datetimeArray", "[", "1", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "1", "]", "-", "1", ":", "(", "isset", "(", "$", "datetimeArray", "[", "'mon'", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "'mon'", "]", "-", "1", ":", "0", ")", ";", "$", "finalDatetimeArray", "[", "2", "]", "=", "isset", "(", "$", "datetimeArray", "[", "2", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "2", "]", ":", "(", "isset", "(", "$", "datetimeArray", "[", "'mday'", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "'mday'", "]", ":", "1", ")", ";", "$", "finalDatetimeArray", "[", "3", "]", "=", "isset", "(", "$", "datetimeArray", "[", "3", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "3", "]", ":", "(", "isset", "(", "$", "datetimeArray", "[", "'hours'", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "'hours'", "]", ":", "0", ")", ";", "$", "finalDatetimeArray", "[", "4", "]", "=", "isset", "(", "$", "datetimeArray", "[", "4", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "4", "]", ":", "(", "isset", "(", "$", "datetimeArray", "[", "'minutes'", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "'minutes'", "]", ":", "0", ")", ";", "$", "finalDatetimeArray", "[", "5", "]", "=", "isset", "(", "$", "datetimeArray", "[", "5", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "5", "]", ":", "(", "isset", "(", "$", "datetimeArray", "[", "'seconds'", "]", ")", "?", "(", "int", ")", "$", "datetimeArray", "[", "'seconds'", "]", ":", "0", ")", ";", "return", "$", "finalDatetimeArray", ";", "}" ]
Parse DateTime information array to be in correct format. @param array $datetimeArray array contains information of DateTime in `year, month, day, hour, minute, day` order. This parameter can be a either associative or non-associative array. For the former, keys must be compitiable with http://php.net/manual/en/function.getdate.php. For missing pieces of information, a corresponded part from 1970/1/Jan., 00:00:00 will be replaced. @throws Exception @return array An `IntlDateFormatter` compatible array.
[ "Parse", "DateTime", "information", "array", "to", "be", "in", "correct", "format", "." ]
cb5abc65562f6151520f640480d14cc9a31c18e0
https://github.com/meysampg/intldate/blob/cb5abc65562f6151520f640480d14cc9a31c18e0/IntlDateTrait.php#L617-L633
222,901
sgpatil/oriquent
src/Sgpatil/Orientdb/Connection.php
Connection.createConnection
public function createConnection() { // below code is used to create connection usinf Orientdb $client = new OriClient($this->getHost(), $this->getPort(), $this->getDatabase()); $client->getTransport()->setAuth($this->getUsername(), $this->getPassword()); return $client; }
php
public function createConnection() { // below code is used to create connection usinf Orientdb $client = new OriClient($this->getHost(), $this->getPort(), $this->getDatabase()); $client->getTransport()->setAuth($this->getUsername(), $this->getPassword()); return $client; }
[ "public", "function", "createConnection", "(", ")", "{", "// below code is used to create connection usinf Orientdb", "$", "client", "=", "new", "OriClient", "(", "$", "this", "->", "getHost", "(", ")", ",", "$", "this", "->", "getPort", "(", ")", ",", "$", "this", "->", "getDatabase", "(", ")", ")", ";", "$", "client", "->", "getTransport", "(", ")", "->", "setAuth", "(", "$", "this", "->", "getUsername", "(", ")", ",", "$", "this", "->", "getPassword", "(", ")", ")", ";", "return", "$", "client", ";", "}" ]
Create a new Orientdb client @return
[ "Create", "a", "new", "Orientdb", "client" ]
cf0f2ba688496260946f569a20c351e91f287c32
https://github.com/sgpatil/oriquent/blob/cf0f2ba688496260946f569a20c351e91f287c32/src/Sgpatil/Orientdb/Connection.php#L73-L78
222,902
sgpatil/oriquent
src/Sgpatil/Orientdb/Connection.php
Connection.getBatchQuery
public function getBatchQuery($query, array $bindings) { return new BatchQuery($this->getClient(), $query, $this->prepareBindings($bindings)); }
php
public function getBatchQuery($query, array $bindings) { return new BatchQuery($this->getClient(), $query, $this->prepareBindings($bindings)); }
[ "public", "function", "getBatchQuery", "(", "$", "query", ",", "array", "$", "bindings", ")", "{", "return", "new", "BatchQuery", "(", "$", "this", "->", "getClient", "(", ")", ",", "$", "query", ",", "$", "this", "->", "prepareBindings", "(", "$", "bindings", ")", ")", ";", "}" ]
Make a query out of a Batch statement and the bindings values @param string $query @param array $bindings
[ "Make", "a", "query", "out", "of", "a", "Batch", "statement", "and", "the", "bindings", "values" ]
cf0f2ba688496260946f569a20c351e91f287c32
https://github.com/sgpatil/oriquent/blob/cf0f2ba688496260946f569a20c351e91f287c32/src/Sgpatil/Orientdb/Connection.php#L260-L262
222,903
sgpatil/oriquent
src/Sgpatil/Orientdb/Connection.php
Connection.table
public function table($table) { $query = new Builder($this, $this->getQueryGrammar()); return $query->from($table); }
php
public function table($table) { $query = new Builder($this, $this->getQueryGrammar()); return $query->from($table); }
[ "public", "function", "table", "(", "$", "table", ")", "{", "$", "query", "=", "new", "Builder", "(", "$", "this", ",", "$", "this", "->", "getQueryGrammar", "(", ")", ")", ";", "return", "$", "query", "->", "from", "(", "$", "table", ")", ";", "}" ]
Begin a fluent query against a database table. In Orientdb's terminologies this is a node. @param string $table @return \Sgpatil\Orientdb\Query\Builder
[ "Begin", "a", "fluent", "query", "against", "a", "database", "table", ".", "In", "Orientdb", "s", "terminologies", "this", "is", "a", "node", "." ]
cf0f2ba688496260946f569a20c351e91f287c32
https://github.com/sgpatil/oriquent/blob/cf0f2ba688496260946f569a20c351e91f287c32/src/Sgpatil/Orientdb/Connection.php#L421-L425
222,904
sgpatil/oriquent
src/Sgpatil/Orientdb/Connection.php
Connection.run
protected function run($query, $bindings, Closure $callback) { $start = microtime(true); // To execute the statement, we'll simply call the callback, which will actually // run the Cypher against the Orientdb connection. Then we can calculate the time it // took to execute and log the query Cypher, bindings and time in our memory. try { $result = $callback($this, $query, $bindings); } // If an exception occurs when attempting to run a query, we'll format the error // message to include the bindings with Cypher, which will make this exception a // lot more helpful to the developer instead of just the database's errors. catch (\Exception $e) { throw new QueryException($query, $bindings, $e); } // Once we have run the query we will calculate the time that it took to run and // then log the query, bindings, and execution time so we will report them on // the event that the developer needs them. We'll log time in milliseconds. $time = $this->getElapsedTime($start); $this->logQuery($query, $bindings, $time); return $result; }
php
protected function run($query, $bindings, Closure $callback) { $start = microtime(true); // To execute the statement, we'll simply call the callback, which will actually // run the Cypher against the Orientdb connection. Then we can calculate the time it // took to execute and log the query Cypher, bindings and time in our memory. try { $result = $callback($this, $query, $bindings); } // If an exception occurs when attempting to run a query, we'll format the error // message to include the bindings with Cypher, which will make this exception a // lot more helpful to the developer instead of just the database's errors. catch (\Exception $e) { throw new QueryException($query, $bindings, $e); } // Once we have run the query we will calculate the time that it took to run and // then log the query, bindings, and execution time so we will report them on // the event that the developer needs them. We'll log time in milliseconds. $time = $this->getElapsedTime($start); $this->logQuery($query, $bindings, $time); return $result; }
[ "protected", "function", "run", "(", "$", "query", ",", "$", "bindings", ",", "Closure", "$", "callback", ")", "{", "$", "start", "=", "microtime", "(", "true", ")", ";", "// To execute the statement, we'll simply call the callback, which will actually", "// run the Cypher against the Orientdb connection. Then we can calculate the time it", "// took to execute and log the query Cypher, bindings and time in our memory.", "try", "{", "$", "result", "=", "$", "callback", "(", "$", "this", ",", "$", "query", ",", "$", "bindings", ")", ";", "}", "// If an exception occurs when attempting to run a query, we'll format the error", "// message to include the bindings with Cypher, which will make this exception a", "// lot more helpful to the developer instead of just the database's errors.", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "throw", "new", "QueryException", "(", "$", "query", ",", "$", "bindings", ",", "$", "e", ")", ";", "}", "// Once we have run the query we will calculate the time that it took to run and", "// then log the query, bindings, and execution time so we will report them on", "// the event that the developer needs them. We'll log time in milliseconds.", "$", "time", "=", "$", "this", "->", "getElapsedTime", "(", "$", "start", ")", ";", "$", "this", "->", "logQuery", "(", "$", "query", ",", "$", "bindings", ",", "$", "time", ")", ";", "return", "$", "result", ";", "}" ]
Run a Cypher statement and log its execution context. @param string $query @param array $bindings @param Closure $callback @return mixed @throws QueryException
[ "Run", "a", "Cypher", "statement", "and", "log", "its", "execution", "context", "." ]
cf0f2ba688496260946f569a20c351e91f287c32
https://github.com/sgpatil/oriquent/blob/cf0f2ba688496260946f569a20c351e91f287c32/src/Sgpatil/Orientdb/Connection.php#L437-L462
222,905
ajfranzoia/cakephp-mailgun
Lib/Network/Email/MailgunTransport.php
MailgunTransport.send
public function send(CakeEmail $email) { if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) { throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)'); } $mgClient = new Mailgun($this->_config['mg_api_key']); $headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'); $params = []; foreach ($email->getHeaders($headersList) as $header => $value) { if (isset($this->_paramMapping[$header]) && !empty($value)) { $key = $this->_paramMapping[$header]; $params[$key] = $value; } } $params['text'] = $email->message(CakeEmail::MESSAGE_TEXT); $params['html'] = $email->message(CakeEmail::MESSAGE_HTML); $attachments = array(); foreach ($email->attachments() as $name => $info) { $attachments['attachment'][] = '@' . $info['file']; } try { $result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments); if ($result->http_response_code != 200) { throw new Exception($result->http_response_body->message); } } catch (Exception $e) { throw $e; } return $result; }
php
public function send(CakeEmail $email) { if (Configure::read('Mailgun.preventManyToRecipients') !== false && count($email->to()) > 1) { throw new Exception('More than one "to" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)'); } $mgClient = new Mailgun($this->_config['mg_api_key']); $headersList = array('from', 'sender', 'replyTo', 'readReceipt', 'returnPath', 'to', 'cc', 'bcc', 'subject'); $params = []; foreach ($email->getHeaders($headersList) as $header => $value) { if (isset($this->_paramMapping[$header]) && !empty($value)) { $key = $this->_paramMapping[$header]; $params[$key] = $value; } } $params['text'] = $email->message(CakeEmail::MESSAGE_TEXT); $params['html'] = $email->message(CakeEmail::MESSAGE_HTML); $attachments = array(); foreach ($email->attachments() as $name => $info) { $attachments['attachment'][] = '@' . $info['file']; } try { $result = $mgClient->sendMessage($this->_config['mg_domain'], $params, $attachments); if ($result->http_response_code != 200) { throw new Exception($result->http_response_body->message); } } catch (Exception $e) { throw $e; } return $result; }
[ "public", "function", "send", "(", "CakeEmail", "$", "email", ")", "{", "if", "(", "Configure", "::", "read", "(", "'Mailgun.preventManyToRecipients'", ")", "!==", "false", "&&", "count", "(", "$", "email", "->", "to", "(", ")", ")", ">", "1", ")", "{", "throw", "new", "Exception", "(", "'More than one \"to\" recipient not allowed (set Mailgun.preventManyToRecipients = false to disable check)'", ")", ";", "}", "$", "mgClient", "=", "new", "Mailgun", "(", "$", "this", "->", "_config", "[", "'mg_api_key'", "]", ")", ";", "$", "headersList", "=", "array", "(", "'from'", ",", "'sender'", ",", "'replyTo'", ",", "'readReceipt'", ",", "'returnPath'", ",", "'to'", ",", "'cc'", ",", "'bcc'", ",", "'subject'", ")", ";", "$", "params", "=", "[", "]", ";", "foreach", "(", "$", "email", "->", "getHeaders", "(", "$", "headersList", ")", "as", "$", "header", "=>", "$", "value", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "_paramMapping", "[", "$", "header", "]", ")", "&&", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "key", "=", "$", "this", "->", "_paramMapping", "[", "$", "header", "]", ";", "$", "params", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "$", "params", "[", "'text'", "]", "=", "$", "email", "->", "message", "(", "CakeEmail", "::", "MESSAGE_TEXT", ")", ";", "$", "params", "[", "'html'", "]", "=", "$", "email", "->", "message", "(", "CakeEmail", "::", "MESSAGE_HTML", ")", ";", "$", "attachments", "=", "array", "(", ")", ";", "foreach", "(", "$", "email", "->", "attachments", "(", ")", "as", "$", "name", "=>", "$", "info", ")", "{", "$", "attachments", "[", "'attachment'", "]", "[", "]", "=", "'@'", ".", "$", "info", "[", "'file'", "]", ";", "}", "try", "{", "$", "result", "=", "$", "mgClient", "->", "sendMessage", "(", "$", "this", "->", "_config", "[", "'mg_domain'", "]", ",", "$", "params", ",", "$", "attachments", ")", ";", "if", "(", "$", "result", "->", "http_response_code", "!=", "200", ")", "{", "throw", "new", "Exception", "(", "$", "result", "->", "http_response_body", "->", "message", ")", ";", "}", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "$", "e", ";", "}", "return", "$", "result", ";", "}" ]
Send email via Mailgun @param CakeEmail $email @return array @throws Exception
[ "Send", "email", "via", "Mailgun" ]
0393f9a12e9a1f71181d6d68f2105a433cbc041d
https://github.com/ajfranzoia/cakephp-mailgun/blob/0393f9a12e9a1f71181d6d68f2105a433cbc041d/Lib/Network/Email/MailgunTransport.php#L80-L114
222,906
digiaonline/lumen-dynamodb
src/Console/DeleteTablesCommand.php
DeleteTablesCommand.deleteTables
protected function deleteTables() { if (empty( self::$tables )) { throw new \Exception('Cannot delete tables, as no configuration file given, or the ::$tables is not overridden.'); } $client = $this->dynamoDb->getClient(); $defaultAnswer = $this->input->getOption('yes'); $a = 'n'; foreach (self::$tables as $tableData) { $tableName = $tableData['TableName']; if ($this->tableExists($tableName)) { if ($defaultAnswer === false) { $a = $this->ask(sprintf('Are you sure you want to delete table "%s"? [y/N]', $tableName), 'n'); } if ($defaultAnswer || strtolower($a) === 'y') { // Reset the answer. $a = null; $this->comment(sprintf('Deleting table "%s"', $tableName)); $client->deleteTable([ 'TableName' => $tableName, ]); $client->waitUntil('TableNotExists', ['TableName' => $tableName]); $this->info('Table deleted.'); } else { $this->comment(sprintf('Skipping table %s', $tableName)); } } else { $this->warn(sprintf('Table "%s" does not exist.', $tableName)); } } }
php
protected function deleteTables() { if (empty( self::$tables )) { throw new \Exception('Cannot delete tables, as no configuration file given, or the ::$tables is not overridden.'); } $client = $this->dynamoDb->getClient(); $defaultAnswer = $this->input->getOption('yes'); $a = 'n'; foreach (self::$tables as $tableData) { $tableName = $tableData['TableName']; if ($this->tableExists($tableName)) { if ($defaultAnswer === false) { $a = $this->ask(sprintf('Are you sure you want to delete table "%s"? [y/N]', $tableName), 'n'); } if ($defaultAnswer || strtolower($a) === 'y') { // Reset the answer. $a = null; $this->comment(sprintf('Deleting table "%s"', $tableName)); $client->deleteTable([ 'TableName' => $tableName, ]); $client->waitUntil('TableNotExists', ['TableName' => $tableName]); $this->info('Table deleted.'); } else { $this->comment(sprintf('Skipping table %s', $tableName)); } } else { $this->warn(sprintf('Table "%s" does not exist.', $tableName)); } } }
[ "protected", "function", "deleteTables", "(", ")", "{", "if", "(", "empty", "(", "self", "::", "$", "tables", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "'Cannot delete tables, as no configuration file given, or the ::$tables is not overridden.'", ")", ";", "}", "$", "client", "=", "$", "this", "->", "dynamoDb", "->", "getClient", "(", ")", ";", "$", "defaultAnswer", "=", "$", "this", "->", "input", "->", "getOption", "(", "'yes'", ")", ";", "$", "a", "=", "'n'", ";", "foreach", "(", "self", "::", "$", "tables", "as", "$", "tableData", ")", "{", "$", "tableName", "=", "$", "tableData", "[", "'TableName'", "]", ";", "if", "(", "$", "this", "->", "tableExists", "(", "$", "tableName", ")", ")", "{", "if", "(", "$", "defaultAnswer", "===", "false", ")", "{", "$", "a", "=", "$", "this", "->", "ask", "(", "sprintf", "(", "'Are you sure you want to delete table \"%s\"? [y/N]'", ",", "$", "tableName", ")", ",", "'n'", ")", ";", "}", "if", "(", "$", "defaultAnswer", "||", "strtolower", "(", "$", "a", ")", "===", "'y'", ")", "{", "// Reset the answer.\r", "$", "a", "=", "null", ";", "$", "this", "->", "comment", "(", "sprintf", "(", "'Deleting table \"%s\"'", ",", "$", "tableName", ")", ")", ";", "$", "client", "->", "deleteTable", "(", "[", "'TableName'", "=>", "$", "tableName", ",", "]", ")", ";", "$", "client", "->", "waitUntil", "(", "'TableNotExists'", ",", "[", "'TableName'", "=>", "$", "tableName", "]", ")", ";", "$", "this", "->", "info", "(", "'Table deleted.'", ")", ";", "}", "else", "{", "$", "this", "->", "comment", "(", "sprintf", "(", "'Skipping table %s'", ",", "$", "tableName", ")", ")", ";", "}", "}", "else", "{", "$", "this", "->", "warn", "(", "sprintf", "(", "'Table \"%s\" does not exist.'", ",", "$", "tableName", ")", ")", ";", "}", "}", "}" ]
Deletes the tables defined in configuration file, or overridden. @throws \Exception
[ "Deletes", "the", "tables", "defined", "in", "configuration", "file", "or", "overridden", "." ]
d29edefbe461af0bc902037e397cc8586a2ec87c
https://github.com/digiaonline/lumen-dynamodb/blob/d29edefbe461af0bc902037e397cc8586a2ec87c/src/Console/DeleteTablesCommand.php#L61-L97
222,907
sgpatil/oriquent
src/Sgpatil/Orientdb/Query/Grammars/CypherGrammar.php
CypherGrammar.compileEdge
public function compileEdge(Builder $query, $parent, $related, $relationship = 'E', $values = []) { // Essentially we will force every insert to be treated as a batch insert which // simply makes creating the SQL easier for us since we can utilize the same // basic routine regardless of an amount of records given to us to insert. $from = $this->columnize([$parent->getAttributes()[$parent->getKeyName()]]); $to = $this->columnize([$related->getAttributes()[$related->getKeyName()]]); // code to check if relationship object exist or not // // if($relationship instanceof Relatio){ // // } // Add content if there are the $values present $property_query = NULL; if ($values != NULL) { $property_query = "CONTENT " . json_encode($values); } return "create edge {$relationship->getType()} from $from to $to " . $property_query; }
php
public function compileEdge(Builder $query, $parent, $related, $relationship = 'E', $values = []) { // Essentially we will force every insert to be treated as a batch insert which // simply makes creating the SQL easier for us since we can utilize the same // basic routine regardless of an amount of records given to us to insert. $from = $this->columnize([$parent->getAttributes()[$parent->getKeyName()]]); $to = $this->columnize([$related->getAttributes()[$related->getKeyName()]]); // code to check if relationship object exist or not // // if($relationship instanceof Relatio){ // // } // Add content if there are the $values present $property_query = NULL; if ($values != NULL) { $property_query = "CONTENT " . json_encode($values); } return "create edge {$relationship->getType()} from $from to $to " . $property_query; }
[ "public", "function", "compileEdge", "(", "Builder", "$", "query", ",", "$", "parent", ",", "$", "related", ",", "$", "relationship", "=", "'E'", ",", "$", "values", "=", "[", "]", ")", "{", "// Essentially we will force every insert to be treated as a batch insert which", "// simply makes creating the SQL easier for us since we can utilize the same", "// basic routine regardless of an amount of records given to us to insert.", "$", "from", "=", "$", "this", "->", "columnize", "(", "[", "$", "parent", "->", "getAttributes", "(", ")", "[", "$", "parent", "->", "getKeyName", "(", ")", "]", "]", ")", ";", "$", "to", "=", "$", "this", "->", "columnize", "(", "[", "$", "related", "->", "getAttributes", "(", ")", "[", "$", "related", "->", "getKeyName", "(", ")", "]", "]", ")", ";", "// code to check if relationship object exist or not", "// ", "// if($relationship instanceof Relatio){", "// ", "// }", "// Add content if there are the $values present", "$", "property_query", "=", "NULL", ";", "if", "(", "$", "values", "!=", "NULL", ")", "{", "$", "property_query", "=", "\"CONTENT \"", ".", "json_encode", "(", "$", "values", ")", ";", "}", "return", "\"create edge {$relationship->getType()} from $from to $to \"", ".", "$", "property_query", ";", "}" ]
Compile an Edge statement into SQL. @param \Illuminate\Database\Query\Builder $query @param array $values @return string
[ "Compile", "an", "Edge", "statement", "into", "SQL", "." ]
cf0f2ba688496260946f569a20c351e91f287c32
https://github.com/sgpatil/oriquent/blob/cf0f2ba688496260946f569a20c351e91f287c32/src/Sgpatil/Orientdb/Query/Grammars/CypherGrammar.php#L735-L756
222,908
coderity/wallet
src/Billable.php
Billable.addCard
public function addCard($params, $setAsDefault = false) { if (is_array($params)) { $result = $this->generateToken($params); if ($result['status'] === 'error') { return $result; } $token = $result['token']; } else { $token = $params; } if (!$this->stripe_id) { $customer = $this->createAsStripeCustomer($token); $card = $this->getDefaultCard(); return [ 'status' => 'success', 'cardId' => $card['id'] ]; } $customerId = $this->stripe_id; try { $stripe = new Stripe(Billable::getStripeKey()); $card = $stripe->cards() ->create($customerId, $token); if ($setAsDefault) { // lets set this card as the default $this->updateDefaultCard($card['id']); } return [ 'status' => 'success', 'cardId' => $card['id'] ]; } catch (\Exception $e) { return [ 'status' => 'error', 'message' => $e->getMessage() ]; } }
php
public function addCard($params, $setAsDefault = false) { if (is_array($params)) { $result = $this->generateToken($params); if ($result['status'] === 'error') { return $result; } $token = $result['token']; } else { $token = $params; } if (!$this->stripe_id) { $customer = $this->createAsStripeCustomer($token); $card = $this->getDefaultCard(); return [ 'status' => 'success', 'cardId' => $card['id'] ]; } $customerId = $this->stripe_id; try { $stripe = new Stripe(Billable::getStripeKey()); $card = $stripe->cards() ->create($customerId, $token); if ($setAsDefault) { // lets set this card as the default $this->updateDefaultCard($card['id']); } return [ 'status' => 'success', 'cardId' => $card['id'] ]; } catch (\Exception $e) { return [ 'status' => 'error', 'message' => $e->getMessage() ]; } }
[ "public", "function", "addCard", "(", "$", "params", ",", "$", "setAsDefault", "=", "false", ")", "{", "if", "(", "is_array", "(", "$", "params", ")", ")", "{", "$", "result", "=", "$", "this", "->", "generateToken", "(", "$", "params", ")", ";", "if", "(", "$", "result", "[", "'status'", "]", "===", "'error'", ")", "{", "return", "$", "result", ";", "}", "$", "token", "=", "$", "result", "[", "'token'", "]", ";", "}", "else", "{", "$", "token", "=", "$", "params", ";", "}", "if", "(", "!", "$", "this", "->", "stripe_id", ")", "{", "$", "customer", "=", "$", "this", "->", "createAsStripeCustomer", "(", "$", "token", ")", ";", "$", "card", "=", "$", "this", "->", "getDefaultCard", "(", ")", ";", "return", "[", "'status'", "=>", "'success'", ",", "'cardId'", "=>", "$", "card", "[", "'id'", "]", "]", ";", "}", "$", "customerId", "=", "$", "this", "->", "stripe_id", ";", "try", "{", "$", "stripe", "=", "new", "Stripe", "(", "Billable", "::", "getStripeKey", "(", ")", ")", ";", "$", "card", "=", "$", "stripe", "->", "cards", "(", ")", "->", "create", "(", "$", "customerId", ",", "$", "token", ")", ";", "if", "(", "$", "setAsDefault", ")", "{", "// lets set this card as the default", "$", "this", "->", "updateDefaultCard", "(", "$", "card", "[", "'id'", "]", ")", ";", "}", "return", "[", "'status'", "=>", "'success'", ",", "'cardId'", "=>", "$", "card", "[", "'id'", "]", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "[", "'status'", "=>", "'error'", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ";", "}", "}" ]
Adds a card @param mixed Either an array of params as per the generateToken method or simply a token @param bool $setAsDefault @return array
[ "Adds", "a", "card" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L18-L66
222,909
coderity/wallet
src/Billable.php
Billable.deleteCard
public function deleteCard($cardId) { if (!$this->stripe_id) { return [ 'status' => 'error', 'message' => 'Invalid StripeId' ]; } try { $stripe = new Stripe(Billable::getStripeKey()); $card = $stripe->cards() ->delete($this->stripe_id, $cardId); return [ 'status' => 'success', 'cardId' => $card['id'] ]; } catch (\Exception $e) { return [ 'status' => 'error', 'message' => $e->getMessage() ]; } }
php
public function deleteCard($cardId) { if (!$this->stripe_id) { return [ 'status' => 'error', 'message' => 'Invalid StripeId' ]; } try { $stripe = new Stripe(Billable::getStripeKey()); $card = $stripe->cards() ->delete($this->stripe_id, $cardId); return [ 'status' => 'success', 'cardId' => $card['id'] ]; } catch (\Exception $e) { return [ 'status' => 'error', 'message' => $e->getMessage() ]; } }
[ "public", "function", "deleteCard", "(", "$", "cardId", ")", "{", "if", "(", "!", "$", "this", "->", "stripe_id", ")", "{", "return", "[", "'status'", "=>", "'error'", ",", "'message'", "=>", "'Invalid StripeId'", "]", ";", "}", "try", "{", "$", "stripe", "=", "new", "Stripe", "(", "Billable", "::", "getStripeKey", "(", ")", ")", ";", "$", "card", "=", "$", "stripe", "->", "cards", "(", ")", "->", "delete", "(", "$", "this", "->", "stripe_id", ",", "$", "cardId", ")", ";", "return", "[", "'status'", "=>", "'success'", ",", "'cardId'", "=>", "$", "card", "[", "'id'", "]", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "[", "'status'", "=>", "'error'", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ";", "}", "}" ]
Deletes a card @param string $cardId @return array
[ "Deletes", "a", "card" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L106-L131
222,910
coderity/wallet
src/Billable.php
Billable.generateToken
public function generateToken(array $params) { $stripe = new Stripe(Billable::getStripeKey()); try { $attributes = [ 'card' => [ 'number' => $params['cardNumber'], 'exp_month' => $params['expiryMonth'], 'cvc' => $params['cvc'], 'exp_year' => $params['expiryYear'], ], ]; $token = $stripe->tokens()->create($attributes); return [ 'status' => 'success', 'token' => $token['id'] ]; } catch (\Exception $e) { return [ 'status' => 'error', 'message' => $e->getMessage() ]; } }
php
public function generateToken(array $params) { $stripe = new Stripe(Billable::getStripeKey()); try { $attributes = [ 'card' => [ 'number' => $params['cardNumber'], 'exp_month' => $params['expiryMonth'], 'cvc' => $params['cvc'], 'exp_year' => $params['expiryYear'], ], ]; $token = $stripe->tokens()->create($attributes); return [ 'status' => 'success', 'token' => $token['id'] ]; } catch (\Exception $e) { return [ 'status' => 'error', 'message' => $e->getMessage() ]; } }
[ "public", "function", "generateToken", "(", "array", "$", "params", ")", "{", "$", "stripe", "=", "new", "Stripe", "(", "Billable", "::", "getStripeKey", "(", ")", ")", ";", "try", "{", "$", "attributes", "=", "[", "'card'", "=>", "[", "'number'", "=>", "$", "params", "[", "'cardNumber'", "]", ",", "'exp_month'", "=>", "$", "params", "[", "'expiryMonth'", "]", ",", "'cvc'", "=>", "$", "params", "[", "'cvc'", "]", ",", "'exp_year'", "=>", "$", "params", "[", "'expiryYear'", "]", ",", "]", ",", "]", ";", "$", "token", "=", "$", "stripe", "->", "tokens", "(", ")", "->", "create", "(", "$", "attributes", ")", ";", "return", "[", "'status'", "=>", "'success'", ",", "'token'", "=>", "$", "token", "[", "'id'", "]", "]", ";", "}", "catch", "(", "\\", "Exception", "$", "e", ")", "{", "return", "[", "'status'", "=>", "'error'", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ";", "}", "}" ]
Generates a Stripe Token @param array $params Expects: cardNumber, expiryMonth, expiryYear, cvc @return array
[ "Generates", "a", "Stripe", "Token" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L138-L164
222,911
coderity/wallet
src/Billable.php
Billable.getCard
public function getCard($cardId) { if (!$this->stripe_id) { return null; } $customer = $this->asStripeCustomer(); foreach ($customer->sources->data as $card) { if ($card->id === $cardId) { return $card; } } return null; }
php
public function getCard($cardId) { if (!$this->stripe_id) { return null; } $customer = $this->asStripeCustomer(); foreach ($customer->sources->data as $card) { if ($card->id === $cardId) { return $card; } } return null; }
[ "public", "function", "getCard", "(", "$", "cardId", ")", "{", "if", "(", "!", "$", "this", "->", "stripe_id", ")", "{", "return", "null", ";", "}", "$", "customer", "=", "$", "this", "->", "asStripeCustomer", "(", ")", ";", "foreach", "(", "$", "customer", "->", "sources", "->", "data", "as", "$", "card", ")", "{", "if", "(", "$", "card", "->", "id", "===", "$", "cardId", ")", "{", "return", "$", "card", ";", "}", "}", "return", "null", ";", "}" ]
Gets a card @param string $cardId @return Laravel\Cashier\Stripe\Card
[ "Gets", "a", "card" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L171-L186
222,912
coderity/wallet
src/Billable.php
Billable.getDefaultCard
public function getDefaultCard() { if (!$this->stripe_id) { return null; } $customer = $this->asStripeCustomer(); foreach ($customer->sources->data as $card) { if ($card->id === $customer->default_source) { return $card; } } return null; }
php
public function getDefaultCard() { if (!$this->stripe_id) { return null; } $customer = $this->asStripeCustomer(); foreach ($customer->sources->data as $card) { if ($card->id === $customer->default_source) { return $card; } } return null; }
[ "public", "function", "getDefaultCard", "(", ")", "{", "if", "(", "!", "$", "this", "->", "stripe_id", ")", "{", "return", "null", ";", "}", "$", "customer", "=", "$", "this", "->", "asStripeCustomer", "(", ")", ";", "foreach", "(", "$", "customer", "->", "sources", "->", "data", "as", "$", "card", ")", "{", "if", "(", "$", "card", "->", "id", "===", "$", "customer", "->", "default_source", ")", "{", "return", "$", "card", ";", "}", "}", "return", "null", ";", "}" ]
Returns the default card @return Laravel\Cashier\Stripe\Card
[ "Returns", "the", "default", "card" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L192-L207
222,913
coderity/wallet
src/Billable.php
Billable.getStripeId
public function getStripeId() { if ($this->stripe_id) { return $this->stripe_id; } $customer = $this->createAsStripeCustomer(null); return $customer->id; }
php
public function getStripeId() { if ($this->stripe_id) { return $this->stripe_id; } $customer = $this->createAsStripeCustomer(null); return $customer->id; }
[ "public", "function", "getStripeId", "(", ")", "{", "if", "(", "$", "this", "->", "stripe_id", ")", "{", "return", "$", "this", "->", "stripe_id", ";", "}", "$", "customer", "=", "$", "this", "->", "createAsStripeCustomer", "(", "null", ")", ";", "return", "$", "customer", "->", "id", ";", "}" ]
Gets a users stripeId Or generates a new one if the user doesn't have one @return string
[ "Gets", "a", "users", "stripeId", "Or", "generates", "a", "new", "one", "if", "the", "user", "doesn", "t", "have", "one" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L214-L223
222,914
coderity/wallet
src/Billable.php
Billable.updateDefaultCard
public function updateDefaultCard($cardId) { // first lets update the default source for the stripe customer $customer = $this->asStripeCustomer(); $customer->default_source = $cardId; $result = $customer->save(); // now lets update the users default card $card = $this->getCard($cardId); $this->card_brand = $card->brand; $this->card_last_four = $card->last4; $this->save(); return $this; }
php
public function updateDefaultCard($cardId) { // first lets update the default source for the stripe customer $customer = $this->asStripeCustomer(); $customer->default_source = $cardId; $result = $customer->save(); // now lets update the users default card $card = $this->getCard($cardId); $this->card_brand = $card->brand; $this->card_last_four = $card->last4; $this->save(); return $this; }
[ "public", "function", "updateDefaultCard", "(", "$", "cardId", ")", "{", "// first lets update the default source for the stripe customer", "$", "customer", "=", "$", "this", "->", "asStripeCustomer", "(", ")", ";", "$", "customer", "->", "default_source", "=", "$", "cardId", ";", "$", "result", "=", "$", "customer", "->", "save", "(", ")", ";", "// now lets update the users default card", "$", "card", "=", "$", "this", "->", "getCard", "(", "$", "cardId", ")", ";", "$", "this", "->", "card_brand", "=", "$", "card", "->", "brand", ";", "$", "this", "->", "card_last_four", "=", "$", "card", "->", "last4", ";", "$", "this", "->", "save", "(", ")", ";", "return", "$", "this", ";", "}" ]
Updates the default card @param string $cardId The cardId to update to the default card @return $this
[ "Updates", "the", "default", "card" ]
9b64a12f3679379be10353d134d687abec464013
https://github.com/coderity/wallet/blob/9b64a12f3679379be10353d134d687abec464013/src/Billable.php#L242-L258
222,915
corneltek/FormKit
src/Widget/TextareaInput.php
TextareaInput.render
public function render($attributes = null) { if($attributes) $this->setAttributes( $attributes ); return '<textarea' . $this->renderAttributes() . '>' . htmlspecialchars($this->value, ENT_NOQUOTES, 'UTF-8') . '</textarea>'; }
php
public function render($attributes = null) { if($attributes) $this->setAttributes( $attributes ); return '<textarea' . $this->renderAttributes() . '>' . htmlspecialchars($this->value, ENT_NOQUOTES, 'UTF-8') . '</textarea>'; }
[ "public", "function", "render", "(", "$", "attributes", "=", "null", ")", "{", "if", "(", "$", "attributes", ")", "$", "this", "->", "setAttributes", "(", "$", "attributes", ")", ";", "return", "'<textarea'", ".", "$", "this", "->", "renderAttributes", "(", ")", ".", "'>'", ".", "htmlspecialchars", "(", "$", "this", "->", "value", ",", "ENT_NOQUOTES", ",", "'UTF-8'", ")", ".", "'</textarea>'", ";", "}" ]
Render Widget with attributes @param array $attributes @param string HTML string
[ "Render", "Widget", "with", "attributes" ]
c8963d494b8bd7d7f63928002057db86e5873c26
https://github.com/corneltek/FormKit/blob/c8963d494b8bd7d7f63928002057db86e5873c26/src/Widget/TextareaInput.php#L16-L26
222,916
joomla-framework/image
src/Image.php
Image.getImageFileProperties
public static function getImageFileProperties($path) { // Make sure the file exists. if (!file_exists($path)) { throw new \InvalidArgumentException('The image file does not exist.'); } // Get the image file information. $info = getimagesize($path); if (!$info) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to get properties for the image.'); // @codeCoverageIgnoreEnd } // Build the response object. $properties = (object) array( 'width' => $info[0], 'height' => $info[1], 'type' => $info[2], 'attributes' => $info[3], 'bits' => isset($info['bits']) ? $info['bits'] : null, 'channels' => isset($info['channels']) ? $info['channels'] : null, 'mime' => $info['mime'], 'filesize' => filesize($path), 'orientation' => self::getOrientationString((int) $info[0], (int) $info[1]), ); return $properties; }
php
public static function getImageFileProperties($path) { // Make sure the file exists. if (!file_exists($path)) { throw new \InvalidArgumentException('The image file does not exist.'); } // Get the image file information. $info = getimagesize($path); if (!$info) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to get properties for the image.'); // @codeCoverageIgnoreEnd } // Build the response object. $properties = (object) array( 'width' => $info[0], 'height' => $info[1], 'type' => $info[2], 'attributes' => $info[3], 'bits' => isset($info['bits']) ? $info['bits'] : null, 'channels' => isset($info['channels']) ? $info['channels'] : null, 'mime' => $info['mime'], 'filesize' => filesize($path), 'orientation' => self::getOrientationString((int) $info[0], (int) $info[1]), ); return $properties; }
[ "public", "static", "function", "getImageFileProperties", "(", "$", "path", ")", "{", "// Make sure the file exists.", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The image file does not exist.'", ")", ";", "}", "// Get the image file information.", "$", "info", "=", "getimagesize", "(", "$", "path", ")", ";", "if", "(", "!", "$", "info", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "RuntimeException", "(", "'Unable to get properties for the image.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "// Build the response object.", "$", "properties", "=", "(", "object", ")", "array", "(", "'width'", "=>", "$", "info", "[", "0", "]", ",", "'height'", "=>", "$", "info", "[", "1", "]", ",", "'type'", "=>", "$", "info", "[", "2", "]", ",", "'attributes'", "=>", "$", "info", "[", "3", "]", ",", "'bits'", "=>", "isset", "(", "$", "info", "[", "'bits'", "]", ")", "?", "$", "info", "[", "'bits'", "]", ":", "null", ",", "'channels'", "=>", "isset", "(", "$", "info", "[", "'channels'", "]", ")", "?", "$", "info", "[", "'channels'", "]", ":", "null", ",", "'mime'", "=>", "$", "info", "[", "'mime'", "]", ",", "'filesize'", "=>", "filesize", "(", "$", "path", ")", ",", "'orientation'", "=>", "self", "::", "getOrientationString", "(", "(", "int", ")", "$", "info", "[", "0", "]", ",", "(", "int", ")", "$", "info", "[", "1", "]", ")", ",", ")", ";", "return", "$", "properties", ";", "}" ]
Method to return a properties object for an image given a filesystem path. The result object has values for image width, height, type, attributes, mime type, bits, and channels. @param string $path The filesystem path to the image for which to get properties. @return \stdClass @since 1.0 @throws \InvalidArgumentException @throws \RuntimeException
[ "Method", "to", "return", "a", "properties", "object", "for", "an", "image", "given", "a", "filesystem", "path", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L213-L246
222,917
joomla-framework/image
src/Image.php
Image.getOrientationString
private static function getOrientationString($width, $height) { switch (true) { case $width > $height : return self::ORIENTATION_LANDSCAPE; case $width < $height : return self::ORIENTATION_PORTRAIT; default: return self::ORIENTATION_SQUARE; } }
php
private static function getOrientationString($width, $height) { switch (true) { case $width > $height : return self::ORIENTATION_LANDSCAPE; case $width < $height : return self::ORIENTATION_PORTRAIT; default: return self::ORIENTATION_SQUARE; } }
[ "private", "static", "function", "getOrientationString", "(", "$", "width", ",", "$", "height", ")", "{", "switch", "(", "true", ")", "{", "case", "$", "width", ">", "$", "height", ":", "return", "self", "::", "ORIENTATION_LANDSCAPE", ";", "case", "$", "width", "<", "$", "height", ":", "return", "self", "::", "ORIENTATION_PORTRAIT", ";", "default", ":", "return", "self", "::", "ORIENTATION_SQUARE", ";", "}", "}" ]
Compare width and height integers to determine image orientation. @param integer $width The width value to use for calculation @param integer $height The height value to use for calculation @return string Orientation string @since 1.2.0
[ "Compare", "width", "and", "height", "integers", "to", "determine", "image", "orientation", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L275-L288
222,918
joomla-framework/image
src/Image.php
Image.createThumbs
public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null) { // Make sure the resource handle is valid. if (!$this->isLoaded()) { throw new \LogicException('No valid image was loaded.'); } // No thumbFolder set -> we will create a thumbs folder in the current image folder if ($thumbsFolder === null) { $thumbsFolder = \dirname($this->getPath()) . '/thumbs'; } // Check destination if (!is_dir($thumbsFolder) && (!is_dir(\dirname($thumbsFolder)) || !@mkdir($thumbsFolder))) { throw new \InvalidArgumentException('Folder does not exist and cannot be created: ' . $thumbsFolder); } // Process thumbs $thumbsCreated = array(); if ($thumbs = $this->generateThumbs($thumbSizes, $creationMethod)) { // Parent image properties $imgProperties = static::getImageFileProperties($this->getPath()); foreach ($thumbs as $thumb) { // Get thumb properties $thumbWidth = $thumb->getWidth(); $thumbHeight = $thumb->getHeight(); // Generate thumb name $filename = pathinfo($this->getPath(), PATHINFO_FILENAME); $fileExtension = pathinfo($this->getPath(), PATHINFO_EXTENSION); $thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension; // Save thumb file to disk $thumbFileName = $thumbsFolder . '/' . $thumbFileName; if ($thumb->toFile($thumbFileName, $imgProperties->type)) { // Return Image object with thumb path to ease further manipulation $thumb->path = $thumbFileName; $thumbsCreated[] = $thumb; } } } return $thumbsCreated; }
php
public function createThumbs($thumbSizes, $creationMethod = self::SCALE_INSIDE, $thumbsFolder = null) { // Make sure the resource handle is valid. if (!$this->isLoaded()) { throw new \LogicException('No valid image was loaded.'); } // No thumbFolder set -> we will create a thumbs folder in the current image folder if ($thumbsFolder === null) { $thumbsFolder = \dirname($this->getPath()) . '/thumbs'; } // Check destination if (!is_dir($thumbsFolder) && (!is_dir(\dirname($thumbsFolder)) || !@mkdir($thumbsFolder))) { throw new \InvalidArgumentException('Folder does not exist and cannot be created: ' . $thumbsFolder); } // Process thumbs $thumbsCreated = array(); if ($thumbs = $this->generateThumbs($thumbSizes, $creationMethod)) { // Parent image properties $imgProperties = static::getImageFileProperties($this->getPath()); foreach ($thumbs as $thumb) { // Get thumb properties $thumbWidth = $thumb->getWidth(); $thumbHeight = $thumb->getHeight(); // Generate thumb name $filename = pathinfo($this->getPath(), PATHINFO_FILENAME); $fileExtension = pathinfo($this->getPath(), PATHINFO_EXTENSION); $thumbFileName = $filename . '_' . $thumbWidth . 'x' . $thumbHeight . '.' . $fileExtension; // Save thumb file to disk $thumbFileName = $thumbsFolder . '/' . $thumbFileName; if ($thumb->toFile($thumbFileName, $imgProperties->type)) { // Return Image object with thumb path to ease further manipulation $thumb->path = $thumbFileName; $thumbsCreated[] = $thumb; } } } return $thumbsCreated; }
[ "public", "function", "createThumbs", "(", "$", "thumbSizes", ",", "$", "creationMethod", "=", "self", "::", "SCALE_INSIDE", ",", "$", "thumbsFolder", "=", "null", ")", "{", "// Make sure the resource handle is valid.", "if", "(", "!", "$", "this", "->", "isLoaded", "(", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'No valid image was loaded.'", ")", ";", "}", "// No thumbFolder set -> we will create a thumbs folder in the current image folder", "if", "(", "$", "thumbsFolder", "===", "null", ")", "{", "$", "thumbsFolder", "=", "\\", "dirname", "(", "$", "this", "->", "getPath", "(", ")", ")", ".", "'/thumbs'", ";", "}", "// Check destination", "if", "(", "!", "is_dir", "(", "$", "thumbsFolder", ")", "&&", "(", "!", "is_dir", "(", "\\", "dirname", "(", "$", "thumbsFolder", ")", ")", "||", "!", "@", "mkdir", "(", "$", "thumbsFolder", ")", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Folder does not exist and cannot be created: '", ".", "$", "thumbsFolder", ")", ";", "}", "// Process thumbs", "$", "thumbsCreated", "=", "array", "(", ")", ";", "if", "(", "$", "thumbs", "=", "$", "this", "->", "generateThumbs", "(", "$", "thumbSizes", ",", "$", "creationMethod", ")", ")", "{", "// Parent image properties", "$", "imgProperties", "=", "static", "::", "getImageFileProperties", "(", "$", "this", "->", "getPath", "(", ")", ")", ";", "foreach", "(", "$", "thumbs", "as", "$", "thumb", ")", "{", "// Get thumb properties", "$", "thumbWidth", "=", "$", "thumb", "->", "getWidth", "(", ")", ";", "$", "thumbHeight", "=", "$", "thumb", "->", "getHeight", "(", ")", ";", "// Generate thumb name", "$", "filename", "=", "pathinfo", "(", "$", "this", "->", "getPath", "(", ")", ",", "PATHINFO_FILENAME", ")", ";", "$", "fileExtension", "=", "pathinfo", "(", "$", "this", "->", "getPath", "(", ")", ",", "PATHINFO_EXTENSION", ")", ";", "$", "thumbFileName", "=", "$", "filename", ".", "'_'", ".", "$", "thumbWidth", ".", "'x'", ".", "$", "thumbHeight", ".", "'.'", ".", "$", "fileExtension", ";", "// Save thumb file to disk", "$", "thumbFileName", "=", "$", "thumbsFolder", ".", "'/'", ".", "$", "thumbFileName", ";", "if", "(", "$", "thumb", "->", "toFile", "(", "$", "thumbFileName", ",", "$", "imgProperties", "->", "type", ")", ")", "{", "// Return Image object with thumb path to ease further manipulation", "$", "thumb", "->", "path", "=", "$", "thumbFileName", ";", "$", "thumbsCreated", "[", "]", "=", "$", "thumb", ";", "}", "}", "}", "return", "$", "thumbsCreated", ";", "}" ]
Method to create thumbnails from the current image and save them to disk. It allows creation by resizing or cropping the original image. @param mixed $thumbSizes string or array of strings. Example: $thumbSizes = array('150x75','250x150'); @param integer $creationMethod 1-3 resize $scaleMethod | 4 create cropping @param string $thumbsFolder destination thumbs folder. null generates a thumbs folder in the image folder @return array @since 1.0 @throws \LogicException @throws \InvalidArgumentException
[ "Method", "to", "create", "thumbnails", "from", "the", "current", "image", "and", "save", "them", "to", "disk", ".", "It", "allows", "creation", "by", "resizing", "or", "cropping", "the", "original", "image", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L377-L429
222,919
joomla-framework/image
src/Image.php
Image.loadFile
public function loadFile($path) { // Destroy the current image handle if it exists $this->destroy(); // Make sure the file exists. if (!file_exists($path)) { throw new \InvalidArgumentException('The image file does not exist.'); } // Get the image properties. $properties = static::getImageFileProperties($path); // Attempt to load the image based on the MIME-Type switch ($properties->mime) { case 'image/gif': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_GIF])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type GIF.'); throw new \RuntimeException('Attempting to load an image of unsupported type GIF.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefromgif($path); if (!\is_resource($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process GIF image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; case 'image/jpeg': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_JPEG])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type JPG.'); throw new \RuntimeException('Attempting to load an image of unsupported type JPG.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefromjpeg($path); if (!\is_resource($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process JPG image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; case 'image/png': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_PNG])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type PNG.'); throw new \RuntimeException('Attempting to load an image of unsupported type PNG.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefrompng($path); if (!\is_resource($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process PNG image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; default: $this->getLogger()->error('Attempting to load an image of unsupported type ' . $properties->mime); throw new \InvalidArgumentException('Attempting to load an image of unsupported type ' . $properties->mime); } // Set the filesystem path to the source image. $this->path = $path; }
php
public function loadFile($path) { // Destroy the current image handle if it exists $this->destroy(); // Make sure the file exists. if (!file_exists($path)) { throw new \InvalidArgumentException('The image file does not exist.'); } // Get the image properties. $properties = static::getImageFileProperties($path); // Attempt to load the image based on the MIME-Type switch ($properties->mime) { case 'image/gif': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_GIF])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type GIF.'); throw new \RuntimeException('Attempting to load an image of unsupported type GIF.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefromgif($path); if (!\is_resource($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process GIF image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; case 'image/jpeg': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_JPEG])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type JPG.'); throw new \RuntimeException('Attempting to load an image of unsupported type JPG.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefromjpeg($path); if (!\is_resource($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process JPG image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; case 'image/png': // Make sure the image type is supported. if (empty(static::$formats[IMAGETYPE_PNG])) { // @codeCoverageIgnoreStart $this->getLogger()->error('Attempting to load an image of unsupported type PNG.'); throw new \RuntimeException('Attempting to load an image of unsupported type PNG.'); // @codeCoverageIgnoreEnd } // Attempt to create the image handle. $handle = imagecreatefrompng($path); if (!\is_resource($handle)) { // @codeCoverageIgnoreStart throw new \RuntimeException('Unable to process PNG image.'); // @codeCoverageIgnoreEnd } $this->handle = $handle; break; default: $this->getLogger()->error('Attempting to load an image of unsupported type ' . $properties->mime); throw new \InvalidArgumentException('Attempting to load an image of unsupported type ' . $properties->mime); } // Set the filesystem path to the source image. $this->path = $path; }
[ "public", "function", "loadFile", "(", "$", "path", ")", "{", "// Destroy the current image handle if it exists", "$", "this", "->", "destroy", "(", ")", ";", "// Make sure the file exists.", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'The image file does not exist.'", ")", ";", "}", "// Get the image properties.", "$", "properties", "=", "static", "::", "getImageFileProperties", "(", "$", "path", ")", ";", "// Attempt to load the image based on the MIME-Type", "switch", "(", "$", "properties", "->", "mime", ")", "{", "case", "'image/gif'", ":", "// Make sure the image type is supported.", "if", "(", "empty", "(", "static", "::", "$", "formats", "[", "IMAGETYPE_GIF", "]", ")", ")", "{", "// @codeCoverageIgnoreStart", "$", "this", "->", "getLogger", "(", ")", "->", "error", "(", "'Attempting to load an image of unsupported type GIF.'", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "'Attempting to load an image of unsupported type GIF.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "// Attempt to create the image handle.", "$", "handle", "=", "imagecreatefromgif", "(", "$", "path", ")", ";", "if", "(", "!", "\\", "is_resource", "(", "$", "handle", ")", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "RuntimeException", "(", "'Unable to process GIF image.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "$", "this", "->", "handle", "=", "$", "handle", ";", "break", ";", "case", "'image/jpeg'", ":", "// Make sure the image type is supported.", "if", "(", "empty", "(", "static", "::", "$", "formats", "[", "IMAGETYPE_JPEG", "]", ")", ")", "{", "// @codeCoverageIgnoreStart", "$", "this", "->", "getLogger", "(", ")", "->", "error", "(", "'Attempting to load an image of unsupported type JPG.'", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "'Attempting to load an image of unsupported type JPG.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "// Attempt to create the image handle.", "$", "handle", "=", "imagecreatefromjpeg", "(", "$", "path", ")", ";", "if", "(", "!", "\\", "is_resource", "(", "$", "handle", ")", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "RuntimeException", "(", "'Unable to process JPG image.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "$", "this", "->", "handle", "=", "$", "handle", ";", "break", ";", "case", "'image/png'", ":", "// Make sure the image type is supported.", "if", "(", "empty", "(", "static", "::", "$", "formats", "[", "IMAGETYPE_PNG", "]", ")", ")", "{", "// @codeCoverageIgnoreStart", "$", "this", "->", "getLogger", "(", ")", "->", "error", "(", "'Attempting to load an image of unsupported type PNG.'", ")", ";", "throw", "new", "\\", "RuntimeException", "(", "'Attempting to load an image of unsupported type PNG.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "// Attempt to create the image handle.", "$", "handle", "=", "imagecreatefrompng", "(", "$", "path", ")", ";", "if", "(", "!", "\\", "is_resource", "(", "$", "handle", ")", ")", "{", "// @codeCoverageIgnoreStart", "throw", "new", "\\", "RuntimeException", "(", "'Unable to process PNG image.'", ")", ";", "// @codeCoverageIgnoreEnd", "}", "$", "this", "->", "handle", "=", "$", "handle", ";", "break", ";", "default", ":", "$", "this", "->", "getLogger", "(", ")", "->", "error", "(", "'Attempting to load an image of unsupported type '", ".", "$", "properties", "->", "mime", ")", ";", "throw", "new", "\\", "InvalidArgumentException", "(", "'Attempting to load an image of unsupported type '", ".", "$", "properties", "->", "mime", ")", ";", "}", "// Set the filesystem path to the source image.", "$", "this", "->", "path", "=", "$", "path", ";", "}" ]
Method to load a file into the Image object as the resource. @param string $path The filesystem path to load as an image. @return void @since 1.0 @throws \InvalidArgumentException @throws \RuntimeException
[ "Method", "to", "load", "a", "file", "into", "the", "Image", "object", "as", "the", "resource", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L624-L730
222,920
joomla-framework/image
src/Image.php
Image.cropResize
public function cropResize($width, $height, $createNew = true) { $width = $this->sanitizeWidth($width, $height); $height = $this->sanitizeHeight($height, $width); $resizewidth = $width; $resizeheight = $height; if (($this->getWidth() / $width) < ($this->getHeight() / $height)) { $resizeheight = 0; } else { $resizewidth = 0; } return $this->resize($resizewidth, $resizeheight, $createNew)->crop($width, $height, null, null, false); }
php
public function cropResize($width, $height, $createNew = true) { $width = $this->sanitizeWidth($width, $height); $height = $this->sanitizeHeight($height, $width); $resizewidth = $width; $resizeheight = $height; if (($this->getWidth() / $width) < ($this->getHeight() / $height)) { $resizeheight = 0; } else { $resizewidth = 0; } return $this->resize($resizewidth, $resizeheight, $createNew)->crop($width, $height, null, null, false); }
[ "public", "function", "cropResize", "(", "$", "width", ",", "$", "height", ",", "$", "createNew", "=", "true", ")", "{", "$", "width", "=", "$", "this", "->", "sanitizeWidth", "(", "$", "width", ",", "$", "height", ")", ";", "$", "height", "=", "$", "this", "->", "sanitizeHeight", "(", "$", "height", ",", "$", "width", ")", ";", "$", "resizewidth", "=", "$", "width", ";", "$", "resizeheight", "=", "$", "height", ";", "if", "(", "(", "$", "this", "->", "getWidth", "(", ")", "/", "$", "width", ")", "<", "(", "$", "this", "->", "getHeight", "(", ")", "/", "$", "height", ")", ")", "{", "$", "resizeheight", "=", "0", ";", "}", "else", "{", "$", "resizewidth", "=", "0", ";", "}", "return", "$", "this", "->", "resize", "(", "$", "resizewidth", ",", "$", "resizeheight", ",", "$", "createNew", ")", "->", "crop", "(", "$", "width", ",", "$", "height", ",", "null", ",", "null", ",", "false", ")", ";", "}" ]
Method to crop an image after resizing it to maintain proportions without having to do all the set up work. @param integer $width The desired width of the image in pixels or a percentage. @param integer $height The desired height of the image in pixels or a percentage. @param integer $createNew If true the current image will be cloned, resized, cropped and returned. @return Image @since 1.0
[ "Method", "to", "crop", "an", "image", "after", "resizing", "it", "to", "maintain", "proportions", "without", "having", "to", "do", "all", "the", "set", "up", "work", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L858-L876
222,921
joomla-framework/image
src/Image.php
Image.flip
public function flip($mode, $createNew = true) { // Create the new truecolor image handle. $handle = imagecreatetruecolor($this->getWidth(), $this->getHeight()); // Copy the image imagecopy($handle, $this->getHandle(), 0, 0, 0, 0, $this->getWidth(), $this->getHeight()); // Flip the image if (!imageflip($handle, $mode)) { throw new \LogicException('Unable to flip the image.'); } // If we are resizing to a new image, create a new Image object. if ($createNew) { // @codeCoverageIgnoreStart return new static($handle); // @codeCoverageIgnoreEnd } // Free the memory from the current handle $this->destroy(); // Swap out the current handle for the new image handle. $this->handle = $handle; return $this; }
php
public function flip($mode, $createNew = true) { // Create the new truecolor image handle. $handle = imagecreatetruecolor($this->getWidth(), $this->getHeight()); // Copy the image imagecopy($handle, $this->getHandle(), 0, 0, 0, 0, $this->getWidth(), $this->getHeight()); // Flip the image if (!imageflip($handle, $mode)) { throw new \LogicException('Unable to flip the image.'); } // If we are resizing to a new image, create a new Image object. if ($createNew) { // @codeCoverageIgnoreStart return new static($handle); // @codeCoverageIgnoreEnd } // Free the memory from the current handle $this->destroy(); // Swap out the current handle for the new image handle. $this->handle = $handle; return $this; }
[ "public", "function", "flip", "(", "$", "mode", ",", "$", "createNew", "=", "true", ")", "{", "// Create the new truecolor image handle.", "$", "handle", "=", "imagecreatetruecolor", "(", "$", "this", "->", "getWidth", "(", ")", ",", "$", "this", "->", "getHeight", "(", ")", ")", ";", "// Copy the image", "imagecopy", "(", "$", "handle", ",", "$", "this", "->", "getHandle", "(", ")", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "getWidth", "(", ")", ",", "$", "this", "->", "getHeight", "(", ")", ")", ";", "// Flip the image", "if", "(", "!", "imageflip", "(", "$", "handle", ",", "$", "mode", ")", ")", "{", "throw", "new", "\\", "LogicException", "(", "'Unable to flip the image.'", ")", ";", "}", "// If we are resizing to a new image, create a new Image object.", "if", "(", "$", "createNew", ")", "{", "// @codeCoverageIgnoreStart", "return", "new", "static", "(", "$", "handle", ")", ";", "// @codeCoverageIgnoreEnd", "}", "// Free the memory from the current handle", "$", "this", "->", "destroy", "(", ")", ";", "// Swap out the current handle for the new image handle.", "$", "this", "->", "handle", "=", "$", "handle", ";", "return", "$", "this", ";", "}" ]
Method to flip the current image. @param integer $mode The flip mode for flipping the image {@link https://www.php.net/imageflip#refsect1-function.imageflip-parameters} @param boolean $createNew If true the current image will be cloned, flipped and returned; else the current image will be flipped and returned. @return Image @since 1.2.0 @throws \LogicException
[ "Method", "to", "flip", "the", "current", "image", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L944-L974
222,922
joomla-framework/image
src/Image.php
Image.watermark
public function watermark(Image $watermark, $transparency = 50, $bottomMargin = 0, $rightMargin = 0) { imagecopymerge( $this->getHandle(), $watermark->getHandle(), $this->getWidth() - $watermark->getWidth() - $rightMargin, $this->getHeight() - $watermark->getHeight() - $bottomMargin, 0, 0, $watermark->getWidth(), $watermark->getHeight(), $transparency ); return $this; }
php
public function watermark(Image $watermark, $transparency = 50, $bottomMargin = 0, $rightMargin = 0) { imagecopymerge( $this->getHandle(), $watermark->getHandle(), $this->getWidth() - $watermark->getWidth() - $rightMargin, $this->getHeight() - $watermark->getHeight() - $bottomMargin, 0, 0, $watermark->getWidth(), $watermark->getHeight(), $transparency ); return $this; }
[ "public", "function", "watermark", "(", "Image", "$", "watermark", ",", "$", "transparency", "=", "50", ",", "$", "bottomMargin", "=", "0", ",", "$", "rightMargin", "=", "0", ")", "{", "imagecopymerge", "(", "$", "this", "->", "getHandle", "(", ")", ",", "$", "watermark", "->", "getHandle", "(", ")", ",", "$", "this", "->", "getWidth", "(", ")", "-", "$", "watermark", "->", "getWidth", "(", ")", "-", "$", "rightMargin", ",", "$", "this", "->", "getHeight", "(", ")", "-", "$", "watermark", "->", "getHeight", "(", ")", "-", "$", "bottomMargin", ",", "0", ",", "0", ",", "$", "watermark", "->", "getWidth", "(", ")", ",", "$", "watermark", "->", "getHeight", "(", ")", ",", "$", "transparency", ")", ";", "return", "$", "this", ";", "}" ]
Watermark the image @param Image $watermark The Image object containing the watermark graphic @param integer $transparency The transparency to use for the watermark graphic @param integer $bottomMargin The margin from the bottom of this image @param integer $rightMargin The margin from the right side of this image @return Image @since 1.3.0 @link https://www.php.net/manual/en/image.examples-watermark.php
[ "Watermark", "the", "image" ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L989-L1004
222,923
joomla-framework/image
src/Image.php
Image.sanitizeWidth
protected function sanitizeWidth($width, $height) { // If no width was given we will assume it is a square and use the height. $width = ($width === null) ? $height : $width; // If we were given a percentage, calculate the integer value. if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $width)) { $width = (int) round($this->getWidth() * (float) str_replace('%', '', $width) / 100); } else { // Else do some rounding so we come out with a sane integer value. $width = (int) round((float) $width); } return $width; }
php
protected function sanitizeWidth($width, $height) { // If no width was given we will assume it is a square and use the height. $width = ($width === null) ? $height : $width; // If we were given a percentage, calculate the integer value. if (preg_match('/^[0-9]+(\.[0-9]+)?\%$/', $width)) { $width = (int) round($this->getWidth() * (float) str_replace('%', '', $width) / 100); } else { // Else do some rounding so we come out with a sane integer value. $width = (int) round((float) $width); } return $width; }
[ "protected", "function", "sanitizeWidth", "(", "$", "width", ",", "$", "height", ")", "{", "// If no width was given we will assume it is a square and use the height.", "$", "width", "=", "(", "$", "width", "===", "null", ")", "?", "$", "height", ":", "$", "width", ";", "// If we were given a percentage, calculate the integer value.", "if", "(", "preg_match", "(", "'/^[0-9]+(\\.[0-9]+)?\\%$/'", ",", "$", "width", ")", ")", "{", "$", "width", "=", "(", "int", ")", "round", "(", "$", "this", "->", "getWidth", "(", ")", "*", "(", "float", ")", "str_replace", "(", "'%'", ",", "''", ",", "$", "width", ")", "/", "100", ")", ";", "}", "else", "{", "// Else do some rounding so we come out with a sane integer value.", "$", "width", "=", "(", "int", ")", "round", "(", "(", "float", ")", "$", "width", ")", ";", "}", "return", "$", "width", ";", "}" ]
Method to sanitize a width value. @param mixed $width The input width value to sanitize. @param mixed $height The input height value for reference. @return integer @since 1.0
[ "Method", "to", "sanitize", "a", "width", "value", "." ]
f393328f2fae287991afb554e3bc3146c5da0ffc
https://github.com/joomla-framework/image/blob/f393328f2fae287991afb554e3bc3146c5da0ffc/src/Image.php#L1183-L1200
222,924
awakenweb/livedocx
src/Document.php
Document.getAvailableFormats
public function getAvailableFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetDocumentFormats(); if ( isset($result->GetDocumentFormatsResult->string) ) { $ret = $result->GetDocumentFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of available document formats' , $ex); } }
php
public function getAvailableFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetDocumentFormats(); if ( isset($result->GetDocumentFormatsResult->string) ) { $ret = $result->GetDocumentFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of available document formats' , $ex); } }
[ "public", "function", "getAvailableFormats", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetDocumentFormats", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "GetDocumentFormatsResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetDocumentFormatsResult", "->", "string", ";", "$", "ret", "=", "array_map", "(", "'strtolower'", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of available document formats'", ",", "$", "ex", ")", ";", "}", "}" ]
Return a list of all available return formats you can ask for when generating the document @return array @throws StatusException
[ "Return", "a", "list", "of", "all", "available", "return", "formats", "you", "can", "ask", "for", "when", "generating", "the", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L85-L99
222,925
awakenweb/livedocx
src/Document.php
Document.setPassword
public function setPassword($password) { try { $this->getSoapClient()->SetDocumentPassword(array( 'password' => $password , )); return $this; } catch ( SoapException $ex ) { throw new PasswordException('Error while setting a password for the document' , $ex); } }
php
public function setPassword($password) { try { $this->getSoapClient()->SetDocumentPassword(array( 'password' => $password , )); return $this; } catch ( SoapException $ex ) { throw new PasswordException('Error while setting a password for the document' , $ex); } }
[ "public", "function", "setPassword", "(", "$", "password", ")", "{", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetDocumentPassword", "(", "array", "(", "'password'", "=>", "$", "password", ",", ")", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "PasswordException", "(", "'Error while setting a password for the document'", ",", "$", "ex", ")", ";", "}", "}" ]
Set a password for the generated document @param string $password @return Document @throws PasswordException
[ "Set", "a", "password", "for", "the", "generated", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L110-L121
222,926
awakenweb/livedocx
src/Document.php
Document.setPermissions
public function setPermissions($permissions , $password) { if ( ! is_array($permissions) || ! is_string($password) || $password === '' ) { throw new InvalidException('Permissions and password must be respectively an array and a string'); } try { $this->getSoapClient()->SetDocumentAccessPermissions(array( 'permissions' => $permissions , 'password' => $password , )); return $this; } catch ( SoapException $ex ) { throw new PermissionsException('Error while setting the list of permissions and master password for the document' , $ex); } }
php
public function setPermissions($permissions , $password) { if ( ! is_array($permissions) || ! is_string($password) || $password === '' ) { throw new InvalidException('Permissions and password must be respectively an array and a string'); } try { $this->getSoapClient()->SetDocumentAccessPermissions(array( 'permissions' => $permissions , 'password' => $password , )); return $this; } catch ( SoapException $ex ) { throw new PermissionsException('Error while setting the list of permissions and master password for the document' , $ex); } }
[ "public", "function", "setPermissions", "(", "$", "permissions", ",", "$", "password", ")", "{", "if", "(", "!", "is_array", "(", "$", "permissions", ")", "||", "!", "is_string", "(", "$", "password", ")", "||", "$", "password", "===", "''", ")", "{", "throw", "new", "InvalidException", "(", "'Permissions and password must be respectively an array and a string'", ")", ";", "}", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetDocumentAccessPermissions", "(", "array", "(", "'permissions'", "=>", "$", "permissions", ",", "'password'", "=>", "$", "password", ",", ")", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "PermissionsException", "(", "'Error while setting the list of permissions and master password for the document'", ",", "$", "ex", ")", ";", "}", "}" ]
Set a master password and a list of features accessible without this password @param array $permissions @param string $password @throws PermissionsException @throws InvalidException
[ "Set", "a", "master", "password", "and", "a", "list", "of", "features", "accessible", "without", "this", "password" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L132-L147
222,927
awakenweb/livedocx
src/Document.php
Document.getAccessOptions
public function getAccessOptions() { try { $ret = array(); $result = $this->getSoapClient()->GetDocumentAccessOptions(); if ( isset($result->GetDocumentAccessOptionsResult->string) ) { $ret = $result->GetDocumentAccessOptionsResult->string; } return $ret; } catch ( SoapException $ex ) { throw new PermissionsException('Error while getting the list of available permissions for the document' , $ex); } }
php
public function getAccessOptions() { try { $ret = array(); $result = $this->getSoapClient()->GetDocumentAccessOptions(); if ( isset($result->GetDocumentAccessOptionsResult->string) ) { $ret = $result->GetDocumentAccessOptionsResult->string; } return $ret; } catch ( SoapException $ex ) { throw new PermissionsException('Error while getting the list of available permissions for the document' , $ex); } }
[ "public", "function", "getAccessOptions", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetDocumentAccessOptions", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "GetDocumentAccessOptionsResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetDocumentAccessOptionsResult", "->", "string", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "PermissionsException", "(", "'Error while getting the list of available permissions for the document'", ",", "$", "ex", ")", ";", "}", "}" ]
Return a list of permissions you can use in setPermissions @return array @throws PermissionsException
[ "Return", "a", "list", "of", "permissions", "you", "can", "use", "in", "setPermissions" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L156-L169
222,928
awakenweb/livedocx
src/Document.php
Document.retrieve
public function retrieve($format = null) { if ( is_null($format) ) { $format = $this->format; } if ( is_null($format) ) { throw new InvalidException('You must provide a format to retrieve the document'); } $format = strtolower($format); try { $result = $this->getSoapClient()->RetrieveDocument(array( 'format' => $format , )); $this->data = base64_decode($result->RetrieveDocumentResult); return $this->data; } catch ( SoapException $ex ) { throw new RetrieveException('Error while retrieving the final document from Livedocx service' , $ex); } }
php
public function retrieve($format = null) { if ( is_null($format) ) { $format = $this->format; } if ( is_null($format) ) { throw new InvalidException('You must provide a format to retrieve the document'); } $format = strtolower($format); try { $result = $this->getSoapClient()->RetrieveDocument(array( 'format' => $format , )); $this->data = base64_decode($result->RetrieveDocumentResult); return $this->data; } catch ( SoapException $ex ) { throw new RetrieveException('Error while retrieving the final document from Livedocx service' , $ex); } }
[ "public", "function", "retrieve", "(", "$", "format", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "format", ")", ")", "{", "$", "format", "=", "$", "this", "->", "format", ";", "}", "if", "(", "is_null", "(", "$", "format", ")", ")", "{", "throw", "new", "InvalidException", "(", "'You must provide a format to retrieve the document'", ")", ";", "}", "$", "format", "=", "strtolower", "(", "$", "format", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "RetrieveDocument", "(", "array", "(", "'format'", "=>", "$", "format", ",", ")", ")", ";", "$", "this", "->", "data", "=", "base64_decode", "(", "$", "result", "->", "RetrieveDocumentResult", ")", ";", "return", "$", "this", "->", "data", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "RetrieveException", "(", "'Error while retrieving the final document from Livedocx service'", ",", "$", "ex", ")", ";", "}", "}" ]
Retrieve the final document from Livedocx service. If you didn't provide a format for retrieval using the setFormat method, you can do it here. @param string|null $format @return string @throws InvalidException @throws RetrieveException
[ "Retrieve", "the", "final", "document", "from", "Livedocx", "service", ".", "If", "you", "didn", "t", "provide", "a", "format", "for", "retrieval", "using", "the", "setFormat", "method", "you", "can", "do", "it", "here", "." ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L200-L220
222,929
awakenweb/livedocx
src/Document.php
Document.getPaginatedMetaFiles
protected function getPaginatedMetaFiles($from , $to) { if ( $from > $to ) { throw new InvalidException('Start page for metafiles must be inferior to end page'); } $ret = array(); try { $result = $this->getSoapClient()->GetMetafiles(array( 'fromPage' => ( integer ) $from , 'toPage' => ( integer ) $to , )); } catch ( SoapException $ex ) { throw new MetafilesException('Error while retrieving the document from Livedocx service' , $ex); } if ( isset($result->GetMetafilesResult->string) ) { $pageCounter = ( integer ) $from; if ( is_array($result->GetMetafilesResult->string) ) { foreach ( $result->GetMetafilesResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetMetafilesResult->string); } } return $ret; }
php
protected function getPaginatedMetaFiles($from , $to) { if ( $from > $to ) { throw new InvalidException('Start page for metafiles must be inferior to end page'); } $ret = array(); try { $result = $this->getSoapClient()->GetMetafiles(array( 'fromPage' => ( integer ) $from , 'toPage' => ( integer ) $to , )); } catch ( SoapException $ex ) { throw new MetafilesException('Error while retrieving the document from Livedocx service' , $ex); } if ( isset($result->GetMetafilesResult->string) ) { $pageCounter = ( integer ) $from; if ( is_array($result->GetMetafilesResult->string) ) { foreach ( $result->GetMetafilesResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetMetafilesResult->string); } } return $ret; }
[ "protected", "function", "getPaginatedMetaFiles", "(", "$", "from", ",", "$", "to", ")", "{", "if", "(", "$", "from", ">", "$", "to", ")", "{", "throw", "new", "InvalidException", "(", "'Start page for metafiles must be inferior to end page'", ")", ";", "}", "$", "ret", "=", "array", "(", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetMetafiles", "(", "array", "(", "'fromPage'", "=>", "(", "integer", ")", "$", "from", ",", "'toPage'", "=>", "(", "integer", ")", "$", "to", ",", ")", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "MetafilesException", "(", "'Error while retrieving the document from Livedocx service'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetMetafilesResult", "->", "string", ")", ")", "{", "$", "pageCounter", "=", "(", "integer", ")", "$", "from", ";", "if", "(", "is_array", "(", "$", "result", "->", "GetMetafilesResult", "->", "string", ")", ")", "{", "foreach", "(", "$", "result", "->", "GetMetafilesResult", "->", "string", "as", "$", "string", ")", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "string", ")", ";", "$", "pageCounter", "++", ";", "}", "}", "else", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "result", "->", "GetMetafilesResult", "->", "string", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Get a paginated list of document as Metafile images. @param int $from @param int $to @return array @throws MetafilesException @throws InvalidException
[ "Get", "a", "paginated", "list", "of", "document", "as", "Metafile", "images", "." ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L257-L285
222,930
awakenweb/livedocx
src/Document.php
Document.getAllMetafiles
protected function getAllMetafiles() { $ret = array(); try { $result = $this->getSoapClient()->GetAllMetafiles(); } catch ( SoapException $ex ) { throw new MetafilesException('Error while retrieving the document from Livedocx service' , $ex); } if ( isset($result->GetAllMetafilesResult->string) ) { $pageCounter = 1; if ( is_array($result->GetAllMetafilesResult->string) ) { foreach ( $result->GetAllMetafilesResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetAllMetafilesResult->string); } } return $ret; }
php
protected function getAllMetafiles() { $ret = array(); try { $result = $this->getSoapClient()->GetAllMetafiles(); } catch ( SoapException $ex ) { throw new MetafilesException('Error while retrieving the document from Livedocx service' , $ex); } if ( isset($result->GetAllMetafilesResult->string) ) { $pageCounter = 1; if ( is_array($result->GetAllMetafilesResult->string) ) { foreach ( $result->GetAllMetafilesResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetAllMetafilesResult->string); } } return $ret; }
[ "protected", "function", "getAllMetafiles", "(", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetAllMetafiles", "(", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "MetafilesException", "(", "'Error while retrieving the document from Livedocx service'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetAllMetafilesResult", "->", "string", ")", ")", "{", "$", "pageCounter", "=", "1", ";", "if", "(", "is_array", "(", "$", "result", "->", "GetAllMetafilesResult", "->", "string", ")", ")", "{", "foreach", "(", "$", "result", "->", "GetAllMetafilesResult", "->", "string", "as", "$", "string", ")", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "string", ")", ";", "$", "pageCounter", "++", ";", "}", "}", "else", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "result", "->", "GetAllMetafilesResult", "->", "string", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Get a complete list of document as Metafile images. @return array @throws MetafilesException
[ "Get", "a", "complete", "list", "of", "document", "as", "Metafile", "images", "." ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L294-L315
222,931
awakenweb/livedocx
src/Document.php
Document.getPaginatedBitmaps
protected function getPaginatedBitmaps($zoomFactor , $format , $from , $to) { if ( $from > $to ) { throw new InvalidException('Start page for bitmaps must be inferior to end page'); } $ret = array(); try { $result = $this->getSoapClient()->GetBitmaps(array( 'fromPage' => ( integer ) $from , 'toPage' => ( integer ) $to , 'zoomFactor' => ( integer ) $zoomFactor , 'format' => ( string ) $format , )); } catch ( SoapException $ex ) { throw new BitmapsException('Error while retrieving the final document as paginated bitmaps from Livedocx service' , $ex); } if ( isset($result->GetBitmapsResult->string) ) { $pageCounter = ( integer ) $from; if ( is_array($result->GetBitmapsResult->string) ) { foreach ( $result->GetBitmapsResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetBitmapsResult->string); } } return $ret; }
php
protected function getPaginatedBitmaps($zoomFactor , $format , $from , $to) { if ( $from > $to ) { throw new InvalidException('Start page for bitmaps must be inferior to end page'); } $ret = array(); try { $result = $this->getSoapClient()->GetBitmaps(array( 'fromPage' => ( integer ) $from , 'toPage' => ( integer ) $to , 'zoomFactor' => ( integer ) $zoomFactor , 'format' => ( string ) $format , )); } catch ( SoapException $ex ) { throw new BitmapsException('Error while retrieving the final document as paginated bitmaps from Livedocx service' , $ex); } if ( isset($result->GetBitmapsResult->string) ) { $pageCounter = ( integer ) $from; if ( is_array($result->GetBitmapsResult->string) ) { foreach ( $result->GetBitmapsResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetBitmapsResult->string); } } return $ret; }
[ "protected", "function", "getPaginatedBitmaps", "(", "$", "zoomFactor", ",", "$", "format", ",", "$", "from", ",", "$", "to", ")", "{", "if", "(", "$", "from", ">", "$", "to", ")", "{", "throw", "new", "InvalidException", "(", "'Start page for bitmaps must be inferior to end page'", ")", ";", "}", "$", "ret", "=", "array", "(", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetBitmaps", "(", "array", "(", "'fromPage'", "=>", "(", "integer", ")", "$", "from", ",", "'toPage'", "=>", "(", "integer", ")", "$", "to", ",", "'zoomFactor'", "=>", "(", "integer", ")", "$", "zoomFactor", ",", "'format'", "=>", "(", "string", ")", "$", "format", ",", ")", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "BitmapsException", "(", "'Error while retrieving the final document as paginated bitmaps from Livedocx service'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetBitmapsResult", "->", "string", ")", ")", "{", "$", "pageCounter", "=", "(", "integer", ")", "$", "from", ";", "if", "(", "is_array", "(", "$", "result", "->", "GetBitmapsResult", "->", "string", ")", ")", "{", "foreach", "(", "$", "result", "->", "GetBitmapsResult", "->", "string", "as", "$", "string", ")", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "string", ")", ";", "$", "pageCounter", "++", ";", "}", "}", "else", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "result", "->", "GetBitmapsResult", "->", "string", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Retrieve the final document as a list of paginated bitmap files @param int $zoomFactor @param string $format @return array @throws BitmapsException @throws InvalidException
[ "Retrieve", "the", "final", "document", "as", "a", "list", "of", "paginated", "bitmap", "files" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L357-L387
222,932
awakenweb/livedocx
src/Document.php
Document.getAllBitmaps
protected function getAllBitmaps($zoomFactor , $format) { $ret = array(); try { $result = $this->getSoapClient()->GetAllBitmaps(array( 'zoomFactor' => ( integer ) $zoomFactor , 'format' => ( string ) $format , )); } catch ( SoapException $ex ) { throw new BitmapsException('Error while retrieving the final document as bitmaps from Livedocx service' , $ex); } if ( isset($result->GetAllBitmapsResult->string) ) { $pageCounter = 1; if ( is_array($result->GetAllBitmapsResult->string) ) { foreach ( $result->GetAllBitmapsResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetAllBitmapsResult->string); } } return $ret; }
php
protected function getAllBitmaps($zoomFactor , $format) { $ret = array(); try { $result = $this->getSoapClient()->GetAllBitmaps(array( 'zoomFactor' => ( integer ) $zoomFactor , 'format' => ( string ) $format , )); } catch ( SoapException $ex ) { throw new BitmapsException('Error while retrieving the final document as bitmaps from Livedocx service' , $ex); } if ( isset($result->GetAllBitmapsResult->string) ) { $pageCounter = 1; if ( is_array($result->GetAllBitmapsResult->string) ) { foreach ( $result->GetAllBitmapsResult->string as $string ) { $ret[ $pageCounter ] = base64_decode($string); $pageCounter ++; } } else { $ret[ $pageCounter ] = base64_decode($result->GetAllBitmapsResult->string); } } return $ret; }
[ "protected", "function", "getAllBitmaps", "(", "$", "zoomFactor", ",", "$", "format", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetAllBitmaps", "(", "array", "(", "'zoomFactor'", "=>", "(", "integer", ")", "$", "zoomFactor", ",", "'format'", "=>", "(", "string", ")", "$", "format", ",", ")", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "BitmapsException", "(", "'Error while retrieving the final document as bitmaps from Livedocx service'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetAllBitmapsResult", "->", "string", ")", ")", "{", "$", "pageCounter", "=", "1", ";", "if", "(", "is_array", "(", "$", "result", "->", "GetAllBitmapsResult", "->", "string", ")", ")", "{", "foreach", "(", "$", "result", "->", "GetAllBitmapsResult", "->", "string", "as", "$", "string", ")", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "string", ")", ";", "$", "pageCounter", "++", ";", "}", "}", "else", "{", "$", "ret", "[", "$", "pageCounter", "]", "=", "base64_decode", "(", "$", "result", "->", "GetAllBitmapsResult", "->", "string", ")", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Retrieve the final document as a list of bitmap files @param int $zoomFactor @param string $format @return array @throws BitmapsException
[ "Retrieve", "the", "final", "document", "as", "a", "list", "of", "bitmap", "files" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Document.php#L399-L424
222,933
mongator/mongator
src/Mongator/Query/CachedQuery.php
CachedQuery.getDataCache
public function getDataCache() { $key = $this->generateKey(); return $this->getRepository()->getMongator()->getDataCache()->get($key); }
php
public function getDataCache() { $key = $this->generateKey(); return $this->getRepository()->getMongator()->getDataCache()->get($key); }
[ "public", "function", "getDataCache", "(", ")", "{", "$", "key", "=", "$", "this", "->", "generateKey", "(", ")", ";", "return", "$", "this", "->", "getRepository", "(", ")", "->", "getMongator", "(", ")", "->", "getDataCache", "(", ")", "->", "get", "(", "$", "key", ")", ";", "}" ]
Returns the data in cache. @return array|null The fields in cache, or null if there is not.
[ "Returns", "the", "data", "in", "cache", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Query/CachedQuery.php#L23-L28
222,934
lcache/lcache
src/Entry.php
Entry.getTTL
public function getTTL() { if (is_null($this->expiration)) { return null; } if ($this->expiration > $_SERVER['REQUEST_TIME']) { return $this->expiration - $_SERVER['REQUEST_TIME']; } return 0; }
php
public function getTTL() { if (is_null($this->expiration)) { return null; } if ($this->expiration > $_SERVER['REQUEST_TIME']) { return $this->expiration - $_SERVER['REQUEST_TIME']; } return 0; }
[ "public", "function", "getTTL", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "expiration", ")", ")", "{", "return", "null", ";", "}", "if", "(", "$", "this", "->", "expiration", ">", "$", "_SERVER", "[", "'REQUEST_TIME'", "]", ")", "{", "return", "$", "this", "->", "expiration", "-", "$", "_SERVER", "[", "'REQUEST_TIME'", "]", ";", "}", "return", "0", ";", "}" ]
Return the time-to-live for this entry. @return integer
[ "Return", "the", "time", "-", "to", "-", "live", "for", "this", "entry", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/Entry.php#L39-L48
222,935
mongator/mongator
src/Mongator/Document/AbstractDocument.php
AbstractDocument.clearEmbeddedsOneChanged
public function clearEmbeddedsOneChanged() { if (isset($this->data['embeddedsOne'])) { foreach ($this->data['embeddedsOne'] as $name => $embedded) { $this->getArchive()->remove('embedded_one.'.$name); } } }
php
public function clearEmbeddedsOneChanged() { if (isset($this->data['embeddedsOne'])) { foreach ($this->data['embeddedsOne'] as $name => $embedded) { $this->getArchive()->remove('embedded_one.'.$name); } } }
[ "public", "function", "clearEmbeddedsOneChanged", "(", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "data", "[", "'embeddedsOne'", "]", ")", ")", "{", "foreach", "(", "$", "this", "->", "data", "[", "'embeddedsOne'", "]", "as", "$", "name", "=>", "$", "embedded", ")", "{", "$", "this", "->", "getArchive", "(", ")", "->", "remove", "(", "'embedded_one.'", ".", "$", "name", ")", ";", "}", "}", "}" ]
Clear the embedded ones changed, that is, they will not be changed apart from here. @api
[ "Clear", "the", "embedded", "ones", "changed", "that", "is", "they", "will", "not", "be", "changed", "apart", "from", "here", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Document/AbstractDocument.php#L361-L368
222,936
webtoolsnz/yii2-admin-lte
src/Theme.php
Theme.init
public function init() { $this->basePath = __DIR__; AdminLteAsset::$skin = $this->skin; AdminLteAsset::$customSkin = $this->customSkin; if (!$this->pathMap) { $this->createPathMap(); } }
php
public function init() { $this->basePath = __DIR__; AdminLteAsset::$skin = $this->skin; AdminLteAsset::$customSkin = $this->customSkin; if (!$this->pathMap) { $this->createPathMap(); } }
[ "public", "function", "init", "(", ")", "{", "$", "this", "->", "basePath", "=", "__DIR__", ";", "AdminLteAsset", "::", "$", "skin", "=", "$", "this", "->", "skin", ";", "AdminLteAsset", "::", "$", "customSkin", "=", "$", "this", "->", "customSkin", ";", "if", "(", "!", "$", "this", "->", "pathMap", ")", "{", "$", "this", "->", "createPathMap", "(", ")", ";", "}", "}" ]
Set the basePath of the theme, the
[ "Set", "the", "basePath", "of", "the", "theme", "the" ]
6c08456503421b2a6c67109beb2df2f1fbfea875
https://github.com/webtoolsnz/yii2-admin-lte/blob/6c08456503421b2a6c67109beb2df2f1fbfea875/src/Theme.php#L62-L71
222,937
webtoolsnz/yii2-admin-lte
src/widgets/Menu.php
Menu.getItemOptions
protected function getItemOptions($items, $index) { $options = array_merge( $this->itemOptions, ArrayHelper::getValue($items[$index], 'options', []) ); Html::addCssClass($options, $this->generateItemClass($items, $index)); return $options; }
php
protected function getItemOptions($items, $index) { $options = array_merge( $this->itemOptions, ArrayHelper::getValue($items[$index], 'options', []) ); Html::addCssClass($options, $this->generateItemClass($items, $index)); return $options; }
[ "protected", "function", "getItemOptions", "(", "$", "items", ",", "$", "index", ")", "{", "$", "options", "=", "array_merge", "(", "$", "this", "->", "itemOptions", ",", "ArrayHelper", "::", "getValue", "(", "$", "items", "[", "$", "index", "]", ",", "'options'", ",", "[", "]", ")", ")", ";", "Html", "::", "addCssClass", "(", "$", "options", ",", "$", "this", "->", "generateItemClass", "(", "$", "items", ",", "$", "index", ")", ")", ";", "return", "$", "options", ";", "}" ]
Generates options for the item @param $items @param $index @return array
[ "Generates", "options", "for", "the", "item" ]
6c08456503421b2a6c67109beb2df2f1fbfea875
https://github.com/webtoolsnz/yii2-admin-lte/blob/6c08456503421b2a6c67109beb2df2f1fbfea875/src/widgets/Menu.php#L91-L101
222,938
lcache/lcache
src/L1CacheFactory.php
L1CacheFactory.create
public function create($driverName = null, $customPool = null) { // Normalize input. $pool = $this->getPool($customPool); $driver = mb_convert_case($driverName, MB_CASE_LOWER); $factoryName = 'create' . $driver; if (!method_exists($this, $factoryName)) { // TODO: Decide on better fallback (if needed). $factoryName = 'createStatic'; } $l1CacheInstance = call_user_func([$this, $factoryName], $pool); return $l1CacheInstance; }
php
public function create($driverName = null, $customPool = null) { // Normalize input. $pool = $this->getPool($customPool); $driver = mb_convert_case($driverName, MB_CASE_LOWER); $factoryName = 'create' . $driver; if (!method_exists($this, $factoryName)) { // TODO: Decide on better fallback (if needed). $factoryName = 'createStatic'; } $l1CacheInstance = call_user_func([$this, $factoryName], $pool); return $l1CacheInstance; }
[ "public", "function", "create", "(", "$", "driverName", "=", "null", ",", "$", "customPool", "=", "null", ")", "{", "// Normalize input.", "$", "pool", "=", "$", "this", "->", "getPool", "(", "$", "customPool", ")", ";", "$", "driver", "=", "mb_convert_case", "(", "$", "driverName", ",", "MB_CASE_LOWER", ")", ";", "$", "factoryName", "=", "'create'", ".", "$", "driver", ";", "if", "(", "!", "method_exists", "(", "$", "this", ",", "$", "factoryName", ")", ")", "{", "// TODO: Decide on better fallback (if needed).", "$", "factoryName", "=", "'createStatic'", ";", "}", "$", "l1CacheInstance", "=", "call_user_func", "(", "[", "$", "this", ",", "$", "factoryName", "]", ",", "$", "pool", ")", ";", "return", "$", "l1CacheInstance", ";", "}" ]
L1 cache drivers const @todo Change the return value to L1CacheInterface @param string $driverName Name of the L1 driver implementation to create. One of the DRIVER_* class constants. @param string $customPool Pool ID to use for the data separation. @return L1 Concrete instance that confirms to an L1 interface.
[ "L1", "cache", "drivers", "const" ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/L1CacheFactory.php#L31-L45
222,939
lcache/lcache
src/L1CacheFactory.php
L1CacheFactory.createSQLite
protected function createSQLite($pool) { $hasApcu = function_exists('apcu_fetch'); // TODO: Maybe implement StateL1SQLite class instead of NULL one. $state = $hasApcu ? new StateL1APCu("sqlite-$pool") : new StateL1Static(); $cache = new SQLiteL1($pool, $state); return $cache; }
php
protected function createSQLite($pool) { $hasApcu = function_exists('apcu_fetch'); // TODO: Maybe implement StateL1SQLite class instead of NULL one. $state = $hasApcu ? new StateL1APCu("sqlite-$pool") : new StateL1Static(); $cache = new SQLiteL1($pool, $state); return $cache; }
[ "protected", "function", "createSQLite", "(", "$", "pool", ")", "{", "$", "hasApcu", "=", "function_exists", "(", "'apcu_fetch'", ")", ";", "// TODO: Maybe implement StateL1SQLite class instead of NULL one.", "$", "state", "=", "$", "hasApcu", "?", "new", "StateL1APCu", "(", "\"sqlite-$pool\"", ")", ":", "new", "StateL1Static", "(", ")", ";", "$", "cache", "=", "new", "SQLiteL1", "(", "$", "pool", ",", "$", "state", ")", ";", "return", "$", "cache", ";", "}" ]
Factory method for the L1 SQLite driver. @param string $pool @return \LCache\SQLiteL1
[ "Factory", "method", "for", "the", "L1", "SQLite", "driver", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/L1CacheFactory.php#L86-L93
222,940
lcache/lcache
src/L1CacheFactory.php
L1CacheFactory.getPool
protected function getPool($pool = null) { if (!is_null($pool)) { $result = (string) $pool; } elseif (isset($_SERVER['SERVER_ADDR']) && isset($_SERVER['SERVER_PORT'])) { $result = $_SERVER['SERVER_ADDR'] . '-' . $_SERVER['SERVER_PORT']; } else { $result = $this->generateUniqueID(); } return $result; }
php
protected function getPool($pool = null) { if (!is_null($pool)) { $result = (string) $pool; } elseif (isset($_SERVER['SERVER_ADDR']) && isset($_SERVER['SERVER_PORT'])) { $result = $_SERVER['SERVER_ADDR'] . '-' . $_SERVER['SERVER_PORT']; } else { $result = $this->generateUniqueID(); } return $result; }
[ "protected", "function", "getPool", "(", "$", "pool", "=", "null", ")", "{", "if", "(", "!", "is_null", "(", "$", "pool", ")", ")", "{", "$", "result", "=", "(", "string", ")", "$", "pool", ";", "}", "elseif", "(", "isset", "(", "$", "_SERVER", "[", "'SERVER_ADDR'", "]", ")", "&&", "isset", "(", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ")", ")", "{", "$", "result", "=", "$", "_SERVER", "[", "'SERVER_ADDR'", "]", ".", "'-'", ".", "$", "_SERVER", "[", "'SERVER_PORT'", "]", ";", "}", "else", "{", "$", "result", "=", "$", "this", "->", "generateUniqueID", "(", ")", ";", "}", "return", "$", "result", ";", "}" ]
Pool generator utility. @param string $pool Custom pool to use. Defaults to NULL. If the default is uesed, it will atempt to generate a pool value for use. @return string Pool value based on input and/or environment variables / state.
[ "Pool", "generator", "utility", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/L1CacheFactory.php#L105-L115
222,941
awakenweb/livedocx
src/Livedocx.php
Livedocx.prepare
public function prepare() { $blocks = $this->container->getBlocks(); $fields = array_merge($this->container->getFields() , $this->container->getImages()); $this->declareListOfBlocks($blocks) ->declareListOfValues($fields); return $this->createDocument(); }
php
public function prepare() { $blocks = $this->container->getBlocks(); $fields = array_merge($this->container->getFields() , $this->container->getImages()); $this->declareListOfBlocks($blocks) ->declareListOfValues($fields); return $this->createDocument(); }
[ "public", "function", "prepare", "(", ")", "{", "$", "blocks", "=", "$", "this", "->", "container", "->", "getBlocks", "(", ")", ";", "$", "fields", "=", "array_merge", "(", "$", "this", "->", "container", "->", "getFields", "(", ")", ",", "$", "this", "->", "container", "->", "getImages", "(", ")", ")", ";", "$", "this", "->", "declareListOfBlocks", "(", "$", "blocks", ")", "->", "declareListOfValues", "(", "$", "fields", ")", ";", "return", "$", "this", "->", "createDocument", "(", ")", ";", "}" ]
Prepare the merging of the fields and return a document @param Container $container @return Document
[ "Prepare", "the", "merging", "of", "the", "fields", "and", "return", "a", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Livedocx.php#L135-L145
222,942
awakenweb/livedocx
src/Livedocx.php
Livedocx.declareListOfBlocks
protected function declareListOfBlocks($blocks) { foreach ( $blocks as $block ) { try { $this->getSoapClient()->SetBlockFieldValues(array( 'blockName' => $block->getName() , 'blockFieldValues' => $this->getSoapClient()->convertArray($block->retrieveValues()) )); } catch ( SoapException $ex ) { $s = ''; if ( ! is_null($block->getName()) ) { $s.= " (block: {$block->getName()})"; } throw new DeclarationException("Error while sending blocks informations to Livedocx service" . $s , $ex); } } return $this; }
php
protected function declareListOfBlocks($blocks) { foreach ( $blocks as $block ) { try { $this->getSoapClient()->SetBlockFieldValues(array( 'blockName' => $block->getName() , 'blockFieldValues' => $this->getSoapClient()->convertArray($block->retrieveValues()) )); } catch ( SoapException $ex ) { $s = ''; if ( ! is_null($block->getName()) ) { $s.= " (block: {$block->getName()})"; } throw new DeclarationException("Error while sending blocks informations to Livedocx service" . $s , $ex); } } return $this; }
[ "protected", "function", "declareListOfBlocks", "(", "$", "blocks", ")", "{", "foreach", "(", "$", "blocks", "as", "$", "block", ")", "{", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetBlockFieldValues", "(", "array", "(", "'blockName'", "=>", "$", "block", "->", "getName", "(", ")", ",", "'blockFieldValues'", "=>", "$", "this", "->", "getSoapClient", "(", ")", "->", "convertArray", "(", "$", "block", "->", "retrieveValues", "(", ")", ")", ")", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "$", "s", "=", "''", ";", "if", "(", "!", "is_null", "(", "$", "block", "->", "getName", "(", ")", ")", ")", "{", "$", "s", ".=", "\" (block: {$block->getName()})\"", ";", "}", "throw", "new", "DeclarationException", "(", "\"Error while sending blocks informations to Livedocx service\"", ".", "$", "s", ",", "$", "ex", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Send the list of all block values to Livedocx service to prepare the merging @param array $blocks @return Livedocx @throws DeclarationException
[ "Send", "the", "list", "of", "all", "block", "values", "to", "Livedocx", "service", "to", "prepare", "the", "merging" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Livedocx.php#L156-L173
222,943
awakenweb/livedocx
src/Livedocx.php
Livedocx.declareListOfValues
protected function declareListOfValues($fields) { try { $this->getSoapClient()->SetFieldValues(array( 'fieldValues' => $this->getSoapClient()->convertArray($fields) )); } catch ( SoapException $e ) { throw new DeclarationException('Error while sending the fields/values binding to Livedocx service' , $e); } return $this; }
php
protected function declareListOfValues($fields) { try { $this->getSoapClient()->SetFieldValues(array( 'fieldValues' => $this->getSoapClient()->convertArray($fields) )); } catch ( SoapException $e ) { throw new DeclarationException('Error while sending the fields/values binding to Livedocx service' , $e); } return $this; }
[ "protected", "function", "declareListOfValues", "(", "$", "fields", ")", "{", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetFieldValues", "(", "array", "(", "'fieldValues'", "=>", "$", "this", "->", "getSoapClient", "(", ")", "->", "convertArray", "(", "$", "fields", ")", ")", ")", ";", "}", "catch", "(", "SoapException", "$", "e", ")", "{", "throw", "new", "DeclarationException", "(", "'Error while sending the fields/values binding to Livedocx service'", ",", "$", "e", ")", ";", "}", "return", "$", "this", ";", "}" ]
Send the list of all field values to Livedocx service to prepare the merging @param array $fields @return Livedocx @throws DeclarationException
[ "Send", "the", "list", "of", "all", "field", "values", "to", "Livedocx", "service", "to", "prepare", "the", "merging" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Livedocx.php#L184-L195
222,944
lcache/lcache
src/DatabaseL2.php
DatabaseL2.getEvent
public function getEvent($event_id) { $sth = $this->dbh->prepare('SELECT * FROM ' . $this->prefixTable('lcache_events') .' WHERE event_id = :event_id'); $sth->bindValue(':event_id', $event_id, \PDO::PARAM_INT); $sth->execute(); $event = $sth->fetchObject(); if (false === $event) { return null; } $event->value = unserialize($event->value); return $event; }
php
public function getEvent($event_id) { $sth = $this->dbh->prepare('SELECT * FROM ' . $this->prefixTable('lcache_events') .' WHERE event_id = :event_id'); $sth->bindValue(':event_id', $event_id, \PDO::PARAM_INT); $sth->execute(); $event = $sth->fetchObject(); if (false === $event) { return null; } $event->value = unserialize($event->value); return $event; }
[ "public", "function", "getEvent", "(", "$", "event_id", ")", "{", "$", "sth", "=", "$", "this", "->", "dbh", "->", "prepare", "(", "'SELECT * FROM '", ".", "$", "this", "->", "prefixTable", "(", "'lcache_events'", ")", ".", "' WHERE event_id = :event_id'", ")", ";", "$", "sth", "->", "bindValue", "(", "':event_id'", ",", "$", "event_id", ",", "\\", "PDO", "::", "PARAM_INT", ")", ";", "$", "sth", "->", "execute", "(", ")", ";", "$", "event", "=", "$", "sth", "->", "fetchObject", "(", ")", ";", "if", "(", "false", "===", "$", "event", ")", "{", "return", "null", ";", "}", "$", "event", "->", "value", "=", "unserialize", "(", "$", "event", "->", "value", ")", ";", "return", "$", "event", ";", "}" ]
Returns the event entry. Currently used only for testing.
[ "Returns", "the", "event", "entry", ".", "Currently", "used", "only", "for", "testing", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/DatabaseL2.php#L189-L200
222,945
awakenweb/livedocx
src/Template.php
Template.listAll
public function listAll() { try { $ret = array(); $result = $this->getSoapClient()->ListTemplates(); if ( isset($result->ListTemplatesResult) ) { $ret = $this->getSoapClient()->backendListArrayToMultiAssocArray($result->ListTemplatesResult); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all uploaded templates' , $ex); } }
php
public function listAll() { try { $ret = array(); $result = $this->getSoapClient()->ListTemplates(); if ( isset($result->ListTemplatesResult) ) { $ret = $this->getSoapClient()->backendListArrayToMultiAssocArray($result->ListTemplatesResult); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all uploaded templates' , $ex); } }
[ "public", "function", "listAll", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "ListTemplates", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "ListTemplatesResult", ")", ")", "{", "$", "ret", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "backendListArrayToMultiAssocArray", "(", "$", "result", "->", "ListTemplatesResult", ")", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of all uploaded templates'", ",", "$", "ex", ")", ";", "}", "}" ]
Return the list of all templates uploaded to the Livedocx service @return type @throws StatusException
[ "Return", "the", "list", "of", "all", "templates", "uploaded", "to", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Template.php#L73-L86
222,946
awakenweb/livedocx
src/Template.php
Template.getAcceptedTemplateFormats
public function getAcceptedTemplateFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetTemplateFormats(); if ( isset($result->GetTemplateFormatsResult->string) ) { $ret = $result->GetTemplateFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of accepted template formats' , $ex); } }
php
public function getAcceptedTemplateFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetTemplateFormats(); if ( isset($result->GetTemplateFormatsResult->string) ) { $ret = $result->GetTemplateFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of accepted template formats' , $ex); } }
[ "public", "function", "getAcceptedTemplateFormats", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetTemplateFormats", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "GetTemplateFormatsResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetTemplateFormatsResult", "->", "string", ";", "$", "ret", "=", "array_map", "(", "'strtolower'", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of accepted template formats'", ",", "$", "ex", ")", ";", "}", "}" ]
Return a list of all the accepted template formats you can use to generate your document @return array @throws StatusException
[ "Return", "a", "list", "of", "all", "the", "accepted", "template", "formats", "you", "can", "use", "to", "generate", "your", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Template.php#L95-L109
222,947
awakenweb/livedocx
src/Template.php
Template.getAvailableFonts
public function getAvailableFonts() { try { $ret = array(); $result = $this->getSoapClient()->GetFontNames(); if ( isset($result->GetFontNamesResult->string) ) { $ret = $result->GetFontNamesResult->string; } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of available fonts' , $ex); } }
php
public function getAvailableFonts() { try { $ret = array(); $result = $this->getSoapClient()->GetFontNames(); if ( isset($result->GetFontNamesResult->string) ) { $ret = $result->GetFontNamesResult->string; } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of available fonts' , $ex); } }
[ "public", "function", "getAvailableFonts", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetFontNames", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "GetFontNamesResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetFontNamesResult", "->", "string", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of available fonts'", ",", "$", "ex", ")", ";", "}", "}" ]
Get the list of all available fonts on the Livedocx service @return type @throws StatusException
[ "Get", "the", "list", "of", "all", "available", "fonts", "on", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Template.php#L118-L131
222,948
awakenweb/livedocx
src/Template.php
Template.ignoreAllSubTemplates
public function ignoreAllSubTemplates($state = true) { $state = ( bool ) $state; try { $this->getSoapClient()->SetIgnoreSubTemplates(array( 'ignoreSubTemplates' => $state , )); return $this; } catch ( SoapException $ex ) { throw new IgnoreException("Error while telling the server to ignore subtemplates" , $ex); } }
php
public function ignoreAllSubTemplates($state = true) { $state = ( bool ) $state; try { $this->getSoapClient()->SetIgnoreSubTemplates(array( 'ignoreSubTemplates' => $state , )); return $this; } catch ( SoapException $ex ) { throw new IgnoreException("Error while telling the server to ignore subtemplates" , $ex); } }
[ "public", "function", "ignoreAllSubTemplates", "(", "$", "state", "=", "true", ")", "{", "$", "state", "=", "(", "bool", ")", "$", "state", ";", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetIgnoreSubTemplates", "(", "array", "(", "'ignoreSubTemplates'", "=>", "$", "state", ",", ")", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "IgnoreException", "(", "\"Error while telling the server to ignore subtemplates\"", ",", "$", "ex", ")", ";", "}", "}" ]
Tell the Livedocx service to ignore included subtemplates when generating the final document @param boolean $state @return Template @throws IgnoreException
[ "Tell", "the", "Livedocx", "service", "to", "ignore", "included", "subtemplates", "when", "generating", "the", "final", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Template.php#L143-L155
222,949
awakenweb/livedocx
src/Template.php
Template.ignoreListOfSubTemplates
public function ignoreListOfSubTemplates($subtemplates_list) { if ( ! is_array($subtemplates_list) ) { throw new InvalidException('List of subtemplate filenames must be an array'); } $filenames = array_values($subtemplates_list); try { $this->getSoapClient()->SetSubTemplateIgnoreList(array( 'filenames' => $filenames , )); return $this; } catch ( SoapException $ex ) { throw new IgnoreException("Error while telling the server to ignore a list of subtemplates" , $ex); } }
php
public function ignoreListOfSubTemplates($subtemplates_list) { if ( ! is_array($subtemplates_list) ) { throw new InvalidException('List of subtemplate filenames must be an array'); } $filenames = array_values($subtemplates_list); try { $this->getSoapClient()->SetSubTemplateIgnoreList(array( 'filenames' => $filenames , )); return $this; } catch ( SoapException $ex ) { throw new IgnoreException("Error while telling the server to ignore a list of subtemplates" , $ex); } }
[ "public", "function", "ignoreListOfSubTemplates", "(", "$", "subtemplates_list", ")", "{", "if", "(", "!", "is_array", "(", "$", "subtemplates_list", ")", ")", "{", "throw", "new", "InvalidException", "(", "'List of subtemplate filenames must be an array'", ")", ";", "}", "$", "filenames", "=", "array_values", "(", "$", "subtemplates_list", ")", ";", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetSubTemplateIgnoreList", "(", "array", "(", "'filenames'", "=>", "$", "filenames", ",", ")", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "IgnoreException", "(", "\"Error while telling the server to ignore a list of subtemplates\"", ",", "$", "ex", ")", ";", "}", "}" ]
Define a list of subtemplates to ignore when generating the final document @param array $subtemplates_list @return Template @throws IgnoreException @throws InvalidException
[ "Define", "a", "list", "of", "subtemplates", "to", "ignore", "when", "generating", "the", "final", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Template.php#L167-L182
222,950
lcache/lcache
src/LX.php
LX.get
public function get(Address $address) { $entry = $this->getEntry($address); if (is_null($entry)) { return null; } return $entry->value; }
php
public function get(Address $address) { $entry = $this->getEntry($address); if (is_null($entry)) { return null; } return $entry->value; }
[ "public", "function", "get", "(", "Address", "$", "address", ")", "{", "$", "entry", "=", "$", "this", "->", "getEntry", "(", "$", "address", ")", ";", "if", "(", "is_null", "(", "$", "entry", ")", ")", "{", "return", "null", ";", "}", "return", "$", "entry", "->", "value", ";", "}" ]
Fetch a value from the cache. @param Address $address @return string|null
[ "Fetch", "a", "value", "from", "the", "cache", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/LX.php#L19-L26
222,951
mongator/mongator
src/Mongator/Group/AbstractGroup.php
AbstractGroup.markAllSaved
public function markAllSaved() { $this->saved = $this->all(); foreach ($this->saved as $document) { $document->clearModified(); $rap = $document->getRootAndPath(); $rap['path'] = str_replace('._add', '.', $rap['path']); $document->setRootAndPath($rap['root'], $rap['path']); } $this->clearAdd(); $this->clearRemove(); }
php
public function markAllSaved() { $this->saved = $this->all(); foreach ($this->saved as $document) { $document->clearModified(); $rap = $document->getRootAndPath(); $rap['path'] = str_replace('._add', '.', $rap['path']); $document->setRootAndPath($rap['root'], $rap['path']); } $this->clearAdd(); $this->clearRemove(); }
[ "public", "function", "markAllSaved", "(", ")", "{", "$", "this", "->", "saved", "=", "$", "this", "->", "all", "(", ")", ";", "foreach", "(", "$", "this", "->", "saved", "as", "$", "document", ")", "{", "$", "document", "->", "clearModified", "(", ")", ";", "$", "rap", "=", "$", "document", "->", "getRootAndPath", "(", ")", ";", "$", "rap", "[", "'path'", "]", "=", "str_replace", "(", "'._add'", ",", "'.'", ",", "$", "rap", "[", "'path'", "]", ")", ";", "$", "document", "->", "setRootAndPath", "(", "$", "rap", "[", "'root'", "]", ",", "$", "rap", "[", "'path'", "]", ")", ";", "}", "$", "this", "->", "clearAdd", "(", ")", ";", "$", "this", "->", "clearRemove", "(", ")", ";", "}" ]
Marks everything as saved, removes pending add and delete arrays
[ "Marks", "everything", "as", "saved", "removes", "pending", "add", "and", "delete", "arrays" ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Group/AbstractGroup.php#L154-L165
222,952
mongator/mongator
src/Mongator/Archive.php
Archive.set
public function set($key, $value) { $this->keys[$key] = true; $this->archive[$key] = $value; }
php
public function set($key, $value) { $this->keys[$key] = true; $this->archive[$key] = $value; }
[ "public", "function", "set", "(", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "keys", "[", "$", "key", "]", "=", "true", ";", "$", "this", "->", "archive", "[", "$", "key", "]", "=", "$", "value", ";", "}" ]
Set a key value. @param string $key The key. @param mixed $value The value.
[ "Set", "a", "key", "value", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Archive.php#L56-L60
222,953
mongator/mongator
src/Mongator/Archive.php
Archive.remove
public function remove($key) { if (!$this->has($key)) { return; } unset($this->archive[$key]); unset($this->keys[$key]); }
php
public function remove($key) { if (!$this->has($key)) { return; } unset($this->archive[$key]); unset($this->keys[$key]); }
[ "public", "function", "remove", "(", "$", "key", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "return", ";", "}", "unset", "(", "$", "this", "->", "archive", "[", "$", "key", "]", ")", ";", "unset", "(", "$", "this", "->", "keys", "[", "$", "key", "]", ")", ";", "}" ]
Remove a key. @param string $key The key.
[ "Remove", "a", "key", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Archive.php#L67-L76
222,954
mongator/mongator
src/Mongator/Archive.php
Archive.&
public function &getByRef($key, $default = null) { if (!$this->has($key)) { $this->set($key, $default); } return $this->archive[$key]; }
php
public function &getByRef($key, $default = null) { if (!$this->has($key)) { $this->set($key, $default); } return $this->archive[$key]; }
[ "public", "function", "&", "getByRef", "(", "$", "key", ",", "$", "default", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "has", "(", "$", "key", ")", ")", "{", "$", "this", "->", "set", "(", "$", "key", ",", "$", "default", ")", ";", "}", "return", "$", "this", "->", "archive", "[", "$", "key", "]", ";", "}" ]
Returns a key by reference. It creates the key if the key does not exist. @param string $key The key. @param mixed $default The default value, used to create the key if it does not exist (null by default). @return mixed The object key value.
[ "Returns", "a", "key", "by", "reference", ".", "It", "creates", "the", "key", "if", "the", "key", "does", "not", "exist", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Archive.php#L86-L93
222,955
mongator/mongator
src/Mongator/Type/Container.php
Container.get
public static function get($name) { if (!isset(static::$types[$name])) { if (!static::has($name)) { throw new \InvalidArgumentException(sprintf('The type "%s" does not exists.', $name)); } static::$types[$name] = new static::$map[$name]; } return static::$types[$name]; }
php
public static function get($name) { if (!isset(static::$types[$name])) { if (!static::has($name)) { throw new \InvalidArgumentException(sprintf('The type "%s" does not exists.', $name)); } static::$types[$name] = new static::$map[$name]; } return static::$types[$name]; }
[ "public", "static", "function", "get", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "static", "::", "$", "types", "[", "$", "name", "]", ")", ")", "{", "if", "(", "!", "static", "::", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The type \"%s\" does not exists.'", ",", "$", "name", ")", ")", ";", "}", "static", "::", "$", "types", "[", "$", "name", "]", "=", "new", "static", "::", "$", "map", "[", "$", "name", "]", ";", "}", "return", "static", "::", "$", "types", "[", "$", "name", "]", ";", "}" ]
Returns a type. @param string $name The type name. @return \Mongator\Type\Type The type. @throws \InvalidArgumentException If the type does not exists. @api
[ "Returns", "a", "type", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Type/Container.php#L88-L99
222,956
mongator/mongator
src/Mongator/Type/Container.php
Container.remove
public static function remove($name) { if (!static::has($name)) { throw new \InvalidArgumentException(sprintf('The type "%s" does not exists.', $name)); } unset(static::$map[$name], static::$types[$name]); }
php
public static function remove($name) { if (!static::has($name)) { throw new \InvalidArgumentException(sprintf('The type "%s" does not exists.', $name)); } unset(static::$map[$name], static::$types[$name]); }
[ "public", "static", "function", "remove", "(", "$", "name", ")", "{", "if", "(", "!", "static", "::", "has", "(", "$", "name", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "sprintf", "(", "'The type \"%s\" does not exists.'", ",", "$", "name", ")", ")", ";", "}", "unset", "(", "static", "::", "$", "map", "[", "$", "name", "]", ",", "static", "::", "$", "types", "[", "$", "name", "]", ")", ";", "}" ]
Remove a type. @param string $name The type name. @throws \InvalidArgumentException If the type does not exists. @api
[ "Remove", "a", "type", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Type/Container.php#L110-L117
222,957
awakenweb/livedocx
src/Templates/Remote.php
Remote.setAsActive
public function setAsActive() { if ( ! $this->exists() ) { throw new FileExistException('Remote template does not exist'); } try { $this->getSoapClient()->SetRemoteTemplate(['filename' => $this->getName() ]); $this->isActive = true; return $this; } catch ( SoapException $ex ) { throw new ActiveException('Error while setting the remote template as the active template' , $ex); } }
php
public function setAsActive() { if ( ! $this->exists() ) { throw new FileExistException('Remote template does not exist'); } try { $this->getSoapClient()->SetRemoteTemplate(['filename' => $this->getName() ]); $this->isActive = true; return $this; } catch ( SoapException $ex ) { throw new ActiveException('Error while setting the remote template as the active template' , $ex); } }
[ "public", "function", "setAsActive", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "throw", "new", "FileExistException", "(", "'Remote template does not exist'", ")", ";", "}", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "SetRemoteTemplate", "(", "[", "'filename'", "=>", "$", "this", "->", "getName", "(", ")", "]", ")", ";", "$", "this", "->", "isActive", "=", "true", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "ActiveException", "(", "'Error while setting the remote template as the active template'", ",", "$", "ex", ")", ";", "}", "}" ]
Set the remote template as active to be used when generating the final document @return Remote @throws ActiveException @throws InvalidException
[ "Set", "the", "remote", "template", "as", "active", "to", "be", "used", "when", "generating", "the", "final", "document" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Remote.php#L56-L70
222,958
awakenweb/livedocx
src/Templates/Remote.php
Remote.exists
public function exists() { try { $result = $this->soapClient->templateExists(['filename' => $this->getName() ]); return ( bool ) $result->TemplateExistsResult; } catch ( SoapException $ex ) { throw new StatusException('Error while verifying the existence of a remote template' , $ex); } }
php
public function exists() { try { $result = $this->soapClient->templateExists(['filename' => $this->getName() ]); return ( bool ) $result->TemplateExistsResult; } catch ( SoapException $ex ) { throw new StatusException('Error while verifying the existence of a remote template' , $ex); } }
[ "public", "function", "exists", "(", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "soapClient", "->", "templateExists", "(", "[", "'filename'", "=>", "$", "this", "->", "getName", "(", ")", "]", ")", ";", "return", "(", "bool", ")", "$", "result", "->", "TemplateExistsResult", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while verifying the existence of a remote template'", ",", "$", "ex", ")", ";", "}", "}" ]
Check if a remote template exists on the Livedocx service @return boolean @throw StatusException
[ "Check", "if", "a", "remote", "template", "exists", "on", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Remote.php#L84-L93
222,959
awakenweb/livedocx
src/Templates/Remote.php
Remote.getFieldNames
public function getFieldNames() { if ( ! $this->isActive ) { throw new NonActiveException('You can only get the field names of the active template'); } $ret = array(); try { $result = $this->getSoapClient()->GetFieldNames(); } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all fields in the active template' , $ex); } if ( isset($result->GetFieldNamesResult->string) ) { if ( is_array($result->GetFieldNamesResult->string) ) { $ret = $result->GetFieldNamesResult->string; } else { $ret[] = $result->GetFieldNamesResult->string; } } return $ret; }
php
public function getFieldNames() { if ( ! $this->isActive ) { throw new NonActiveException('You can only get the field names of the active template'); } $ret = array(); try { $result = $this->getSoapClient()->GetFieldNames(); } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all fields in the active template' , $ex); } if ( isset($result->GetFieldNamesResult->string) ) { if ( is_array($result->GetFieldNamesResult->string) ) { $ret = $result->GetFieldNamesResult->string; } else { $ret[] = $result->GetFieldNamesResult->string; } } return $ret; }
[ "public", "function", "getFieldNames", "(", ")", "{", "if", "(", "!", "$", "this", "->", "isActive", ")", "{", "throw", "new", "NonActiveException", "(", "'You can only get the field names of the active template'", ")", ";", "}", "$", "ret", "=", "array", "(", ")", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetFieldNames", "(", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of all fields in the active template'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetFieldNamesResult", "->", "string", ")", ")", "{", "if", "(", "is_array", "(", "$", "result", "->", "GetFieldNamesResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetFieldNamesResult", "->", "string", ";", "}", "else", "{", "$", "ret", "[", "]", "=", "$", "result", "->", "GetFieldNamesResult", "->", "string", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Return the list of all fields in the active template @return array @throws StatusException @throws NonActiveException
[ "Return", "the", "list", "of", "all", "fields", "in", "the", "active", "template" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Remote.php#L103-L126
222,960
awakenweb/livedocx
src/Templates/Remote.php
Remote.download
public function download() { if ( ! $this->exists() ) { throw new FileExistException('Remote template does not exist'); } try { $result = $this->getSoapClient()->DownloadTemplate(array( 'filename' => basename($this->getName()) )); return base64_decode($result->DownloadTemplateResult); } catch ( SoapException $ex ) { throw new DownloadException('Error while downloading the remote template from Livedocx service' , $ex); } }
php
public function download() { if ( ! $this->exists() ) { throw new FileExistException('Remote template does not exist'); } try { $result = $this->getSoapClient()->DownloadTemplate(array( 'filename' => basename($this->getName()) )); return base64_decode($result->DownloadTemplateResult); } catch ( SoapException $ex ) { throw new DownloadException('Error while downloading the remote template from Livedocx service' , $ex); } }
[ "public", "function", "download", "(", ")", "{", "if", "(", "!", "$", "this", "->", "exists", "(", ")", ")", "{", "throw", "new", "FileExistException", "(", "'Remote template does not exist'", ")", ";", "}", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "DownloadTemplate", "(", "array", "(", "'filename'", "=>", "basename", "(", "$", "this", "->", "getName", "(", ")", ")", ")", ")", ";", "return", "base64_decode", "(", "$", "result", "->", "DownloadTemplateResult", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "DownloadException", "(", "'Error while downloading the remote template from Livedocx service'", ",", "$", "ex", ")", ";", "}", "}" ]
Download a remote template from the Livedocx service @throws TemplateException @throws FileExistException
[ "Download", "a", "remote", "template", "from", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Remote.php#L134-L148
222,961
awakenweb/livedocx
src/Templates/Remote.php
Remote.delete
public function delete() { try { $this->getSoapClient()->DeleteTemplate(array( 'filename' => basename($this->getName()) )); return $this; } catch ( SoapException $ex ) { throw new DeleteException('Error while deleting the remote template from Livedocx service' , $ex); } }
php
public function delete() { try { $this->getSoapClient()->DeleteTemplate(array( 'filename' => basename($this->getName()) )); return $this; } catch ( SoapException $ex ) { throw new DeleteException('Error while deleting the remote template from Livedocx service' , $ex); } }
[ "public", "function", "delete", "(", ")", "{", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "DeleteTemplate", "(", "array", "(", "'filename'", "=>", "basename", "(", "$", "this", "->", "getName", "(", ")", ")", ")", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "DeleteException", "(", "'Error while deleting the remote template from Livedocx service'", ",", "$", "ex", ")", ";", "}", "}" ]
Delete a remote template from the Livedocx service. @return Remote @throws TemplateException
[ "Delete", "a", "remote", "template", "from", "the", "Livedocx", "service", "." ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Templates/Remote.php#L157-L168
222,962
mongator/mongator
src/Mongator/Group/EmbeddedGroup.php
EmbeddedGroup.setRootAndPath
public function setRootAndPath(Document $root, $path) { $this->getArchive()->set('root_and_path', array('root' => $root, 'path' => $path)); foreach ($this->getAdd() as $key => $document) { $document->setRootAndPath($root, $path.'._add'.$key); } }
php
public function setRootAndPath(Document $root, $path) { $this->getArchive()->set('root_and_path', array('root' => $root, 'path' => $path)); foreach ($this->getAdd() as $key => $document) { $document->setRootAndPath($root, $path.'._add'.$key); } }
[ "public", "function", "setRootAndPath", "(", "Document", "$", "root", ",", "$", "path", ")", "{", "$", "this", "->", "getArchive", "(", ")", "->", "set", "(", "'root_and_path'", ",", "array", "(", "'root'", "=>", "$", "root", ",", "'path'", "=>", "$", "path", ")", ")", ";", "foreach", "(", "$", "this", "->", "getAdd", "(", ")", "as", "$", "key", "=>", "$", "document", ")", "{", "$", "document", "->", "setRootAndPath", "(", "$", "root", ",", "$", "path", ".", "'._add'", ".", "$", "key", ")", ";", "}", "}" ]
Set the root and path of the embedded group. @param \Mongator\Document\Document $root The root document. @param string $path The path. @api
[ "Set", "the", "root", "and", "path", "of", "the", "embedded", "group", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Group/EmbeddedGroup.php#L34-L41
222,963
awakenweb/livedocx
src/Image.php
Image.setFilename
public function setFilename($filename , $directory = null) { $this->filename = $filename; $this->directory = $directory; }
php
public function setFilename($filename , $directory = null) { $this->filename = $filename; $this->directory = $directory; }
[ "public", "function", "setFilename", "(", "$", "filename", ",", "$", "directory", "=", "null", ")", "{", "$", "this", "->", "filename", "=", "$", "filename", ";", "$", "this", "->", "directory", "=", "$", "directory", ";", "}" ]
Define the file and the working directory for a localfile @param string $filename @param string|null $directory
[ "Define", "the", "file", "and", "the", "working", "directory", "for", "a", "localfile" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L64-L68
222,964
awakenweb/livedocx
src/Image.php
Image.listAll
public function listAll() { try { $return = [ ]; $result = $this->getSoapClient()->ListImages(); if ( isset($result->ListImagesResult) ) { $return = $this->getSoapClient()->backendListArrayToMultiAssocArray($result->ListImagesResult); } return $return; } catch ( SoapException $ex ) { throw new StatusException('Error while obtaining the list of all images' , $ex); } }
php
public function listAll() { try { $return = [ ]; $result = $this->getSoapClient()->ListImages(); if ( isset($result->ListImagesResult) ) { $return = $this->getSoapClient()->backendListArrayToMultiAssocArray($result->ListImagesResult); } return $return; } catch ( SoapException $ex ) { throw new StatusException('Error while obtaining the list of all images' , $ex); } }
[ "public", "function", "listAll", "(", ")", "{", "try", "{", "$", "return", "=", "[", "]", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "ListImages", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "ListImagesResult", ")", ")", "{", "$", "return", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "backendListArrayToMultiAssocArray", "(", "$", "result", "->", "ListImagesResult", ")", ";", "}", "return", "$", "return", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while obtaining the list of all images'", ",", "$", "ex", ")", ";", "}", "}" ]
Return a list of all images present on the Livedocx service @return array @throws StatusException
[ "Return", "a", "list", "of", "all", "images", "present", "on", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L95-L108
222,965
awakenweb/livedocx
src/Image.php
Image.getAcceptedFormats
public function getAcceptedFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetImageImportFormats(); if ( isset($result->GetImageImportFormatsResult->string) ) { $ret = $result->GetImageImportFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while obtaining the list of accepted image formats' , $ex); } }
php
public function getAcceptedFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetImageImportFormats(); if ( isset($result->GetImageImportFormatsResult->string) ) { $ret = $result->GetImageImportFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while obtaining the list of accepted image formats' , $ex); } }
[ "public", "function", "getAcceptedFormats", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetImageImportFormats", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "GetImageImportFormatsResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetImageImportFormatsResult", "->", "string", ";", "$", "ret", "=", "array_map", "(", "'strtolower'", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while obtaining the list of accepted image formats'", ",", "$", "ex", ")", ";", "}", "}" ]
Get the list of accepted images format for upload @return array @throws StatusException
[ "Get", "the", "list", "of", "accepted", "images", "format", "for", "upload" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L117-L131
222,966
awakenweb/livedocx
src/Image.php
Image.getAvailableReturnFormats
public function getAvailableReturnFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetImageExportFormats(); if ( isset($result->GetImageExportFormatsResult->string) ) { $ret = $result->GetImageExportFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while obtaining the list of all available image formats' , $ex); } }
php
public function getAvailableReturnFormats() { try { $ret = array(); $result = $this->getSoapClient()->GetImageExportFormats(); if ( isset($result->GetImageExportFormatsResult->string) ) { $ret = $result->GetImageExportFormatsResult->string; $ret = array_map('strtolower' , $ret); } return $ret; } catch ( SoapException $ex ) { throw new StatusException('Error while obtaining the list of all available image formats' , $ex); } }
[ "public", "function", "getAvailableReturnFormats", "(", ")", "{", "try", "{", "$", "ret", "=", "array", "(", ")", ";", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetImageExportFormats", "(", ")", ";", "if", "(", "isset", "(", "$", "result", "->", "GetImageExportFormatsResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetImageExportFormatsResult", "->", "string", ";", "$", "ret", "=", "array_map", "(", "'strtolower'", ",", "$", "ret", ")", ";", "}", "return", "$", "ret", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while obtaining the list of all available image formats'", ",", "$", "ex", ")", ";", "}", "}" ]
Get the list of accepted formats for image generation @return array @throws StatusException
[ "Get", "the", "list", "of", "accepted", "formats", "for", "image", "generation" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L140-L154
222,967
awakenweb/livedocx
src/Image.php
Image.upload
public function upload() { $filename = $this->getName(true); if ( ! is_readable($filename) ) { throw new FileExistException('Image file from disk is not readable'); } try { $this->getSoapClient()->UploadImage(array( 'image' => base64_encode(file_get_contents($filename)) , 'filename' => basename($filename) , )); return $this; } catch ( SoapException $e ) { throw new UploadException('Error while uploading the image' , $e); } }
php
public function upload() { $filename = $this->getName(true); if ( ! is_readable($filename) ) { throw new FileExistException('Image file from disk is not readable'); } try { $this->getSoapClient()->UploadImage(array( 'image' => base64_encode(file_get_contents($filename)) , 'filename' => basename($filename) , )); return $this; } catch ( SoapException $e ) { throw new UploadException('Error while uploading the image' , $e); } }
[ "public", "function", "upload", "(", ")", "{", "$", "filename", "=", "$", "this", "->", "getName", "(", "true", ")", ";", "if", "(", "!", "is_readable", "(", "$", "filename", ")", ")", "{", "throw", "new", "FileExistException", "(", "'Image file from disk is not readable'", ")", ";", "}", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "UploadImage", "(", "array", "(", "'image'", "=>", "base64_encode", "(", "file_get_contents", "(", "$", "filename", ")", ")", ",", "'filename'", "=>", "basename", "(", "$", "filename", ")", ",", ")", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "e", ")", "{", "throw", "new", "UploadException", "(", "'Error while uploading the image'", ",", "$", "e", ")", ";", "}", "}" ]
Upload the active image on the livedocx server @return Image @throws UploadException @throws FileExistException
[ "Upload", "the", "active", "image", "on", "the", "livedocx", "server" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L164-L182
222,968
awakenweb/livedocx
src/Image.php
Image.download
public function download() { try { $result = $this->getSoapClient()->DownloadImage(array( 'filename' => basename($this->filename) , )); return base64_decode($result->DownloadImageResult); } catch ( SoapException $e ) { throw new DownloadException('Error while downloading the image' , $e); } }
php
public function download() { try { $result = $this->getSoapClient()->DownloadImage(array( 'filename' => basename($this->filename) , )); return base64_decode($result->DownloadImageResult); } catch ( SoapException $e ) { throw new DownloadException('Error while downloading the image' , $e); } }
[ "public", "function", "download", "(", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "DownloadImage", "(", "array", "(", "'filename'", "=>", "basename", "(", "$", "this", "->", "filename", ")", ",", ")", ")", ";", "return", "base64_decode", "(", "$", "result", "->", "DownloadImageResult", ")", ";", "}", "catch", "(", "SoapException", "$", "e", ")", "{", "throw", "new", "DownloadException", "(", "'Error while downloading the image'", ",", "$", "e", ")", ";", "}", "}" ]
Download an image file from Livedocx @return string @throws DownloadException
[ "Download", "an", "image", "file", "from", "Livedocx" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L191-L202
222,969
awakenweb/livedocx
src/Image.php
Image.exists
public function exists() { try { $result = $this->getSoapClient()->ImageExists(array( 'filename' => basename($this->filename) , )); return ( boolean ) $result->ImageExistsResult; } catch ( SoapException $e ) { throw new StatusException('Error while verifying existence of the image' , $e); } }
php
public function exists() { try { $result = $this->getSoapClient()->ImageExists(array( 'filename' => basename($this->filename) , )); return ( boolean ) $result->ImageExistsResult; } catch ( SoapException $e ) { throw new StatusException('Error while verifying existence of the image' , $e); } }
[ "public", "function", "exists", "(", ")", "{", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "ImageExists", "(", "array", "(", "'filename'", "=>", "basename", "(", "$", "this", "->", "filename", ")", ",", ")", ")", ";", "return", "(", "boolean", ")", "$", "result", "->", "ImageExistsResult", ";", "}", "catch", "(", "SoapException", "$", "e", ")", "{", "throw", "new", "StatusException", "(", "'Error while verifying existence of the image'", ",", "$", "e", ")", ";", "}", "}" ]
Check if an image exists on the Livedocx service @return boolean @throws StatusException
[ "Check", "if", "an", "image", "exists", "on", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L211-L222
222,970
awakenweb/livedocx
src/Image.php
Image.delete
public function delete() { try { $this->getSoapClient()->DeleteImage([ 'filename' => basename($this->getName(true)) , ]); return $this; } catch ( SoapException $e ) { throw new DeleteException('Error while deleting the image' , $e); } }
php
public function delete() { try { $this->getSoapClient()->DeleteImage([ 'filename' => basename($this->getName(true)) , ]); return $this; } catch ( SoapException $e ) { throw new DeleteException('Error while deleting the image' , $e); } }
[ "public", "function", "delete", "(", ")", "{", "try", "{", "$", "this", "->", "getSoapClient", "(", ")", "->", "DeleteImage", "(", "[", "'filename'", "=>", "basename", "(", "$", "this", "->", "getName", "(", "true", ")", ")", ",", "]", ")", ";", "return", "$", "this", ";", "}", "catch", "(", "SoapException", "$", "e", ")", "{", "throw", "new", "DeleteException", "(", "'Error while deleting the image'", ",", "$", "e", ")", ";", "}", "}" ]
Delete the file from the Livedocx service @return Image @throws DeleteException
[ "Delete", "the", "file", "from", "the", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Image.php#L231-L242
222,971
mongator/mongator
src/Mongator/Repository.php
Repository.text
public function text($search, array $filter = array(), $fields = array(), $limit = null, $language = null, $options = array()) { $command = array( 'text' => $this->getCollectionName(), 'search' => $search, 'filter' => $filter, 'project' => $fields, 'limit' => $limit, 'language' => $language ); return $this->command($command, $options); }
php
public function text($search, array $filter = array(), $fields = array(), $limit = null, $language = null, $options = array()) { $command = array( 'text' => $this->getCollectionName(), 'search' => $search, 'filter' => $filter, 'project' => $fields, 'limit' => $limit, 'language' => $language ); return $this->command($command, $options); }
[ "public", "function", "text", "(", "$", "search", ",", "array", "$", "filter", "=", "array", "(", ")", ",", "$", "fields", "=", "array", "(", ")", ",", "$", "limit", "=", "null", ",", "$", "language", "=", "null", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "command", "=", "array", "(", "'text'", "=>", "$", "this", "->", "getCollectionName", "(", ")", ",", "'search'", "=>", "$", "search", ",", "'filter'", "=>", "$", "filter", ",", "'project'", "=>", "$", "fields", ",", "'limit'", "=>", "$", "limit", ",", "'language'", "=>", "$", "language", ")", ";", "return", "$", "this", "->", "command", "(", "$", "command", ",", "$", "options", ")", ";", "}" ]
Search text content stored in the text index. @param string $search A string of terms that MongoDB parses and uses to query the text index. @param array $filter (optional) A query array, you can use any valid MongoDB query @param array $fields (optional) Allows you to limit the fields returned by the query to only those specified. @param integer $limit (optional) Specify the maximum number of documents to include in the response. @param string $language (optional) Specify the language that determines for the search the list of stop words and the rules for the stemmer and tokenizer. @param array $options Extra options for the command (optional). @return array The results. @api
[ "Search", "text", "content", "stored", "in", "the", "text", "index", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Repository.php#L379-L391
222,972
mongator/mongator
src/Mongator/Repository.php
Repository.mapReduce
public function mapReduce( $map, $reduce, array $out, array $query = array(), array $command = array(), $options = array()) { $command = array_merge($command, array( 'mapreduce' => $this->getCollectionName(), 'map' => is_string($map) ? new \MongoCode($map) : $map, 'reduce' => is_string($reduce) ? new \MongoCode($reduce) : $reduce, 'out' => $out, 'query' => $query, )); $result = $this->command($command, $options); if (isset($out['inline']) && $out['inline']) { return $result['results']; } return $this->getConnection()->getMongoDB()->selectCollection($result['result'])->find(); }
php
public function mapReduce( $map, $reduce, array $out, array $query = array(), array $command = array(), $options = array()) { $command = array_merge($command, array( 'mapreduce' => $this->getCollectionName(), 'map' => is_string($map) ? new \MongoCode($map) : $map, 'reduce' => is_string($reduce) ? new \MongoCode($reduce) : $reduce, 'out' => $out, 'query' => $query, )); $result = $this->command($command, $options); if (isset($out['inline']) && $out['inline']) { return $result['results']; } return $this->getConnection()->getMongoDB()->selectCollection($result['result'])->find(); }
[ "public", "function", "mapReduce", "(", "$", "map", ",", "$", "reduce", ",", "array", "$", "out", ",", "array", "$", "query", "=", "array", "(", ")", ",", "array", "$", "command", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "command", "=", "array_merge", "(", "$", "command", ",", "array", "(", "'mapreduce'", "=>", "$", "this", "->", "getCollectionName", "(", ")", ",", "'map'", "=>", "is_string", "(", "$", "map", ")", "?", "new", "\\", "MongoCode", "(", "$", "map", ")", ":", "$", "map", ",", "'reduce'", "=>", "is_string", "(", "$", "reduce", ")", "?", "new", "\\", "MongoCode", "(", "$", "reduce", ")", ":", "$", "reduce", ",", "'out'", "=>", "$", "out", ",", "'query'", "=>", "$", "query", ",", ")", ")", ";", "$", "result", "=", "$", "this", "->", "command", "(", "$", "command", ",", "$", "options", ")", ";", "if", "(", "isset", "(", "$", "out", "[", "'inline'", "]", ")", "&&", "$", "out", "[", "'inline'", "]", ")", "{", "return", "$", "result", "[", "'results'", "]", ";", "}", "return", "$", "this", "->", "getConnection", "(", ")", "->", "getMongoDB", "(", ")", "->", "selectCollection", "(", "$", "result", "[", "'result'", "]", ")", "->", "find", "(", ")", ";", "}" ]
Shortcut to make map reduce. @param mixed $map The map function. @param mixed $reduce The reduce function. @param array $out The out. @param array $query The query (optional). @param array $options Extra options for the command (optional). @return array With the @throws \RuntimeException If the database returns an error.
[ "Shortcut", "to", "make", "map", "reduce", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Repository.php#L406-L425
222,973
mongator/mongator
src/Mongator/Repository.php
Repository.aggregate
public function aggregate(array $pipeline, array $options = array()) { $command = array( 'aggregate' => $this->getCollectionName(), 'pipeline' => $pipeline ); $result = $this->command($command, $options); return $result['result']; }
php
public function aggregate(array $pipeline, array $options = array()) { $command = array( 'aggregate' => $this->getCollectionName(), 'pipeline' => $pipeline ); $result = $this->command($command, $options); return $result['result']; }
[ "public", "function", "aggregate", "(", "array", "$", "pipeline", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "$", "command", "=", "array", "(", "'aggregate'", "=>", "$", "this", "->", "getCollectionName", "(", ")", ",", "'pipeline'", "=>", "$", "pipeline", ")", ";", "$", "result", "=", "$", "this", "->", "command", "(", "$", "command", ",", "$", "options", ")", ";", "return", "$", "result", "[", "'result'", "]", ";", "}" ]
Shortcut to make an aggregation. @param array $pipeline The pipeline for aggregation @param array $options Extra options for the command (optional). @return array With the aggregation @throws \RuntimeException If the database returns an error.
[ "Shortcut", "to", "make", "an", "aggregation", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Repository.php#L437-L446
222,974
stil/cool-captcha
src/Captcha.php
Captcha.createImage
public function createImage() { $ini = microtime(true); /** Initialization */ $this->imageAllocate(); /** Text insertion */ $text = $this->getCaptchaText(); $fontcfg = $this->fonts[array_rand($this->fonts)]; $this->writeText($text, $fontcfg); /** Transformations */ if (!empty($this->lineWidth)) { $this->writeLine(); } $this->waveImage(); if ($this->blur && function_exists('imagefilter')) { imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR); } $this->reduceImage(); if ($this->debug) { imagestring( $this->im, 1, 1, $this->height-8, "$text {$fontcfg['font']} ".round((microtime(true)-$ini)*1000)."ms", $this->GdFgColor ); } /** Output */ $this->writeImage(); $this->cleanup(); return $text; }
php
public function createImage() { $ini = microtime(true); /** Initialization */ $this->imageAllocate(); /** Text insertion */ $text = $this->getCaptchaText(); $fontcfg = $this->fonts[array_rand($this->fonts)]; $this->writeText($text, $fontcfg); /** Transformations */ if (!empty($this->lineWidth)) { $this->writeLine(); } $this->waveImage(); if ($this->blur && function_exists('imagefilter')) { imagefilter($this->im, IMG_FILTER_GAUSSIAN_BLUR); } $this->reduceImage(); if ($this->debug) { imagestring( $this->im, 1, 1, $this->height-8, "$text {$fontcfg['font']} ".round((microtime(true)-$ini)*1000)."ms", $this->GdFgColor ); } /** Output */ $this->writeImage(); $this->cleanup(); return $text; }
[ "public", "function", "createImage", "(", ")", "{", "$", "ini", "=", "microtime", "(", "true", ")", ";", "/** Initialization */", "$", "this", "->", "imageAllocate", "(", ")", ";", "/** Text insertion */", "$", "text", "=", "$", "this", "->", "getCaptchaText", "(", ")", ";", "$", "fontcfg", "=", "$", "this", "->", "fonts", "[", "array_rand", "(", "$", "this", "->", "fonts", ")", "]", ";", "$", "this", "->", "writeText", "(", "$", "text", ",", "$", "fontcfg", ")", ";", "/** Transformations */", "if", "(", "!", "empty", "(", "$", "this", "->", "lineWidth", ")", ")", "{", "$", "this", "->", "writeLine", "(", ")", ";", "}", "$", "this", "->", "waveImage", "(", ")", ";", "if", "(", "$", "this", "->", "blur", "&&", "function_exists", "(", "'imagefilter'", ")", ")", "{", "imagefilter", "(", "$", "this", "->", "im", ",", "IMG_FILTER_GAUSSIAN_BLUR", ")", ";", "}", "$", "this", "->", "reduceImage", "(", ")", ";", "if", "(", "$", "this", "->", "debug", ")", "{", "imagestring", "(", "$", "this", "->", "im", ",", "1", ",", "1", ",", "$", "this", "->", "height", "-", "8", ",", "\"$text {$fontcfg['font']} \"", ".", "round", "(", "(", "microtime", "(", "true", ")", "-", "$", "ini", ")", "*", "1000", ")", ".", "\"ms\"", ",", "$", "this", "->", "GdFgColor", ")", ";", "}", "/** Output */", "$", "this", "->", "writeImage", "(", ")", ";", "$", "this", "->", "cleanup", "(", ")", ";", "return", "$", "text", ";", "}" ]
Generates captcha and outputs it to the browser. @return string Text answer of generated captcha
[ "Generates", "captcha", "and", "outputs", "it", "to", "the", "browser", "." ]
9883c01a8135dddf22e3fd76075e4d21bd059195
https://github.com/stil/cool-captcha/blob/9883c01a8135dddf22e3fd76075e4d21bd059195/src/Captcha.php#L159-L197
222,975
stil/cool-captcha
src/Captcha.php
Captcha.imageAllocate
protected function imageAllocate() { // Cleanup if (!empty($this->im)) { imagedestroy($this->im); } $this->im = imagecreatetruecolor($this->width*$this->scale, $this->height*$this->scale); // Background color $this->GdBgColor = imagecolorallocate( $this->im, $this->backgroundColor[0], $this->backgroundColor[1], $this->backgroundColor[2] ); imagefilledrectangle($this->im, 0, 0, $this->width*$this->scale, $this->height*$this->scale, $this->GdBgColor); // Foreground color $color = $this->colors[mt_rand(0, sizeof($this->colors)-1)]; $this->GdFgColor = imagecolorallocate($this->im, $color[0], $color[1], $color[2]); // Shadow color if (!empty($this->shadowColor) && is_array($this->shadowColor) && sizeof($this->shadowColor) >= 3) { $this->GdShadowColor = imagecolorallocate( $this->im, $this->shadowColor[0], $this->shadowColor[1], $this->shadowColor[2] ); } }
php
protected function imageAllocate() { // Cleanup if (!empty($this->im)) { imagedestroy($this->im); } $this->im = imagecreatetruecolor($this->width*$this->scale, $this->height*$this->scale); // Background color $this->GdBgColor = imagecolorallocate( $this->im, $this->backgroundColor[0], $this->backgroundColor[1], $this->backgroundColor[2] ); imagefilledrectangle($this->im, 0, 0, $this->width*$this->scale, $this->height*$this->scale, $this->GdBgColor); // Foreground color $color = $this->colors[mt_rand(0, sizeof($this->colors)-1)]; $this->GdFgColor = imagecolorallocate($this->im, $color[0], $color[1], $color[2]); // Shadow color if (!empty($this->shadowColor) && is_array($this->shadowColor) && sizeof($this->shadowColor) >= 3) { $this->GdShadowColor = imagecolorallocate( $this->im, $this->shadowColor[0], $this->shadowColor[1], $this->shadowColor[2] ); } }
[ "protected", "function", "imageAllocate", "(", ")", "{", "// Cleanup", "if", "(", "!", "empty", "(", "$", "this", "->", "im", ")", ")", "{", "imagedestroy", "(", "$", "this", "->", "im", ")", ";", "}", "$", "this", "->", "im", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", "*", "$", "this", "->", "scale", ",", "$", "this", "->", "height", "*", "$", "this", "->", "scale", ")", ";", "// Background color", "$", "this", "->", "GdBgColor", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "this", "->", "backgroundColor", "[", "0", "]", ",", "$", "this", "->", "backgroundColor", "[", "1", "]", ",", "$", "this", "->", "backgroundColor", "[", "2", "]", ")", ";", "imagefilledrectangle", "(", "$", "this", "->", "im", ",", "0", ",", "0", ",", "$", "this", "->", "width", "*", "$", "this", "->", "scale", ",", "$", "this", "->", "height", "*", "$", "this", "->", "scale", ",", "$", "this", "->", "GdBgColor", ")", ";", "// Foreground color", "$", "color", "=", "$", "this", "->", "colors", "[", "mt_rand", "(", "0", ",", "sizeof", "(", "$", "this", "->", "colors", ")", "-", "1", ")", "]", ";", "$", "this", "->", "GdFgColor", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "color", "[", "0", "]", ",", "$", "color", "[", "1", "]", ",", "$", "color", "[", "2", "]", ")", ";", "// Shadow color", "if", "(", "!", "empty", "(", "$", "this", "->", "shadowColor", ")", "&&", "is_array", "(", "$", "this", "->", "shadowColor", ")", "&&", "sizeof", "(", "$", "this", "->", "shadowColor", ")", ">=", "3", ")", "{", "$", "this", "->", "GdShadowColor", "=", "imagecolorallocate", "(", "$", "this", "->", "im", ",", "$", "this", "->", "shadowColor", "[", "0", "]", ",", "$", "this", "->", "shadowColor", "[", "1", "]", ",", "$", "this", "->", "shadowColor", "[", "2", "]", ")", ";", "}", "}" ]
Creates the image resources
[ "Creates", "the", "image", "resources" ]
9883c01a8135dddf22e3fd76075e4d21bd059195
https://github.com/stil/cool-captcha/blob/9883c01a8135dddf22e3fd76075e4d21bd059195/src/Captcha.php#L202-L233
222,976
stil/cool-captcha
src/Captcha.php
Captcha.getRandomCaptchaText
protected function getRandomCaptchaText($length = null) { if (empty($length)) { $length = rand($this->minWordLength, $this->maxWordLength); } $words = "abcdefghijlmnopqrstvwyz"; $vocals = "aeiou"; $text = ""; $vocal = rand(0, 1); for ($i=0; $i<$length; $i++) { if ($vocal) { $text .= substr($vocals, mt_rand(0, 4), 1); } else { $text .= substr($words, mt_rand(0, 22), 1); } $vocal = !$vocal; } return $text; }
php
protected function getRandomCaptchaText($length = null) { if (empty($length)) { $length = rand($this->minWordLength, $this->maxWordLength); } $words = "abcdefghijlmnopqrstvwyz"; $vocals = "aeiou"; $text = ""; $vocal = rand(0, 1); for ($i=0; $i<$length; $i++) { if ($vocal) { $text .= substr($vocals, mt_rand(0, 4), 1); } else { $text .= substr($words, mt_rand(0, 22), 1); } $vocal = !$vocal; } return $text; }
[ "protected", "function", "getRandomCaptchaText", "(", "$", "length", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "length", ")", ")", "{", "$", "length", "=", "rand", "(", "$", "this", "->", "minWordLength", ",", "$", "this", "->", "maxWordLength", ")", ";", "}", "$", "words", "=", "\"abcdefghijlmnopqrstvwyz\"", ";", "$", "vocals", "=", "\"aeiou\"", ";", "$", "text", "=", "\"\"", ";", "$", "vocal", "=", "rand", "(", "0", ",", "1", ")", ";", "for", "(", "$", "i", "=", "0", ";", "$", "i", "<", "$", "length", ";", "$", "i", "++", ")", "{", "if", "(", "$", "vocal", ")", "{", "$", "text", ".=", "substr", "(", "$", "vocals", ",", "mt_rand", "(", "0", ",", "4", ")", ",", "1", ")", ";", "}", "else", "{", "$", "text", ".=", "substr", "(", "$", "words", ",", "mt_rand", "(", "0", ",", "22", ")", ",", "1", ")", ";", "}", "$", "vocal", "=", "!", "$", "vocal", ";", "}", "return", "$", "text", ";", "}" ]
Random text generation @param int|null Text length @return string Text
[ "Random", "text", "generation" ]
9883c01a8135dddf22e3fd76075e4d21bd059195
https://github.com/stil/cool-captcha/blob/9883c01a8135dddf22e3fd76075e4d21bd059195/src/Captcha.php#L255-L275
222,977
stil/cool-captcha
src/Captcha.php
Captcha.getDictionaryCaptchaText
public function getDictionaryCaptchaText($extended = false) { if (empty($this->wordsFile)) { return false; } // Full path of words file if (substr($this->wordsFile, 0, 1) == '/') { $wordsfile = $this->wordsFile; } else { $wordsfile = $this->resourcesPath.'/'.$this->wordsFile; } if (!file_exists($wordsfile)) { return false; } $fp = fopen($wordsfile, "r"); $length = strlen(fgets($fp)); if (!$length) { return false; } $line = rand(1, (filesize($wordsfile)/$length)-2); if (fseek($fp, $length*$line) == -1) { return false; } $text = trim(fgets($fp)); fclose($fp); /** Change ramdom volcals */ if ($extended) { $text = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY); $vocals = array('a', 'e', 'i', 'o', 'u'); foreach ($text as $i => $char) { if (mt_rand(0, 1) && in_array($char, $vocals)) { $text[$i] = $vocals[mt_rand(0, 4)]; } } $text = implode('', $text); } return $text; }
php
public function getDictionaryCaptchaText($extended = false) { if (empty($this->wordsFile)) { return false; } // Full path of words file if (substr($this->wordsFile, 0, 1) == '/') { $wordsfile = $this->wordsFile; } else { $wordsfile = $this->resourcesPath.'/'.$this->wordsFile; } if (!file_exists($wordsfile)) { return false; } $fp = fopen($wordsfile, "r"); $length = strlen(fgets($fp)); if (!$length) { return false; } $line = rand(1, (filesize($wordsfile)/$length)-2); if (fseek($fp, $length*$line) == -1) { return false; } $text = trim(fgets($fp)); fclose($fp); /** Change ramdom volcals */ if ($extended) { $text = preg_split('//', $text, -1, PREG_SPLIT_NO_EMPTY); $vocals = array('a', 'e', 'i', 'o', 'u'); foreach ($text as $i => $char) { if (mt_rand(0, 1) && in_array($char, $vocals)) { $text[$i] = $vocals[mt_rand(0, 4)]; } } $text = implode('', $text); } return $text; }
[ "public", "function", "getDictionaryCaptchaText", "(", "$", "extended", "=", "false", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "wordsFile", ")", ")", "{", "return", "false", ";", "}", "// Full path of words file", "if", "(", "substr", "(", "$", "this", "->", "wordsFile", ",", "0", ",", "1", ")", "==", "'/'", ")", "{", "$", "wordsfile", "=", "$", "this", "->", "wordsFile", ";", "}", "else", "{", "$", "wordsfile", "=", "$", "this", "->", "resourcesPath", ".", "'/'", ".", "$", "this", "->", "wordsFile", ";", "}", "if", "(", "!", "file_exists", "(", "$", "wordsfile", ")", ")", "{", "return", "false", ";", "}", "$", "fp", "=", "fopen", "(", "$", "wordsfile", ",", "\"r\"", ")", ";", "$", "length", "=", "strlen", "(", "fgets", "(", "$", "fp", ")", ")", ";", "if", "(", "!", "$", "length", ")", "{", "return", "false", ";", "}", "$", "line", "=", "rand", "(", "1", ",", "(", "filesize", "(", "$", "wordsfile", ")", "/", "$", "length", ")", "-", "2", ")", ";", "if", "(", "fseek", "(", "$", "fp", ",", "$", "length", "*", "$", "line", ")", "==", "-", "1", ")", "{", "return", "false", ";", "}", "$", "text", "=", "trim", "(", "fgets", "(", "$", "fp", ")", ")", ";", "fclose", "(", "$", "fp", ")", ";", "/** Change ramdom volcals */", "if", "(", "$", "extended", ")", "{", "$", "text", "=", "preg_split", "(", "'//'", ",", "$", "text", ",", "-", "1", ",", "PREG_SPLIT_NO_EMPTY", ")", ";", "$", "vocals", "=", "array", "(", "'a'", ",", "'e'", ",", "'i'", ",", "'o'", ",", "'u'", ")", ";", "foreach", "(", "$", "text", "as", "$", "i", "=>", "$", "char", ")", "{", "if", "(", "mt_rand", "(", "0", ",", "1", ")", "&&", "in_array", "(", "$", "char", ",", "$", "vocals", ")", ")", "{", "$", "text", "[", "$", "i", "]", "=", "$", "vocals", "[", "mt_rand", "(", "0", ",", "4", ")", "]", ";", "}", "}", "$", "text", "=", "implode", "(", "''", ",", "$", "text", ")", ";", "}", "return", "$", "text", ";", "}" ]
Random dictionary word generation @param boolean $extended Add extended "fake" words @return string Word
[ "Random", "dictionary", "word", "generation" ]
9883c01a8135dddf22e3fd76075e4d21bd059195
https://github.com/stil/cool-captcha/blob/9883c01a8135dddf22e3fd76075e4d21bd059195/src/Captcha.php#L283-L326
222,978
stil/cool-captcha
src/Captcha.php
Captcha.writeLine
protected function writeLine() { $x1 = $this->width*$this->scale*.15; $x2 = $this->textFinalX; $y1 = rand($this->height*$this->scale*.40, $this->height*$this->scale*.65); $y2 = rand($this->height*$this->scale*.40, $this->height*$this->scale*.65); $width = $this->lineWidth/2*$this->scale; for ($i = $width*-1; $i <= $width; $i++) { imageline($this->im, $x1, $y1+$i, $x2, $y2+$i, $this->GdFgColor); } }
php
protected function writeLine() { $x1 = $this->width*$this->scale*.15; $x2 = $this->textFinalX; $y1 = rand($this->height*$this->scale*.40, $this->height*$this->scale*.65); $y2 = rand($this->height*$this->scale*.40, $this->height*$this->scale*.65); $width = $this->lineWidth/2*$this->scale; for ($i = $width*-1; $i <= $width; $i++) { imageline($this->im, $x1, $y1+$i, $x2, $y2+$i, $this->GdFgColor); } }
[ "protected", "function", "writeLine", "(", ")", "{", "$", "x1", "=", "$", "this", "->", "width", "*", "$", "this", "->", "scale", "*", ".15", ";", "$", "x2", "=", "$", "this", "->", "textFinalX", ";", "$", "y1", "=", "rand", "(", "$", "this", "->", "height", "*", "$", "this", "->", "scale", "*", ".40", ",", "$", "this", "->", "height", "*", "$", "this", "->", "scale", "*", ".65", ")", ";", "$", "y2", "=", "rand", "(", "$", "this", "->", "height", "*", "$", "this", "->", "scale", "*", ".40", ",", "$", "this", "->", "height", "*", "$", "this", "->", "scale", "*", ".65", ")", ";", "$", "width", "=", "$", "this", "->", "lineWidth", "/", "2", "*", "$", "this", "->", "scale", ";", "for", "(", "$", "i", "=", "$", "width", "*", "-", "1", ";", "$", "i", "<=", "$", "width", ";", "$", "i", "++", ")", "{", "imageline", "(", "$", "this", "->", "im", ",", "$", "x1", ",", "$", "y1", "+", "$", "i", ",", "$", "x2", ",", "$", "y2", "+", "$", "i", ",", "$", "this", "->", "GdFgColor", ")", ";", "}", "}" ]
Horizontal line insertion
[ "Horizontal", "line", "insertion" ]
9883c01a8135dddf22e3fd76075e4d21bd059195
https://github.com/stil/cool-captcha/blob/9883c01a8135dddf22e3fd76075e4d21bd059195/src/Captcha.php#L331-L342
222,979
stil/cool-captcha
src/Captcha.php
Captcha.reduceImage
protected function reduceImage() { $imResampled = imagecreatetruecolor($this->width, $this->height); imagecopyresampled($imResampled, $this->im, 0, 0, 0, 0, $this->width, $this->height, $this->width*$this->scale, $this->height*$this->scale ); imagedestroy($this->im); $this->im = $imResampled; }
php
protected function reduceImage() { $imResampled = imagecreatetruecolor($this->width, $this->height); imagecopyresampled($imResampled, $this->im, 0, 0, 0, 0, $this->width, $this->height, $this->width*$this->scale, $this->height*$this->scale ); imagedestroy($this->im); $this->im = $imResampled; }
[ "protected", "function", "reduceImage", "(", ")", "{", "$", "imResampled", "=", "imagecreatetruecolor", "(", "$", "this", "->", "width", ",", "$", "this", "->", "height", ")", ";", "imagecopyresampled", "(", "$", "imResampled", ",", "$", "this", "->", "im", ",", "0", ",", "0", ",", "0", ",", "0", ",", "$", "this", "->", "width", ",", "$", "this", "->", "height", ",", "$", "this", "->", "width", "*", "$", "this", "->", "scale", ",", "$", "this", "->", "height", "*", "$", "this", "->", "scale", ")", ";", "imagedestroy", "(", "$", "this", "->", "im", ")", ";", "$", "this", "->", "im", "=", "$", "imResampled", ";", "}" ]
Reduce the image to the final size
[ "Reduce", "the", "image", "to", "the", "final", "size" ]
9883c01a8135dddf22e3fd76075e4d21bd059195
https://github.com/stil/cool-captcha/blob/9883c01a8135dddf22e3fd76075e4d21bd059195/src/Captcha.php#L426-L436
222,980
fiunchinho/rabbitmq-service-provider
src/fiunchinho/Silex/Provider/RabbitServiceProvider.php
RabbitServiceProvider.getConnection
private function getConnection($app, $options, $connections) { $connection_name = @$options['connection']?: self::DEFAULT_CONNECTION; if (!isset($connections[$connection_name])) { throw new \InvalidArgumentException('Configuration for connection [' . $connection_name . '] not found'); } return $app['rabbit.connection'][$connection_name]; }
php
private function getConnection($app, $options, $connections) { $connection_name = @$options['connection']?: self::DEFAULT_CONNECTION; if (!isset($connections[$connection_name])) { throw new \InvalidArgumentException('Configuration for connection [' . $connection_name . '] not found'); } return $app['rabbit.connection'][$connection_name]; }
[ "private", "function", "getConnection", "(", "$", "app", ",", "$", "options", ",", "$", "connections", ")", "{", "$", "connection_name", "=", "@", "$", "options", "[", "'connection'", "]", "?", ":", "self", "::", "DEFAULT_CONNECTION", ";", "if", "(", "!", "isset", "(", "$", "connections", "[", "$", "connection_name", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'Configuration for connection ['", ".", "$", "connection_name", ".", "'] not found'", ")", ";", "}", "return", "$", "app", "[", "'rabbit.connection'", "]", "[", "$", "connection_name", "]", ";", "}" ]
Return the name of the connection to use. @param array $options Options for the Producer or Consumer. @param array $connections Connections defined in the config file. @return string The connection name that will be used
[ "Return", "the", "name", "of", "the", "connection", "to", "use", "." ]
89e0226c3dc7dbd4bf173c2ee8c5e9369beb1970
https://github.com/fiunchinho/rabbitmq-service-provider/blob/89e0226c3dc7dbd4bf173c2ee8c5e9369beb1970/src/fiunchinho/Silex/Provider/RabbitServiceProvider.php#L43-L52
222,981
mongator/mongator
src/Mongator/Cache/AbstractCache.php
AbstractCache.get
public function get($key) { if ( !$content = $this->info($key) ) { return null; } return $this->unpack($content); }
php
public function get($key) { if ( !$content = $this->info($key) ) { return null; } return $this->unpack($content); }
[ "public", "function", "get", "(", "$", "key", ")", "{", "if", "(", "!", "$", "content", "=", "$", "this", "->", "info", "(", "$", "key", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "unpack", "(", "$", "content", ")", ";", "}" ]
Returns the value for a key. @param string $key A unique key. @return mixed The value for a key.
[ "Returns", "the", "value", "for", "a", "key", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Cache/AbstractCache.php#L40-L47
222,982
mongator/mongator
src/Mongator/Cache/AbstractCache.php
AbstractCache.pack
protected function pack($key, $value, $ttl = 0) { $content = array( 'key' => $key, 'time' => time(), 'ttl' => $ttl, 'value' => $value ); return $content; }
php
protected function pack($key, $value, $ttl = 0) { $content = array( 'key' => $key, 'time' => time(), 'ttl' => $ttl, 'value' => $value ); return $content; }
[ "protected", "function", "pack", "(", "$", "key", ",", "$", "value", ",", "$", "ttl", "=", "0", ")", "{", "$", "content", "=", "array", "(", "'key'", "=>", "$", "key", ",", "'time'", "=>", "time", "(", ")", ",", "'ttl'", "=>", "$", "ttl", ",", "'value'", "=>", "$", "value", ")", ";", "return", "$", "content", ";", "}" ]
Pack the value in array with metadata @param string $key A unique key. @param mixed $value The value to be cached. @param integer $ttl (optional) time to life in seconds. @return bool Whether the cache has a key.
[ "Pack", "the", "value", "in", "array", "with", "metadata" ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Cache/AbstractCache.php#L87-L97
222,983
mongator/mongator
src/Mongator/Cache/AbstractCache.php
AbstractCache.unpack
protected function unpack($content) { if ( !is_array($content) ) return null; if ( $content['ttl'] > 0 && time() >= $content['time'] + $content['ttl'] ) { $this->remove($content['key']); return null; } return $content['value']; }
php
protected function unpack($content) { if ( !is_array($content) ) return null; if ( $content['ttl'] > 0 && time() >= $content['time'] + $content['ttl'] ) { $this->remove($content['key']); return null; } return $content['value']; }
[ "protected", "function", "unpack", "(", "$", "content", ")", "{", "if", "(", "!", "is_array", "(", "$", "content", ")", ")", "return", "null", ";", "if", "(", "$", "content", "[", "'ttl'", "]", ">", "0", "&&", "time", "(", ")", ">=", "$", "content", "[", "'time'", "]", "+", "$", "content", "[", "'ttl'", "]", ")", "{", "$", "this", "->", "remove", "(", "$", "content", "[", "'key'", "]", ")", ";", "return", "null", ";", "}", "return", "$", "content", "[", "'value'", "]", ";", "}" ]
Unpack the data from cache, and unserialize the value. If ttl is ussed and is expired false is return @param array $content Data from cache. @return mixed
[ "Unpack", "the", "data", "from", "cache", "and", "unserialize", "the", "value", ".", "If", "ttl", "is", "ussed", "and", "is", "expired", "false", "is", "return" ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Cache/AbstractCache.php#L106-L117
222,984
awakenweb/livedocx
src/Block.php
Block.bind
public function bind($values) { if ( ! is_array($values) ) { throw new InvalidException('Values assigned to a block must be an array'); } // only one value if ( ! $this->isArrayMulti($values) ) { $this->bindings[] = $values; return $this; } // multiple values foreach ( $values as $line ) { $this->bind($line); } return $this; }
php
public function bind($values) { if ( ! is_array($values) ) { throw new InvalidException('Values assigned to a block must be an array'); } // only one value if ( ! $this->isArrayMulti($values) ) { $this->bindings[] = $values; return $this; } // multiple values foreach ( $values as $line ) { $this->bind($line); } return $this; }
[ "public", "function", "bind", "(", "$", "values", ")", "{", "if", "(", "!", "is_array", "(", "$", "values", ")", ")", "{", "throw", "new", "InvalidException", "(", "'Values assigned to a block must be an array'", ")", ";", "}", "// only one value", "if", "(", "!", "$", "this", "->", "isArrayMulti", "(", "$", "values", ")", ")", "{", "$", "this", "->", "bindings", "[", "]", "=", "$", "values", ";", "return", "$", "this", ";", "}", "// multiple values", "foreach", "(", "$", "values", "as", "$", "line", ")", "{", "$", "this", "->", "bind", "(", "$", "line", ")", ";", "}", "return", "$", "this", ";", "}" ]
Bind a set of values to a block fieldname @param array $values @return Block @throws InvalidException @api
[ "Bind", "a", "set", "of", "values", "to", "a", "block", "fieldname" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Block.php#L82-L100
222,985
awakenweb/livedocx
src/Block.php
Block.getAllBlockNames
public function getAllBlockNames() { $ret = [ ]; try { $result = $this->getSoapClient()->GetBlockNames(); } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all blocks in the active template' , $ex); } if ( isset($result->GetBlockNamesResult->string) ) { if ( is_array($result->GetBlockNamesResult->string) ) { $ret = $result->GetBlockNamesResult->string; } else { $ret[] = $result->GetBlockNamesResult->string; } } return $ret; }
php
public function getAllBlockNames() { $ret = [ ]; try { $result = $this->getSoapClient()->GetBlockNames(); } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all blocks in the active template' , $ex); } if ( isset($result->GetBlockNamesResult->string) ) { if ( is_array($result->GetBlockNamesResult->string) ) { $ret = $result->GetBlockNamesResult->string; } else { $ret[] = $result->GetBlockNamesResult->string; } } return $ret; }
[ "public", "function", "getAllBlockNames", "(", ")", "{", "$", "ret", "=", "[", "]", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetBlockNames", "(", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of all blocks in the active template'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetBlockNamesResult", "->", "string", ")", ")", "{", "if", "(", "is_array", "(", "$", "result", "->", "GetBlockNamesResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetBlockNamesResult", "->", "string", ";", "}", "else", "{", "$", "ret", "[", "]", "=", "$", "result", "->", "GetBlockNamesResult", "->", "string", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Return the names of all blocks included in the active template @return array @throws StatusException @api
[ "Return", "the", "names", "of", "all", "blocks", "included", "in", "the", "active", "template" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Block.php#L137-L154
222,986
awakenweb/livedocx
src/Block.php
Block.getFieldNames
public function getFieldNames() { $ret = [ ]; try { $result = $this->getSoapClient()->GetBlockFieldNames([ 'blockName' => $this->getName() , ]); } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all fields in this block' , $ex); } if ( isset($result->GetBlockFieldNamesResult->string) ) { if ( is_array($result->GetBlockFieldNamesResult->string) ) { $ret = $result->GetBlockFieldNamesResult->string; } else { $ret[] = $result->GetBlockFieldNamesResult->string; } } return $ret; }
php
public function getFieldNames() { $ret = [ ]; try { $result = $this->getSoapClient()->GetBlockFieldNames([ 'blockName' => $this->getName() , ]); } catch ( SoapException $ex ) { throw new StatusException('Error while getting the list of all fields in this block' , $ex); } if ( isset($result->GetBlockFieldNamesResult->string) ) { if ( is_array($result->GetBlockFieldNamesResult->string) ) { $ret = $result->GetBlockFieldNamesResult->string; } else { $ret[] = $result->GetBlockFieldNamesResult->string; } } return $ret; }
[ "public", "function", "getFieldNames", "(", ")", "{", "$", "ret", "=", "[", "]", ";", "try", "{", "$", "result", "=", "$", "this", "->", "getSoapClient", "(", ")", "->", "GetBlockFieldNames", "(", "[", "'blockName'", "=>", "$", "this", "->", "getName", "(", ")", ",", "]", ")", ";", "}", "catch", "(", "SoapException", "$", "ex", ")", "{", "throw", "new", "StatusException", "(", "'Error while getting the list of all fields in this block'", ",", "$", "ex", ")", ";", "}", "if", "(", "isset", "(", "$", "result", "->", "GetBlockFieldNamesResult", "->", "string", ")", ")", "{", "if", "(", "is_array", "(", "$", "result", "->", "GetBlockFieldNamesResult", "->", "string", ")", ")", "{", "$", "ret", "=", "$", "result", "->", "GetBlockFieldNamesResult", "->", "string", ";", "}", "else", "{", "$", "ret", "[", "]", "=", "$", "result", "->", "GetBlockFieldNamesResult", "->", "string", ";", "}", "}", "return", "$", "ret", ";", "}" ]
Return the list of all fields contained in this block inside the active template @return array @throws StatusException @throws NameException @see Block::getName @api
[ "Return", "the", "list", "of", "all", "fields", "contained", "in", "this", "block", "inside", "the", "active", "template" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Block.php#L166-L186
222,987
awakenweb/livedocx
src/Soap/Client.php
Client.connect
public function connect($username , $password) { if ( ! $this->isConnected ) { try { $this->client->LogIn([ 'username' => $username , 'password' => $password ]); $this->isConnected = true; } catch ( SoapFault $ex ) { throw new ConnectException('Either an error occured when connecting to Livedocx, or the credentials you provided are wrong' , $ex); } } return $this; }
php
public function connect($username , $password) { if ( ! $this->isConnected ) { try { $this->client->LogIn([ 'username' => $username , 'password' => $password ]); $this->isConnected = true; } catch ( SoapFault $ex ) { throw new ConnectException('Either an error occured when connecting to Livedocx, or the credentials you provided are wrong' , $ex); } } return $this; }
[ "public", "function", "connect", "(", "$", "username", ",", "$", "password", ")", "{", "if", "(", "!", "$", "this", "->", "isConnected", ")", "{", "try", "{", "$", "this", "->", "client", "->", "LogIn", "(", "[", "'username'", "=>", "$", "username", ",", "'password'", "=>", "$", "password", "]", ")", ";", "$", "this", "->", "isConnected", "=", "true", ";", "}", "catch", "(", "SoapFault", "$", "ex", ")", "{", "throw", "new", "ConnectException", "(", "'Either an error occured when connecting to Livedocx, or the credentials you provided are wrong'", ",", "$", "ex", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Create a session on Livedocx service @param string $username @param string $password @return Client @throws SoapException @api
[ "Create", "a", "session", "on", "Livedocx", "service" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Soap/Client.php#L79-L90
222,988
awakenweb/livedocx
src/Soap/Client.php
Client.assocArrayToArrayOfArrayOfString
protected function assocArrayToArrayOfArrayOfString($assoc) { $arrayKeys = array_keys($assoc); $arrayValues = array_values($assoc); return array( $arrayKeys , $arrayValues ); }
php
protected function assocArrayToArrayOfArrayOfString($assoc) { $arrayKeys = array_keys($assoc); $arrayValues = array_values($assoc); return array( $arrayKeys , $arrayValues ); }
[ "protected", "function", "assocArrayToArrayOfArrayOfString", "(", "$", "assoc", ")", "{", "$", "arrayKeys", "=", "array_keys", "(", "$", "assoc", ")", ";", "$", "arrayValues", "=", "array_values", "(", "$", "assoc", ")", ";", "return", "array", "(", "$", "arrayKeys", ",", "$", "arrayValues", ")", ";", "}" ]
Convert an associative PHP array to an array of array of strings @param array $assoc @return array @internal
[ "Convert", "an", "associative", "PHP", "array", "to", "an", "array", "of", "array", "of", "strings" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Soap/Client.php#L169-L175
222,989
awakenweb/livedocx
src/Soap/Client.php
Client.multiAssocArrayToArrayOfArrayOfString
protected function multiAssocArrayToArrayOfArrayOfString($multi) { $arrayKeys = array_keys($multi[ 0 ]); $arrayValues = array(); foreach ( $multi as $v ) { $arrayValues[] = array_values($v); } $_arrayKeys = array(); $_arrayKeys[ 0 ] = $arrayKeys; return array_merge($_arrayKeys , $arrayValues); }
php
protected function multiAssocArrayToArrayOfArrayOfString($multi) { $arrayKeys = array_keys($multi[ 0 ]); $arrayValues = array(); foreach ( $multi as $v ) { $arrayValues[] = array_values($v); } $_arrayKeys = array(); $_arrayKeys[ 0 ] = $arrayKeys; return array_merge($_arrayKeys , $arrayValues); }
[ "protected", "function", "multiAssocArrayToArrayOfArrayOfString", "(", "$", "multi", ")", "{", "$", "arrayKeys", "=", "array_keys", "(", "$", "multi", "[", "0", "]", ")", ";", "$", "arrayValues", "=", "array", "(", ")", ";", "foreach", "(", "$", "multi", "as", "$", "v", ")", "{", "$", "arrayValues", "[", "]", "=", "array_values", "(", "$", "v", ")", ";", "}", "$", "_arrayKeys", "=", "array", "(", ")", ";", "$", "_arrayKeys", "[", "0", "]", "=", "$", "arrayKeys", ";", "return", "array_merge", "(", "$", "_arrayKeys", ",", "$", "arrayValues", ")", ";", "}" ]
Convert a multidimensional PHP array to an array of array of arrays of strings @param array $multi @return array @internal
[ "Convert", "a", "multidimensional", "PHP", "array", "to", "an", "array", "of", "array", "of", "arrays", "of", "strings" ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Soap/Client.php#L187-L200
222,990
awakenweb/livedocx
src/Soap/Client.php
Client.backendListArrayToMultiAssocArray
public function backendListArrayToMultiAssocArray(stdClass $list) { $ret = array(); if ( isset($list->ArrayOfString) ) { foreach ( $list->ArrayOfString as $a ) { if ( is_array($a) ) { // 1 template only $o = new StdClass(); $o->string = $a; } else { // 2 or more templates $o = $a; } unset($a); if ( isset($o->string) ) { $date1 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 3 ]); $date2 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 1 ]); $ret[] = array( 'filename' => $o->string[ 0 ] , 'fileSize' => ( integer ) $o->string[ 2 ] , 'createTime' => ( integer ) $date1->getTimestamp() , 'modifyTime' => ( integer ) $date2->getTimestamp() , ); unset($date1 , $date2); } } } return $ret; }
php
public function backendListArrayToMultiAssocArray(stdClass $list) { $ret = array(); if ( isset($list->ArrayOfString) ) { foreach ( $list->ArrayOfString as $a ) { if ( is_array($a) ) { // 1 template only $o = new StdClass(); $o->string = $a; } else { // 2 or more templates $o = $a; } unset($a); if ( isset($o->string) ) { $date1 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 3 ]); $date2 = DateTime::createFromFormat(DateTime::RFC1123 , $o->string[ 1 ]); $ret[] = array( 'filename' => $o->string[ 0 ] , 'fileSize' => ( integer ) $o->string[ 2 ] , 'createTime' => ( integer ) $date1->getTimestamp() , 'modifyTime' => ( integer ) $date2->getTimestamp() , ); unset($date1 , $date2); } } } return $ret; }
[ "public", "function", "backendListArrayToMultiAssocArray", "(", "stdClass", "$", "list", ")", "{", "$", "ret", "=", "array", "(", ")", ";", "if", "(", "isset", "(", "$", "list", "->", "ArrayOfString", ")", ")", "{", "foreach", "(", "$", "list", "->", "ArrayOfString", "as", "$", "a", ")", "{", "if", "(", "is_array", "(", "$", "a", ")", ")", "{", "// 1 template only", "$", "o", "=", "new", "StdClass", "(", ")", ";", "$", "o", "->", "string", "=", "$", "a", ";", "}", "else", "{", "// 2 or more templates", "$", "o", "=", "$", "a", ";", "}", "unset", "(", "$", "a", ")", ";", "if", "(", "isset", "(", "$", "o", "->", "string", ")", ")", "{", "$", "date1", "=", "DateTime", "::", "createFromFormat", "(", "DateTime", "::", "RFC1123", ",", "$", "o", "->", "string", "[", "3", "]", ")", ";", "$", "date2", "=", "DateTime", "::", "createFromFormat", "(", "DateTime", "::", "RFC1123", ",", "$", "o", "->", "string", "[", "1", "]", ")", ";", "$", "ret", "[", "]", "=", "array", "(", "'filename'", "=>", "$", "o", "->", "string", "[", "0", "]", ",", "'fileSize'", "=>", "(", "integer", ")", "$", "o", "->", "string", "[", "2", "]", ",", "'createTime'", "=>", "(", "integer", ")", "$", "date1", "->", "getTimestamp", "(", ")", ",", "'modifyTime'", "=>", "(", "integer", ")", "$", "date2", "->", "getTimestamp", "(", ")", ",", ")", ";", "unset", "(", "$", "date1", ",", "$", "date2", ")", ";", "}", "}", "}", "return", "$", "ret", ";", "}" ]
Convert LiveDocx service return value from list methods to consistent PHP array. @param stdClass $list @return array @internal
[ "Convert", "LiveDocx", "service", "return", "value", "from", "list", "methods", "to", "consistent", "PHP", "array", "." ]
e83abb0df1c122ed1fed67d799fd3643ca134a59
https://github.com/awakenweb/livedocx/blob/e83abb0df1c122ed1fed67d799fd3643ca134a59/src/Soap/Client.php#L212-L241
222,991
lcache/lcache
src/Address.php
Address.isMatch
public function isMatch(Address $address) { if (!is_null($address->getBin()) && !is_null($this->bin) && $address->getBin() !== $this->bin) { return false; } if (!is_null($address->getKey()) && !is_null($this->key) && $address->getKey() !== $this->key) { return false; } return true; }
php
public function isMatch(Address $address) { if (!is_null($address->getBin()) && !is_null($this->bin) && $address->getBin() !== $this->bin) { return false; } if (!is_null($address->getKey()) && !is_null($this->key) && $address->getKey() !== $this->key) { return false; } return true; }
[ "public", "function", "isMatch", "(", "Address", "$", "address", ")", "{", "if", "(", "!", "is_null", "(", "$", "address", "->", "getBin", "(", ")", ")", "&&", "!", "is_null", "(", "$", "this", "->", "bin", ")", "&&", "$", "address", "->", "getBin", "(", ")", "!==", "$", "this", "->", "bin", ")", "{", "return", "false", ";", "}", "if", "(", "!", "is_null", "(", "$", "address", "->", "getKey", "(", ")", ")", "&&", "!", "is_null", "(", "$", "this", "->", "key", ")", "&&", "$", "address", "->", "getKey", "(", ")", "!==", "$", "this", "->", "key", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Return true if this object refers to any of the same objects as the provided Address object. @param Address $address @return boolean
[ "Return", "true", "if", "this", "object", "refers", "to", "any", "of", "the", "same", "objects", "as", "the", "provided", "Address", "object", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/Address.php#L71-L80
222,992
lcache/lcache
src/Address.php
Address.serialize
public function serialize() { if (is_null($this->bin)) { return ''; } $length_prefixed_bin = strlen($this->bin) . ':' . $this->bin; if (is_null($this->key)) { return $length_prefixed_bin . ':'; } return $length_prefixed_bin . ':' . $this->key; }
php
public function serialize() { if (is_null($this->bin)) { return ''; } $length_prefixed_bin = strlen($this->bin) . ':' . $this->bin; if (is_null($this->key)) { return $length_prefixed_bin . ':'; } return $length_prefixed_bin . ':' . $this->key; }
[ "public", "function", "serialize", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "bin", ")", ")", "{", "return", "''", ";", "}", "$", "length_prefixed_bin", "=", "strlen", "(", "$", "this", "->", "bin", ")", ".", "':'", ".", "$", "this", "->", "bin", ";", "if", "(", "is_null", "(", "$", "this", "->", "key", ")", ")", "{", "return", "$", "length_prefixed_bin", ".", "':'", ";", "}", "return", "$", "length_prefixed_bin", ".", "':'", ".", "$", "this", "->", "key", ";", "}" ]
Serialize this object, returning a string representing this address. The serialized form must: - Place the bin first - Return a prefix matching all entries in a bin with a NULL key - Return a prefix matching all entries with a NULL bin @return string
[ "Serialize", "this", "object", "returning", "a", "string", "representing", "this", "address", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/Address.php#L93-L105
222,993
lcache/lcache
src/Address.php
Address.unserialize
public function unserialize($serialized) { $entries = explode(':', $serialized, 2); $this->bin = null; $this->key = null; if (count($entries) === 2) { list($bin_length, $bin_and_key) = $entries; $bin_length = intval($bin_length); $this->bin = substr($bin_and_key, 0, $bin_length); $this->key = substr($bin_and_key, $bin_length + 1); } // @TODO: Remove check against false for PHP 7+ if (false === $this->key || '' === $this->key) { $this->key = null; } }
php
public function unserialize($serialized) { $entries = explode(':', $serialized, 2); $this->bin = null; $this->key = null; if (count($entries) === 2) { list($bin_length, $bin_and_key) = $entries; $bin_length = intval($bin_length); $this->bin = substr($bin_and_key, 0, $bin_length); $this->key = substr($bin_and_key, $bin_length + 1); } // @TODO: Remove check against false for PHP 7+ if (false === $this->key || '' === $this->key) { $this->key = null; } }
[ "public", "function", "unserialize", "(", "$", "serialized", ")", "{", "$", "entries", "=", "explode", "(", "':'", ",", "$", "serialized", ",", "2", ")", ";", "$", "this", "->", "bin", "=", "null", ";", "$", "this", "->", "key", "=", "null", ";", "if", "(", "count", "(", "$", "entries", ")", "===", "2", ")", "{", "list", "(", "$", "bin_length", ",", "$", "bin_and_key", ")", "=", "$", "entries", ";", "$", "bin_length", "=", "intval", "(", "$", "bin_length", ")", ";", "$", "this", "->", "bin", "=", "substr", "(", "$", "bin_and_key", ",", "0", ",", "$", "bin_length", ")", ";", "$", "this", "->", "key", "=", "substr", "(", "$", "bin_and_key", ",", "$", "bin_length", "+", "1", ")", ";", "}", "// @TODO: Remove check against false for PHP 7+", "if", "(", "false", "===", "$", "this", "->", "key", "||", "''", "===", "$", "this", "->", "key", ")", "{", "$", "this", "->", "key", "=", "null", ";", "}", "}" ]
Unpack a serialized Address into this object. @param string $serialized
[ "Unpack", "a", "serialized", "Address", "into", "this", "object", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/Address.php#L111-L127
222,994
lcache/lcache
src/StateL1APCu.php
StateL1APCu.recordEvent
private function recordEvent($key) { $success = null; apcu_inc($key, 1, $success); if ($success !== null && !$success) { // @TODO: Remove this fallback when we drop APCu 4.x support. // @codeCoverageIgnoreStart // Ignore coverage because (1) it's tested with other code and // (2) APCu 5.x does not use it. $success = apcu_store($key, 1); // @codeCoverageIgnoreEnd } return $success; }
php
private function recordEvent($key) { $success = null; apcu_inc($key, 1, $success); if ($success !== null && !$success) { // @TODO: Remove this fallback when we drop APCu 4.x support. // @codeCoverageIgnoreStart // Ignore coverage because (1) it's tested with other code and // (2) APCu 5.x does not use it. $success = apcu_store($key, 1); // @codeCoverageIgnoreEnd } return $success; }
[ "private", "function", "recordEvent", "(", "$", "key", ")", "{", "$", "success", "=", "null", ";", "apcu_inc", "(", "$", "key", ",", "1", ",", "$", "success", ")", ";", "if", "(", "$", "success", "!==", "null", "&&", "!", "$", "success", ")", "{", "// @TODO: Remove this fallback when we drop APCu 4.x support.", "// @codeCoverageIgnoreStart", "// Ignore coverage because (1) it's tested with other code and", "// (2) APCu 5.x does not use it.", "$", "success", "=", "apcu_store", "(", "$", "key", ",", "1", ")", ";", "// @codeCoverageIgnoreEnd", "}", "return", "$", "success", ";", "}" ]
Utility method to reduce code duplication. @param string $key Key to store the evet counters in. @return bool True on success, false otherwise.
[ "Utility", "method", "to", "reduce", "code", "duplication", "." ]
275282b60811d58d9aaa3c2c752ff01e48d02f6d
https://github.com/lcache/lcache/blob/275282b60811d58d9aaa3c2c752ff01e48d02f6d/src/StateL1APCu.php#L70-L83
222,995
mongator/mongator
src/Mongator/IndexManager.php
IndexManager.getDiff
public function getDiff() { $set = $this->getIndexInfo(); unset($set['_id_1']); $present = array(); $missing = array(); foreach ($this->config as $index) { if ( !isset($index['options']) ) $index['options'] = array(); $name = $this->generateIndexKeyFromConfig($index); if ( isset($set[$name]) ) { $present[$name] = $index; unset($set[$name]); } else { $missing[$name] = $index; } } return array( 'missing' => $missing, 'present' => $present, 'unknown' => $set ); }
php
public function getDiff() { $set = $this->getIndexInfo(); unset($set['_id_1']); $present = array(); $missing = array(); foreach ($this->config as $index) { if ( !isset($index['options']) ) $index['options'] = array(); $name = $this->generateIndexKeyFromConfig($index); if ( isset($set[$name]) ) { $present[$name] = $index; unset($set[$name]); } else { $missing[$name] = $index; } } return array( 'missing' => $missing, 'present' => $present, 'unknown' => $set ); }
[ "public", "function", "getDiff", "(", ")", "{", "$", "set", "=", "$", "this", "->", "getIndexInfo", "(", ")", ";", "unset", "(", "$", "set", "[", "'_id_1'", "]", ")", ";", "$", "present", "=", "array", "(", ")", ";", "$", "missing", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "config", "as", "$", "index", ")", "{", "if", "(", "!", "isset", "(", "$", "index", "[", "'options'", "]", ")", ")", "$", "index", "[", "'options'", "]", "=", "array", "(", ")", ";", "$", "name", "=", "$", "this", "->", "generateIndexKeyFromConfig", "(", "$", "index", ")", ";", "if", "(", "isset", "(", "$", "set", "[", "$", "name", "]", ")", ")", "{", "$", "present", "[", "$", "name", "]", "=", "$", "index", ";", "unset", "(", "$", "set", "[", "$", "name", "]", ")", ";", "}", "else", "{", "$", "missing", "[", "$", "name", "]", "=", "$", "index", ";", "}", "}", "return", "array", "(", "'missing'", "=>", "$", "missing", ",", "'present'", "=>", "$", "present", ",", "'unknown'", "=>", "$", "set", ")", ";", "}" ]
Returns the diferences between server indexes and class config, when a indexes change will be marked in db as unknown and missing the new version. @return array Associative array with keys: missing, present and unknown @api
[ "Returns", "the", "diferences", "between", "server", "indexes", "and", "class", "config", "when", "a", "indexes", "change", "will", "be", "marked", "in", "db", "as", "unknown", "and", "missing", "the", "new", "version", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/IndexManager.php#L80-L105
222,996
mongator/mongator
src/Mongator/IndexManager.php
IndexManager.commit
public function commit($delete = true) { $diff = $this->getDiff(); if ($delete) { foreach ($diff['unknown'] as $index) { $this->deleteIndex($index['name']); } } foreach ($diff['missing'] as $name => $index) { $this->ensureIndex($index['keys'], $index['options']); } return true; }
php
public function commit($delete = true) { $diff = $this->getDiff(); if ($delete) { foreach ($diff['unknown'] as $index) { $this->deleteIndex($index['name']); } } foreach ($diff['missing'] as $name => $index) { $this->ensureIndex($index['keys'], $index['options']); } return true; }
[ "public", "function", "commit", "(", "$", "delete", "=", "true", ")", "{", "$", "diff", "=", "$", "this", "->", "getDiff", "(", ")", ";", "if", "(", "$", "delete", ")", "{", "foreach", "(", "$", "diff", "[", "'unknown'", "]", "as", "$", "index", ")", "{", "$", "this", "->", "deleteIndex", "(", "$", "index", "[", "'name'", "]", ")", ";", "}", "}", "foreach", "(", "$", "diff", "[", "'missing'", "]", "as", "$", "name", "=>", "$", "index", ")", "{", "$", "this", "->", "ensureIndex", "(", "$", "index", "[", "'keys'", "]", ",", "$", "index", "[", "'options'", "]", ")", ";", "}", "return", "true", ";", "}" ]
Commit the indexes to the database @param boolean $delete (optional) true by default or the unknown indexes will be dropeed from collection @return boolean @api
[ "Commit", "the", "indexes", "to", "the", "database" ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/IndexManager.php#L116-L131
222,997
mongator/mongator
src/Mongator/Query/Query.php
Query.text
public function text($search, $requiredScore = null, $language = null) { if ($search === null) { $this->text = null; } else { $this->text = array( 'search' => $search, 'requiredScore' => $requiredScore, 'language' => $language ); } return $this; }
php
public function text($search, $requiredScore = null, $language = null) { if ($search === null) { $this->text = null; } else { $this->text = array( 'search' => $search, 'requiredScore' => $requiredScore, 'language' => $language ); } return $this; }
[ "public", "function", "text", "(", "$", "search", ",", "$", "requiredScore", "=", "null", ",", "$", "language", "=", "null", ")", "{", "if", "(", "$", "search", "===", "null", ")", "{", "$", "this", "->", "text", "=", "null", ";", "}", "else", "{", "$", "this", "->", "text", "=", "array", "(", "'search'", "=>", "$", "search", ",", "'requiredScore'", "=>", "$", "requiredScore", ",", "'language'", "=>", "$", "language", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the text search criterias. The text methods requires a text index. @param string $search A string of terms @param int $requiredScore (optional) All the documents with less score will be omitted @param int $language (optional) Specify the language that determines for the search the list of stop words and the rules for the stemmer and tokenizer. If not specified, the search uses the default language of the index. @return \Mongator\Query\Query The query instance (fluent interface). @api
[ "Set", "the", "text", "search", "criterias", ".", "The", "text", "methods", "requires", "a", "text", "index", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Query/Query.php#L537-L550
222,998
mongator/mongator
src/Mongator/Query/Query.php
Query.createResult
public function createResult() { if (!$this->text) { return false; } list($search, $requiredScore, $language) = array_values($this->text); $limit = $this->limit; if ($this->skip && $this->limit) { $limit += $this->skip; } $options = array(); if ( $this->timeout ) $options['timeout'] = $this->timeout; $fields = array(); foreach ($this->fields as $key => $value) { if ( !is_numeric($value) ) $fields[$value] = 1; else $fields[$key] = $value; } $response = $this->repository->text( $search, $this->criteria, $fields, $limit, $language, $options ); $result = new \ArrayObject; foreach ($response['results'] as $index => $document) { if ( $requiredScore && $requiredScore > $document['score'] ) continue; if ( $this->skip && $index < $this->skip ) continue; $result[(string) $document['obj']['_id']] = $document['obj']; } return new Result($result); }
php
public function createResult() { if (!$this->text) { return false; } list($search, $requiredScore, $language) = array_values($this->text); $limit = $this->limit; if ($this->skip && $this->limit) { $limit += $this->skip; } $options = array(); if ( $this->timeout ) $options['timeout'] = $this->timeout; $fields = array(); foreach ($this->fields as $key => $value) { if ( !is_numeric($value) ) $fields[$value] = 1; else $fields[$key] = $value; } $response = $this->repository->text( $search, $this->criteria, $fields, $limit, $language, $options ); $result = new \ArrayObject; foreach ($response['results'] as $index => $document) { if ( $requiredScore && $requiredScore > $document['score'] ) continue; if ( $this->skip && $index < $this->skip ) continue; $result[(string) $document['obj']['_id']] = $document['obj']; } return new Result($result); }
[ "public", "function", "createResult", "(", ")", "{", "if", "(", "!", "$", "this", "->", "text", ")", "{", "return", "false", ";", "}", "list", "(", "$", "search", ",", "$", "requiredScore", ",", "$", "language", ")", "=", "array_values", "(", "$", "this", "->", "text", ")", ";", "$", "limit", "=", "$", "this", "->", "limit", ";", "if", "(", "$", "this", "->", "skip", "&&", "$", "this", "->", "limit", ")", "{", "$", "limit", "+=", "$", "this", "->", "skip", ";", "}", "$", "options", "=", "array", "(", ")", ";", "if", "(", "$", "this", "->", "timeout", ")", "$", "options", "[", "'timeout'", "]", "=", "$", "this", "->", "timeout", ";", "$", "fields", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "is_numeric", "(", "$", "value", ")", ")", "$", "fields", "[", "$", "value", "]", "=", "1", ";", "else", "$", "fields", "[", "$", "key", "]", "=", "$", "value", ";", "}", "$", "response", "=", "$", "this", "->", "repository", "->", "text", "(", "$", "search", ",", "$", "this", "->", "criteria", ",", "$", "fields", ",", "$", "limit", ",", "$", "language", ",", "$", "options", ")", ";", "$", "result", "=", "new", "\\", "ArrayObject", ";", "foreach", "(", "$", "response", "[", "'results'", "]", "as", "$", "index", "=>", "$", "document", ")", "{", "if", "(", "$", "requiredScore", "&&", "$", "requiredScore", ">", "$", "document", "[", "'score'", "]", ")", "continue", ";", "if", "(", "$", "this", "->", "skip", "&&", "$", "index", "<", "$", "this", "->", "skip", ")", "continue", ";", "$", "result", "[", "(", "string", ")", "$", "document", "[", "'obj'", "]", "[", "'_id'", "]", "]", "=", "$", "document", "[", "'obj'", "]", ";", "}", "return", "new", "Result", "(", "$", "result", ")", ";", "}" ]
Create an ArrayObject with a result's text command of the query. @return Result A iterable object with the data of the query.
[ "Create", "an", "ArrayObject", "with", "a", "result", "s", "text", "command", "of", "the", "query", "." ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Query/Query.php#L667-L707
222,999
mongator/mongator
src/Mongator/Query/Query.php
Query.generateKey
public function generateKey($includeHash = true) { $keys = array(); $keys['vars'] = get_object_vars($this); $keys['class'] = get_class($this); $keys['metadata'] = $this->repository->getMetadata(); $keys['dbname'] = $this->repository->getConnection()->getDbName(); unset($keys['vars']['repository']); if ( !$includeHash ) unset($keys['vars']['hash']); return md5(serialize($keys)); }
php
public function generateKey($includeHash = true) { $keys = array(); $keys['vars'] = get_object_vars($this); $keys['class'] = get_class($this); $keys['metadata'] = $this->repository->getMetadata(); $keys['dbname'] = $this->repository->getConnection()->getDbName(); unset($keys['vars']['repository']); if ( !$includeHash ) unset($keys['vars']['hash']); return md5(serialize($keys)); }
[ "public", "function", "generateKey", "(", "$", "includeHash", "=", "true", ")", "{", "$", "keys", "=", "array", "(", ")", ";", "$", "keys", "[", "'vars'", "]", "=", "get_object_vars", "(", "$", "this", ")", ";", "$", "keys", "[", "'class'", "]", "=", "get_class", "(", "$", "this", ")", ";", "$", "keys", "[", "'metadata'", "]", "=", "$", "this", "->", "repository", "->", "getMetadata", "(", ")", ";", "$", "keys", "[", "'dbname'", "]", "=", "$", "this", "->", "repository", "->", "getConnection", "(", ")", "->", "getDbName", "(", ")", ";", "unset", "(", "$", "keys", "[", "'vars'", "]", "[", "'repository'", "]", ")", ";", "if", "(", "!", "$", "includeHash", ")", "unset", "(", "$", "keys", "[", "'vars'", "]", "[", "'hash'", "]", ")", ";", "return", "md5", "(", "serialize", "(", "$", "keys", ")", ")", ";", "}" ]
Generate a unique key for this query @return string md5
[ "Generate", "a", "unique", "key", "for", "this", "query" ]
c29b94989677597a84dc5d3907224bf608967c26
https://github.com/mongator/mongator/blob/c29b94989677597a84dc5d3907224bf608967c26/src/Mongator/Query/Query.php#L729-L741