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
30,500
SIELOnline/libAcumulus
src/Invoice/Creator.php
Creator.callSourceTypeSpecificMethod
protected function callSourceTypeSpecificMethod($method, $args = array()) { $method .= $this->invoiceSource->getType(); return call_user_func_array(array($this, $method), $args); }
php
protected function callSourceTypeSpecificMethod($method, $args = array()) { $method .= $this->invoiceSource->getType(); return call_user_func_array(array($this, $method), $args); }
[ "protected", "function", "callSourceTypeSpecificMethod", "(", "$", "method", ",", "$", "args", "=", "array", "(", ")", ")", "{", "$", "method", ".=", "$", "this", "->", "invoiceSource", "->", "getType", "(", ")", ";", "return", "call_user_func_array", "(", "array", "(", "$", "this", ",", "$", "method", ")", ",", "$", "args", ")", ";", "}" ]
Calls a method constructed of the method name and the source type. If the implementation/override of a method depends on the type of invoice source it might be better to implement 1 method per source type. This method calls such a method assuming it is named {method}{source-type}. Example: if getLineItem($line) would be very different for an order versus a credit note: do not override the base method but implement 2 new methods getLineItemOrder($line) and getLineItemCreditNote($line). @param string $method @param array $args @return mixed
[ "Calls", "a", "method", "constructed", "of", "the", "method", "name", "and", "the", "source", "type", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/Creator.php#L1129-L1133
30,501
ipunkt/rancherize
app/Configuration/Services/ProjectConfiguration.php
ProjectConfiguration.save
public function save( Configuration $configuration ) { /** * Only values under the `project` key should be written to the project config */ $prefixDecorator = new PrefixConfigurableDecorator( $configuration, 'project' ); $rancherizePath = $this->getConfigPath(); $this->writer->write( $prefixDecorator, $rancherizePath ); }
php
public function save( Configuration $configuration ) { /** * Only values under the `project` key should be written to the project config */ $prefixDecorator = new PrefixConfigurableDecorator( $configuration, 'project' ); $rancherizePath = $this->getConfigPath(); $this->writer->write( $prefixDecorator, $rancherizePath ); }
[ "public", "function", "save", "(", "Configuration", "$", "configuration", ")", "{", "/**\n\t\t * Only values under the `project` key should be written to the project config\n\t\t */", "$", "prefixDecorator", "=", "new", "PrefixConfigurableDecorator", "(", "$", "configuration", ",", "'project'", ")", ";", "$", "rancherizePath", "=", "$", "this", "->", "getConfigPath", "(", ")", ";", "$", "this", "->", "writer", "->", "write", "(", "$", "prefixDecorator", ",", "$", "rancherizePath", ")", ";", "}" ]
Save the project part of the configuration @param Configuration $configuration
[ "Save", "the", "project", "part", "of", "the", "configuration" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/Configuration/Services/ProjectConfiguration.php#L74-L85
30,502
ipunkt/rancherize
app/File/FileLoader.php
FileLoader.get
public function get(string $path) : string { if(! file_exists($path) ) throw new FileNotFoundException($path, 200); return file_get_contents($path); }
php
public function get(string $path) : string { if(! file_exists($path) ) throw new FileNotFoundException($path, 200); return file_get_contents($path); }
[ "public", "function", "get", "(", "string", "$", "path", ")", ":", "string", "{", "if", "(", "!", "file_exists", "(", "$", "path", ")", ")", "throw", "new", "FileNotFoundException", "(", "$", "path", ",", "200", ")", ";", "return", "file_get_contents", "(", "$", "path", ")", ";", "}" ]
Load file from disk @param $path @return string
[ "Load", "file", "from", "disk" ]
3c226da686b283e7fef961a9a79b54db53b8757b
https://github.com/ipunkt/rancherize/blob/3c226da686b283e7fef961a9a79b54db53b8757b/app/File/FileLoader.php#L18-L24
30,503
SIELOnline/libAcumulus
src/Helpers/Log.php
Log.getSeverityString
protected function getSeverityString($severity) { switch ($severity) { case Log::Error: return 'Error'; case Log::Warning: return 'Warning'; case Log::Notice: return 'Notice'; case Log::Info: return 'Info'; case Log::Debug: default: return 'Debug'; } }
php
protected function getSeverityString($severity) { switch ($severity) { case Log::Error: return 'Error'; case Log::Warning: return 'Warning'; case Log::Notice: return 'Notice'; case Log::Info: return 'Info'; case Log::Debug: default: return 'Debug'; } }
[ "protected", "function", "getSeverityString", "(", "$", "severity", ")", "{", "switch", "(", "$", "severity", ")", "{", "case", "Log", "::", "Error", ":", "return", "'Error'", ";", "case", "Log", "::", "Warning", ":", "return", "'Warning'", ";", "case", "Log", "::", "Notice", ":", "return", "'Notice'", ";", "case", "Log", "::", "Info", ":", "return", "'Info'", ";", "case", "Log", "::", "Debug", ":", "default", ":", "return", "'Debug'", ";", "}", "}" ]
Returns a textual representation of the severity. @param int $severity One of the constants of this class. @return string A textual representation of the severity.
[ "Returns", "a", "textual", "representation", "of", "the", "severity", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Log.php#L74-L89
30,504
SIELOnline/libAcumulus
src/Helpers/Log.php
Log.log
public function log($severity, $message, array $args = array()) { if ($severity <= max($this->getLogLevel(), Log::Warning)) { if (count($args) > 0) { $message = vsprintf($message, $args); } $this->write($message, $severity); } return $message; }
php
public function log($severity, $message, array $args = array()) { if ($severity <= max($this->getLogLevel(), Log::Warning)) { if (count($args) > 0) { $message = vsprintf($message, $args); } $this->write($message, $severity); } return $message; }
[ "public", "function", "log", "(", "$", "severity", ",", "$", "message", ",", "array", "$", "args", "=", "array", "(", ")", ")", "{", "if", "(", "$", "severity", "<=", "max", "(", "$", "this", "->", "getLogLevel", "(", ")", ",", "Log", "::", "Warning", ")", ")", "{", "if", "(", "count", "(", "$", "args", ")", ">", "0", ")", "{", "$", "message", "=", "vsprintf", "(", "$", "message", ",", "$", "args", ")", ";", "}", "$", "this", "->", "write", "(", "$", "message", ",", "$", "severity", ")", ";", "}", "return", "$", "message", ";", "}" ]
Formats and logs the message if the log level indicates so. Errors and Warnings are always logged, other levels only if the log level is set to do so. Formatting involves: - calling vsprintf() if $args is not empty - adding "Acumulus {version} {severity}: " in front of the message. @param int $severity @param string $message @param array $args @return string The full formatted message whether it got logged or not.
[ "Formats", "and", "logs", "the", "message", "if", "the", "log", "level", "indicates", "so", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Log.php#L108-L117
30,505
SIELOnline/libAcumulus
src/Helpers/Log.php
Log.notice
public function notice($message) { $args = func_get_args(); array_shift($args); return $this->log(Log::Notice, $message, $args); }
php
public function notice($message) { $args = func_get_args(); array_shift($args); return $this->log(Log::Notice, $message, $args); }
[ "public", "function", "notice", "(", "$", "message", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "return", "$", "this", "->", "log", "(", "Log", "::", "Notice", ",", "$", "message", ",", "$", "args", ")", ";", "}" ]
Logs a notice. @param string $message,... The message to log, optionally followed by arguments. If there are arguments the $message is passed through vsprintf(). @return string The full formatted message whether it got logged or not.
[ "Logs", "a", "notice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Log.php#L146-L151
30,506
SIELOnline/libAcumulus
src/Helpers/Log.php
Log.info
public function info($message) { $args = func_get_args(); array_shift($args); return $this->log(Log::Info, $message, $args); }
php
public function info($message) { $args = func_get_args(); array_shift($args); return $this->log(Log::Info, $message, $args); }
[ "public", "function", "info", "(", "$", "message", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "return", "$", "this", "->", "log", "(", "Log", "::", "Info", ",", "$", "message", ",", "$", "args", ")", ";", "}" ]
Logs an informational message. @param string $message,... The message to log, optionally followed by arguments. If there are arguments the $message is passed through vsprintf(). @return string The full formatted message whether it got logged or not.
[ "Logs", "an", "informational", "message", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Log.php#L163-L168
30,507
SIELOnline/libAcumulus
src/Helpers/Log.php
Log.warning
public function warning($message) { $args = func_get_args(); array_shift($args); return $this->log(Log::Warning, $message, $args); }
php
public function warning($message) { $args = func_get_args(); array_shift($args); return $this->log(Log::Warning, $message, $args); }
[ "public", "function", "warning", "(", "$", "message", ")", "{", "$", "args", "=", "func_get_args", "(", ")", ";", "array_shift", "(", "$", "args", ")", ";", "return", "$", "this", "->", "log", "(", "Log", "::", "Warning", ",", "$", "message", ",", "$", "args", ")", ";", "}" ]
Logs a warning. @param string $message,... The message to log, optionally followed by arguments. If there are arguments the $message is passed through vsprintf(). @return string The full formatted message whether it got logged or not.
[ "Logs", "a", "warning", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Log.php#L180-L185
30,508
SIELOnline/libAcumulus
src/Helpers/Log.php
Log.write
protected function write($message, $severity) { $message = sprintf('Acumulus %s: %s - %s', $this->getLibraryVersion(), $this->getSeverityString($severity), $message); error_log($message); }
php
protected function write($message, $severity) { $message = sprintf('Acumulus %s: %s - %s', $this->getLibraryVersion(), $this->getSeverityString($severity), $message); error_log($message); }
[ "protected", "function", "write", "(", "$", "message", ",", "$", "severity", ")", "{", "$", "message", "=", "sprintf", "(", "'Acumulus %s: %s - %s'", ",", "$", "this", "->", "getLibraryVersion", "(", ")", ",", "$", "this", "->", "getSeverityString", "(", "$", "severity", ")", ",", "$", "message", ")", ";", "error_log", "(", "$", "message", ")", ";", "}" ]
Writes the message to the actual log sink. This base implementation adds the name Acumulus, the version of this library, and the severity and then sends the message to error_log(). Override if the web shop offers its own log mechanism. @param string $message @param int $severity
[ "Writes", "the", "message", "to", "the", "actual", "log", "sink", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Log.php#L215-L219
30,509
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.handleLogin
public function handleLogin($request) { $filterString = $this->generateFilter($request); $remoteUser = $this->getRemoteUser($filterString); $password = $request->input($this->passwordField); $passwordHash = array_get($remoteUser, $this->passwordField); if ($this->verifyPassword($password, $passwordHash)) { $user = $this->createShadowUser($remoteUser); $forever = $request->input(static::REMEMBER_ME); $appId = Session::get('app.id'); Session::setUserInfoWithJWT($user, $forever, $appId); return Session::getPublicInfo(); } else { throw new UnauthorizedException('Invalid credential supplied.'); } }
php
public function handleLogin($request) { $filterString = $this->generateFilter($request); $remoteUser = $this->getRemoteUser($filterString); $password = $request->input($this->passwordField); $passwordHash = array_get($remoteUser, $this->passwordField); if ($this->verifyPassword($password, $passwordHash)) { $user = $this->createShadowUser($remoteUser); $forever = $request->input(static::REMEMBER_ME); $appId = Session::get('app.id'); Session::setUserInfoWithJWT($user, $forever, $appId); return Session::getPublicInfo(); } else { throw new UnauthorizedException('Invalid credential supplied.'); } }
[ "public", "function", "handleLogin", "(", "$", "request", ")", "{", "$", "filterString", "=", "$", "this", "->", "generateFilter", "(", "$", "request", ")", ";", "$", "remoteUser", "=", "$", "this", "->", "getRemoteUser", "(", "$", "filterString", ")", ";", "$", "password", "=", "$", "request", "->", "input", "(", "$", "this", "->", "passwordField", ")", ";", "$", "passwordHash", "=", "array_get", "(", "$", "remoteUser", ",", "$", "this", "->", "passwordField", ")", ";", "if", "(", "$", "this", "->", "verifyPassword", "(", "$", "password", ",", "$", "passwordHash", ")", ")", "{", "$", "user", "=", "$", "this", "->", "createShadowUser", "(", "$", "remoteUser", ")", ";", "$", "forever", "=", "$", "request", "->", "input", "(", "static", "::", "REMEMBER_ME", ")", ";", "$", "appId", "=", "Session", "::", "get", "(", "'app.id'", ")", ";", "Session", "::", "setUserInfoWithJWT", "(", "$", "user", ",", "$", "forever", ",", "$", "appId", ")", ";", "return", "Session", "::", "getPublicInfo", "(", ")", ";", "}", "else", "{", "throw", "new", "UnauthorizedException", "(", "'Invalid credential supplied.'", ")", ";", "}", "}" ]
Handles login action including creating shadow user if needed @param \DreamFactory\Core\Contracts\ServiceRequestInterface $request @return array @throws \DreamFactory\Core\Exceptions\InternalServerErrorException @throws \DreamFactory\Core\Exceptions\RestException @throws \DreamFactory\Core\Exceptions\UnauthorizedException @throws \Exception
[ "Handles", "login", "action", "including", "creating", "shadow", "user", "if", "needed" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L71-L88
30,510
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.generateFilter
protected function generateFilter($request) { $this->filters[$this->usernameField] = trim($request->input($this->usernameField)); foreach ($this->otherFields as $of) { $of = trim($of); $this->filters[$of] = $request->input($of); } $string = ''; $multiple = 0; foreach ($this->filters as $f => $v) { if (!empty($string)) { $string .= " AND "; $multiple = 1; } if (is_bool($v) || 'true' === strtolower($v) || 'false' === strtolower($v)) { if ($v === true || $v === 'true') { $v = 1; } else { $v = 0; } } $string .= "($f=$v)"; } return ($multiple) ? "(" . $string . ")" : $string; }
php
protected function generateFilter($request) { $this->filters[$this->usernameField] = trim($request->input($this->usernameField)); foreach ($this->otherFields as $of) { $of = trim($of); $this->filters[$of] = $request->input($of); } $string = ''; $multiple = 0; foreach ($this->filters as $f => $v) { if (!empty($string)) { $string .= " AND "; $multiple = 1; } if (is_bool($v) || 'true' === strtolower($v) || 'false' === strtolower($v)) { if ($v === true || $v === 'true') { $v = 1; } else { $v = 0; } } $string .= "($f=$v)"; } return ($multiple) ? "(" . $string . ")" : $string; }
[ "protected", "function", "generateFilter", "(", "$", "request", ")", "{", "$", "this", "->", "filters", "[", "$", "this", "->", "usernameField", "]", "=", "trim", "(", "$", "request", "->", "input", "(", "$", "this", "->", "usernameField", ")", ")", ";", "foreach", "(", "$", "this", "->", "otherFields", "as", "$", "of", ")", "{", "$", "of", "=", "trim", "(", "$", "of", ")", ";", "$", "this", "->", "filters", "[", "$", "of", "]", "=", "$", "request", "->", "input", "(", "$", "of", ")", ";", "}", "$", "string", "=", "''", ";", "$", "multiple", "=", "0", ";", "foreach", "(", "$", "this", "->", "filters", "as", "$", "f", "=>", "$", "v", ")", "{", "if", "(", "!", "empty", "(", "$", "string", ")", ")", "{", "$", "string", ".=", "\" AND \"", ";", "$", "multiple", "=", "1", ";", "}", "if", "(", "is_bool", "(", "$", "v", ")", "||", "'true'", "===", "strtolower", "(", "$", "v", ")", "||", "'false'", "===", "strtolower", "(", "$", "v", ")", ")", "{", "if", "(", "$", "v", "===", "true", "||", "$", "v", "===", "'true'", ")", "{", "$", "v", "=", "1", ";", "}", "else", "{", "$", "v", "=", "0", ";", "}", "}", "$", "string", ".=", "\"($f=$v)\"", ";", "}", "return", "(", "$", "multiple", ")", "?", "\"(\"", ".", "$", "string", ".", "\")\"", ":", "$", "string", ";", "}" ]
Generates filter string based on request parameter and configured options @param \DreamFactory\Core\Contracts\ServiceRequestInterface $request @return string
[ "Generates", "filter", "string", "based", "on", "request", "parameter", "and", "configured", "options" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L97-L123
30,511
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.getRemoteUser
protected function getRemoteUser($filter) { $resource = '_table/' . $this->table; $response = ServiceManager::handleRequest( $this->service, Verbs::GET, $resource, ['filter' => $filter], [], null, null, false ); $status = $response->getStatusCode(); if ($status === 200) { $result = ResourcesWrapper::unwrapResources($response->getContent()); if (!Arr::isAssoc($result)) { if (count($result) > 1) { throw new InternalServerErrorException('An unexpected error occurred. More than one user found with your credentials!'); } if (count($result) === 0) { throw new UnauthorizedException('Invalid user information provided.'); } $result = $result[0]; } return $result; } else { $message = 'DB service responded with code ' . $status; if ($status >= 400) { $content = $response->getContent(); $message = array_get($content, 'error.message', $message); } else { $status = 500; } throw new RestException($status, $message); } }
php
protected function getRemoteUser($filter) { $resource = '_table/' . $this->table; $response = ServiceManager::handleRequest( $this->service, Verbs::GET, $resource, ['filter' => $filter], [], null, null, false ); $status = $response->getStatusCode(); if ($status === 200) { $result = ResourcesWrapper::unwrapResources($response->getContent()); if (!Arr::isAssoc($result)) { if (count($result) > 1) { throw new InternalServerErrorException('An unexpected error occurred. More than one user found with your credentials!'); } if (count($result) === 0) { throw new UnauthorizedException('Invalid user information provided.'); } $result = $result[0]; } return $result; } else { $message = 'DB service responded with code ' . $status; if ($status >= 400) { $content = $response->getContent(); $message = array_get($content, 'error.message', $message); } else { $status = 500; } throw new RestException($status, $message); } }
[ "protected", "function", "getRemoteUser", "(", "$", "filter", ")", "{", "$", "resource", "=", "'_table/'", ".", "$", "this", "->", "table", ";", "$", "response", "=", "ServiceManager", "::", "handleRequest", "(", "$", "this", "->", "service", ",", "Verbs", "::", "GET", ",", "$", "resource", ",", "[", "'filter'", "=>", "$", "filter", "]", ",", "[", "]", ",", "null", ",", "null", ",", "false", ")", ";", "$", "status", "=", "$", "response", "->", "getStatusCode", "(", ")", ";", "if", "(", "$", "status", "===", "200", ")", "{", "$", "result", "=", "ResourcesWrapper", "::", "unwrapResources", "(", "$", "response", "->", "getContent", "(", ")", ")", ";", "if", "(", "!", "Arr", "::", "isAssoc", "(", "$", "result", ")", ")", "{", "if", "(", "count", "(", "$", "result", ")", ">", "1", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'An unexpected error occurred. More than one user found with your credentials!'", ")", ";", "}", "if", "(", "count", "(", "$", "result", ")", "===", "0", ")", "{", "throw", "new", "UnauthorizedException", "(", "'Invalid user information provided.'", ")", ";", "}", "$", "result", "=", "$", "result", "[", "0", "]", ";", "}", "return", "$", "result", ";", "}", "else", "{", "$", "message", "=", "'DB service responded with code '", ".", "$", "status", ";", "if", "(", "$", "status", ">=", "400", ")", "{", "$", "content", "=", "$", "response", "->", "getContent", "(", ")", ";", "$", "message", "=", "array_get", "(", "$", "content", ",", "'error.message'", ",", "$", "message", ")", ";", "}", "else", "{", "$", "status", "=", "500", ";", "}", "throw", "new", "RestException", "(", "$", "status", ",", "$", "message", ")", ";", "}", "}" ]
Retrieves the user from remote source @param $filter @return mixed @throws \DreamFactory\Core\Exceptions\BadRequestException @throws \DreamFactory\Core\Exceptions\InternalServerErrorException @throws \DreamFactory\Core\Exceptions\RestException @throws \DreamFactory\Core\Exceptions\UnauthorizedException @throws \Exception
[ "Retrieves", "the", "user", "from", "remote", "source" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L137-L172
30,512
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.verifyPassword
protected function verifyPassword($password, $hash) { // Check plain password. if($password === $hash){ return true; } // Check md5 hash if (md5($password) === $hash) { return true; } // Check bcrypt hash return password_verify($password, $hash); }
php
protected function verifyPassword($password, $hash) { // Check plain password. if($password === $hash){ return true; } // Check md5 hash if (md5($password) === $hash) { return true; } // Check bcrypt hash return password_verify($password, $hash); }
[ "protected", "function", "verifyPassword", "(", "$", "password", ",", "$", "hash", ")", "{", "// Check plain password.", "if", "(", "$", "password", "===", "$", "hash", ")", "{", "return", "true", ";", "}", "// Check md5 hash", "if", "(", "md5", "(", "$", "password", ")", "===", "$", "hash", ")", "{", "return", "true", ";", "}", "// Check bcrypt hash", "return", "password_verify", "(", "$", "password", ",", "$", "hash", ")", ";", "}" ]
Verifies the password hash @param $password @param $hash @return bool
[ "Verifies", "the", "password", "hash" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L182-L194
30,513
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.createShadowUser
protected function createShadowUser($userInfo) { $email = filter_var(array_get($userInfo, $this->emailField), FILTER_SANITIZE_EMAIL); if (empty($email)) { throw new InternalServerErrorException( 'Failed to retrieve alternate user\'s email address using field ' . $this->emailField . '.' ); } $dfUser = User::whereEmail($email)->first(); if (empty($dfUser)) { $altUser = [ 'email' => $email, 'first_name' => 'Alternate', 'last_name' => 'User', 'name' => 'Alternate User' ]; $dfUser = User::create($altUser); } return $dfUser; }
php
protected function createShadowUser($userInfo) { $email = filter_var(array_get($userInfo, $this->emailField), FILTER_SANITIZE_EMAIL); if (empty($email)) { throw new InternalServerErrorException( 'Failed to retrieve alternate user\'s email address using field ' . $this->emailField . '.' ); } $dfUser = User::whereEmail($email)->first(); if (empty($dfUser)) { $altUser = [ 'email' => $email, 'first_name' => 'Alternate', 'last_name' => 'User', 'name' => 'Alternate User' ]; $dfUser = User::create($altUser); } return $dfUser; }
[ "protected", "function", "createShadowUser", "(", "$", "userInfo", ")", "{", "$", "email", "=", "filter_var", "(", "array_get", "(", "$", "userInfo", ",", "$", "this", "->", "emailField", ")", ",", "FILTER_SANITIZE_EMAIL", ")", ";", "if", "(", "empty", "(", "$", "email", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'Failed to retrieve alternate user\\'s email address using field '", ".", "$", "this", "->", "emailField", ".", "'.'", ")", ";", "}", "$", "dfUser", "=", "User", "::", "whereEmail", "(", "$", "email", ")", "->", "first", "(", ")", ";", "if", "(", "empty", "(", "$", "dfUser", ")", ")", "{", "$", "altUser", "=", "[", "'email'", "=>", "$", "email", ",", "'first_name'", "=>", "'Alternate'", ",", "'last_name'", "=>", "'User'", ",", "'name'", "=>", "'Alternate User'", "]", ";", "$", "dfUser", "=", "User", "::", "create", "(", "$", "altUser", ")", ";", "}", "return", "$", "dfUser", ";", "}" ]
Creates the shadow user if needed @param array $userInfo @return \DreamFactory\Core\Models\BaseModel|\Illuminate\Database\Eloquent\Model|null|static @throws \DreamFactory\Core\Exceptions\InternalServerErrorException @throws \Exception
[ "Creates", "the", "shadow", "user", "if", "needed" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L205-L226
30,514
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.setService
public function setService($id) { $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT); if (empty($id)) { throw new InternalServerErrorException('No service id provided.'); } if (empty($this->service = ServiceManager::getServiceNameById($id))) { throw new InternalServerErrorException('No alternate db service found with id ' . $id); } }
php
public function setService($id) { $id = filter_var($id, FILTER_SANITIZE_NUMBER_INT); if (empty($id)) { throw new InternalServerErrorException('No service id provided.'); } if (empty($this->service = ServiceManager::getServiceNameById($id))) { throw new InternalServerErrorException('No alternate db service found with id ' . $id); } }
[ "public", "function", "setService", "(", "$", "id", ")", "{", "$", "id", "=", "filter_var", "(", "$", "id", ",", "FILTER_SANITIZE_NUMBER_INT", ")", ";", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No service id provided.'", ")", ";", "}", "if", "(", "empty", "(", "$", "this", "->", "service", "=", "ServiceManager", "::", "getServiceNameById", "(", "$", "id", ")", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No alternate db service found with id '", ".", "$", "id", ")", ";", "}", "}" ]
Sets the db service name @param integer $id @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "Sets", "the", "db", "service", "name" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L235-L245
30,515
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.setTable
public function setTable($table) { $table = trim(filter_var($table, FILTER_SANITIZE_STRING)); if (empty($table)) { throw new InternalServerErrorException('No table name provided.'); } $this->table = $table; }
php
public function setTable($table) { $table = trim(filter_var($table, FILTER_SANITIZE_STRING)); if (empty($table)) { throw new InternalServerErrorException('No table name provided.'); } $this->table = $table; }
[ "public", "function", "setTable", "(", "$", "table", ")", "{", "$", "table", "=", "trim", "(", "filter_var", "(", "$", "table", ",", "FILTER_SANITIZE_STRING", ")", ")", ";", "if", "(", "empty", "(", "$", "table", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No table name provided.'", ")", ";", "}", "$", "this", "->", "table", "=", "$", "table", ";", "}" ]
Sets the table name @param string $table @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "Sets", "the", "table", "name" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L254-L262
30,516
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.setUsernameField
public function setUsernameField($uf) { $uf = trim(filter_var($uf, FILTER_SANITIZE_STRING)); if (empty($uf)) { throw new InternalServerErrorException('No username field provided.'); } $this->usernameField = $uf; }
php
public function setUsernameField($uf) { $uf = trim(filter_var($uf, FILTER_SANITIZE_STRING)); if (empty($uf)) { throw new InternalServerErrorException('No username field provided.'); } $this->usernameField = $uf; }
[ "public", "function", "setUsernameField", "(", "$", "uf", ")", "{", "$", "uf", "=", "trim", "(", "filter_var", "(", "$", "uf", ",", "FILTER_SANITIZE_STRING", ")", ")", ";", "if", "(", "empty", "(", "$", "uf", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No username field provided.'", ")", ";", "}", "$", "this", "->", "usernameField", "=", "$", "uf", ";", "}" ]
Sets the username field @param string $uf @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "Sets", "the", "username", "field" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L271-L279
30,517
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.setPasswordField
public function setPasswordField($pf) { $pf = trim(filter_var($pf, FILTER_SANITIZE_STRING)); if (empty($pf)) { throw new InternalServerErrorException('No password field provided.'); } $this->passwordField = $pf; }
php
public function setPasswordField($pf) { $pf = trim(filter_var($pf, FILTER_SANITIZE_STRING)); if (empty($pf)) { throw new InternalServerErrorException('No password field provided.'); } $this->passwordField = $pf; }
[ "public", "function", "setPasswordField", "(", "$", "pf", ")", "{", "$", "pf", "=", "trim", "(", "filter_var", "(", "$", "pf", ",", "FILTER_SANITIZE_STRING", ")", ")", ";", "if", "(", "empty", "(", "$", "pf", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No password field provided.'", ")", ";", "}", "$", "this", "->", "passwordField", "=", "$", "pf", ";", "}" ]
Sets the password field @param string $pf @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "Sets", "the", "password", "field" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L288-L296
30,518
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.setEmailField
public function setEmailField($ef) { $ef = trim(filter_var($ef, FILTER_SANITIZE_STRING)); if (empty($ef)) { throw new InternalServerErrorException('No email field provided.'); } $this->emailField = $ef; }
php
public function setEmailField($ef) { $ef = trim(filter_var($ef, FILTER_SANITIZE_STRING)); if (empty($ef)) { throw new InternalServerErrorException('No email field provided.'); } $this->emailField = $ef; }
[ "public", "function", "setEmailField", "(", "$", "ef", ")", "{", "$", "ef", "=", "trim", "(", "filter_var", "(", "$", "ef", ",", "FILTER_SANITIZE_STRING", ")", ")", ";", "if", "(", "empty", "(", "$", "ef", ")", ")", "{", "throw", "new", "InternalServerErrorException", "(", "'No email field provided.'", ")", ";", "}", "$", "this", "->", "emailField", "=", "$", "ef", ";", "}" ]
Sets the email field @param string $ef @throws \DreamFactory\Core\Exceptions\InternalServerErrorException
[ "Sets", "the", "email", "field" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L305-L313
30,519
dreamfactorysoftware/df-user
src/Components/AlternateAuth.php
AlternateAuth.parseFilters
protected function parseFilters($filters) { $parsed = []; if (!empty($filters) && is_string($filters)) { $filters = trim($filters); if (!empty($filters)) { $filterArray = array_filter(explode(',', $filters), function ($value){ return trim($value); }); foreach ($filterArray as $filter) { list($field, $value) = explode('=', $filter); $field = trim($field); $value = trim($value); if (!empty($field)) { $parsed[$field] = $value; } } } } return $parsed; }
php
protected function parseFilters($filters) { $parsed = []; if (!empty($filters) && is_string($filters)) { $filters = trim($filters); if (!empty($filters)) { $filterArray = array_filter(explode(',', $filters), function ($value){ return trim($value); }); foreach ($filterArray as $filter) { list($field, $value) = explode('=', $filter); $field = trim($field); $value = trim($value); if (!empty($field)) { $parsed[$field] = $value; } } } } return $parsed; }
[ "protected", "function", "parseFilters", "(", "$", "filters", ")", "{", "$", "parsed", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "filters", ")", "&&", "is_string", "(", "$", "filters", ")", ")", "{", "$", "filters", "=", "trim", "(", "$", "filters", ")", ";", "if", "(", "!", "empty", "(", "$", "filters", ")", ")", "{", "$", "filterArray", "=", "array_filter", "(", "explode", "(", "','", ",", "$", "filters", ")", ",", "function", "(", "$", "value", ")", "{", "return", "trim", "(", "$", "value", ")", ";", "}", ")", ";", "foreach", "(", "$", "filterArray", "as", "$", "filter", ")", "{", "list", "(", "$", "field", ",", "$", "value", ")", "=", "explode", "(", "'='", ",", "$", "filter", ")", ";", "$", "field", "=", "trim", "(", "$", "field", ")", ";", "$", "value", "=", "trim", "(", "$", "value", ")", ";", "if", "(", "!", "empty", "(", "$", "field", ")", ")", "{", "$", "parsed", "[", "$", "field", "]", "=", "$", "value", ";", "}", "}", "}", "}", "return", "$", "parsed", ";", "}" ]
Parses filter string @param string $filters @return array
[ "Parses", "filter", "string" ]
06747c83f03d51693d212d948dd5d49f098192ca
https://github.com/dreamfactorysoftware/df-user/blob/06747c83f03d51693d212d948dd5d49f098192ca/src/Components/AlternateAuth.php#L356-L378
30,520
ICEPAY/deprecated-i
src/icepay_api_pbm.php
Icepay_Api_Pbm.createLink
public function createLink(Icepay_Pbm_Object $pbmObject) { $this->validateSettings(); $linkObj = new StdClass(); $linkObj->merchantid = $this->getMerchantID(); $linkObj->timestamp = $this->getTimestamp(); $linkObj->amount = $pbmObject->getAmount(); $linkObj->currency = $pbmObject->getCurrency(); $linkObj->language = $pbmObject->getLanguage(); $linkObj->orderid = $pbmObject->getOrderID(); $linkObj->country = $pbmObject->getCountry(); $linkObj->description = $pbmObject->getDescription(); $linkObj->reference = $pbmObject->getReference(); $linkObj->checksum = $this->generateChecksum($linkObj); $result = $this->generateURL($linkObj); return json_decode($result); }
php
public function createLink(Icepay_Pbm_Object $pbmObject) { $this->validateSettings(); $linkObj = new StdClass(); $linkObj->merchantid = $this->getMerchantID(); $linkObj->timestamp = $this->getTimestamp(); $linkObj->amount = $pbmObject->getAmount(); $linkObj->currency = $pbmObject->getCurrency(); $linkObj->language = $pbmObject->getLanguage(); $linkObj->orderid = $pbmObject->getOrderID(); $linkObj->country = $pbmObject->getCountry(); $linkObj->description = $pbmObject->getDescription(); $linkObj->reference = $pbmObject->getReference(); $linkObj->checksum = $this->generateChecksum($linkObj); $result = $this->generateURL($linkObj); return json_decode($result); }
[ "public", "function", "createLink", "(", "Icepay_Pbm_Object", "$", "pbmObject", ")", "{", "$", "this", "->", "validateSettings", "(", ")", ";", "$", "linkObj", "=", "new", "StdClass", "(", ")", ";", "$", "linkObj", "->", "merchantid", "=", "$", "this", "->", "getMerchantID", "(", ")", ";", "$", "linkObj", "->", "timestamp", "=", "$", "this", "->", "getTimestamp", "(", ")", ";", "$", "linkObj", "->", "amount", "=", "$", "pbmObject", "->", "getAmount", "(", ")", ";", "$", "linkObj", "->", "currency", "=", "$", "pbmObject", "->", "getCurrency", "(", ")", ";", "$", "linkObj", "->", "language", "=", "$", "pbmObject", "->", "getLanguage", "(", ")", ";", "$", "linkObj", "->", "orderid", "=", "$", "pbmObject", "->", "getOrderID", "(", ")", ";", "$", "linkObj", "->", "country", "=", "$", "pbmObject", "->", "getCountry", "(", ")", ";", "$", "linkObj", "->", "description", "=", "$", "pbmObject", "->", "getDescription", "(", ")", ";", "$", "linkObj", "->", "reference", "=", "$", "pbmObject", "->", "getReference", "(", ")", ";", "$", "linkObj", "->", "checksum", "=", "$", "this", "->", "generateChecksum", "(", "$", "linkObj", ")", ";", "$", "result", "=", "$", "this", "->", "generateURL", "(", "$", "linkObj", ")", ";", "return", "json_decode", "(", "$", "result", ")", ";", "}" ]
Create a PBM link @since 1.0.0 @param Icepay_Pbm_Object $pbmObject @return string
[ "Create", "a", "PBM", "link" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_pbm.php#L78-L97
30,521
ICEPAY/deprecated-i
src/icepay_api_pbm.php
Icepay_Api_Pbm.generateURL
private function generateURL($parameters) { $ch = curl_init(); $parameters = http_build_query($parameters); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); $result = curl_exec($ch); curl_close($ch); return $result; }
php
private function generateURL($parameters) { $ch = curl_init(); $parameters = http_build_query($parameters); curl_setopt($ch, CURLOPT_URL, $this->url); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $parameters); $result = curl_exec($ch); curl_close($ch); return $result; }
[ "private", "function", "generateURL", "(", "$", "parameters", ")", "{", "$", "ch", "=", "curl_init", "(", ")", ";", "$", "parameters", "=", "http_build_query", "(", "$", "parameters", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_URL", ",", "$", "this", "->", "url", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POST", ",", "true", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_RETURNTRANSFER", ",", "1", ")", ";", "curl_setopt", "(", "$", "ch", ",", "CURLOPT_POSTFIELDS", ",", "$", "parameters", ")", ";", "$", "result", "=", "curl_exec", "(", "$", "ch", ")", ";", "curl_close", "(", "$", "ch", ")", ";", "return", "$", "result", ";", "}" ]
Calls PBM platform and returns generated PBM link @since 1.0.0 @param object $parameters @return string
[ "Calls", "PBM", "platform", "and", "returns", "generated", "PBM", "link" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_pbm.php#L106-L122
30,522
ICEPAY/deprecated-i
src/icepay_api_pbm.php
Icepay_Api_Pbm.generateChecksum
private function generateChecksum($linkObj) { $arr = (array)$linkObj; $arr[] = $this->getSecretCode(); return sha1(implode("|", $arr)); }
php
private function generateChecksum($linkObj) { $arr = (array)$linkObj; $arr[] = $this->getSecretCode(); return sha1(implode("|", $arr)); }
[ "private", "function", "generateChecksum", "(", "$", "linkObj", ")", "{", "$", "arr", "=", "(", "array", ")", "$", "linkObj", ";", "$", "arr", "[", "]", "=", "$", "this", "->", "getSecretCode", "(", ")", ";", "return", "sha1", "(", "implode", "(", "\"|\"", ",", "$", "arr", ")", ")", ";", "}" ]
Generates PBM checksum @since 1.0.0 @param obj $linkObj @return string
[ "Generates", "PBM", "checksum" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_pbm.php#L131-L137
30,523
ICEPAY/deprecated-i
src/icepay_api_pbm.php
Icepay_Api_Pbm.validateSettings
private function validateSettings() { // Validate Merchant ID if (!Icepay_Parameter_Validation::merchantID($this->getMerchantID())) throw new Exception('Merchant ID not set, use the setMerchantID() method', 1001); // Validate SecretCode if (!Icepay_Parameter_Validation::secretCode($this->getSecretCode())) throw new Exception('Secretcode ID not set, use the setSecretCode() method', 1002); }
php
private function validateSettings() { // Validate Merchant ID if (!Icepay_Parameter_Validation::merchantID($this->getMerchantID())) throw new Exception('Merchant ID not set, use the setMerchantID() method', 1001); // Validate SecretCode if (!Icepay_Parameter_Validation::secretCode($this->getSecretCode())) throw new Exception('Secretcode ID not set, use the setSecretCode() method', 1002); }
[ "private", "function", "validateSettings", "(", ")", "{", "// Validate Merchant ID", "if", "(", "!", "Icepay_Parameter_Validation", "::", "merchantID", "(", "$", "this", "->", "getMerchantID", "(", ")", ")", ")", "throw", "new", "Exception", "(", "'Merchant ID not set, use the setMerchantID() method'", ",", "1001", ")", ";", "// Validate SecretCode", "if", "(", "!", "Icepay_Parameter_Validation", "::", "secretCode", "(", "$", "this", "->", "getSecretCode", "(", ")", ")", ")", "throw", "new", "Exception", "(", "'Secretcode ID not set, use the setSecretCode() method'", ",", "1002", ")", ";", "}" ]
Validate the merchant settings @since 1.0.0 @throws Exception
[ "Validate", "the", "merchant", "settings" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_pbm.php#L145-L154
30,524
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyBase.php
CompletorStrategyBase.getName
public function getName() { $nsClass = get_class($this); $nsClass = substr($nsClass, strrpos($nsClass, '\\') + 1); return $nsClass; }
php
public function getName() { $nsClass = get_class($this); $nsClass = substr($nsClass, strrpos($nsClass, '\\') + 1); return $nsClass; }
[ "public", "function", "getName", "(", ")", "{", "$", "nsClass", "=", "get_class", "(", "$", "this", ")", ";", "$", "nsClass", "=", "substr", "(", "$", "nsClass", ",", "strrpos", "(", "$", "nsClass", ",", "'\\\\'", ")", "+", "1", ")", ";", "return", "$", "nsClass", ";", "}" ]
Returns the non namespaced name of the current strategy. @return string
[ "Returns", "the", "non", "namespaced", "name", "of", "the", "current", "strategy", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyBase.php#L134-L139
30,525
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyBase.php
CompletorStrategyBase.initAmounts
protected function initAmounts() { $invoicePart = &$this->invoice[Tag::Customer][Tag::Invoice]; $this->vatAmount = isset($invoicePart[Meta::InvoiceVatAmount]) ? $invoicePart[Meta::InvoiceVatAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceAmount]; $this->invoiceAmount = isset($invoicePart[Meta::InvoiceAmount]) ? $invoicePart[Meta::InvoiceAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceVatAmount]; // The vat amount to divide over the non completed lines is the total vat // amount of the invoice minus all known vat amounts per line. $this->vat2Divide = (float) $this->vatAmount; foreach ($invoicePart[Tag::Line] as $line) { if ($line[Meta::VatRateSource] !== Creator::VatRateSource_Strategy) { // Deduct the vat amount from this line: if set, deduct it directly, // otherwise calculate the vat amount using the vat rate and unit price. if (isset($line[Meta::VatAmount])) { $this->vat2Divide -= $line[Meta::VatAmount] * $line[Tag::Quantity]; } else { $this->vat2Divide -= ($line[Tag::VatRate] / 100.0) * $line[Tag::UnitPrice] * $line[Tag::Quantity]; } } } }
php
protected function initAmounts() { $invoicePart = &$this->invoice[Tag::Customer][Tag::Invoice]; $this->vatAmount = isset($invoicePart[Meta::InvoiceVatAmount]) ? $invoicePart[Meta::InvoiceVatAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceAmount]; $this->invoiceAmount = isset($invoicePart[Meta::InvoiceAmount]) ? $invoicePart[Meta::InvoiceAmount] : $invoicePart[Meta::InvoiceAmountInc] - $invoicePart[Meta::InvoiceVatAmount]; // The vat amount to divide over the non completed lines is the total vat // amount of the invoice minus all known vat amounts per line. $this->vat2Divide = (float) $this->vatAmount; foreach ($invoicePart[Tag::Line] as $line) { if ($line[Meta::VatRateSource] !== Creator::VatRateSource_Strategy) { // Deduct the vat amount from this line: if set, deduct it directly, // otherwise calculate the vat amount using the vat rate and unit price. if (isset($line[Meta::VatAmount])) { $this->vat2Divide -= $line[Meta::VatAmount] * $line[Tag::Quantity]; } else { $this->vat2Divide -= ($line[Tag::VatRate] / 100.0) * $line[Tag::UnitPrice] * $line[Tag::Quantity]; } } } }
[ "protected", "function", "initAmounts", "(", ")", "{", "$", "invoicePart", "=", "&", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", ";", "$", "this", "->", "vatAmount", "=", "isset", "(", "$", "invoicePart", "[", "Meta", "::", "InvoiceVatAmount", "]", ")", "?", "$", "invoicePart", "[", "Meta", "::", "InvoiceVatAmount", "]", ":", "$", "invoicePart", "[", "Meta", "::", "InvoiceAmountInc", "]", "-", "$", "invoicePart", "[", "Meta", "::", "InvoiceAmount", "]", ";", "$", "this", "->", "invoiceAmount", "=", "isset", "(", "$", "invoicePart", "[", "Meta", "::", "InvoiceAmount", "]", ")", "?", "$", "invoicePart", "[", "Meta", "::", "InvoiceAmount", "]", ":", "$", "invoicePart", "[", "Meta", "::", "InvoiceAmountInc", "]", "-", "$", "invoicePart", "[", "Meta", "::", "InvoiceVatAmount", "]", ";", "// The vat amount to divide over the non completed lines is the total vat", "// amount of the invoice minus all known vat amounts per line.", "$", "this", "->", "vat2Divide", "=", "(", "float", ")", "$", "this", "->", "vatAmount", ";", "foreach", "(", "$", "invoicePart", "[", "Tag", "::", "Line", "]", "as", "$", "line", ")", "{", "if", "(", "$", "line", "[", "Meta", "::", "VatRateSource", "]", "!==", "Creator", "::", "VatRateSource_Strategy", ")", "{", "// Deduct the vat amount from this line: if set, deduct it directly,", "// otherwise calculate the vat amount using the vat rate and unit price.", "if", "(", "isset", "(", "$", "line", "[", "Meta", "::", "VatAmount", "]", ")", ")", "{", "$", "this", "->", "vat2Divide", "-=", "$", "line", "[", "Meta", "::", "VatAmount", "]", "*", "$", "line", "[", "Tag", "::", "Quantity", "]", ";", "}", "else", "{", "$", "this", "->", "vat2Divide", "-=", "(", "$", "line", "[", "Tag", "::", "VatRate", "]", "/", "100.0", ")", "*", "$", "line", "[", "Tag", "::", "UnitPrice", "]", "*", "$", "line", "[", "Tag", "::", "Quantity", "]", ";", "}", "}", "}", "}" ]
Initializes the amount properties. to be able to calculate the amounts, at least 2 of the 3 meta amounts meta-invoice-vatamount, meta-invoice-amountinc, or meta-invoice-amount must be known.
[ "Initializes", "the", "amount", "properties", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyBase.php#L199-L219
30,526
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyBase.php
CompletorStrategyBase.getVatBreakDownMinRate
protected function getVatBreakDownMinRate() { $result = array(Tag::VatRate => PHP_INT_MAX); foreach ($this->vatBreakdown as $breakDown) { if ($breakDown[Tag::VatRate] < $result[Tag::VatRate]) { $result = $breakDown; } } return $result; }
php
protected function getVatBreakDownMinRate() { $result = array(Tag::VatRate => PHP_INT_MAX); foreach ($this->vatBreakdown as $breakDown) { if ($breakDown[Tag::VatRate] < $result[Tag::VatRate]) { $result = $breakDown; } } return $result; }
[ "protected", "function", "getVatBreakDownMinRate", "(", ")", "{", "$", "result", "=", "array", "(", "Tag", "::", "VatRate", "=>", "PHP_INT_MAX", ")", ";", "foreach", "(", "$", "this", "->", "vatBreakdown", "as", "$", "breakDown", ")", "{", "if", "(", "$", "breakDown", "[", "Tag", "::", "VatRate", "]", "<", "$", "result", "[", "Tag", "::", "VatRate", "]", ")", "{", "$", "result", "=", "$", "breakDown", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns the minimum vat rate on the invoice. @return array A vat rate overview: array with keys vatrate, vatamount, amount, count.
[ "Returns", "the", "minimum", "vat", "rate", "on", "the", "invoice", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyBase.php#L272-L281
30,527
SIELOnline/libAcumulus
src/Invoice/CompletorStrategyBase.php
CompletorStrategyBase.apply
public function apply() { $this->replacingLines = array(); $this->init(); if ($this->checkPreconditions()) { return $this->execute(); } else { if (!empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed])) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= ', '; } else { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] = ''; } $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= $this->getName(); return false; } }
php
public function apply() { $this->replacingLines = array(); $this->init(); if ($this->checkPreconditions()) { return $this->execute(); } else { if (!empty($this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed])) { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= ', '; } else { $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] = ''; } $this->invoice[Tag::Customer][Tag::Invoice][Meta::CompletorStrategyPreconditionFailed] .= $this->getName(); return false; } }
[ "public", "function", "apply", "(", ")", "{", "$", "this", "->", "replacingLines", "=", "array", "(", ")", ";", "$", "this", "->", "init", "(", ")", ";", "if", "(", "$", "this", "->", "checkPreconditions", "(", ")", ")", "{", "return", "$", "this", "->", "execute", "(", ")", ";", "}", "else", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "CompletorStrategyPreconditionFailed", "]", ")", ")", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "CompletorStrategyPreconditionFailed", "]", ".=", "', '", ";", "}", "else", "{", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "CompletorStrategyPreconditionFailed", "]", "=", "''", ";", "}", "$", "this", "->", "invoice", "[", "Tag", "::", "Customer", "]", "[", "Tag", "::", "Invoice", "]", "[", "Meta", "::", "CompletorStrategyPreconditionFailed", "]", ".=", "$", "this", "->", "getName", "(", ")", ";", "return", "false", ";", "}", "}" ]
Applies the strategy to see if it results in a valid solution. @return bool Success.
[ "Applies", "the", "strategy", "to", "see", "if", "it", "results", "in", "a", "valid", "solution", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Invoice/CompletorStrategyBase.php#L323-L338
30,528
SIELOnline/libAcumulus
src/Shop/BatchForm.php
BatchForm.getInvoiceSourceReferenceList
protected function getInvoiceSourceReferenceList(array $invoiceSources) { $result = array(); foreach ($invoiceSources as $invoiceSource) { $result[] = $invoiceSource->getReference(); } return '{' . implode(',', $result) . '}'; }
php
protected function getInvoiceSourceReferenceList(array $invoiceSources) { $result = array(); foreach ($invoiceSources as $invoiceSource) { $result[] = $invoiceSource->getReference(); } return '{' . implode(',', $result) . '}'; }
[ "protected", "function", "getInvoiceSourceReferenceList", "(", "array", "$", "invoiceSources", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "invoiceSources", "as", "$", "invoiceSource", ")", "{", "$", "result", "[", "]", "=", "$", "invoiceSource", "->", "getReference", "(", ")", ";", "}", "return", "'{'", ".", "implode", "(", "','", ",", "$", "result", ")", ".", "'}'", ";", "}" ]
Returns a formatted string with the list of ids of the given sources. @param \Siel\Acumulus\Invoice\Source[] $invoiceSources @return string A loggable (formatted) string with a list of ids of the sources.
[ "Returns", "a", "formatted", "string", "with", "the", "list", "of", "ids", "of", "the", "given", "sources", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/BatchForm.php#L303-L310
30,529
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.getSourcesByIdsOrSources
public function getSourcesByIdsOrSources($invoiceSourceType, array $idsOrSources) { $results = array(); foreach ($idsOrSources as $sourceId) { $results[] = $this->getSourceByIdOrSource($invoiceSourceType, $sourceId); } return $results; }
php
public function getSourcesByIdsOrSources($invoiceSourceType, array $idsOrSources) { $results = array(); foreach ($idsOrSources as $sourceId) { $results[] = $this->getSourceByIdOrSource($invoiceSourceType, $sourceId); } return $results; }
[ "public", "function", "getSourcesByIdsOrSources", "(", "$", "invoiceSourceType", ",", "array", "$", "idsOrSources", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "idsOrSources", "as", "$", "sourceId", ")", "{", "$", "results", "[", "]", "=", "$", "this", "->", "getSourceByIdOrSource", "(", "$", "invoiceSourceType", ",", "$", "sourceId", ")", ";", "}", "return", "$", "results", ";", "}" ]
Creates a set of Invoice Sources given their ids or shop specific sources. @param string $invoiceSourceType @param array $idsOrSources An array with shop specific orders or credit notes or just their ids. @return \Siel\Acumulus\Invoice\Source[] A non keyed array with invoice Sources.
[ "Creates", "a", "set", "of", "Invoice", "Sources", "given", "their", "ids", "or", "shop", "specific", "sources", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L228-L235
30,530
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.sendMultiple
public function sendMultiple(array $invoiceSources, $forceSend, $dryRun, array &$log) { $this->getTranslator()->add(new ResultTranslations()); $errorLogged = false; $success = true; $time_limit = ini_get('max_execution_time'); foreach ($invoiceSources as $invoiceSource) { // Try to keep the script running, but note that other systems // involved, like the (Apache) web server, may have their own // time-out. Use @ to prevent messages like "Warning: // set_time_limit(): Cannot set max execution time limit due to // system policy in ...". if (!@set_time_limit($time_limit) && !$errorLogged) { $this->getLog()->warning('InvoiceManager::sendMultiple(): could not set time limit.'); $errorLogged = true; } $result = $this->getInvoiceResult('InvoiceManager::sendMultiple()'); $result = $this->createAndSend($invoiceSource, $result, $forceSend, $dryRun); $success = $success && !$result->hasError(); $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); $log[$invoiceSource->getId()] = $this->getSendResultLogText($invoiceSource, $result,Result::AddReqResp_Never); } return $success; }
php
public function sendMultiple(array $invoiceSources, $forceSend, $dryRun, array &$log) { $this->getTranslator()->add(new ResultTranslations()); $errorLogged = false; $success = true; $time_limit = ini_get('max_execution_time'); foreach ($invoiceSources as $invoiceSource) { // Try to keep the script running, but note that other systems // involved, like the (Apache) web server, may have their own // time-out. Use @ to prevent messages like "Warning: // set_time_limit(): Cannot set max execution time limit due to // system policy in ...". if (!@set_time_limit($time_limit) && !$errorLogged) { $this->getLog()->warning('InvoiceManager::sendMultiple(): could not set time limit.'); $errorLogged = true; } $result = $this->getInvoiceResult('InvoiceManager::sendMultiple()'); $result = $this->createAndSend($invoiceSource, $result, $forceSend, $dryRun); $success = $success && !$result->hasError(); $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); $log[$invoiceSource->getId()] = $this->getSendResultLogText($invoiceSource, $result,Result::AddReqResp_Never); } return $success; }
[ "public", "function", "sendMultiple", "(", "array", "$", "invoiceSources", ",", "$", "forceSend", ",", "$", "dryRun", ",", "array", "&", "$", "log", ")", "{", "$", "this", "->", "getTranslator", "(", ")", "->", "add", "(", "new", "ResultTranslations", "(", ")", ")", ";", "$", "errorLogged", "=", "false", ";", "$", "success", "=", "true", ";", "$", "time_limit", "=", "ini_get", "(", "'max_execution_time'", ")", ";", "foreach", "(", "$", "invoiceSources", "as", "$", "invoiceSource", ")", "{", "// Try to keep the script running, but note that other systems", "// involved, like the (Apache) web server, may have their own", "// time-out. Use @ to prevent messages like \"Warning:", "// set_time_limit(): Cannot set max execution time limit due to", "// system policy in ...\".", "if", "(", "!", "@", "set_time_limit", "(", "$", "time_limit", ")", "&&", "!", "$", "errorLogged", ")", "{", "$", "this", "->", "getLog", "(", ")", "->", "warning", "(", "'InvoiceManager::sendMultiple(): could not set time limit.'", ")", ";", "$", "errorLogged", "=", "true", ";", "}", "$", "result", "=", "$", "this", "->", "getInvoiceResult", "(", "'InvoiceManager::sendMultiple()'", ")", ";", "$", "result", "=", "$", "this", "->", "createAndSend", "(", "$", "invoiceSource", ",", "$", "result", ",", "$", "forceSend", ",", "$", "dryRun", ")", ";", "$", "success", "=", "$", "success", "&&", "!", "$", "result", "->", "hasError", "(", ")", ";", "$", "this", "->", "getLog", "(", ")", "->", "notice", "(", "$", "this", "->", "getSendResultLogText", "(", "$", "invoiceSource", ",", "$", "result", ")", ")", ";", "$", "log", "[", "$", "invoiceSource", "->", "getId", "(", ")", "]", "=", "$", "this", "->", "getSendResultLogText", "(", "$", "invoiceSource", ",", "$", "result", ",", "Result", "::", "AddReqResp_Never", ")", ";", "}", "return", "$", "success", ";", "}" ]
Sends multiple invoices to Acumulus. @param \Siel\Acumulus\Invoice\Source[] $invoiceSources @param bool $forceSend If true, force sending the invoices even if an invoice has already been sent for a given invoice source. @param bool $dryRun If true, return the reason/status only but do not actually send the invoice, nor mail the result or store the result. @param string[] $log @return bool Success.
[ "Sends", "multiple", "invoices", "to", "Acumulus", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L267-L291
30,531
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.send1
public function send1(Source $invoiceSource, $forceSend) { $this->getTranslator()->add(new ResultTranslations()); $result = $this->getInvoiceResult('InvoiceManager::send1()'); $result = $this->createAndSend($invoiceSource, $result, $forceSend); $success = !$result->hasError(); $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $success; }
php
public function send1(Source $invoiceSource, $forceSend) { $this->getTranslator()->add(new ResultTranslations()); $result = $this->getInvoiceResult('InvoiceManager::send1()'); $result = $this->createAndSend($invoiceSource, $result, $forceSend); $success = !$result->hasError(); $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $success; }
[ "public", "function", "send1", "(", "Source", "$", "invoiceSource", ",", "$", "forceSend", ")", "{", "$", "this", "->", "getTranslator", "(", ")", "->", "add", "(", "new", "ResultTranslations", "(", ")", ")", ";", "$", "result", "=", "$", "this", "->", "getInvoiceResult", "(", "'InvoiceManager::send1()'", ")", ";", "$", "result", "=", "$", "this", "->", "createAndSend", "(", "$", "invoiceSource", ",", "$", "result", ",", "$", "forceSend", ")", ";", "$", "success", "=", "!", "$", "result", "->", "hasError", "(", ")", ";", "$", "this", "->", "getLog", "(", ")", "->", "notice", "(", "$", "this", "->", "getSendResultLogText", "(", "$", "invoiceSource", ",", "$", "result", ")", ")", ";", "return", "$", "success", ";", "}" ]
Sends 1 invoice to Acumulus. @param \Siel\Acumulus\Invoice\Source $invoiceSource The invoice source to send the invoice for. @param bool $forceSend If true, force sending the invoices even if an invoice has already been sent for a given invoice source. @return bool Success.
[ "Sends", "1", "invoice", "to", "Acumulus", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L304-L312
30,532
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.sourceStatusChange
public function sourceStatusChange(Source $invoiceSource) { $result = $this->getInvoiceResult('InvoiceManager::sourceStatusChange()'); $status = $invoiceSource->getStatus(); $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($invoiceSource->getType() === Source::Order) { $doSend = in_array($status, $shopEventSettings['triggerOrderStatus']); $arguments = array($status, implode(',', $shopEventSettings['triggerOrderStatus'])); $notSendReason = Result::NotSent_WrongStatus; } else { $doSend = $shopEventSettings['triggerCreditNoteEvent'] === PluginConfig::TriggerCreditNoteEvent_Create; $arguments = array(); $notSendReason = Result::NotSent_TriggerCreditNoteEventNotEnabled; } if ($doSend) { $result = $this->createAndSend($invoiceSource, $result); // Add argument to send status, this will add the current status and // the set of statuses on which to send to the log line. $result->setSendStatus($result->getSendStatus(), $arguments); } else { $result->setSendStatus($notSendReason, $arguments); } $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $result; }
php
public function sourceStatusChange(Source $invoiceSource) { $result = $this->getInvoiceResult('InvoiceManager::sourceStatusChange()'); $status = $invoiceSource->getStatus(); $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($invoiceSource->getType() === Source::Order) { $doSend = in_array($status, $shopEventSettings['triggerOrderStatus']); $arguments = array($status, implode(',', $shopEventSettings['triggerOrderStatus'])); $notSendReason = Result::NotSent_WrongStatus; } else { $doSend = $shopEventSettings['triggerCreditNoteEvent'] === PluginConfig::TriggerCreditNoteEvent_Create; $arguments = array(); $notSendReason = Result::NotSent_TriggerCreditNoteEventNotEnabled; } if ($doSend) { $result = $this->createAndSend($invoiceSource, $result); // Add argument to send status, this will add the current status and // the set of statuses on which to send to the log line. $result->setSendStatus($result->getSendStatus(), $arguments); } else { $result->setSendStatus($notSendReason, $arguments); } $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $result; }
[ "public", "function", "sourceStatusChange", "(", "Source", "$", "invoiceSource", ")", "{", "$", "result", "=", "$", "this", "->", "getInvoiceResult", "(", "'InvoiceManager::sourceStatusChange()'", ")", ";", "$", "status", "=", "$", "invoiceSource", "->", "getStatus", "(", ")", ";", "$", "shopEventSettings", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getShopEventSettings", "(", ")", ";", "if", "(", "$", "invoiceSource", "->", "getType", "(", ")", "===", "Source", "::", "Order", ")", "{", "$", "doSend", "=", "in_array", "(", "$", "status", ",", "$", "shopEventSettings", "[", "'triggerOrderStatus'", "]", ")", ";", "$", "arguments", "=", "array", "(", "$", "status", ",", "implode", "(", "','", ",", "$", "shopEventSettings", "[", "'triggerOrderStatus'", "]", ")", ")", ";", "$", "notSendReason", "=", "Result", "::", "NotSent_WrongStatus", ";", "}", "else", "{", "$", "doSend", "=", "$", "shopEventSettings", "[", "'triggerCreditNoteEvent'", "]", "===", "PluginConfig", "::", "TriggerCreditNoteEvent_Create", ";", "$", "arguments", "=", "array", "(", ")", ";", "$", "notSendReason", "=", "Result", "::", "NotSent_TriggerCreditNoteEventNotEnabled", ";", "}", "if", "(", "$", "doSend", ")", "{", "$", "result", "=", "$", "this", "->", "createAndSend", "(", "$", "invoiceSource", ",", "$", "result", ")", ";", "// Add argument to send status, this will add the current status and", "// the set of statuses on which to send to the log line.", "$", "result", "->", "setSendStatus", "(", "$", "result", "->", "getSendStatus", "(", ")", ",", "$", "arguments", ")", ";", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "$", "notSendReason", ",", "$", "arguments", ")", ";", "}", "$", "this", "->", "getLog", "(", ")", "->", "notice", "(", "$", "this", "->", "getSendResultLogText", "(", "$", "invoiceSource", ",", "$", "result", ")", ")", ";", "return", "$", "result", ";", "}" ]
Processes an invoice source status change event. For now we don't look at credit note statuses, they are always sent. @param \Siel\Acumulus\Invoice\Source $invoiceSource The source whose status has changed. @return \Siel\Acumulus\Invoice\Result The result of sending (or not sending) the invoice.
[ "Processes", "an", "invoice", "source", "status", "change", "event", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L325-L349
30,533
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.invoiceCreate
public function invoiceCreate(Source $invoiceSource) { $result = $this->getInvoiceResult('InvoiceManager::invoiceCreate()'); $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($shopEventSettings['triggerInvoiceEvent'] == PluginConfig::TriggerInvoiceEvent_Create) { $result = $this->createAndSend($invoiceSource, $result); } else { $result->setSendStatus(Result::NotSent_TriggerInvoiceCreateNotEnabled); } $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $result; }
php
public function invoiceCreate(Source $invoiceSource) { $result = $this->getInvoiceResult('InvoiceManager::invoiceCreate()'); $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($shopEventSettings['triggerInvoiceEvent'] == PluginConfig::TriggerInvoiceEvent_Create) { $result = $this->createAndSend($invoiceSource, $result); } else { $result->setSendStatus(Result::NotSent_TriggerInvoiceCreateNotEnabled); } $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $result; }
[ "public", "function", "invoiceCreate", "(", "Source", "$", "invoiceSource", ")", "{", "$", "result", "=", "$", "this", "->", "getInvoiceResult", "(", "'InvoiceManager::invoiceCreate()'", ")", ";", "$", "shopEventSettings", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getShopEventSettings", "(", ")", ";", "if", "(", "$", "shopEventSettings", "[", "'triggerInvoiceEvent'", "]", "==", "PluginConfig", "::", "TriggerInvoiceEvent_Create", ")", "{", "$", "result", "=", "$", "this", "->", "createAndSend", "(", "$", "invoiceSource", ",", "$", "result", ")", ";", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_TriggerInvoiceCreateNotEnabled", ")", ";", "}", "$", "this", "->", "getLog", "(", ")", "->", "notice", "(", "$", "this", "->", "getSendResultLogText", "(", "$", "invoiceSource", ",", "$", "result", ")", ")", ";", "return", "$", "result", ";", "}" ]
Processes an invoice create event. @param \Siel\Acumulus\Invoice\Source $invoiceSource The source for which a shop invoice was created. @return \Siel\Acumulus\Invoice\Result The result of sending (or not sending) the invoice.
[ "Processes", "an", "invoice", "create", "event", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L360-L371
30,534
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.invoiceSend
public function invoiceSend(Source $invoiceSource) { $result = $this->getInvoiceResult('InvoiceManager::invoiceSend()'); $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($shopEventSettings['triggerInvoiceEvent'] == PluginConfig::TriggerInvoiceEvent_Send) { $result = $this->createAndSend($invoiceSource, $result); } else { $result->setSendStatus(Result::NotSent_TriggerInvoiceSentNotEnabled); } $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $result; }
php
public function invoiceSend(Source $invoiceSource) { $result = $this->getInvoiceResult('InvoiceManager::invoiceSend()'); $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($shopEventSettings['triggerInvoiceEvent'] == PluginConfig::TriggerInvoiceEvent_Send) { $result = $this->createAndSend($invoiceSource, $result); } else { $result->setSendStatus(Result::NotSent_TriggerInvoiceSentNotEnabled); } $this->getLog()->notice($this->getSendResultLogText($invoiceSource, $result)); return $result; }
[ "public", "function", "invoiceSend", "(", "Source", "$", "invoiceSource", ")", "{", "$", "result", "=", "$", "this", "->", "getInvoiceResult", "(", "'InvoiceManager::invoiceSend()'", ")", ";", "$", "shopEventSettings", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getShopEventSettings", "(", ")", ";", "if", "(", "$", "shopEventSettings", "[", "'triggerInvoiceEvent'", "]", "==", "PluginConfig", "::", "TriggerInvoiceEvent_Send", ")", "{", "$", "result", "=", "$", "this", "->", "createAndSend", "(", "$", "invoiceSource", ",", "$", "result", ")", ";", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_TriggerInvoiceSentNotEnabled", ")", ";", "}", "$", "this", "->", "getLog", "(", ")", "->", "notice", "(", "$", "this", "->", "getSendResultLogText", "(", "$", "invoiceSource", ",", "$", "result", ")", ")", ";", "return", "$", "result", ";", "}" ]
Processes a shop invoice send event. This is the invoice created by the shop and that is now sent/mailed to the customer. @param \Siel\Acumulus\Invoice\Source $invoiceSource The source for which a shop invoice was created. @return \Siel\Acumulus\Invoice\Result The result of sending (or not sending) the invoice.
[ "Processes", "a", "shop", "invoice", "send", "event", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L385-L396
30,535
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.createAndSend
protected function createAndSend(Source $invoiceSource, Result $result, $forceSend = false, $dryRun = false) { $acumulusEntry = null; if ($this->isTestMode()) { $result->setSendStatus(Result::Send_TestMode); } elseif (($acumulusEntry = $this->getAcumulusEntryManager()->getByInvoiceSource($invoiceSource, false)) === null) { $result->setSendStatus(Result::Send_New); } elseif ($forceSend) { $result->setSendStatus(Result::Send_Forced); } elseif ($acumulusEntry->hasLockExpired()) { $result->setSendStatus(Result::Send_LockExpired); } elseif ($acumulusEntry->isSendLock()) { $result->setSendStatus(Result::NotSent_LockedForSending); } else { $result->setSendStatus(Result::NotSent_AlreadySent); } if (($result->getSendStatus() & Result::Send_Mask) !== 0) { $invoice = $this->getCreator()->create($invoiceSource); // Do not send 0-amount invoices, if set so. $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($shopEventSettings['sendEmptyInvoice'] || !$this->isEmptyInvoice($invoice)) { // Trigger the InvoiceCreated event. $this->triggerInvoiceCreated($invoice, $invoiceSource, $result); // If the invoice is not set to null, we continue by completing it. if ($invoice !== null) { $invoice = $this->getCompletor()->complete($invoice, $invoiceSource, $result); // Trigger the InvoiceCompleted event. $this->triggerInvoiceSendBefore($invoice, $invoiceSource, $result); // If the invoice is not set to null, we continue by sending it. if ($invoice !== null) { if (!$result->hasError()) { if (!$dryRun) { $result = $this->lockAndSend($invoice, $invoiceSource, $result); } else { $result->setSendStatus(Result::NotSent_DryRun); } } else { $result->setSendStatus(Result::NotSent_LocalErrors); } } else { $result->setSendStatus(Result::NotSent_EventInvoiceCompleted); } } else { $result->setSendStatus(Result::NotSent_EventInvoiceCreated); } } else { $result->setSendStatus(Result::NotSent_EmptyInvoice); } } return $result; }
php
protected function createAndSend(Source $invoiceSource, Result $result, $forceSend = false, $dryRun = false) { $acumulusEntry = null; if ($this->isTestMode()) { $result->setSendStatus(Result::Send_TestMode); } elseif (($acumulusEntry = $this->getAcumulusEntryManager()->getByInvoiceSource($invoiceSource, false)) === null) { $result->setSendStatus(Result::Send_New); } elseif ($forceSend) { $result->setSendStatus(Result::Send_Forced); } elseif ($acumulusEntry->hasLockExpired()) { $result->setSendStatus(Result::Send_LockExpired); } elseif ($acumulusEntry->isSendLock()) { $result->setSendStatus(Result::NotSent_LockedForSending); } else { $result->setSendStatus(Result::NotSent_AlreadySent); } if (($result->getSendStatus() & Result::Send_Mask) !== 0) { $invoice = $this->getCreator()->create($invoiceSource); // Do not send 0-amount invoices, if set so. $shopEventSettings = $this->getConfig()->getShopEventSettings(); if ($shopEventSettings['sendEmptyInvoice'] || !$this->isEmptyInvoice($invoice)) { // Trigger the InvoiceCreated event. $this->triggerInvoiceCreated($invoice, $invoiceSource, $result); // If the invoice is not set to null, we continue by completing it. if ($invoice !== null) { $invoice = $this->getCompletor()->complete($invoice, $invoiceSource, $result); // Trigger the InvoiceCompleted event. $this->triggerInvoiceSendBefore($invoice, $invoiceSource, $result); // If the invoice is not set to null, we continue by sending it. if ($invoice !== null) { if (!$result->hasError()) { if (!$dryRun) { $result = $this->lockAndSend($invoice, $invoiceSource, $result); } else { $result->setSendStatus(Result::NotSent_DryRun); } } else { $result->setSendStatus(Result::NotSent_LocalErrors); } } else { $result->setSendStatus(Result::NotSent_EventInvoiceCompleted); } } else { $result->setSendStatus(Result::NotSent_EventInvoiceCreated); } } else { $result->setSendStatus(Result::NotSent_EmptyInvoice); } } return $result; }
[ "protected", "function", "createAndSend", "(", "Source", "$", "invoiceSource", ",", "Result", "$", "result", ",", "$", "forceSend", "=", "false", ",", "$", "dryRun", "=", "false", ")", "{", "$", "acumulusEntry", "=", "null", ";", "if", "(", "$", "this", "->", "isTestMode", "(", ")", ")", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "Send_TestMode", ")", ";", "}", "elseif", "(", "(", "$", "acumulusEntry", "=", "$", "this", "->", "getAcumulusEntryManager", "(", ")", "->", "getByInvoiceSource", "(", "$", "invoiceSource", ",", "false", ")", ")", "===", "null", ")", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "Send_New", ")", ";", "}", "elseif", "(", "$", "forceSend", ")", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "Send_Forced", ")", ";", "}", "elseif", "(", "$", "acumulusEntry", "->", "hasLockExpired", "(", ")", ")", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "Send_LockExpired", ")", ";", "}", "elseif", "(", "$", "acumulusEntry", "->", "isSendLock", "(", ")", ")", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_LockedForSending", ")", ";", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_AlreadySent", ")", ";", "}", "if", "(", "(", "$", "result", "->", "getSendStatus", "(", ")", "&", "Result", "::", "Send_Mask", ")", "!==", "0", ")", "{", "$", "invoice", "=", "$", "this", "->", "getCreator", "(", ")", "->", "create", "(", "$", "invoiceSource", ")", ";", "// Do not send 0-amount invoices, if set so.", "$", "shopEventSettings", "=", "$", "this", "->", "getConfig", "(", ")", "->", "getShopEventSettings", "(", ")", ";", "if", "(", "$", "shopEventSettings", "[", "'sendEmptyInvoice'", "]", "||", "!", "$", "this", "->", "isEmptyInvoice", "(", "$", "invoice", ")", ")", "{", "// Trigger the InvoiceCreated event.", "$", "this", "->", "triggerInvoiceCreated", "(", "$", "invoice", ",", "$", "invoiceSource", ",", "$", "result", ")", ";", "// If the invoice is not set to null, we continue by completing it.", "if", "(", "$", "invoice", "!==", "null", ")", "{", "$", "invoice", "=", "$", "this", "->", "getCompletor", "(", ")", "->", "complete", "(", "$", "invoice", ",", "$", "invoiceSource", ",", "$", "result", ")", ";", "// Trigger the InvoiceCompleted event.", "$", "this", "->", "triggerInvoiceSendBefore", "(", "$", "invoice", ",", "$", "invoiceSource", ",", "$", "result", ")", ";", "// If the invoice is not set to null, we continue by sending it.", "if", "(", "$", "invoice", "!==", "null", ")", "{", "if", "(", "!", "$", "result", "->", "hasError", "(", ")", ")", "{", "if", "(", "!", "$", "dryRun", ")", "{", "$", "result", "=", "$", "this", "->", "lockAndSend", "(", "$", "invoice", ",", "$", "invoiceSource", ",", "$", "result", ")", ";", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_DryRun", ")", ";", "}", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_LocalErrors", ")", ";", "}", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_EventInvoiceCompleted", ")", ";", "}", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_EventInvoiceCreated", ")", ";", "}", "}", "else", "{", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_EmptyInvoice", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Creates and sends an invoice to Acumulus for an order. @param \Siel\Acumulus\Invoice\Source $invoiceSource The source object (order, credit note) for which the invoice was created. @param \Siel\Acumulus\Invoice\Result $result @param bool $forceSend If true, force sending the invoice even if an invoice has already been sent for the given invoice source. @param bool $dryRun If true, return the reason/status only but do not actually send the invoice, nor mail the result or store the result. @return \Siel\Acumulus\Invoice\Result The result of sending (or not sending) the invoice.
[ "Creates", "and", "sends", "an", "invoice", "to", "Acumulus", "for", "an", "order", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L415-L471
30,536
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.lockAndSend
protected function lockAndSend(array $invoice, Source $invoiceSource, Result $result) { $doLock = !$this->isTestMode() && in_array($result->getSendStatus(), array(Result::Send_New, Result::Send_LockExpired)); if ($doLock) { // Check if we may expect an expired lock and, if so, remove it. if ($result->getSendStatus() === Result::Send_LockExpired) { $lockStatus = $this->getAcumulusEntryManager()->deleteLock($invoiceSource); if ($lockStatus === AcumulusEntry::Lock_BecameRealEntry) { // Bail out: invoice already sent after all. return $result->setSendStatus(Result::NotSent_AlreadySent); } } // Acquire lock. if (!$this->getAcumulusEntryManager()->lockForSending($invoiceSource)) { // Bail out: Lock not acquired. return $result->setSendStatus(Result::NotSent_LockedForSending); } } try { $result = $this->doSend($invoice, $invoiceSource, $result); } catch (Exception $e) { $result->setException($e); } // When everything went well, the lock will have been replaced by a real // entry. So we only delete the lock in case of errors. if ($doLock && $result->hasError()) { // deleteLock() is expected to return AcumulusEntry::Lock_Deleted, // so we don't act on that return status. With any of the other // statuses it is unclear what happened and what the status will be // in Acumulus: tell user to check. if (($lockStatus = $this->getAcumulusEntryManager()->deleteLock($invoiceSource)) !== AcumulusEntry::Lock_Deleted) { $code = $lockStatus === AcumulusEntry::Lock_NoLongerExists ? 903 : 904; $result->addWarning($code, '', sprintf($this->t('message_warning_delete_lock_failed'), $this->t($invoiceSource->getType()))); } } // Trigger the InvoiceSent event. $this->triggerInvoiceSendAfter($invoice, $invoiceSource, $result); // Send a mail if there are messages. $this->mailInvoiceAddResult($result, $invoiceSource); return $result; }
php
protected function lockAndSend(array $invoice, Source $invoiceSource, Result $result) { $doLock = !$this->isTestMode() && in_array($result->getSendStatus(), array(Result::Send_New, Result::Send_LockExpired)); if ($doLock) { // Check if we may expect an expired lock and, if so, remove it. if ($result->getSendStatus() === Result::Send_LockExpired) { $lockStatus = $this->getAcumulusEntryManager()->deleteLock($invoiceSource); if ($lockStatus === AcumulusEntry::Lock_BecameRealEntry) { // Bail out: invoice already sent after all. return $result->setSendStatus(Result::NotSent_AlreadySent); } } // Acquire lock. if (!$this->getAcumulusEntryManager()->lockForSending($invoiceSource)) { // Bail out: Lock not acquired. return $result->setSendStatus(Result::NotSent_LockedForSending); } } try { $result = $this->doSend($invoice, $invoiceSource, $result); } catch (Exception $e) { $result->setException($e); } // When everything went well, the lock will have been replaced by a real // entry. So we only delete the lock in case of errors. if ($doLock && $result->hasError()) { // deleteLock() is expected to return AcumulusEntry::Lock_Deleted, // so we don't act on that return status. With any of the other // statuses it is unclear what happened and what the status will be // in Acumulus: tell user to check. if (($lockStatus = $this->getAcumulusEntryManager()->deleteLock($invoiceSource)) !== AcumulusEntry::Lock_Deleted) { $code = $lockStatus === AcumulusEntry::Lock_NoLongerExists ? 903 : 904; $result->addWarning($code, '', sprintf($this->t('message_warning_delete_lock_failed'), $this->t($invoiceSource->getType()))); } } // Trigger the InvoiceSent event. $this->triggerInvoiceSendAfter($invoice, $invoiceSource, $result); // Send a mail if there are messages. $this->mailInvoiceAddResult($result, $invoiceSource); return $result; }
[ "protected", "function", "lockAndSend", "(", "array", "$", "invoice", ",", "Source", "$", "invoiceSource", ",", "Result", "$", "result", ")", "{", "$", "doLock", "=", "!", "$", "this", "->", "isTestMode", "(", ")", "&&", "in_array", "(", "$", "result", "->", "getSendStatus", "(", ")", ",", "array", "(", "Result", "::", "Send_New", ",", "Result", "::", "Send_LockExpired", ")", ")", ";", "if", "(", "$", "doLock", ")", "{", "// Check if we may expect an expired lock and, if so, remove it.", "if", "(", "$", "result", "->", "getSendStatus", "(", ")", "===", "Result", "::", "Send_LockExpired", ")", "{", "$", "lockStatus", "=", "$", "this", "->", "getAcumulusEntryManager", "(", ")", "->", "deleteLock", "(", "$", "invoiceSource", ")", ";", "if", "(", "$", "lockStatus", "===", "AcumulusEntry", "::", "Lock_BecameRealEntry", ")", "{", "// Bail out: invoice already sent after all.", "return", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_AlreadySent", ")", ";", "}", "}", "// Acquire lock.", "if", "(", "!", "$", "this", "->", "getAcumulusEntryManager", "(", ")", "->", "lockForSending", "(", "$", "invoiceSource", ")", ")", "{", "// Bail out: Lock not acquired.", "return", "$", "result", "->", "setSendStatus", "(", "Result", "::", "NotSent_LockedForSending", ")", ";", "}", "}", "try", "{", "$", "result", "=", "$", "this", "->", "doSend", "(", "$", "invoice", ",", "$", "invoiceSource", ",", "$", "result", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "result", "->", "setException", "(", "$", "e", ")", ";", "}", "// When everything went well, the lock will have been replaced by a real", "// entry. So we only delete the lock in case of errors.", "if", "(", "$", "doLock", "&&", "$", "result", "->", "hasError", "(", ")", ")", "{", "// deleteLock() is expected to return AcumulusEntry::Lock_Deleted,", "// so we don't act on that return status. With any of the other", "// statuses it is unclear what happened and what the status will be", "// in Acumulus: tell user to check.", "if", "(", "(", "$", "lockStatus", "=", "$", "this", "->", "getAcumulusEntryManager", "(", ")", "->", "deleteLock", "(", "$", "invoiceSource", ")", ")", "!==", "AcumulusEntry", "::", "Lock_Deleted", ")", "{", "$", "code", "=", "$", "lockStatus", "===", "AcumulusEntry", "::", "Lock_NoLongerExists", "?", "903", ":", "904", ";", "$", "result", "->", "addWarning", "(", "$", "code", ",", "''", ",", "sprintf", "(", "$", "this", "->", "t", "(", "'message_warning_delete_lock_failed'", ")", ",", "$", "this", "->", "t", "(", "$", "invoiceSource", "->", "getType", "(", ")", ")", ")", ")", ";", "}", "}", "// Trigger the InvoiceSent event.", "$", "this", "->", "triggerInvoiceSendAfter", "(", "$", "invoice", ",", "$", "invoiceSource", ",", "$", "result", ")", ";", "// Send a mail if there are messages.", "$", "this", "->", "mailInvoiceAddResult", "(", "$", "result", ",", "$", "invoiceSource", ")", ";", "return", "$", "result", ";", "}" ]
Locks, if needed, the invoice for sending and, if acquired, sends it. NOTE: the mechanism used to lock and verify if we got the lock is not atomic, nor fool proof for all possible situations. However, it is a relatively easy to understand solution that will catch 99,9% of the situations. If double sending still occurs, some warning mechanisms are built in (were already built in) to delete one of the entries in Acumulus and warn the user. After sending the invoice: - The invoice sent event gets triggered. - A mail with the results may be sent. @param \Siel\Acumulus\Invoice\Source $invoiceSource @param array $invoice @param \Siel\Acumulus\Invoice\Result $result @return \Siel\Acumulus\Invoice\Result The result structure of the invoice add API call merged with any local messages.
[ "Locks", "if", "needed", "the", "invoice", "for", "sending", "and", "if", "acquired", "sends", "it", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L495-L543
30,537
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.doSend
protected function doSend(array $invoice, Source $invoiceSource, Result $result) { /** @var \Siel\Acumulus\Invoice\Result $result */ $result = $this->getService()->invoiceAdd($invoice, $result);// Store the reference between the source of the webshop invoice and the // Save Acumulus entry: // - If we were sending in test mode or there were errors, no invoice // will have been created in Acumulus: nothing to store. // - If the invoice was sent as a concept, the entry id and token will // be empty: store nulls. if (!$this->isTestMode() && !$result->hasError()) { // If we are going to overwrite an existing entry, we want to delete // that from Acumulus. $acumulusEntryManager = $this->getAcumulusEntryManager(); $oldEntry = $acumulusEntryManager->getByInvoiceSource($invoiceSource, true); $response = $result->getResponse(); $saved = (bool) $acumulusEntryManager->save($invoiceSource, empty($response['entryid']) ? null : $response['entryid'], empty($response['token']) ? null : $response['token'] ); // Delete if there is an old entry and we successfully saved the new // entry. if ($saved && isset($oldEntry) && $oldEntry->getEntryId()) { // But only if the old entry does not refer to a concept as // concepts do not have an entry id and thus cannot be deleted. $entryId = $oldEntry->getEntryId(); $deleteResult = $this->getService()->setDeleteStatus($entryId, API::Entry_Delete); if ($deleteResult->hasMessages()) { // Add messages to result but not if the entry has already // the delete status or does not exist at all (anymore). if ($deleteResult->hasCodeTag('P2XFELO12')) { // Successfully deleted the old entry: add a warning so // this info will be mailed to the user. $result->addWarning(902, '', sprintf($this->t('message_warning_old_entry_not_deleted'), $this->t($invoiceSource->getType()), $entryId)); } else { $result->mergeMessages($deleteResult, true); } } else { // Successfully deleted the old entry: add a notice so this // info will be mailed to the user. $result->addNotice(901, '', sprintf($this->t('message_warning_old_entry_deleted'), $this->t($invoiceSource->getType()), $entryId)); } } } return $result; }
php
protected function doSend(array $invoice, Source $invoiceSource, Result $result) { /** @var \Siel\Acumulus\Invoice\Result $result */ $result = $this->getService()->invoiceAdd($invoice, $result);// Store the reference between the source of the webshop invoice and the // Save Acumulus entry: // - If we were sending in test mode or there were errors, no invoice // will have been created in Acumulus: nothing to store. // - If the invoice was sent as a concept, the entry id and token will // be empty: store nulls. if (!$this->isTestMode() && !$result->hasError()) { // If we are going to overwrite an existing entry, we want to delete // that from Acumulus. $acumulusEntryManager = $this->getAcumulusEntryManager(); $oldEntry = $acumulusEntryManager->getByInvoiceSource($invoiceSource, true); $response = $result->getResponse(); $saved = (bool) $acumulusEntryManager->save($invoiceSource, empty($response['entryid']) ? null : $response['entryid'], empty($response['token']) ? null : $response['token'] ); // Delete if there is an old entry and we successfully saved the new // entry. if ($saved && isset($oldEntry) && $oldEntry->getEntryId()) { // But only if the old entry does not refer to a concept as // concepts do not have an entry id and thus cannot be deleted. $entryId = $oldEntry->getEntryId(); $deleteResult = $this->getService()->setDeleteStatus($entryId, API::Entry_Delete); if ($deleteResult->hasMessages()) { // Add messages to result but not if the entry has already // the delete status or does not exist at all (anymore). if ($deleteResult->hasCodeTag('P2XFELO12')) { // Successfully deleted the old entry: add a warning so // this info will be mailed to the user. $result->addWarning(902, '', sprintf($this->t('message_warning_old_entry_not_deleted'), $this->t($invoiceSource->getType()), $entryId)); } else { $result->mergeMessages($deleteResult, true); } } else { // Successfully deleted the old entry: add a notice so this // info will be mailed to the user. $result->addNotice(901, '', sprintf($this->t('message_warning_old_entry_deleted'), $this->t($invoiceSource->getType()), $entryId)); } } } return $result; }
[ "protected", "function", "doSend", "(", "array", "$", "invoice", ",", "Source", "$", "invoiceSource", ",", "Result", "$", "result", ")", "{", "/** @var \\Siel\\Acumulus\\Invoice\\Result $result */", "$", "result", "=", "$", "this", "->", "getService", "(", ")", "->", "invoiceAdd", "(", "$", "invoice", ",", "$", "result", ")", ";", "// Store the reference between the source of the webshop invoice and the", "// Save Acumulus entry:", "// - If we were sending in test mode or there were errors, no invoice", "// will have been created in Acumulus: nothing to store.", "// - If the invoice was sent as a concept, the entry id and token will", "// be empty: store nulls.", "if", "(", "!", "$", "this", "->", "isTestMode", "(", ")", "&&", "!", "$", "result", "->", "hasError", "(", ")", ")", "{", "// If we are going to overwrite an existing entry, we want to delete", "// that from Acumulus.", "$", "acumulusEntryManager", "=", "$", "this", "->", "getAcumulusEntryManager", "(", ")", ";", "$", "oldEntry", "=", "$", "acumulusEntryManager", "->", "getByInvoiceSource", "(", "$", "invoiceSource", ",", "true", ")", ";", "$", "response", "=", "$", "result", "->", "getResponse", "(", ")", ";", "$", "saved", "=", "(", "bool", ")", "$", "acumulusEntryManager", "->", "save", "(", "$", "invoiceSource", ",", "empty", "(", "$", "response", "[", "'entryid'", "]", ")", "?", "null", ":", "$", "response", "[", "'entryid'", "]", ",", "empty", "(", "$", "response", "[", "'token'", "]", ")", "?", "null", ":", "$", "response", "[", "'token'", "]", ")", ";", "// Delete if there is an old entry and we successfully saved the new", "// entry.", "if", "(", "$", "saved", "&&", "isset", "(", "$", "oldEntry", ")", "&&", "$", "oldEntry", "->", "getEntryId", "(", ")", ")", "{", "// But only if the old entry does not refer to a concept as", "// concepts do not have an entry id and thus cannot be deleted.", "$", "entryId", "=", "$", "oldEntry", "->", "getEntryId", "(", ")", ";", "$", "deleteResult", "=", "$", "this", "->", "getService", "(", ")", "->", "setDeleteStatus", "(", "$", "entryId", ",", "API", "::", "Entry_Delete", ")", ";", "if", "(", "$", "deleteResult", "->", "hasMessages", "(", ")", ")", "{", "// Add messages to result but not if the entry has already", "// the delete status or does not exist at all (anymore).", "if", "(", "$", "deleteResult", "->", "hasCodeTag", "(", "'P2XFELO12'", ")", ")", "{", "// Successfully deleted the old entry: add a warning so", "// this info will be mailed to the user.", "$", "result", "->", "addWarning", "(", "902", ",", "''", ",", "sprintf", "(", "$", "this", "->", "t", "(", "'message_warning_old_entry_not_deleted'", ")", ",", "$", "this", "->", "t", "(", "$", "invoiceSource", "->", "getType", "(", ")", ")", ",", "$", "entryId", ")", ")", ";", "}", "else", "{", "$", "result", "->", "mergeMessages", "(", "$", "deleteResult", ",", "true", ")", ";", "}", "}", "else", "{", "// Successfully deleted the old entry: add a notice so this", "// info will be mailed to the user.", "$", "result", "->", "addNotice", "(", "901", ",", "''", ",", "sprintf", "(", "$", "this", "->", "t", "(", "'message_warning_old_entry_deleted'", ")", ",", "$", "this", "->", "t", "(", "$", "invoiceSource", "->", "getType", "(", ")", ")", ",", "$", "entryId", ")", ")", ";", "}", "}", "}", "return", "$", "result", ";", "}" ]
Unconditionally sends the invoice and update the Acumulus entries table. After sending the invoice: - A successful result gets saved to the acumulus entries table. - If an older submission exists, it will be deleted from Acumulus. @param \Siel\Acumulus\Invoice\Source $invoiceSource @param array $invoice @param \Siel\Acumulus\Invoice\Result $result @return \Siel\Acumulus\Invoice\Result The result structure of the invoice add API call merged with any local messages.
[ "Unconditionally", "sends", "the", "invoice", "and", "update", "the", "Acumulus", "entries", "table", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L560-L609
30,538
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.getCol
protected function getCol(array $dbResults, $key) { $results = array(); foreach ($dbResults as $dbResult) { $results[] = (int) $dbResult[$key]; } return $results; }
php
protected function getCol(array $dbResults, $key) { $results = array(); foreach ($dbResults as $dbResult) { $results[] = (int) $dbResult[$key]; } return $results; }
[ "protected", "function", "getCol", "(", "array", "$", "dbResults", ",", "$", "key", ")", "{", "$", "results", "=", "array", "(", ")", ";", "foreach", "(", "$", "dbResults", "as", "$", "dbResult", ")", "{", "$", "results", "[", "]", "=", "(", "int", ")", "$", "dbResult", "[", "$", "key", "]", ";", "}", "return", "$", "results", ";", "}" ]
Helper method to retrieve the values from 1 column of a query result. @param array $dbResults @param string $key @return int[]
[ "Helper", "method", "to", "retrieve", "the", "values", "from", "1", "column", "of", "a", "query", "result", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L731-L738
30,539
SIELOnline/libAcumulus
src/Shop/InvoiceManager.php
InvoiceManager.getSendResultLogText
protected function getSendResultLogText(Source $invoiceSource, Result $result, $addReqResp = Result::AddReqResp_WithOther) { $invoiceSourceText = sprintf($this->t('message_invoice_source'), $this->t($invoiceSource->getType()), $invoiceSource->getReference() ); $logMessage = sprintf($this->t('message_invoice_send'), $result->getTrigger(), $invoiceSourceText, $result->getLogText($addReqResp) ); return $logMessage; }
php
protected function getSendResultLogText(Source $invoiceSource, Result $result, $addReqResp = Result::AddReqResp_WithOther) { $invoiceSourceText = sprintf($this->t('message_invoice_source'), $this->t($invoiceSource->getType()), $invoiceSource->getReference() ); $logMessage = sprintf($this->t('message_invoice_send'), $result->getTrigger(), $invoiceSourceText, $result->getLogText($addReqResp) ); return $logMessage; }
[ "protected", "function", "getSendResultLogText", "(", "Source", "$", "invoiceSource", ",", "Result", "$", "result", ",", "$", "addReqResp", "=", "Result", "::", "AddReqResp_WithOther", ")", "{", "$", "invoiceSourceText", "=", "sprintf", "(", "$", "this", "->", "t", "(", "'message_invoice_source'", ")", ",", "$", "this", "->", "t", "(", "$", "invoiceSource", "->", "getType", "(", ")", ")", ",", "$", "invoiceSource", "->", "getReference", "(", ")", ")", ";", "$", "logMessage", "=", "sprintf", "(", "$", "this", "->", "t", "(", "'message_invoice_send'", ")", ",", "$", "result", "->", "getTrigger", "(", ")", ",", "$", "invoiceSourceText", ",", "$", "result", "->", "getLogText", "(", "$", "addReqResp", ")", ")", ";", "return", "$", "logMessage", ";", "}" ]
Returns a string that details the result of the invoice sending. @param \Siel\Acumulus\Invoice\Source $invoiceSource @param \Siel\Acumulus\Invoice\Result $result @param int $addReqResp Whether to add the raw request and response. One of the Result::AddReqResp_... constants @return string
[ "Returns", "a", "string", "that", "details", "the", "result", "of", "the", "invoice", "sending", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Shop/InvoiceManager.php#L752-L764
30,540
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_PaymentObject.loadBasicPaymentMethodClass
protected function loadBasicPaymentMethodClass() { if (!class_exists("Icepay_Api_Basic")) return $this; $this->pm_class = Icepay_Api_Basic::getInstance() ->readFolder() ->getClassByPaymentMethodCode($this->data->ic_paymentmethod); if (count($this->pm_class->getSupportedIssuers()) == 1) { $this->setIssuer(current($this->pm_class->getSupportedIssuers())); } return $this; }
php
protected function loadBasicPaymentMethodClass() { if (!class_exists("Icepay_Api_Basic")) return $this; $this->pm_class = Icepay_Api_Basic::getInstance() ->readFolder() ->getClassByPaymentMethodCode($this->data->ic_paymentmethod); if (count($this->pm_class->getSupportedIssuers()) == 1) { $this->setIssuer(current($this->pm_class->getSupportedIssuers())); } return $this; }
[ "protected", "function", "loadBasicPaymentMethodClass", "(", ")", "{", "if", "(", "!", "class_exists", "(", "\"Icepay_Api_Basic\"", ")", ")", "return", "$", "this", ";", "$", "this", "->", "pm_class", "=", "Icepay_Api_Basic", "::", "getInstance", "(", ")", "->", "readFolder", "(", ")", "->", "getClassByPaymentMethodCode", "(", "$", "this", "->", "data", "->", "ic_paymentmethod", ")", ";", "if", "(", "count", "(", "$", "this", "->", "pm_class", "->", "getSupportedIssuers", "(", ")", ")", "==", "1", ")", "{", "$", "this", "->", "setIssuer", "(", "current", "(", "$", "this", "->", "pm_class", "->", "getSupportedIssuers", "(", ")", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Load a paymentmethod class for Basic @since version 2.1.0 @access protected
[ "Load", "a", "paymentmethod", "class", "for", "Basic" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L205-L219
30,541
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_PaymentObject.setCountry
public function setCountry($country) { $country = strtoupper($country); if (!Icepay_Parameter_Validation::country($country)) throw new Exception('Country not valid'); $this->data->ic_country = $country; return $this; }
php
public function setCountry($country) { $country = strtoupper($country); if (!Icepay_Parameter_Validation::country($country)) throw new Exception('Country not valid'); $this->data->ic_country = $country; return $this; }
[ "public", "function", "setCountry", "(", "$", "country", ")", "{", "$", "country", "=", "strtoupper", "(", "$", "country", ")", ";", "if", "(", "!", "Icepay_Parameter_Validation", "::", "country", "(", "$", "country", ")", ")", "throw", "new", "Exception", "(", "'Country not valid'", ")", ";", "$", "this", "->", "data", "->", "ic_country", "=", "$", "country", ";", "return", "$", "this", ";", "}" ]
Set the country field @since version 1.0.0 @access public @param string $currency Country ISO 3166-1-alpha-2 code !Required @example setCountry("NL") // Netherlands
[ "Set", "the", "country", "field" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L239-L246
30,542
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_PaymentObject.setLanguage
public function setLanguage($lang) { if (!Icepay_Parameter_Validation::language($lang)) throw new Exception('Language not valid'); $this->data->ic_language = $lang; return $this; }
php
public function setLanguage($lang) { if (!Icepay_Parameter_Validation::language($lang)) throw new Exception('Language not valid'); $this->data->ic_language = $lang; return $this; }
[ "public", "function", "setLanguage", "(", "$", "lang", ")", "{", "if", "(", "!", "Icepay_Parameter_Validation", "::", "language", "(", "$", "lang", ")", ")", "throw", "new", "Exception", "(", "'Language not valid'", ")", ";", "$", "this", "->", "data", "->", "ic_language", "=", "$", "lang", ";", "return", "$", "this", ";", "}" ]
Set the language field @since version 1.0.0 @access public @param string $lang Language ISO 639-1 code !Required @example setLanguage("EN") // English
[ "Set", "the", "language", "field" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L268-L274
30,543
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_PaymentObject.setAmount
public function setAmount($amount) { $amount = (int) (string) $amount; if (!Icepay_Parameter_Validation::amount($amount)) throw new Exception('Amount not valid'); $this->data->ic_amount = $amount; return $this; }
php
public function setAmount($amount) { $amount = (int) (string) $amount; if (!Icepay_Parameter_Validation::amount($amount)) throw new Exception('Amount not valid'); $this->data->ic_amount = $amount; return $this; }
[ "public", "function", "setAmount", "(", "$", "amount", ")", "{", "$", "amount", "=", "(", "int", ")", "(", "string", ")", "$", "amount", ";", "if", "(", "!", "Icepay_Parameter_Validation", "::", "amount", "(", "$", "amount", ")", ")", "throw", "new", "Exception", "(", "'Amount not valid'", ")", ";", "$", "this", "->", "data", "->", "ic_amount", "=", "$", "amount", ";", "return", "$", "this", ";", "}" ]
Set the amount field @since version 1.0.0 @access public @param int $amount !Required
[ "Set", "the", "amount", "field" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L282-L290
30,544
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Api_Base.setMerchantID
public function setMerchantID($merchantID) { if (!Icepay_Parameter_Validation::merchantID($merchantID)) throw new Exception('MerchantID not valid'); $this->_merchantID = (int) $merchantID; return $this; }
php
public function setMerchantID($merchantID) { if (!Icepay_Parameter_Validation::merchantID($merchantID)) throw new Exception('MerchantID not valid'); $this->_merchantID = (int) $merchantID; return $this; }
[ "public", "function", "setMerchantID", "(", "$", "merchantID", ")", "{", "if", "(", "!", "Icepay_Parameter_Validation", "::", "merchantID", "(", "$", "merchantID", ")", ")", "throw", "new", "Exception", "(", "'MerchantID not valid'", ")", ";", "$", "this", "->", "_merchantID", "=", "(", "int", ")", "$", "merchantID", ";", "return", "$", "this", ";", "}" ]
Set the Merchant ID field @since 1.0.0 @access public @param (int) $merchantID
[ "Set", "the", "Merchant", "ID", "field" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L691-L699
30,545
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Api_Base.setSecretCode
public function setSecretCode($secretCode) { if (!Icepay_Parameter_Validation::secretCode($secretCode)) throw new Exception('Secretcode not valid'); $this->_secretCode = (string) $secretCode; return $this; }
php
public function setSecretCode($secretCode) { if (!Icepay_Parameter_Validation::secretCode($secretCode)) throw new Exception('Secretcode not valid'); $this->_secretCode = (string) $secretCode; return $this; }
[ "public", "function", "setSecretCode", "(", "$", "secretCode", ")", "{", "if", "(", "!", "Icepay_Parameter_Validation", "::", "secretCode", "(", "$", "secretCode", ")", ")", "throw", "new", "Exception", "(", "'Secretcode not valid'", ")", ";", "$", "this", "->", "_secretCode", "=", "(", "string", ")", "$", "secretCode", ";", "return", "$", "this", ";", "}" ]
Set the Secret Code field @since 1.0.0 @access public @param (string) $secretCode
[ "Set", "the", "Secret", "Code", "field" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L718-L725
30,546
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Api_Base.setPinCode
public function setPinCode($pinCode) { if (!Icepay_Parameter_Validation::pinCode($pinCode)) throw new Exception('Pincode not valid'); $this->_pinCode = (string) $pinCode; return $this; }
php
public function setPinCode($pinCode) { if (!Icepay_Parameter_Validation::pinCode($pinCode)) throw new Exception('Pincode not valid'); $this->_pinCode = (string) $pinCode; return $this; }
[ "public", "function", "setPinCode", "(", "$", "pinCode", ")", "{", "if", "(", "!", "Icepay_Parameter_Validation", "::", "pinCode", "(", "$", "pinCode", ")", ")", "throw", "new", "Exception", "(", "'Pincode not valid'", ")", ";", "$", "this", "->", "_pinCode", "=", "(", "string", ")", "$", "pinCode", ";", "return", "$", "this", ";", "}" ]
Set the Pin Code field @since 1.0.1 @access public @param (int) $pinCode
[ "Set", "the", "Pin", "Code", "field" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L744-L752
30,547
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Api_Logger.logToFunction
public function logToFunction($className = null, $logFunction = null, $bool = true) { $this->_logToHook = $bool; if (class_exists($className)) $this->_logHookClass = new $className; if (is_callable($logFunction)) $this->_logHookFunc = $logFunction; return $this; }
php
public function logToFunction($className = null, $logFunction = null, $bool = true) { $this->_logToHook = $bool; if (class_exists($className)) $this->_logHookClass = new $className; if (is_callable($logFunction)) $this->_logHookFunc = $logFunction; return $this; }
[ "public", "function", "logToFunction", "(", "$", "className", "=", "null", ",", "$", "logFunction", "=", "null", ",", "$", "bool", "=", "true", ")", "{", "$", "this", "->", "_logToHook", "=", "$", "bool", ";", "if", "(", "class_exists", "(", "$", "className", ")", ")", "$", "this", "->", "_logHookClass", "=", "new", "$", "className", ";", "if", "(", "is_callable", "(", "$", "logFunction", ")", ")", "$", "this", "->", "_logHookFunc", "=", "$", "logFunction", ";", "return", "$", "this", ";", "}" ]
Enable or disable logging to a hooked class @since 2.1.0 @access public @param string $className @param string $logFunction @param bool $bool @return \Icepay_Basicmode
[ "Enable", "or", "disable", "logging", "to", "a", "hooked", "class" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1020-L1031
30,548
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Api_Logger.setLoggingLevel
public function setLoggingLevel($level) { switch ($level) { case Icepay_Api_Logger::LEVEL_ALL: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR); break; case Icepay_Api_Logger::LEVEL_ERRORS: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE, false); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION, false); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR); break; case Icepay_Api_Logger::LEVEL_TRANSACTION: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE, false); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR, false); break; case Icepay_Api_Logger::LEVEL_ERRORS_AND_TRANSACTION: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE, false); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR); break; } return $this; }
php
public function setLoggingLevel($level) { switch ($level) { case Icepay_Api_Logger::LEVEL_ALL: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR); break; case Icepay_Api_Logger::LEVEL_ERRORS: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE, false); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION, false); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR); break; case Icepay_Api_Logger::LEVEL_TRANSACTION: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE, false); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR, false); break; case Icepay_Api_Logger::LEVEL_ERRORS_AND_TRANSACTION: $this->_setLoggingFlag(Icepay_Api_Logger::NOTICE, false); $this->_setLoggingFlag(Icepay_Api_Logger::TRANSACTION); $this->_setLoggingFlag(Icepay_Api_Logger::ERROR); break; } return $this; }
[ "public", "function", "setLoggingLevel", "(", "$", "level", ")", "{", "switch", "(", "$", "level", ")", "{", "case", "Icepay_Api_Logger", "::", "LEVEL_ALL", ":", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "NOTICE", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "TRANSACTION", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "break", ";", "case", "Icepay_Api_Logger", "::", "LEVEL_ERRORS", ":", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "NOTICE", ",", "false", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "TRANSACTION", ",", "false", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "break", ";", "case", "Icepay_Api_Logger", "::", "LEVEL_TRANSACTION", ":", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "NOTICE", ",", "false", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "TRANSACTION", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "ERROR", ",", "false", ")", ";", "break", ";", "case", "Icepay_Api_Logger", "::", "LEVEL_ERRORS_AND_TRANSACTION", ":", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "NOTICE", ",", "false", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "TRANSACTION", ")", ";", "$", "this", "->", "_setLoggingFlag", "(", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "break", ";", "}", "return", "$", "this", ";", "}" ]
Set the logging level @since 2.1.0 @access public @param int $level
[ "Set", "the", "logging", "level" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1072-L1098
30,549
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Api_Logger.log
public function log($line, $level = 1) { // Check if logging is enabled if (!$this->_loggingEnabled) return false; // Check if the level is within the required level if (!$this->_isLoggingSet($level)) return false; $dateTime = date("H:i:s", time()); $line = "{$dateTime} [ICEPAY]: {$line}" . PHP_EOL; // Log to Screen if ($this->_logToScreen) echo "{$line} <br />"; // Log to Hooked Class if ($this->_logToHook && $this->_logHookClass && $this->_logHookFunc) { $function = $this->_logHookFunc; $this->_logHookClass->$function($line); } // Log to Default File if ($this->_logToFile) { $file = $this->_loggingDirectory . DS . $this->_loggingFile; try { $fp = fopen($file, "a"); fwrite($fp, $line); fclose($fp); } catch (Exception $e) { throw new Exception($e->getMessage()); }; } }
php
public function log($line, $level = 1) { // Check if logging is enabled if (!$this->_loggingEnabled) return false; // Check if the level is within the required level if (!$this->_isLoggingSet($level)) return false; $dateTime = date("H:i:s", time()); $line = "{$dateTime} [ICEPAY]: {$line}" . PHP_EOL; // Log to Screen if ($this->_logToScreen) echo "{$line} <br />"; // Log to Hooked Class if ($this->_logToHook && $this->_logHookClass && $this->_logHookFunc) { $function = $this->_logHookFunc; $this->_logHookClass->$function($line); } // Log to Default File if ($this->_logToFile) { $file = $this->_loggingDirectory . DS . $this->_loggingFile; try { $fp = fopen($file, "a"); fwrite($fp, $line); fclose($fp); } catch (Exception $e) { throw new Exception($e->getMessage()); }; } }
[ "public", "function", "log", "(", "$", "line", ",", "$", "level", "=", "1", ")", "{", "// Check if logging is enabled", "if", "(", "!", "$", "this", "->", "_loggingEnabled", ")", "return", "false", ";", "// Check if the level is within the required level", "if", "(", "!", "$", "this", "->", "_isLoggingSet", "(", "$", "level", ")", ")", "return", "false", ";", "$", "dateTime", "=", "date", "(", "\"H:i:s\"", ",", "time", "(", ")", ")", ";", "$", "line", "=", "\"{$dateTime} [ICEPAY]: {$line}\"", ".", "PHP_EOL", ";", "// Log to Screen", "if", "(", "$", "this", "->", "_logToScreen", ")", "echo", "\"{$line} <br />\"", ";", "// Log to Hooked Class", "if", "(", "$", "this", "->", "_logToHook", "&&", "$", "this", "->", "_logHookClass", "&&", "$", "this", "->", "_logHookFunc", ")", "{", "$", "function", "=", "$", "this", "->", "_logHookFunc", ";", "$", "this", "->", "_logHookClass", "->", "$", "function", "(", "$", "line", ")", ";", "}", "// Log to Default File", "if", "(", "$", "this", "->", "_logToFile", ")", "{", "$", "file", "=", "$", "this", "->", "_loggingDirectory", ".", "DS", ".", "$", "this", "->", "_loggingFile", ";", "try", "{", "$", "fp", "=", "fopen", "(", "$", "file", ",", "\"a\"", ")", ";", "fwrite", "(", "$", "fp", ",", "$", "line", ")", ";", "fclose", "(", "$", "fp", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "throw", "new", "Exception", "(", "$", "e", "->", "getMessage", "(", ")", ")", ";", "}", ";", "}", "}" ]
Log given line @since 2.1.0 @access public @param string $line @param int $level @return boolean @throws Exception
[ "Log", "given", "line" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1142-L1178
30,550
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.getTransactionString
public function getTransactionString() { return sprintf( "Paymentmethod: %s \n| OrderID: %s \n| Status: %s \n| StatusCode: %s \n| PaymentID: %s \n| TransactionID: %s \n| Amount: %s", isset($this->data->paymentMethod) ? $this->data->paymentMethod : "", isset($this->data->orderID) ? $this->data->orderID : "", isset($this->data->status) ? $this->data->status : "", isset($this->data->statusCode) ? $this->data->statusCode : "", isset($this->data->paymentID) ? $this->data->paymentID : "", isset($this->data->transactionID) ? $this->data->transactionID : "", isset($this->data->amount) ? $this->data->amount : "" ); }
php
public function getTransactionString() { return sprintf( "Paymentmethod: %s \n| OrderID: %s \n| Status: %s \n| StatusCode: %s \n| PaymentID: %s \n| TransactionID: %s \n| Amount: %s", isset($this->data->paymentMethod) ? $this->data->paymentMethod : "", isset($this->data->orderID) ? $this->data->orderID : "", isset($this->data->status) ? $this->data->status : "", isset($this->data->statusCode) ? $this->data->statusCode : "", isset($this->data->paymentID) ? $this->data->paymentID : "", isset($this->data->transactionID) ? $this->data->transactionID : "", isset($this->data->amount) ? $this->data->amount : "" ); }
[ "public", "function", "getTransactionString", "(", ")", "{", "return", "sprintf", "(", "\"Paymentmethod: %s \\n| OrderID: %s \\n| Status: %s \\n| StatusCode: %s \\n| PaymentID: %s \\n| TransactionID: %s \\n| Amount: %s\"", ",", "isset", "(", "$", "this", "->", "data", "->", "paymentMethod", ")", "?", "$", "this", "->", "data", "->", "paymentMethod", ":", "\"\"", ",", "isset", "(", "$", "this", "->", "data", "->", "orderID", ")", "?", "$", "this", "->", "data", "->", "orderID", ":", "\"\"", ",", "isset", "(", "$", "this", "->", "data", "->", "status", ")", "?", "$", "this", "->", "data", "->", "status", ":", "\"\"", ",", "isset", "(", "$", "this", "->", "data", "->", "statusCode", ")", "?", "$", "this", "->", "data", "->", "statusCode", ":", "\"\"", ",", "isset", "(", "$", "this", "->", "data", "->", "paymentID", ")", "?", "$", "this", "->", "data", "->", "paymentID", ":", "\"\"", ",", "isset", "(", "$", "this", "->", "data", "->", "transactionID", ")", "?", "$", "this", "->", "data", "->", "transactionID", ":", "\"\"", ",", "isset", "(", "$", "this", "->", "data", "->", "amount", ")", "?", "$", "this", "->", "data", "->", "amount", ":", "\"\"", ")", ";", "}" ]
Return minimized transactional data @since version 1.0.0 @access public @return string
[ "Return", "minimized", "transactional", "data" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1231-L1236
30,551
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.generateChecksumForPostback
protected function generateChecksumForPostback() { return sha1( sprintf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", $this->_secretCode, $this->_merchantID, $this->data->status, $this->data->statusCode, $this->data->orderID, $this->data->paymentID, $this->data->reference, $this->data->transactionID, $this->data->amount, $this->data->currency, $this->data->duration, $this->data->consumerIPAddress ) ); }
php
protected function generateChecksumForPostback() { return sha1( sprintf("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s", $this->_secretCode, $this->_merchantID, $this->data->status, $this->data->statusCode, $this->data->orderID, $this->data->paymentID, $this->data->reference, $this->data->transactionID, $this->data->amount, $this->data->currency, $this->data->duration, $this->data->consumerIPAddress ) ); }
[ "protected", "function", "generateChecksumForPostback", "(", ")", "{", "return", "sha1", "(", "sprintf", "(", "\"%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s\"", ",", "$", "this", "->", "_secretCode", ",", "$", "this", "->", "_merchantID", ",", "$", "this", "->", "data", "->", "status", ",", "$", "this", "->", "data", "->", "statusCode", ",", "$", "this", "->", "data", "->", "orderID", ",", "$", "this", "->", "data", "->", "paymentID", ",", "$", "this", "->", "data", "->", "reference", ",", "$", "this", "->", "data", "->", "transactionID", ",", "$", "this", "->", "data", "->", "amount", ",", "$", "this", "->", "data", "->", "currency", ",", "$", "this", "->", "data", "->", "duration", ",", "$", "this", "->", "data", "->", "consumerIPAddress", ")", ")", ";", "}" ]
Return the postback checksum @since version 1.0.0 @access protected @return string SHA1 encoded
[ "Return", "the", "postback", "checksum" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1266-L1272
30,552
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.generateChecksumForVersion
protected function generateChecksumForVersion() { return sha1( sprintf("%s|%s|%s|%s", $this->_secretCode, $this->_merchantID, $this->data->status, substr(strval(time()), 0, 8) ) ); }
php
protected function generateChecksumForVersion() { return sha1( sprintf("%s|%s|%s|%s", $this->_secretCode, $this->_merchantID, $this->data->status, substr(strval(time()), 0, 8) ) ); }
[ "protected", "function", "generateChecksumForVersion", "(", ")", "{", "return", "sha1", "(", "sprintf", "(", "\"%s|%s|%s|%s\"", ",", "$", "this", "->", "_secretCode", ",", "$", "this", "->", "_merchantID", ",", "$", "this", "->", "data", "->", "status", ",", "substr", "(", "strval", "(", "time", "(", ")", ")", ",", "0", ",", "8", ")", ")", ")", ";", "}" ]
Return the version checksum @since version 1.0.2 @access protected @return string SHA1 encoded
[ "Return", "the", "version", "checksum" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1280-L1286
30,553
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.validateVersion
public function validateVersion() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log('Invalid request method', Icepay_Api_Logger::ERROR); return false; } if ($this->generateChecksumForVersion() != $this->data->checksum) { $this->_logger->log('Checksum does not match', Icepay_Api_Logger::ERROR); return false; } return true; }
php
public function validateVersion() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log('Invalid request method', Icepay_Api_Logger::ERROR); return false; } if ($this->generateChecksumForVersion() != $this->data->checksum) { $this->_logger->log('Checksum does not match', Icepay_Api_Logger::ERROR); return false; } return true; }
[ "public", "function", "validateVersion", "(", ")", "{", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!=", "'POST'", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "'Invalid request method'", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "generateChecksumForVersion", "(", ")", "!=", "$", "this", "->", "data", "->", "checksum", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "'Checksum does not match'", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate for version check @since version 1.0.2 @access public @return boolean
[ "Validate", "for", "version", "check" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1328-L1341
30,554
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.isVersionCheck
public function isVersionCheck() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log('Invalid request method', Icepay_Api_Logger::ERROR); return false; } if ($this->data->status != "VCHECK") return false; return true; }
php
public function isVersionCheck() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log('Invalid request method', Icepay_Api_Logger::ERROR); return false; } if ($this->data->status != "VCHECK") return false; return true; }
[ "public", "function", "isVersionCheck", "(", ")", "{", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!=", "'POST'", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "'Invalid request method'", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "data", "->", "status", "!=", "\"VCHECK\"", ")", "return", "false", ";", "return", "true", ";", "}" ]
Has Version Check status @since version 1.0.2 @access public @return boolean
[ "Has", "Version", "Check", "status" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1349-L1360
30,555
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.validate
public function validate() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log("Invalid request method", Icepay_Api_Logger::ERROR); return false; }; $this->_logger->log(sprintf("Postback: %s", serialize($_POST)), Icepay_Api_Logger::TRANSACTION); /* @since version 1.0.2 */ foreach ($this->getPostbackResponseFields() as $obj => $param) { $this->data->$obj = (isset($_POST[$param])) ? $_POST[$param] : ""; } if ($this->isVersionCheck()) return false; if (!Icepay_Parameter_Validation::merchantID($this->data->merchant)) { $this->_logger->log("Merchant ID is not numeric: {$this->data->merchant}", Icepay_Api_Logger::ERROR); return false; } if (!Icepay_Parameter_Validation::amount($this->data->amount)) { $this->_logger->log("Amount is not numeric: {$this->data->amount}", Icepay_Api_Logger::ERROR); return false; } if ($this->_merchantID != $this->data->merchant) { $this->_logger->log("Invalid Merchant ID: {$this->data->merchant}", Icepay_Api_Logger::ERROR); return false; } if (!in_array(strtoupper($this->data->status), array( Icepay_StatusCode::OPEN, Icepay_StatusCode::AUTHORIZED, Icepay_StatusCode::SUCCESS, Icepay_StatusCode::ERROR, Icepay_StatusCode::REFUND, Icepay_StatusCode::CHARGEBACK ))) { $this->_logger->log("Unknown status: {$this->data->status}", Icepay_Api_Logger::ERROR); return false; } if ($this->generateChecksumForPostback() != $this->data->checksum) { $this->_logger->log("Checksum does not match", Icepay_Api_Logger::ERROR); return false; } return true; }
php
public function validate() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log("Invalid request method", Icepay_Api_Logger::ERROR); return false; }; $this->_logger->log(sprintf("Postback: %s", serialize($_POST)), Icepay_Api_Logger::TRANSACTION); /* @since version 1.0.2 */ foreach ($this->getPostbackResponseFields() as $obj => $param) { $this->data->$obj = (isset($_POST[$param])) ? $_POST[$param] : ""; } if ($this->isVersionCheck()) return false; if (!Icepay_Parameter_Validation::merchantID($this->data->merchant)) { $this->_logger->log("Merchant ID is not numeric: {$this->data->merchant}", Icepay_Api_Logger::ERROR); return false; } if (!Icepay_Parameter_Validation::amount($this->data->amount)) { $this->_logger->log("Amount is not numeric: {$this->data->amount}", Icepay_Api_Logger::ERROR); return false; } if ($this->_merchantID != $this->data->merchant) { $this->_logger->log("Invalid Merchant ID: {$this->data->merchant}", Icepay_Api_Logger::ERROR); return false; } if (!in_array(strtoupper($this->data->status), array( Icepay_StatusCode::OPEN, Icepay_StatusCode::AUTHORIZED, Icepay_StatusCode::SUCCESS, Icepay_StatusCode::ERROR, Icepay_StatusCode::REFUND, Icepay_StatusCode::CHARGEBACK ))) { $this->_logger->log("Unknown status: {$this->data->status}", Icepay_Api_Logger::ERROR); return false; } if ($this->generateChecksumForPostback() != $this->data->checksum) { $this->_logger->log("Checksum does not match", Icepay_Api_Logger::ERROR); return false; } return true; }
[ "public", "function", "validate", "(", ")", "{", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!=", "'POST'", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Invalid request method\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", ";", "$", "this", "->", "_logger", "->", "log", "(", "sprintf", "(", "\"Postback: %s\"", ",", "serialize", "(", "$", "_POST", ")", ")", ",", "Icepay_Api_Logger", "::", "TRANSACTION", ")", ";", "/* @since version 1.0.2 */", "foreach", "(", "$", "this", "->", "getPostbackResponseFields", "(", ")", "as", "$", "obj", "=>", "$", "param", ")", "{", "$", "this", "->", "data", "->", "$", "obj", "=", "(", "isset", "(", "$", "_POST", "[", "$", "param", "]", ")", ")", "?", "$", "_POST", "[", "$", "param", "]", ":", "\"\"", ";", "}", "if", "(", "$", "this", "->", "isVersionCheck", "(", ")", ")", "return", "false", ";", "if", "(", "!", "Icepay_Parameter_Validation", "::", "merchantID", "(", "$", "this", "->", "data", "->", "merchant", ")", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Merchant ID is not numeric: {$this->data->merchant}\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "!", "Icepay_Parameter_Validation", "::", "amount", "(", "$", "this", "->", "data", "->", "amount", ")", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Amount is not numeric: {$this->data->amount}\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "_merchantID", "!=", "$", "this", "->", "data", "->", "merchant", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Invalid Merchant ID: {$this->data->merchant}\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "!", "in_array", "(", "strtoupper", "(", "$", "this", "->", "data", "->", "status", ")", ",", "array", "(", "Icepay_StatusCode", "::", "OPEN", ",", "Icepay_StatusCode", "::", "AUTHORIZED", ",", "Icepay_StatusCode", "::", "SUCCESS", ",", "Icepay_StatusCode", "::", "ERROR", ",", "Icepay_StatusCode", "::", "REFUND", ",", "Icepay_StatusCode", "::", "CHARGEBACK", ")", ")", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Unknown status: {$this->data->status}\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "if", "(", "$", "this", "->", "generateChecksumForPostback", "(", ")", "!=", "$", "this", "->", "data", "->", "checksum", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Checksum does not match\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate the postback data @since version 1.0.0 @access public @return boolean
[ "Validate", "the", "postback", "data" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1368-L1417
30,556
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Postback.canUpdateStatus
public function canUpdateStatus($currentStatus) { if (!isset($this->data->status)) { $this->_logger->log("Status not set", Icepay_Api_Logger::ERROR); return false; } switch ($this->data->status) { case Icepay_StatusCode::SUCCESS: return ($currentStatus == Icepay_StatusCode::ERROR || $currentStatus == Icepay_StatusCode::AUTHORIZED || $currentStatus == Icepay_StatusCode::OPEN); case Icepay_StatusCode::OPEN: return ($currentStatus == Icepay_StatusCode::OPEN); case Icepay_StatusCode::AUTHORIZED: return ($currentStatus == Icepay_StatusCode::OPEN); case Icepay_StatusCode::ERROR: return ($currentStatus == Icepay_StatusCode::OPEN || $currentStatus == Icepay_StatusCode::AUTHORIZED); case Icepay_StatusCode::CHARGEBACK: return ($currentStatus == Icepay_StatusCode::SUCCESS); case Icepay_StatusCode::REFUND: return ($currentStatus == Icepay_StatusCode::SUCCESS); default: return false; }; }
php
public function canUpdateStatus($currentStatus) { if (!isset($this->data->status)) { $this->_logger->log("Status not set", Icepay_Api_Logger::ERROR); return false; } switch ($this->data->status) { case Icepay_StatusCode::SUCCESS: return ($currentStatus == Icepay_StatusCode::ERROR || $currentStatus == Icepay_StatusCode::AUTHORIZED || $currentStatus == Icepay_StatusCode::OPEN); case Icepay_StatusCode::OPEN: return ($currentStatus == Icepay_StatusCode::OPEN); case Icepay_StatusCode::AUTHORIZED: return ($currentStatus == Icepay_StatusCode::OPEN); case Icepay_StatusCode::ERROR: return ($currentStatus == Icepay_StatusCode::OPEN || $currentStatus == Icepay_StatusCode::AUTHORIZED); case Icepay_StatusCode::CHARGEBACK: return ($currentStatus == Icepay_StatusCode::SUCCESS); case Icepay_StatusCode::REFUND: return ($currentStatus == Icepay_StatusCode::SUCCESS); default: return false; }; }
[ "public", "function", "canUpdateStatus", "(", "$", "currentStatus", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "->", "status", ")", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Status not set\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "switch", "(", "$", "this", "->", "data", "->", "status", ")", "{", "case", "Icepay_StatusCode", "::", "SUCCESS", ":", "return", "(", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "ERROR", "||", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "AUTHORIZED", "||", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "OPEN", ")", ";", "case", "Icepay_StatusCode", "::", "OPEN", ":", "return", "(", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "OPEN", ")", ";", "case", "Icepay_StatusCode", "::", "AUTHORIZED", ":", "return", "(", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "OPEN", ")", ";", "case", "Icepay_StatusCode", "::", "ERROR", ":", "return", "(", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "OPEN", "||", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "AUTHORIZED", ")", ";", "case", "Icepay_StatusCode", "::", "CHARGEBACK", ":", "return", "(", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "SUCCESS", ")", ";", "case", "Icepay_StatusCode", "::", "REFUND", ":", "return", "(", "$", "currentStatus", "==", "Icepay_StatusCode", "::", "SUCCESS", ")", ";", "default", ":", "return", "false", ";", "}", ";", "}" ]
Check between ICEPAY statuscodes whether the status can be updated. @since version 1.0.0 @access public @param string $currentStatus The ICEPAY statuscode of the order before a statuschange @return boolean
[ "Check", "between", "ICEPAY", "statuscodes", "whether", "the", "status", "can", "be", "updated", "." ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1437-L1454
30,557
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Result.validate
public function validate() { if ($_SERVER['REQUEST_METHOD'] != 'GET') { $this->_logger->log("Invalid request method", Icepay_Api_Logger::ERROR); return false; } $this->_logger->log(sprintf("Page data: %s", serialize($_GET)), Icepay_Api_Logger::NOTICE); $this->data->status = (isset($_GET['Status'])) ? $_GET['Status'] : ""; $this->data->statusCode = (isset($_GET['StatusCode'])) ? $_GET['StatusCode'] : ""; $this->data->merchant = (isset($_GET['Merchant'])) ? $_GET['Merchant'] : ""; $this->data->orderID = (isset($_GET['OrderID'])) ? $_GET['OrderID'] : ""; $this->data->paymentID = (isset($_GET['PaymentID'])) ? $_GET['PaymentID'] : ""; $this->data->reference = (isset($_GET['Reference'])) ? $_GET['Reference'] : ""; $this->data->transactionID = (isset($_GET['TransactionID'])) ? $_GET['TransactionID'] : ""; $this->data->checksum = (isset($_GET['Checksum'])) ? $_GET['Checksum'] : ""; if ($this->generateChecksumForPage() != $this->data->checksum) { $this->_logger->log("Checksum does not match", Icepay_Api_Logger::ERROR); return false; } return true; }
php
public function validate() { if ($_SERVER['REQUEST_METHOD'] != 'GET') { $this->_logger->log("Invalid request method", Icepay_Api_Logger::ERROR); return false; } $this->_logger->log(sprintf("Page data: %s", serialize($_GET)), Icepay_Api_Logger::NOTICE); $this->data->status = (isset($_GET['Status'])) ? $_GET['Status'] : ""; $this->data->statusCode = (isset($_GET['StatusCode'])) ? $_GET['StatusCode'] : ""; $this->data->merchant = (isset($_GET['Merchant'])) ? $_GET['Merchant'] : ""; $this->data->orderID = (isset($_GET['OrderID'])) ? $_GET['OrderID'] : ""; $this->data->paymentID = (isset($_GET['PaymentID'])) ? $_GET['PaymentID'] : ""; $this->data->reference = (isset($_GET['Reference'])) ? $_GET['Reference'] : ""; $this->data->transactionID = (isset($_GET['TransactionID'])) ? $_GET['TransactionID'] : ""; $this->data->checksum = (isset($_GET['Checksum'])) ? $_GET['Checksum'] : ""; if ($this->generateChecksumForPage() != $this->data->checksum) { $this->_logger->log("Checksum does not match", Icepay_Api_Logger::ERROR); return false; } return true; }
[ "public", "function", "validate", "(", ")", "{", "if", "(", "$", "_SERVER", "[", "'REQUEST_METHOD'", "]", "!=", "'GET'", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Invalid request method\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "$", "this", "->", "_logger", "->", "log", "(", "sprintf", "(", "\"Page data: %s\"", ",", "serialize", "(", "$", "_GET", ")", ")", ",", "Icepay_Api_Logger", "::", "NOTICE", ")", ";", "$", "this", "->", "data", "->", "status", "=", "(", "isset", "(", "$", "_GET", "[", "'Status'", "]", ")", ")", "?", "$", "_GET", "[", "'Status'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "statusCode", "=", "(", "isset", "(", "$", "_GET", "[", "'StatusCode'", "]", ")", ")", "?", "$", "_GET", "[", "'StatusCode'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "merchant", "=", "(", "isset", "(", "$", "_GET", "[", "'Merchant'", "]", ")", ")", "?", "$", "_GET", "[", "'Merchant'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "orderID", "=", "(", "isset", "(", "$", "_GET", "[", "'OrderID'", "]", ")", ")", "?", "$", "_GET", "[", "'OrderID'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "paymentID", "=", "(", "isset", "(", "$", "_GET", "[", "'PaymentID'", "]", ")", ")", "?", "$", "_GET", "[", "'PaymentID'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "reference", "=", "(", "isset", "(", "$", "_GET", "[", "'Reference'", "]", ")", ")", "?", "$", "_GET", "[", "'Reference'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "transactionID", "=", "(", "isset", "(", "$", "_GET", "[", "'TransactionID'", "]", ")", ")", "?", "$", "_GET", "[", "'TransactionID'", "]", ":", "\"\"", ";", "$", "this", "->", "data", "->", "checksum", "=", "(", "isset", "(", "$", "_GET", "[", "'Checksum'", "]", ")", ")", "?", "$", "_GET", "[", "'Checksum'", "]", ":", "\"\"", ";", "if", "(", "$", "this", "->", "generateChecksumForPage", "(", ")", "!=", "$", "this", "->", "data", "->", "checksum", ")", "{", "$", "this", "->", "_logger", "->", "log", "(", "\"Checksum does not match\"", ",", "Icepay_Api_Logger", "::", "ERROR", ")", ";", "return", "false", ";", "}", "return", "true", ";", "}" ]
Validate the ICEPAY GET data @since version 1.0.0 @access public @return boolean
[ "Validate", "the", "ICEPAY", "GET", "data" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1479-L1503
30,558
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Result.getStatus
public function getStatus($includeStatusCode = false) { if (!isset($this->data->status)) return null; return ($includeStatusCode) ? sprintf("%s: %s", $this->data->status, $this->data->statusCode) : $this->data->status; }
php
public function getStatus($includeStatusCode = false) { if (!isset($this->data->status)) return null; return ($includeStatusCode) ? sprintf("%s: %s", $this->data->status, $this->data->statusCode) : $this->data->status; }
[ "public", "function", "getStatus", "(", "$", "includeStatusCode", "=", "false", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "data", "->", "status", ")", ")", "return", "null", ";", "return", "(", "$", "includeStatusCode", ")", "?", "sprintf", "(", "\"%s: %s\"", ",", "$", "this", "->", "data", "->", "status", ",", "$", "this", "->", "data", "->", "statusCode", ")", ":", "$", "this", "->", "data", "->", "status", ";", "}" ]
Get the ICEPAY status @since version 1.0.0 @access public @param boolean $includeStatusCode Add the statuscode message to the returned string for display purposes @return string ICEPAY statuscode (and statuscode message)
[ "Get", "the", "ICEPAY", "status" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1512-L1517
30,559
ICEPAY/deprecated-i
src/icepay_api_base.php
Icepay_Result.generateChecksumForPage
protected function generateChecksumForPage() { return sha1( sprintf("%s|%s|%s|%s|%s|%s|%s|%s", $this->_secretCode, $this->data->merchant, $this->data->status, $this->data->statusCode, $this->data->orderID, $this->data->paymentID, $this->data->reference, $this->data->transactionID ) ); }
php
protected function generateChecksumForPage() { return sha1( sprintf("%s|%s|%s|%s|%s|%s|%s|%s", $this->_secretCode, $this->data->merchant, $this->data->status, $this->data->statusCode, $this->data->orderID, $this->data->paymentID, $this->data->reference, $this->data->transactionID ) ); }
[ "protected", "function", "generateChecksumForPage", "(", ")", "{", "return", "sha1", "(", "sprintf", "(", "\"%s|%s|%s|%s|%s|%s|%s|%s\"", ",", "$", "this", "->", "_secretCode", ",", "$", "this", "->", "data", "->", "merchant", ",", "$", "this", "->", "data", "->", "status", ",", "$", "this", "->", "data", "->", "statusCode", ",", "$", "this", "->", "data", "->", "orderID", ",", "$", "this", "->", "data", "->", "paymentID", ",", "$", "this", "->", "data", "->", "reference", ",", "$", "this", "->", "data", "->", "transactionID", ")", ")", ";", "}" ]
Return the result page checksum @since version 1.0.0 @access protected @return string SHA1 hash
[ "Return", "the", "result", "page", "checksum" ]
9a22271dfaea7f318a555c00d7e3f8cca9f2a28e
https://github.com/ICEPAY/deprecated-i/blob/9a22271dfaea7f318a555c00d7e3f8cca9f2a28e/src/icepay_api_base.php#L1536-L1542
30,560
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.addWarningMessages
public function addWarningMessages($message) { if (!empty($message)) { if (is_array($message)) { $this->warningMessages = array_merge($this->warningMessages, $message); } else { $this->warningMessages[] = $message; } } return $this; }
php
public function addWarningMessages($message) { if (!empty($message)) { if (is_array($message)) { $this->warningMessages = array_merge($this->warningMessages, $message); } else { $this->warningMessages[] = $message; } } return $this; }
[ "public", "function", "addWarningMessages", "(", "$", "message", ")", "{", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "if", "(", "is_array", "(", "$", "message", ")", ")", "{", "$", "this", "->", "warningMessages", "=", "array_merge", "(", "$", "this", "->", "warningMessages", ",", "$", "message", ")", ";", "}", "else", "{", "$", "this", "->", "warningMessages", "[", "]", "=", "$", "message", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds 1 or more warning messages. To be used by web shop specific form handling to add a message to the list of messages to display. @param string|string[] $message A warning message or an array of warning messages. If empty, nothing will be added. @return $this
[ "Adds", "1", "or", "more", "warning", "messages", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L232-L243
30,561
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.addErrorMessages
public function addErrorMessages($message) { if (!empty($message)) { if (is_array($message)) { $this->errorMessages = array_merge($this->errorMessages, $message); } else { $this->errorMessages[] = $message; } } return $this; }
php
public function addErrorMessages($message) { if (!empty($message)) { if (is_array($message)) { $this->errorMessages = array_merge($this->errorMessages, $message); } else { $this->errorMessages[] = $message; } } return $this; }
[ "public", "function", "addErrorMessages", "(", "$", "message", ")", "{", "if", "(", "!", "empty", "(", "$", "message", ")", ")", "{", "if", "(", "is_array", "(", "$", "message", ")", ")", "{", "$", "this", "->", "errorMessages", "=", "array_merge", "(", "$", "this", "->", "errorMessages", ",", "$", "message", ")", ";", "}", "else", "{", "$", "this", "->", "errorMessages", "[", "]", "=", "$", "message", ";", "}", "}", "return", "$", "this", ";", "}" ]
Adds 1 or more error messages. To be used by web shop specific form handling to add a message to the list of messages to display. @param string|string[] $message An error message or an array of error messages. If empty, nothing will be added. @return $this
[ "Adds", "1", "or", "more", "error", "messages", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L274-L285
30,562
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.setFormValues
protected function setFormValues() { if (!$this->formValuesSet) { // Start by assuring the field definitions are constructed. $this->getFields(); // 1: Hard coded default value for form fields: empty string. $this->formValues = array_fill_keys($this->getKeys(), ''); // 2: Overwrite with the default values from the field definitions, // but do so with some special array handling. $defaultFormValues = $this->getDefaultFormValues(); foreach ($defaultFormValues as $key => $defaultFormValue) { // We start with a simple overwrite. if (array_key_exists($key, $this->formValues)) { $this->formValues[$key] = $defaultFormValue; } elseif (is_array($defaultFormValue)) { // Distribute keyed arrays over separate values if existing. foreach ($defaultFormValue as $arrayKey => $arrayValue) { $fullKey = "{$key}[{$arrayKey}]"; if (array_key_exists($fullKey, $this->formValues)) { $this->formValues[$fullKey] = $arrayValue; } } } } // 3: Overwrite with the submitted values. if (!empty($this->submittedValues)) { $this->formValues = array_merge($this->formValues, $this->submittedValues); } // 4: Overwrite with the (hard set) values as set in the field // definitions. $this->formValues = array_merge($this->formValues, $this->getFieldValues($this->getFields())); // 5: Allow for any web shop specific processing of the values. // Known usages: // - Prepend (checked) checkboxes with their collection name // (PrestaShop). // - Place (checked) checkboxes in their collection (Magento). $this->formValues = $this->formHelper->alterFormValues($this->formValues); $this->formValuesSet = true; } }
php
protected function setFormValues() { if (!$this->formValuesSet) { // Start by assuring the field definitions are constructed. $this->getFields(); // 1: Hard coded default value for form fields: empty string. $this->formValues = array_fill_keys($this->getKeys(), ''); // 2: Overwrite with the default values from the field definitions, // but do so with some special array handling. $defaultFormValues = $this->getDefaultFormValues(); foreach ($defaultFormValues as $key => $defaultFormValue) { // We start with a simple overwrite. if (array_key_exists($key, $this->formValues)) { $this->formValues[$key] = $defaultFormValue; } elseif (is_array($defaultFormValue)) { // Distribute keyed arrays over separate values if existing. foreach ($defaultFormValue as $arrayKey => $arrayValue) { $fullKey = "{$key}[{$arrayKey}]"; if (array_key_exists($fullKey, $this->formValues)) { $this->formValues[$fullKey] = $arrayValue; } } } } // 3: Overwrite with the submitted values. if (!empty($this->submittedValues)) { $this->formValues = array_merge($this->formValues, $this->submittedValues); } // 4: Overwrite with the (hard set) values as set in the field // definitions. $this->formValues = array_merge($this->formValues, $this->getFieldValues($this->getFields())); // 5: Allow for any web shop specific processing of the values. // Known usages: // - Prepend (checked) checkboxes with their collection name // (PrestaShop). // - Place (checked) checkboxes in their collection (Magento). $this->formValues = $this->formHelper->alterFormValues($this->formValues); $this->formValuesSet = true; } }
[ "protected", "function", "setFormValues", "(", ")", "{", "if", "(", "!", "$", "this", "->", "formValuesSet", ")", "{", "// Start by assuring the field definitions are constructed.", "$", "this", "->", "getFields", "(", ")", ";", "// 1: Hard coded default value for form fields: empty string.", "$", "this", "->", "formValues", "=", "array_fill_keys", "(", "$", "this", "->", "getKeys", "(", ")", ",", "''", ")", ";", "// 2: Overwrite with the default values from the field definitions,", "// but do so with some special array handling.", "$", "defaultFormValues", "=", "$", "this", "->", "getDefaultFormValues", "(", ")", ";", "foreach", "(", "$", "defaultFormValues", "as", "$", "key", "=>", "$", "defaultFormValue", ")", "{", "// We start with a simple overwrite.", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "formValues", ")", ")", "{", "$", "this", "->", "formValues", "[", "$", "key", "]", "=", "$", "defaultFormValue", ";", "}", "elseif", "(", "is_array", "(", "$", "defaultFormValue", ")", ")", "{", "// Distribute keyed arrays over separate values if existing.", "foreach", "(", "$", "defaultFormValue", "as", "$", "arrayKey", "=>", "$", "arrayValue", ")", "{", "$", "fullKey", "=", "\"{$key}[{$arrayKey}]\"", ";", "if", "(", "array_key_exists", "(", "$", "fullKey", ",", "$", "this", "->", "formValues", ")", ")", "{", "$", "this", "->", "formValues", "[", "$", "fullKey", "]", "=", "$", "arrayValue", ";", "}", "}", "}", "}", "// 3: Overwrite with the submitted values.", "if", "(", "!", "empty", "(", "$", "this", "->", "submittedValues", ")", ")", "{", "$", "this", "->", "formValues", "=", "array_merge", "(", "$", "this", "->", "formValues", ",", "$", "this", "->", "submittedValues", ")", ";", "}", "// 4: Overwrite with the (hard set) values as set in the field", "// definitions.", "$", "this", "->", "formValues", "=", "array_merge", "(", "$", "this", "->", "formValues", ",", "$", "this", "->", "getFieldValues", "(", "$", "this", "->", "getFields", "(", ")", ")", ")", ";", "// 5: Allow for any web shop specific processing of the values.", "// Known usages:", "// - Prepend (checked) checkboxes with their collection name", "// (PrestaShop).", "// - Place (checked) checkboxes in their collection (Magento).", "$", "this", "->", "formValues", "=", "$", "this", "->", "formHelper", "->", "alterFormValues", "(", "$", "this", "->", "formValues", ")", ";", "$", "this", "->", "formValuesSet", "=", "true", ";", "}", "}" ]
Sets the form values to use. This is typically the union of the default values, any submitted values, and explicitly set field values.
[ "Sets", "the", "form", "values", "to", "use", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L313-L358
30,563
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.getFormValue
protected function getFormValue($name) { $this->setFormValues(); return isset($this->formValues[$name]) ? $this->formValues[$name] : ''; }
php
protected function getFormValue($name) { $this->setFormValues(); return isset($this->formValues[$name]) ? $this->formValues[$name] : ''; }
[ "protected", "function", "getFormValue", "(", "$", "name", ")", "{", "$", "this", "->", "setFormValues", "(", ")", ";", "return", "isset", "(", "$", "this", "->", "formValues", "[", "$", "name", "]", ")", "?", "$", "this", "->", "formValues", "[", "$", "name", "]", ":", "''", ";", "}" ]
Returns the value for a specific form field. @param string $name The name of the form field. @return string The value for this form field or the empty string if not set.
[ "Returns", "the", "value", "for", "a", "specific", "form", "field", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L385-L389
30,564
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.addValuesToFields
protected function addValuesToFields(array $fields) { foreach ($fields as $name => &$field) { if (!empty($field['fields'])) { $field['fields'] = $this->addValuesToFields($field['fields']); } elseif ($field['type'] === 'checkbox') { // Value is a list of checked options. $value = array(); foreach ($field['options'] as $optionName => $optionLabel) { if ($this->getFormValue($optionName)) { $value[] = $optionName; } } $field['value'] = $value; } elseif (!isset($field['value'])) { // Explicitly set values (in the 'value' key) take precedence // over submitted values, which in turn take precedence over // default values (gathered via getDefaultFormValues()). $field['value'] = $this->getFormValue($name); } } return $fields; }
php
protected function addValuesToFields(array $fields) { foreach ($fields as $name => &$field) { if (!empty($field['fields'])) { $field['fields'] = $this->addValuesToFields($field['fields']); } elseif ($field['type'] === 'checkbox') { // Value is a list of checked options. $value = array(); foreach ($field['options'] as $optionName => $optionLabel) { if ($this->getFormValue($optionName)) { $value[] = $optionName; } } $field['value'] = $value; } elseif (!isset($field['value'])) { // Explicitly set values (in the 'value' key) take precedence // over submitted values, which in turn take precedence over // default values (gathered via getDefaultFormValues()). $field['value'] = $this->getFormValue($name); } } return $fields; }
[ "protected", "function", "addValuesToFields", "(", "array", "$", "fields", ")", "{", "foreach", "(", "$", "fields", "as", "$", "name", "=>", "&", "$", "field", ")", "{", "if", "(", "!", "empty", "(", "$", "field", "[", "'fields'", "]", ")", ")", "{", "$", "field", "[", "'fields'", "]", "=", "$", "this", "->", "addValuesToFields", "(", "$", "field", "[", "'fields'", "]", ")", ";", "}", "elseif", "(", "$", "field", "[", "'type'", "]", "===", "'checkbox'", ")", "{", "// Value is a list of checked options.", "$", "value", "=", "array", "(", ")", ";", "foreach", "(", "$", "field", "[", "'options'", "]", "as", "$", "optionName", "=>", "$", "optionLabel", ")", "{", "if", "(", "$", "this", "->", "getFormValue", "(", "$", "optionName", ")", ")", "{", "$", "value", "[", "]", "=", "$", "optionName", ";", "}", "}", "$", "field", "[", "'value'", "]", "=", "$", "value", ";", "}", "elseif", "(", "!", "isset", "(", "$", "field", "[", "'value'", "]", ")", ")", "{", "// Explicitly set values (in the 'value' key) take precedence", "// over submitted values, which in turn take precedence over", "// default values (gathered via getDefaultFormValues()).", "$", "field", "[", "'value'", "]", "=", "$", "this", "->", "getFormValue", "(", "$", "name", ")", ";", "}", "}", "return", "$", "fields", ";", "}" ]
Adds the form values to the field definitions. This internal version of addValues() passes the fields as a parameter to allow to recursively process field sets. @param array[] $fields @return array[]
[ "Adds", "the", "form", "values", "to", "the", "field", "definitions", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L427-L449
30,565
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.getFieldValues
protected function getFieldValues($fields) { $result = array(); foreach ($fields as $id => $field) { if (isset($field['value'])) { $result[$id] = $field['value']; } if (!empty($field['fields'])) { /** @noinspection SlowArrayOperationsInLoopInspection */ $result = array_merge($result, $this->getFieldValues($field['fields'])); } } return $result; }
php
protected function getFieldValues($fields) { $result = array(); foreach ($fields as $id => $field) { if (isset($field['value'])) { $result[$id] = $field['value']; } if (!empty($field['fields'])) { /** @noinspection SlowArrayOperationsInLoopInspection */ $result = array_merge($result, $this->getFieldValues($field['fields'])); } } return $result; }
[ "protected", "function", "getFieldValues", "(", "$", "fields", ")", "{", "$", "result", "=", "array", "(", ")", ";", "foreach", "(", "$", "fields", "as", "$", "id", "=>", "$", "field", ")", "{", "if", "(", "isset", "(", "$", "field", "[", "'value'", "]", ")", ")", "{", "$", "result", "[", "$", "id", "]", "=", "$", "field", "[", "'value'", "]", ";", "}", "if", "(", "!", "empty", "(", "$", "field", "[", "'fields'", "]", ")", ")", "{", "/** @noinspection SlowArrayOperationsInLoopInspection */", "$", "result", "=", "array_merge", "(", "$", "result", ",", "$", "this", "->", "getFieldValues", "(", "$", "field", "[", "'fields'", "]", ")", ")", ";", "}", "}", "return", "$", "result", ";", "}" ]
Returns the set of values directly assigned to the field definitions. These take precedence over default values @param array[] $fields @return array An array of values keyed by the form field names. An array of values keyed by the form field names.
[ "Returns", "the", "set", "of", "values", "directly", "assigned", "to", "the", "field", "definitions", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L475-L488
30,566
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.getSubmittedValue
protected function getSubmittedValue($name, $default = null) { if (empty($this->submittedValues)) { $this->setSubmittedValues(); } return array_key_exists($name, $this->submittedValues) ? $this->submittedValues[$name] : $default; }
php
protected function getSubmittedValue($name, $default = null) { if (empty($this->submittedValues)) { $this->setSubmittedValues(); } return array_key_exists($name, $this->submittedValues) ? $this->submittedValues[$name] : $default; }
[ "protected", "function", "getSubmittedValue", "(", "$", "name", ",", "$", "default", "=", "null", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "submittedValues", ")", ")", "{", "$", "this", "->", "setSubmittedValues", "(", ")", ";", "}", "return", "array_key_exists", "(", "$", "name", ",", "$", "this", "->", "submittedValues", ")", "?", "$", "this", "->", "submittedValues", "[", "$", "name", "]", ":", "$", "default", ";", "}" ]
Returns a submitted value. @param string $name The name of the value to return @param string|null $default The default to return when this value was not submitted. @return string|null The submitted value, or the default if the value was not submitted.
[ "Returns", "a", "submitted", "value", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L512-L518
30,567
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.getFields
public function getFields() { if (empty($this->fields)) { $this->fields = $this->getFieldDefinitions(); $this->fields = $this->formHelper->addMetaField($this->fields); } return $this->fields; }
php
public function getFields() { if (empty($this->fields)) { $this->fields = $this->getFieldDefinitions(); $this->fields = $this->formHelper->addMetaField($this->fields); } return $this->fields; }
[ "public", "function", "getFields", "(", ")", "{", "if", "(", "empty", "(", "$", "this", "->", "fields", ")", ")", "{", "$", "this", "->", "fields", "=", "$", "this", "->", "getFieldDefinitions", "(", ")", ";", "$", "this", "->", "fields", "=", "$", "this", "->", "formHelper", "->", "addMetaField", "(", "$", "this", "->", "fields", ")", ";", "}", "return", "$", "this", "->", "fields", ";", "}" ]
Returns a definition of the form fields. This should NOT include any: - Submit or cancel buttons. These are often added by the webshop software in their specific way. - Tokens, form-id's or other (hidden) fields used by the webshop software to protect against certain attacks or to facilitate internal form processing. This is a recursive, keyed array defining each form field. The key defines the name of the form field, to be used for the name, and possibly id, attribute. The values are a keyed array, that can have the following keys: - type: (required, string) fieldset, details, text, email, password, date, textarea, select, radio, checkbox, markup. - legend/summary: (string) human readable title for a fieldset/details. - label: (string) human readable label, legend or summary. - description: (string) human readable help text. - value: (string) the value for the form field. - attributes: (array) keyed array with other, possibly html5, attributes to be rendered. Possible keys include e.g: - size - class - required: (bool) whether the field is required. - fields: (array) If the type = 'fieldset' or 'details', this value defines the (possibly recursive) fields of a fieldset/details element. - options: (array) If the type = checkbox, select or radio, this value contains the options as a keyed array, the keys being the value to submit if that choice is selected and the value being the label to show. Do NOT override this method, instead override getFieldDefinitions(). @return array[] The definition of the form.
[ "Returns", "a", "definition", "of", "the", "form", "fields", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L625-L632
30,568
SIELOnline/libAcumulus
src/Helpers/Form.php
Form.addIfIsset
protected function addIfIsset(array &$target, $key, array $source) { if (isset($source[$key])) { $target[$key] = $source[$key]; return true; } return false; }
php
protected function addIfIsset(array &$target, $key, array $source) { if (isset($source[$key])) { $target[$key] = $source[$key]; return true; } return false; }
[ "protected", "function", "addIfIsset", "(", "array", "&", "$", "target", ",", "$", "key", ",", "array", "$", "source", ")", "{", "if", "(", "isset", "(", "$", "source", "[", "$", "key", "]", ")", ")", "{", "$", "target", "[", "$", "key", "]", "=", "$", "source", "[", "$", "key", "]", ";", "return", "true", ";", "}", "return", "false", ";", "}" ]
Helper method to copy a value from one array to another array. @param array $target @param string $key @param array $source @return bool True if the value is set and has been copied, false otherwise.
[ "Helper", "method", "to", "copy", "a", "value", "from", "one", "array", "to", "another", "array", "." ]
82f8d6c9c4929c41948c97d6cfdfac3f27c37255
https://github.com/SIELOnline/libAcumulus/blob/82f8d6c9c4929c41948c97d6cfdfac3f27c37255/src/Helpers/Form.php#L709-L716
30,569
php-cache/cache
src/Encryption/EncryptedItemDecorator.php
EncryptedItemDecorator.transform
private function transform(array $item) { $value = static::jsonDeArmor($item['value']); if ($item['type'] === 'object' || $item['type'] === 'array') { return unserialize($value); } settype($value, $item['type']); return $value; }
php
private function transform(array $item) { $value = static::jsonDeArmor($item['value']); if ($item['type'] === 'object' || $item['type'] === 'array') { return unserialize($value); } settype($value, $item['type']); return $value; }
[ "private", "function", "transform", "(", "array", "$", "item", ")", "{", "$", "value", "=", "static", "::", "jsonDeArmor", "(", "$", "item", "[", "'value'", "]", ")", ";", "if", "(", "$", "item", "[", "'type'", "]", "===", "'object'", "||", "$", "item", "[", "'type'", "]", "===", "'array'", ")", "{", "return", "unserialize", "(", "$", "value", ")", ";", "}", "settype", "(", "$", "value", ",", "$", "item", "[", "'type'", "]", ")", ";", "return", "$", "value", ";", "}" ]
Transform value back to it original type. @param array $item @return mixed
[ "Transform", "value", "back", "to", "it", "original", "type", "." ]
5f7543f58b43714d708b67b233869e4b2ecae9c8
https://github.com/php-cache/cache/blob/5f7543f58b43714d708b67b233869e4b2ecae9c8/src/Encryption/EncryptedItemDecorator.php#L159-L170
30,570
php-cache/cache
src/Adapter/Redis/RedisCachePool.php
RedisCachePool.clearAllObjectsFromCacheCluster
protected function clearAllObjectsFromCacheCluster() { $nodes = $this->cache->_masters(); foreach ($nodes as $node) { if (!$this->cache->flushDB($node)) { return false; } } return true; }
php
protected function clearAllObjectsFromCacheCluster() { $nodes = $this->cache->_masters(); foreach ($nodes as $node) { if (!$this->cache->flushDB($node)) { return false; } } return true; }
[ "protected", "function", "clearAllObjectsFromCacheCluster", "(", ")", "{", "$", "nodes", "=", "$", "this", "->", "cache", "->", "_masters", "(", ")", ";", "foreach", "(", "$", "nodes", "as", "$", "node", ")", "{", "if", "(", "!", "$", "this", "->", "cache", "->", "flushDB", "(", "$", "node", ")", ")", "{", "return", "false", ";", "}", "}", "return", "true", ";", "}" ]
Clear all objects from all nodes in the cluster. @return bool false if error
[ "Clear", "all", "objects", "from", "all", "nodes", "in", "the", "cluster", "." ]
5f7543f58b43714d708b67b233869e4b2ecae9c8
https://github.com/php-cache/cache/blob/5f7543f58b43714d708b67b233869e4b2ecae9c8/src/Adapter/Redis/RedisCachePool.php#L93-L104
30,571
php-cache/cache
src/Adapter/PHPArray/ArrayCachePool.php
ArrayCachePool.cacheToolkit
private function cacheToolkit($keys, $value = null, $unset = false) { $element = &$this->cache; while ($keys && ($key = array_shift($keys))) { if (!$keys && is_null($value) && $unset) { unset($element[$key]); unset($element); $element = null; } else { $element =&$element[$key]; } } if (!$unset && !is_null($value)) { $element = $value; } return $element; }
php
private function cacheToolkit($keys, $value = null, $unset = false) { $element = &$this->cache; while ($keys && ($key = array_shift($keys))) { if (!$keys && is_null($value) && $unset) { unset($element[$key]); unset($element); $element = null; } else { $element =&$element[$key]; } } if (!$unset && !is_null($value)) { $element = $value; } return $element; }
[ "private", "function", "cacheToolkit", "(", "$", "keys", ",", "$", "value", "=", "null", ",", "$", "unset", "=", "false", ")", "{", "$", "element", "=", "&", "$", "this", "->", "cache", ";", "while", "(", "$", "keys", "&&", "(", "$", "key", "=", "array_shift", "(", "$", "keys", ")", ")", ")", "{", "if", "(", "!", "$", "keys", "&&", "is_null", "(", "$", "value", ")", "&&", "$", "unset", ")", "{", "unset", "(", "$", "element", "[", "$", "key", "]", ")", ";", "unset", "(", "$", "element", ")", ";", "$", "element", "=", "null", ";", "}", "else", "{", "$", "element", "=", "&", "$", "element", "[", "$", "key", "]", ";", "}", "}", "if", "(", "!", "$", "unset", "&&", "!", "is_null", "(", "$", "value", ")", ")", "{", "$", "element", "=", "$", "value", ";", "}", "return", "$", "element", ";", "}" ]
Used to manipulate cached data by extracting, inserting or deleting value. @param array $keys @param null|mixed $value @param bool $unset @return mixed
[ "Used", "to", "manipulate", "cached", "data", "by", "extracting", "inserting", "or", "deleting", "value", "." ]
5f7543f58b43714d708b67b233869e4b2ecae9c8
https://github.com/php-cache/cache/blob/5f7543f58b43714d708b67b233869e4b2ecae9c8/src/Adapter/PHPArray/ArrayCachePool.php#L211-L230
30,572
php-cache/cache
src/Adapter/PHPArray/ArrayCachePool.php
ArrayCachePool.cacheIsset
private function cacheIsset($keys) { $has = false; $array = $this->cache; foreach ($keys as $key) { if ($has = array_key_exists($key, $array)) { $array = $array[$key]; } } if (is_array($array)) { $has = $has && array_key_exists(0, $array); } return $has; }
php
private function cacheIsset($keys) { $has = false; $array = $this->cache; foreach ($keys as $key) { if ($has = array_key_exists($key, $array)) { $array = $array[$key]; } } if (is_array($array)) { $has = $has && array_key_exists(0, $array); } return $has; }
[ "private", "function", "cacheIsset", "(", "$", "keys", ")", "{", "$", "has", "=", "false", ";", "$", "array", "=", "$", "this", "->", "cache", ";", "foreach", "(", "$", "keys", "as", "$", "key", ")", "{", "if", "(", "$", "has", "=", "array_key_exists", "(", "$", "key", ",", "$", "array", ")", ")", "{", "$", "array", "=", "$", "array", "[", "$", "key", "]", ";", "}", "}", "if", "(", "is_array", "(", "$", "array", ")", ")", "{", "$", "has", "=", "$", "has", "&&", "array_key_exists", "(", "0", ",", "$", "array", ")", ";", "}", "return", "$", "has", ";", "}" ]
Checking if given keys exists and is valid. @param array $keys @return bool
[ "Checking", "if", "given", "keys", "exists", "and", "is", "valid", "." ]
5f7543f58b43714d708b67b233869e4b2ecae9c8
https://github.com/php-cache/cache/blob/5f7543f58b43714d708b67b233869e4b2ecae9c8/src/Adapter/PHPArray/ArrayCachePool.php#L239-L255
30,573
irazasyed/laravel-gamp
src/LaravelGAMPServiceProvider.php
LaravelGAMPServiceProvider.registerAnalytics
protected function registerAnalytics(Application $app) { $app->singleton('gamp', function ($app) { $config = $app['config']; $analytics = new Analytics($config->get('gamp.is_ssl', false), $config->get('gamp.is_disabled', false)); $analytics->setProtocolVersion($config->get('gamp.protocol_version', 1)) ->setTrackingId($config->get('gamp.tracking_id')); if ($config->get('gamp.anonymize_ip', false)) { $analytics->setAnonymizeIp('1'); } if ($config->get('gamp.async_requests', false)) { $analytics->setAsyncRequest(true); } return $analytics; }); $app->alias('gamp', Analytics::class); }
php
protected function registerAnalytics(Application $app) { $app->singleton('gamp', function ($app) { $config = $app['config']; $analytics = new Analytics($config->get('gamp.is_ssl', false), $config->get('gamp.is_disabled', false)); $analytics->setProtocolVersion($config->get('gamp.protocol_version', 1)) ->setTrackingId($config->get('gamp.tracking_id')); if ($config->get('gamp.anonymize_ip', false)) { $analytics->setAnonymizeIp('1'); } if ($config->get('gamp.async_requests', false)) { $analytics->setAsyncRequest(true); } return $analytics; }); $app->alias('gamp', Analytics::class); }
[ "protected", "function", "registerAnalytics", "(", "Application", "$", "app", ")", "{", "$", "app", "->", "singleton", "(", "'gamp'", ",", "function", "(", "$", "app", ")", "{", "$", "config", "=", "$", "app", "[", "'config'", "]", ";", "$", "analytics", "=", "new", "Analytics", "(", "$", "config", "->", "get", "(", "'gamp.is_ssl'", ",", "false", ")", ",", "$", "config", "->", "get", "(", "'gamp.is_disabled'", ",", "false", ")", ")", ";", "$", "analytics", "->", "setProtocolVersion", "(", "$", "config", "->", "get", "(", "'gamp.protocol_version'", ",", "1", ")", ")", "->", "setTrackingId", "(", "$", "config", "->", "get", "(", "'gamp.tracking_id'", ")", ")", ";", "if", "(", "$", "config", "->", "get", "(", "'gamp.anonymize_ip'", ",", "false", ")", ")", "{", "$", "analytics", "->", "setAnonymizeIp", "(", "'1'", ")", ";", "}", "if", "(", "$", "config", "->", "get", "(", "'gamp.async_requests'", ",", "false", ")", ")", "{", "$", "analytics", "->", "setAsyncRequest", "(", "true", ")", ";", "}", "return", "$", "analytics", ";", "}", ")", ";", "$", "app", "->", "alias", "(", "'gamp'", ",", "Analytics", "::", "class", ")", ";", "}" ]
Initialize Analytics Library with Default Config. @param \Illuminate\Contracts\Container\Container $app
[ "Initialize", "Analytics", "Library", "with", "Default", "Config", "." ]
d935785977bc04930ea58cceb4f023bf36ecae71
https://github.com/irazasyed/laravel-gamp/blob/d935785977bc04930ea58cceb4f023bf36ecae71/src/LaravelGAMPServiceProvider.php#L59-L81
30,574
dpods/plaid-api-php-client
src/Api/AssetReport.php
AssetReport.create
public function create($accessTokens, $daysRequested, $options = []) { return $this->client()->post('/asset_report/create', [ 'access_tokens' => $accessTokens, 'days_requested' => $daysRequested, 'options' => $options, ]); }
php
public function create($accessTokens, $daysRequested, $options = []) { return $this->client()->post('/asset_report/create', [ 'access_tokens' => $accessTokens, 'days_requested' => $daysRequested, 'options' => $options, ]); }
[ "public", "function", "create", "(", "$", "accessTokens", ",", "$", "daysRequested", ",", "$", "options", "=", "[", "]", ")", "{", "return", "$", "this", "->", "client", "(", ")", "->", "post", "(", "'/asset_report/create'", ",", "[", "'access_tokens'", "=>", "$", "accessTokens", ",", "'days_requested'", "=>", "$", "daysRequested", ",", "'options'", "=>", "$", "options", ",", "]", ")", ";", "}" ]
Creates an Asset Report with all accounts linked to each Item associated with passed accessTokens. @link https://plaid.com/docs/#create-asset-report-request @param array $accessTokens An array of access tokens, one token for each Item to be included in the Asset Report. @param int $daysRequested Days of transaction history requested to be included in the Asset Report. @param object $options Optional. See docs for list of options.
[ "Creates", "an", "Asset", "Report", "with", "all", "accounts", "linked", "to", "each", "Item", "associated", "with", "passed", "accessTokens", "." ]
1c3da929ef87ef96914bd554567510bd32bc6f1d
https://github.com/dpods/plaid-api-php-client/blob/1c3da929ef87ef96914bd554567510bd32bc6f1d/src/Api/AssetReport.php#L19-L26
30,575
dpods/plaid-api-php-client
src/Api/AssetReport.php
AssetReport.refresh
public function refresh($assetReportToken, $daysRequested = null, $options = []) { $data = ['asset_report_token' => $assetReportToken]; if (!is_null($daysRequested)) { $data['days_requested'] = $daysRequested; } if (!empty($options)) { $data['options'] = $options; } return $this->client()->post('/asset_report/refresh', $data); }
php
public function refresh($assetReportToken, $daysRequested = null, $options = []) { $data = ['asset_report_token' => $assetReportToken]; if (!is_null($daysRequested)) { $data['days_requested'] = $daysRequested; } if (!empty($options)) { $data['options'] = $options; } return $this->client()->post('/asset_report/refresh', $data); }
[ "public", "function", "refresh", "(", "$", "assetReportToken", ",", "$", "daysRequested", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'asset_report_token'", "=>", "$", "assetReportToken", "]", ";", "if", "(", "!", "is_null", "(", "$", "daysRequested", ")", ")", "{", "$", "data", "[", "'days_requested'", "]", "=", "$", "daysRequested", ";", "}", "if", "(", "!", "empty", "(", "$", "options", ")", ")", "{", "$", "data", "[", "'options'", "]", "=", "$", "options", ";", "}", "return", "$", "this", "->", "client", "(", ")", "->", "post", "(", "'/asset_report/refresh'", ",", "$", "data", ")", ";", "}" ]
Refresh a previously created Asset Report. @link https://plaid.com/docs/#refreshing-an-asset-report @param string $assetReportToken The token returned in create or filter response. @param int $daysRequested Override the days_requested on previously created/filtered report. @param array $options Override the options array on previously created/filtered report.
[ "Refresh", "a", "previously", "created", "Asset", "Report", "." ]
1c3da929ef87ef96914bd554567510bd32bc6f1d
https://github.com/dpods/plaid-api-php-client/blob/1c3da929ef87ef96914bd554567510bd32bc6f1d/src/Api/AssetReport.php#L93-L106
30,576
Sibyx/phpGPX
src/phpGPX/Models/Stats.php
Stats.reset
public function reset() { $this->distance = null; $this->averageSpeed = null; $this->averagePace = null; $this->minAltitude = null; $this->maxAltitude = null; $this->cumulativeElevationGain = null; $this->cumulativeElevationLoss = null; $this->startedAt = null; $this->finishedAt = null; }
php
public function reset() { $this->distance = null; $this->averageSpeed = null; $this->averagePace = null; $this->minAltitude = null; $this->maxAltitude = null; $this->cumulativeElevationGain = null; $this->cumulativeElevationLoss = null; $this->startedAt = null; $this->finishedAt = null; }
[ "public", "function", "reset", "(", ")", "{", "$", "this", "->", "distance", "=", "null", ";", "$", "this", "->", "averageSpeed", "=", "null", ";", "$", "this", "->", "averagePace", "=", "null", ";", "$", "this", "->", "minAltitude", "=", "null", ";", "$", "this", "->", "maxAltitude", "=", "null", ";", "$", "this", "->", "cumulativeElevationGain", "=", "null", ";", "$", "this", "->", "cumulativeElevationLoss", "=", "null", ";", "$", "this", "->", "startedAt", "=", "null", ";", "$", "this", "->", "finishedAt", "=", "null", ";", "}" ]
Reset all stats
[ "Reset", "all", "stats" ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/Models/Stats.php#L82-L93
30,577
Sibyx/phpGPX
src/phpGPX/phpGPX.php
phpGPX.parse
public static function parse($xml) { $xml = simplexml_load_string($xml); $gpx = new GpxFile(); // Parse creator $gpx->creator = isset($xml['creator']) ? (string)$xml['creator'] : null; // Parse metadata $gpx->metadata = isset($xml->metadata) ? MetadataParser::parse($xml->metadata) : null; // Parse waypoints $gpx->waypoints = isset($xml->wpt) ? WaypointParser::parse($xml->wpt) : []; // Parse tracks $gpx->tracks = isset($xml->trk) ? TrackParser::parse($xml->trk) : []; // Parse routes $gpx->routes = isset($xml->rte) ? RouteParser::parse($xml->rte) : []; return $gpx; }
php
public static function parse($xml) { $xml = simplexml_load_string($xml); $gpx = new GpxFile(); // Parse creator $gpx->creator = isset($xml['creator']) ? (string)$xml['creator'] : null; // Parse metadata $gpx->metadata = isset($xml->metadata) ? MetadataParser::parse($xml->metadata) : null; // Parse waypoints $gpx->waypoints = isset($xml->wpt) ? WaypointParser::parse($xml->wpt) : []; // Parse tracks $gpx->tracks = isset($xml->trk) ? TrackParser::parse($xml->trk) : []; // Parse routes $gpx->routes = isset($xml->rte) ? RouteParser::parse($xml->rte) : []; return $gpx; }
[ "public", "static", "function", "parse", "(", "$", "xml", ")", "{", "$", "xml", "=", "simplexml_load_string", "(", "$", "xml", ")", ";", "$", "gpx", "=", "new", "GpxFile", "(", ")", ";", "// Parse creator", "$", "gpx", "->", "creator", "=", "isset", "(", "$", "xml", "[", "'creator'", "]", ")", "?", "(", "string", ")", "$", "xml", "[", "'creator'", "]", ":", "null", ";", "// Parse metadata", "$", "gpx", "->", "metadata", "=", "isset", "(", "$", "xml", "->", "metadata", ")", "?", "MetadataParser", "::", "parse", "(", "$", "xml", "->", "metadata", ")", ":", "null", ";", "// Parse waypoints", "$", "gpx", "->", "waypoints", "=", "isset", "(", "$", "xml", "->", "wpt", ")", "?", "WaypointParser", "::", "parse", "(", "$", "xml", "->", "wpt", ")", ":", "[", "]", ";", "// Parse tracks", "$", "gpx", "->", "tracks", "=", "isset", "(", "$", "xml", "->", "trk", ")", "?", "TrackParser", "::", "parse", "(", "$", "xml", "->", "trk", ")", ":", "[", "]", ";", "// Parse routes", "$", "gpx", "->", "routes", "=", "isset", "(", "$", "xml", "->", "rte", ")", "?", "RouteParser", "::", "parse", "(", "$", "xml", "->", "rte", ")", ":", "[", "]", ";", "return", "$", "gpx", ";", "}" ]
Parse GPX data string. @param $xml @return GpxFile
[ "Parse", "GPX", "data", "string", "." ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/phpGPX.php#L112-L134
30,578
Sibyx/phpGPX
src/phpGPX/Models/GpxFile.php
GpxFile.toXML
public function toXML() { $document = new \DOMDocument("1.0", 'UTF-8'); $gpx = $document->createElementNS("http://www.topografix.com/GPX/1/1", "gpx"); $gpx->setAttribute("version", "1.1"); $gpx->setAttribute("creator", $this->creator ? $this->creator : phpGPX::getSignature()); ExtensionParser::$usedNamespaces = []; if (!empty($this->metadata)) { $gpx->appendChild(MetadataParser::toXML($this->metadata, $document)); } foreach ($this->waypoints as $waypoint) { $gpx->appendChild(PointParser::toXML($waypoint, $document)); } foreach ($this->routes as $route) { $gpx->appendChild(RouteParser::toXML($route, $document)); } foreach ($this->tracks as $track) { $gpx->appendChild(TrackParser::toXML($track, $document)); } if (!empty($this->extensions)) { $gpx->appendChild(ExtensionParser::toXML($this->extensions, $document)); } // Namespaces $schemaLocationArray = [ 'http://www.topografix.com/GPX/1/1', 'http://www.topografix.com/GPX/1/1/gpx.xsd' ]; foreach (ExtensionParser::$usedNamespaces as $usedNamespace) { $gpx->setAttributeNS( "http://www.w3.org/2000/xmlns/", sprintf("xmlns:%s", $usedNamespace['prefix']), $usedNamespace['namespace'] ); $schemaLocationArray[] = $usedNamespace['namespace']; $schemaLocationArray[] = $usedNamespace['xsd']; } $gpx->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', implode(" ", $schemaLocationArray) ); $document->appendChild($gpx); if (phpGPX::$PRETTY_PRINT) { $document->formatOutput = true; $document->preserveWhiteSpace = true; } return $document; }
php
public function toXML() { $document = new \DOMDocument("1.0", 'UTF-8'); $gpx = $document->createElementNS("http://www.topografix.com/GPX/1/1", "gpx"); $gpx->setAttribute("version", "1.1"); $gpx->setAttribute("creator", $this->creator ? $this->creator : phpGPX::getSignature()); ExtensionParser::$usedNamespaces = []; if (!empty($this->metadata)) { $gpx->appendChild(MetadataParser::toXML($this->metadata, $document)); } foreach ($this->waypoints as $waypoint) { $gpx->appendChild(PointParser::toXML($waypoint, $document)); } foreach ($this->routes as $route) { $gpx->appendChild(RouteParser::toXML($route, $document)); } foreach ($this->tracks as $track) { $gpx->appendChild(TrackParser::toXML($track, $document)); } if (!empty($this->extensions)) { $gpx->appendChild(ExtensionParser::toXML($this->extensions, $document)); } // Namespaces $schemaLocationArray = [ 'http://www.topografix.com/GPX/1/1', 'http://www.topografix.com/GPX/1/1/gpx.xsd' ]; foreach (ExtensionParser::$usedNamespaces as $usedNamespace) { $gpx->setAttributeNS( "http://www.w3.org/2000/xmlns/", sprintf("xmlns:%s", $usedNamespace['prefix']), $usedNamespace['namespace'] ); $schemaLocationArray[] = $usedNamespace['namespace']; $schemaLocationArray[] = $usedNamespace['xsd']; } $gpx->setAttributeNS( 'http://www.w3.org/2001/XMLSchema-instance', 'xsi:schemaLocation', implode(" ", $schemaLocationArray) ); $document->appendChild($gpx); if (phpGPX::$PRETTY_PRINT) { $document->formatOutput = true; $document->preserveWhiteSpace = true; } return $document; }
[ "public", "function", "toXML", "(", ")", "{", "$", "document", "=", "new", "\\", "DOMDocument", "(", "\"1.0\"", ",", "'UTF-8'", ")", ";", "$", "gpx", "=", "$", "document", "->", "createElementNS", "(", "\"http://www.topografix.com/GPX/1/1\"", ",", "\"gpx\"", ")", ";", "$", "gpx", "->", "setAttribute", "(", "\"version\"", ",", "\"1.1\"", ")", ";", "$", "gpx", "->", "setAttribute", "(", "\"creator\"", ",", "$", "this", "->", "creator", "?", "$", "this", "->", "creator", ":", "phpGPX", "::", "getSignature", "(", ")", ")", ";", "ExtensionParser", "::", "$", "usedNamespaces", "=", "[", "]", ";", "if", "(", "!", "empty", "(", "$", "this", "->", "metadata", ")", ")", "{", "$", "gpx", "->", "appendChild", "(", "MetadataParser", "::", "toXML", "(", "$", "this", "->", "metadata", ",", "$", "document", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "waypoints", "as", "$", "waypoint", ")", "{", "$", "gpx", "->", "appendChild", "(", "PointParser", "::", "toXML", "(", "$", "waypoint", ",", "$", "document", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "routes", "as", "$", "route", ")", "{", "$", "gpx", "->", "appendChild", "(", "RouteParser", "::", "toXML", "(", "$", "route", ",", "$", "document", ")", ")", ";", "}", "foreach", "(", "$", "this", "->", "tracks", "as", "$", "track", ")", "{", "$", "gpx", "->", "appendChild", "(", "TrackParser", "::", "toXML", "(", "$", "track", ",", "$", "document", ")", ")", ";", "}", "if", "(", "!", "empty", "(", "$", "this", "->", "extensions", ")", ")", "{", "$", "gpx", "->", "appendChild", "(", "ExtensionParser", "::", "toXML", "(", "$", "this", "->", "extensions", ",", "$", "document", ")", ")", ";", "}", "// Namespaces", "$", "schemaLocationArray", "=", "[", "'http://www.topografix.com/GPX/1/1'", ",", "'http://www.topografix.com/GPX/1/1/gpx.xsd'", "]", ";", "foreach", "(", "ExtensionParser", "::", "$", "usedNamespaces", "as", "$", "usedNamespace", ")", "{", "$", "gpx", "->", "setAttributeNS", "(", "\"http://www.w3.org/2000/xmlns/\"", ",", "sprintf", "(", "\"xmlns:%s\"", ",", "$", "usedNamespace", "[", "'prefix'", "]", ")", ",", "$", "usedNamespace", "[", "'namespace'", "]", ")", ";", "$", "schemaLocationArray", "[", "]", "=", "$", "usedNamespace", "[", "'namespace'", "]", ";", "$", "schemaLocationArray", "[", "]", "=", "$", "usedNamespace", "[", "'xsd'", "]", ";", "}", "$", "gpx", "->", "setAttributeNS", "(", "'http://www.w3.org/2001/XMLSchema-instance'", ",", "'xsi:schemaLocation'", ",", "implode", "(", "\" \"", ",", "$", "schemaLocationArray", ")", ")", ";", "$", "document", "->", "appendChild", "(", "$", "gpx", ")", ";", "if", "(", "phpGPX", "::", "$", "PRETTY_PRINT", ")", "{", "$", "document", "->", "formatOutput", "=", "true", ";", "$", "document", "->", "preserveWhiteSpace", "=", "true", ";", "}", "return", "$", "document", ";", "}" ]
Create XML representation of GPX file. @return \DOMDocument
[ "Create", "XML", "representation", "of", "GPX", "file", "." ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/Models/GpxFile.php#L103-L163
30,579
Sibyx/phpGPX
src/phpGPX/Models/GpxFile.php
GpxFile.save
public function save($path, $format) { switch ($format) { case phpGPX::XML_FORMAT: $document = $this->toXML(); $document->save($path); break; case phpGPX::JSON_FORMAT: file_put_contents($path, $this->toJSON()); break; default: throw new \RuntimeException("Unsupported file format!"); }; }
php
public function save($path, $format) { switch ($format) { case phpGPX::XML_FORMAT: $document = $this->toXML(); $document->save($path); break; case phpGPX::JSON_FORMAT: file_put_contents($path, $this->toJSON()); break; default: throw new \RuntimeException("Unsupported file format!"); }; }
[ "public", "function", "save", "(", "$", "path", ",", "$", "format", ")", "{", "switch", "(", "$", "format", ")", "{", "case", "phpGPX", "::", "XML_FORMAT", ":", "$", "document", "=", "$", "this", "->", "toXML", "(", ")", ";", "$", "document", "->", "save", "(", "$", "path", ")", ";", "break", ";", "case", "phpGPX", "::", "JSON_FORMAT", ":", "file_put_contents", "(", "$", "path", ",", "$", "this", "->", "toJSON", "(", ")", ")", ";", "break", ";", "default", ":", "throw", "new", "\\", "RuntimeException", "(", "\"Unsupported file format!\"", ")", ";", "}", ";", "}" ]
Save data to file according to selected format. @param string $path @param string $format
[ "Save", "data", "to", "file", "according", "to", "selected", "format", "." ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/Models/GpxFile.php#L170-L183
30,580
Sibyx/phpGPX
src/phpGPX/Parsers/BoundsParser.php
BoundsParser.parse
public static function parse(\SimpleXMLElement $node) { if ($node->getName() != self::$tagName) { return null; } $bounds = new Bounds(); $bounds->minLatitude = isset($node['minlat']) ? (float) $node['minlat'] : null; $bounds->minLongitude = isset($node['minlon']) ? (float) $node['minlon'] : null; $bounds->maxLatitude = isset($node['maxlat']) ? (float) $node['maxlat'] : null; $bounds->maxLongitude = isset($node['maxlon']) ? (float) $node['maxlon'] : null; return $bounds; }
php
public static function parse(\SimpleXMLElement $node) { if ($node->getName() != self::$tagName) { return null; } $bounds = new Bounds(); $bounds->minLatitude = isset($node['minlat']) ? (float) $node['minlat'] : null; $bounds->minLongitude = isset($node['minlon']) ? (float) $node['minlon'] : null; $bounds->maxLatitude = isset($node['maxlat']) ? (float) $node['maxlat'] : null; $bounds->maxLongitude = isset($node['maxlon']) ? (float) $node['maxlon'] : null; return $bounds; }
[ "public", "static", "function", "parse", "(", "\\", "SimpleXMLElement", "$", "node", ")", "{", "if", "(", "$", "node", "->", "getName", "(", ")", "!=", "self", "::", "$", "tagName", ")", "{", "return", "null", ";", "}", "$", "bounds", "=", "new", "Bounds", "(", ")", ";", "$", "bounds", "->", "minLatitude", "=", "isset", "(", "$", "node", "[", "'minlat'", "]", ")", "?", "(", "float", ")", "$", "node", "[", "'minlat'", "]", ":", "null", ";", "$", "bounds", "->", "minLongitude", "=", "isset", "(", "$", "node", "[", "'minlon'", "]", ")", "?", "(", "float", ")", "$", "node", "[", "'minlon'", "]", ":", "null", ";", "$", "bounds", "->", "maxLatitude", "=", "isset", "(", "$", "node", "[", "'maxlat'", "]", ")", "?", "(", "float", ")", "$", "node", "[", "'maxlat'", "]", ":", "null", ";", "$", "bounds", "->", "maxLongitude", "=", "isset", "(", "$", "node", "[", "'maxlon'", "]", ")", "?", "(", "float", ")", "$", "node", "[", "'maxlon'", "]", ":", "null", ";", "return", "$", "bounds", ";", "}" ]
Parse data from XML. @param \SimpleXMLElement $node @return Bounds|null
[ "Parse", "data", "from", "XML", "." ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/Parsers/BoundsParser.php#L24-L38
30,581
Sibyx/phpGPX
src/phpGPX/Parsers/BoundsParser.php
BoundsParser.toXML
public static function toXML(Bounds $bounds, \DOMDocument &$document) { $node = $document->createElement(self::$tagName); if (!is_null($bounds->minLatitude)) { $node->setAttribute('minlat', $bounds->minLatitude); } if (!is_null($bounds->minLongitude)) { $node->setAttribute('minlon', $bounds->minLongitude); } if (!is_null($bounds->maxLatitude)) { $node->setAttribute('maxlat', $bounds->maxLatitude); } if (!is_null($bounds->maxLongitude)) { $node->setAttribute('maxlon', $bounds->maxLongitude); } return $node; }
php
public static function toXML(Bounds $bounds, \DOMDocument &$document) { $node = $document->createElement(self::$tagName); if (!is_null($bounds->minLatitude)) { $node->setAttribute('minlat', $bounds->minLatitude); } if (!is_null($bounds->minLongitude)) { $node->setAttribute('minlon', $bounds->minLongitude); } if (!is_null($bounds->maxLatitude)) { $node->setAttribute('maxlat', $bounds->maxLatitude); } if (!is_null($bounds->maxLongitude)) { $node->setAttribute('maxlon', $bounds->maxLongitude); } return $node; }
[ "public", "static", "function", "toXML", "(", "Bounds", "$", "bounds", ",", "\\", "DOMDocument", "&", "$", "document", ")", "{", "$", "node", "=", "$", "document", "->", "createElement", "(", "self", "::", "$", "tagName", ")", ";", "if", "(", "!", "is_null", "(", "$", "bounds", "->", "minLatitude", ")", ")", "{", "$", "node", "->", "setAttribute", "(", "'minlat'", ",", "$", "bounds", "->", "minLatitude", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "bounds", "->", "minLongitude", ")", ")", "{", "$", "node", "->", "setAttribute", "(", "'minlon'", ",", "$", "bounds", "->", "minLongitude", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "bounds", "->", "maxLatitude", ")", ")", "{", "$", "node", "->", "setAttribute", "(", "'maxlat'", ",", "$", "bounds", "->", "maxLatitude", ")", ";", "}", "if", "(", "!", "is_null", "(", "$", "bounds", "->", "maxLongitude", ")", ")", "{", "$", "node", "->", "setAttribute", "(", "'maxlon'", ",", "$", "bounds", "->", "maxLongitude", ")", ";", "}", "return", "$", "node", ";", "}" ]
Create XML representation. @param Bounds $bounds @param \DOMDocument $document @return \DOMElement
[ "Create", "XML", "representation", "." ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/Parsers/BoundsParser.php#L46-L67
30,582
Sibyx/phpGPX
src/phpGPX/Helpers/GeoHelper.php
GeoHelper.getDistance
public static function getDistance(Point $point1, Point $point2) { $latFrom = deg2rad($point1->latitude); $lonFrom = deg2rad($point1->longitude); $latTo = deg2rad($point2->latitude); $lonTo = deg2rad($point2->longitude); $lonDelta = $lonTo - $lonFrom; $a = pow(cos($latTo) * sin($lonDelta), 2) + pow(cos($latFrom) * sin($latTo) - sin($latFrom) * cos($latTo) * cos($lonDelta), 2); $b = sin($latFrom) * sin($latTo) + cos($latFrom) * cos($latTo) * cos($lonDelta); $angle = atan2(sqrt($a), $b); return $angle * self::EARTH_RADIUS; }
php
public static function getDistance(Point $point1, Point $point2) { $latFrom = deg2rad($point1->latitude); $lonFrom = deg2rad($point1->longitude); $latTo = deg2rad($point2->latitude); $lonTo = deg2rad($point2->longitude); $lonDelta = $lonTo - $lonFrom; $a = pow(cos($latTo) * sin($lonDelta), 2) + pow(cos($latFrom) * sin($latTo) - sin($latFrom) * cos($latTo) * cos($lonDelta), 2); $b = sin($latFrom) * sin($latTo) + cos($latFrom) * cos($latTo) * cos($lonDelta); $angle = atan2(sqrt($a), $b); return $angle * self::EARTH_RADIUS; }
[ "public", "static", "function", "getDistance", "(", "Point", "$", "point1", ",", "Point", "$", "point2", ")", "{", "$", "latFrom", "=", "deg2rad", "(", "$", "point1", "->", "latitude", ")", ";", "$", "lonFrom", "=", "deg2rad", "(", "$", "point1", "->", "longitude", ")", ";", "$", "latTo", "=", "deg2rad", "(", "$", "point2", "->", "latitude", ")", ";", "$", "lonTo", "=", "deg2rad", "(", "$", "point2", "->", "longitude", ")", ";", "$", "lonDelta", "=", "$", "lonTo", "-", "$", "lonFrom", ";", "$", "a", "=", "pow", "(", "cos", "(", "$", "latTo", ")", "*", "sin", "(", "$", "lonDelta", ")", ",", "2", ")", "+", "pow", "(", "cos", "(", "$", "latFrom", ")", "*", "sin", "(", "$", "latTo", ")", "-", "sin", "(", "$", "latFrom", ")", "*", "cos", "(", "$", "latTo", ")", "*", "cos", "(", "$", "lonDelta", ")", ",", "2", ")", ";", "$", "b", "=", "sin", "(", "$", "latFrom", ")", "*", "sin", "(", "$", "latTo", ")", "+", "cos", "(", "$", "latFrom", ")", "*", "cos", "(", "$", "latTo", ")", "*", "cos", "(", "$", "lonDelta", ")", ";", "$", "angle", "=", "atan2", "(", "sqrt", "(", "$", "a", ")", ",", "$", "b", ")", ";", "return", "$", "angle", "*", "self", "::", "EARTH_RADIUS", ";", "}" ]
Returns distance in meters between two Points according to GPX coordinates. @see Point @param Point $point1 @param Point $point2 @return float
[ "Returns", "distance", "in", "meters", "between", "two", "Points", "according", "to", "GPX", "coordinates", "." ]
13a5b2810915c5cc055f46abd7938419acf14124
https://github.com/Sibyx/phpGPX/blob/13a5b2810915c5cc055f46abd7938419acf14124/src/phpGPX/Helpers/GeoHelper.php#L27-L40
30,583
tylercd100/lern
src/Components/Notifier.php
Notifier.getMessage
public function getMessage(Exception $e) { $msg = $this->getMessageViaView($e); if ($msg === false) { $msg = $this->getMessageViaCallback($e); } if ($msg === false) { $msg = $this->getMessageViaDefault($e); } return $msg; }
php
public function getMessage(Exception $e) { $msg = $this->getMessageViaView($e); if ($msg === false) { $msg = $this->getMessageViaCallback($e); } if ($msg === false) { $msg = $this->getMessageViaDefault($e); } return $msg; }
[ "public", "function", "getMessage", "(", "Exception", "$", "e", ")", "{", "$", "msg", "=", "$", "this", "->", "getMessageViaView", "(", "$", "e", ")", ";", "if", "(", "$", "msg", "===", "false", ")", "{", "$", "msg", "=", "$", "this", "->", "getMessageViaCallback", "(", "$", "e", ")", ";", "}", "if", "(", "$", "msg", "===", "false", ")", "{", "$", "msg", "=", "$", "this", "->", "getMessageViaDefault", "(", "$", "e", ")", ";", "}", "return", "$", "msg", ";", "}" ]
Returns the result of the message closure @param Exception $e The Exception instance that you want to build the message around @return string The message string
[ "Returns", "the", "result", "of", "the", "message", "closure" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L76-L89
30,584
tylercd100/lern
src/Components/Notifier.php
Notifier.getMessageViaDefault
public function getMessageViaDefault(Exception $e) { $msg = get_class($e)." was thrown! \n".$e->getMessage(); if ($this->config['includeExceptionStackTrace'] === true) { $msg .= "\n\n".$e->getTraceAsString(); } return $msg; }
php
public function getMessageViaDefault(Exception $e) { $msg = get_class($e)." was thrown! \n".$e->getMessage(); if ($this->config['includeExceptionStackTrace'] === true) { $msg .= "\n\n".$e->getTraceAsString(); } return $msg; }
[ "public", "function", "getMessageViaDefault", "(", "Exception", "$", "e", ")", "{", "$", "msg", "=", "get_class", "(", "$", "e", ")", ".", "\" was thrown! \\n\"", ".", "$", "e", "->", "getMessage", "(", ")", ";", "if", "(", "$", "this", "->", "config", "[", "'includeExceptionStackTrace'", "]", "===", "true", ")", "{", "$", "msg", ".=", "\"\\n\\n\"", ".", "$", "e", "->", "getTraceAsString", "(", ")", ";", "}", "return", "$", "msg", ";", "}" ]
Gets a basic Exception message @param Exception $e The Exception instance that you want to build the message around @return String Returns the message string
[ "Gets", "a", "basic", "Exception", "message" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L96-L103
30,585
tylercd100/lern
src/Components/Notifier.php
Notifier.getMessageViaCallback
public function getMessageViaCallback(Exception $e) { if (is_callable($this->messageCb)) { return $this->messageCb->__invoke($e); } return false; }
php
public function getMessageViaCallback(Exception $e) { if (is_callable($this->messageCb)) { return $this->messageCb->__invoke($e); } return false; }
[ "public", "function", "getMessageViaCallback", "(", "Exception", "$", "e", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "messageCb", ")", ")", "{", "return", "$", "this", "->", "messageCb", "->", "__invoke", "(", "$", "e", ")", ";", "}", "return", "false", ";", "}" ]
Gets the Exception message using a callback if it is set @param Exception $e The Exception instance that you want to build the message around @return String|false Returns the message string or false
[ "Gets", "the", "Exception", "message", "using", "a", "callback", "if", "it", "is", "set" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L110-L116
30,586
tylercd100/lern
src/Components/Notifier.php
Notifier.getMessageViaView
public function getMessageViaView(Exception $e) { $path = @$this->config["view"]; if (!empty($path) && View::exists($path)) { return View::make($path, [ "exception" => $e, "url" => Request::url(), "method" => Request::method(), "input" => Input::all(), "user" => Auth::user(), ])->render(); } return false; }
php
public function getMessageViaView(Exception $e) { $path = @$this->config["view"]; if (!empty($path) && View::exists($path)) { return View::make($path, [ "exception" => $e, "url" => Request::url(), "method" => Request::method(), "input" => Input::all(), "user" => Auth::user(), ])->render(); } return false; }
[ "public", "function", "getMessageViaView", "(", "Exception", "$", "e", ")", "{", "$", "path", "=", "@", "$", "this", "->", "config", "[", "\"view\"", "]", ";", "if", "(", "!", "empty", "(", "$", "path", ")", "&&", "View", "::", "exists", "(", "$", "path", ")", ")", "{", "return", "View", "::", "make", "(", "$", "path", ",", "[", "\"exception\"", "=>", "$", "e", ",", "\"url\"", "=>", "Request", "::", "url", "(", ")", ",", "\"method\"", "=>", "Request", "::", "method", "(", ")", ",", "\"input\"", "=>", "Input", "::", "all", "(", ")", ",", "\"user\"", "=>", "Auth", "::", "user", "(", ")", ",", "]", ")", "->", "render", "(", ")", ";", "}", "return", "false", ";", "}" ]
Gets the Exception message using a Laravel view file @param Exception $e The Exception instance that you want to build the message around @return String|false Returns the message string or false
[ "Gets", "the", "Exception", "message", "using", "a", "Laravel", "view", "file" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L123-L136
30,587
tylercd100/lern
src/Components/Notifier.php
Notifier.getSubject
public function getSubject(Exception $e) { if (is_callable($this->subjectCb)) { return $this->subjectCb->__invoke($e); } else { return get_class($e); } }
php
public function getSubject(Exception $e) { if (is_callable($this->subjectCb)) { return $this->subjectCb->__invoke($e); } else { return get_class($e); } }
[ "public", "function", "getSubject", "(", "Exception", "$", "e", ")", "{", "if", "(", "is_callable", "(", "$", "this", "->", "subjectCb", ")", ")", "{", "return", "$", "this", "->", "subjectCb", "->", "__invoke", "(", "$", "e", ")", ";", "}", "else", "{", "return", "get_class", "(", "$", "e", ")", ";", "}", "}" ]
Returns the result of the subject closure @param Exception $e The Exception instance that you want to build the subject around @return string The subject string
[ "Returns", "the", "result", "of", "the", "subject", "closure" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L154-L161
30,588
tylercd100/lern
src/Components/Notifier.php
Notifier.getContext
public function getContext(Exception $e, $context = []) { //This needs a better solution. How do I set specific context needs for different drivers? if (in_array('pushover', $this->config['drivers'])) { $context['sound'] = $this->config['pushover']['sound']; } // Call the callback or return the default if (is_callable($this->contextCb)) { return $this->contextCb->__invoke($e, $context); } else { return $context; } }
php
public function getContext(Exception $e, $context = []) { //This needs a better solution. How do I set specific context needs for different drivers? if (in_array('pushover', $this->config['drivers'])) { $context['sound'] = $this->config['pushover']['sound']; } // Call the callback or return the default if (is_callable($this->contextCb)) { return $this->contextCb->__invoke($e, $context); } else { return $context; } }
[ "public", "function", "getContext", "(", "Exception", "$", "e", ",", "$", "context", "=", "[", "]", ")", "{", "//This needs a better solution. How do I set specific context needs for different drivers?\r", "if", "(", "in_array", "(", "'pushover'", ",", "$", "this", "->", "config", "[", "'drivers'", "]", ")", ")", "{", "$", "context", "[", "'sound'", "]", "=", "$", "this", "->", "config", "[", "'pushover'", "]", "[", "'sound'", "]", ";", "}", "// Call the callback or return the default\r", "if", "(", "is_callable", "(", "$", "this", "->", "contextCb", ")", ")", "{", "return", "$", "this", "->", "contextCb", "->", "__invoke", "(", "$", "e", ",", "$", "context", ")", ";", "}", "else", "{", "return", "$", "context", ";", "}", "}" ]
Returns the result of the context closure @param Exception $e The Exception instance that you want to build the context around @return array The context array
[ "Returns", "the", "result", "of", "the", "context", "closure" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L179-L192
30,589
tylercd100/lern
src/Components/Notifier.php
Notifier.send
public function send(Exception $e, array $context = []) { if ($this->shouldntHandle($e)) { return false; } $message = $this->getMessage($e); $subject = $this->getSubject($e); $context = $this->getContext($e, $context); try { $notify = new Notify($this->config, $this->log, $subject); $level = (array_key_exists('log_level', $this->config) && !empty($this->config['log_level'])) ? $this->config['log_level'] : 'critical'; $notify->{$level}($message, $context); Cache::forever($this->getCacheKey($e), Carbon::now()); return true; } catch (Exception $e) { $code = (is_int($e->getCode()) ? $e->getCode() : 0); throw new NotifierFailedException($e->getMessage(), $code, $e); } }
php
public function send(Exception $e, array $context = []) { if ($this->shouldntHandle($e)) { return false; } $message = $this->getMessage($e); $subject = $this->getSubject($e); $context = $this->getContext($e, $context); try { $notify = new Notify($this->config, $this->log, $subject); $level = (array_key_exists('log_level', $this->config) && !empty($this->config['log_level'])) ? $this->config['log_level'] : 'critical'; $notify->{$level}($message, $context); Cache::forever($this->getCacheKey($e), Carbon::now()); return true; } catch (Exception $e) { $code = (is_int($e->getCode()) ? $e->getCode() : 0); throw new NotifierFailedException($e->getMessage(), $code, $e); } }
[ "public", "function", "send", "(", "Exception", "$", "e", ",", "array", "$", "context", "=", "[", "]", ")", "{", "if", "(", "$", "this", "->", "shouldntHandle", "(", "$", "e", ")", ")", "{", "return", "false", ";", "}", "$", "message", "=", "$", "this", "->", "getMessage", "(", "$", "e", ")", ";", "$", "subject", "=", "$", "this", "->", "getSubject", "(", "$", "e", ")", ";", "$", "context", "=", "$", "this", "->", "getContext", "(", "$", "e", ",", "$", "context", ")", ";", "try", "{", "$", "notify", "=", "new", "Notify", "(", "$", "this", "->", "config", ",", "$", "this", "->", "log", ",", "$", "subject", ")", ";", "$", "level", "=", "(", "array_key_exists", "(", "'log_level'", ",", "$", "this", "->", "config", ")", "&&", "!", "empty", "(", "$", "this", "->", "config", "[", "'log_level'", "]", ")", ")", "?", "$", "this", "->", "config", "[", "'log_level'", "]", ":", "'critical'", ";", "$", "notify", "->", "{", "$", "level", "}", "(", "$", "message", ",", "$", "context", ")", ";", "Cache", "::", "forever", "(", "$", "this", "->", "getCacheKey", "(", "$", "e", ")", ",", "Carbon", "::", "now", "(", ")", ")", ";", "return", "true", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "code", "=", "(", "is_int", "(", "$", "e", "->", "getCode", "(", ")", ")", "?", "$", "e", "->", "getCode", "(", ")", ":", "0", ")", ";", "throw", "new", "NotifierFailedException", "(", "$", "e", "->", "getMessage", "(", ")", ",", "$", "code", ",", "$", "e", ")", ";", "}", "}" ]
Triggers the Monolog Logger instance to log an error to all handlers @param Exception $e The exception to use @param array $context Additional information that you would like to pass to Monolog @return bool @throws NotifierFailedException
[ "Triggers", "the", "Monolog", "Logger", "instance", "to", "log", "an", "error", "to", "all", "handlers" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Notifier.php#L232-L258
30,590
tylercd100/lern
src/LERN.php
LERN.handle
public function handle(Exception $e) { $this->exception = $e; $this->notify($e); return $this->record($e); }
php
public function handle(Exception $e) { $this->exception = $e; $this->notify($e); return $this->record($e); }
[ "public", "function", "handle", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "exception", "=", "$", "e", ";", "$", "this", "->", "notify", "(", "$", "e", ")", ";", "return", "$", "this", "->", "record", "(", "$", "e", ")", ";", "}" ]
Will execute record and notify methods @param Exception $e The exception to use @return ExceptionModel the recorded Eloquent Model
[ "Will", "execute", "record", "and", "notify", "methods" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/LERN.php#L47-L52
30,591
tylercd100/lern
src/LERN.php
LERN.record
public function record(Exception $e) { $this->exception = $e; return $this->recorder->record($e); }
php
public function record(Exception $e) { $this->exception = $e; return $this->recorder->record($e); }
[ "public", "function", "record", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "exception", "=", "$", "e", ";", "return", "$", "this", "->", "recorder", "->", "record", "(", "$", "e", ")", ";", "}" ]
Stores the exception in the database @param Exception $e The exception to use @return \Tylercd100\LERN\Models\ExceptionModel|false The recorded Exception as an Eloquent Model
[ "Stores", "the", "exception", "in", "the", "database" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/LERN.php#L59-L63
30,592
tylercd100/lern
src/LERN.php
LERN.notify
public function notify(Exception $e) { $this->exception = $e; $this->notifier->send($e); }
php
public function notify(Exception $e) { $this->exception = $e; $this->notifier->send($e); }
[ "public", "function", "notify", "(", "Exception", "$", "e", ")", "{", "$", "this", "->", "exception", "=", "$", "e", ";", "$", "this", "->", "notifier", "->", "send", "(", "$", "e", ")", ";", "}" ]
Will send the exception to all monolog handlers @param Exception $e The exception to use @return void
[ "Will", "send", "the", "exception", "to", "all", "monolog", "handlers" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/LERN.php#L70-L74
30,593
tylercd100/lern
src/LERN.php
LERN.buildNotifier
protected function buildNotifier(Notifier $notifier = null) { $class = config('lern.notify.class'); $class = !empty($class) ? $class : Notifier::class; if (empty($notifier)) { $notifier = new $class(); } if ($notifier instanceof Notifier) { return $notifier; } else { throw new NotifierFailedException("LERN was expecting an instance of ".Notifier::class); } }
php
protected function buildNotifier(Notifier $notifier = null) { $class = config('lern.notify.class'); $class = !empty($class) ? $class : Notifier::class; if (empty($notifier)) { $notifier = new $class(); } if ($notifier instanceof Notifier) { return $notifier; } else { throw new NotifierFailedException("LERN was expecting an instance of ".Notifier::class); } }
[ "protected", "function", "buildNotifier", "(", "Notifier", "$", "notifier", "=", "null", ")", "{", "$", "class", "=", "config", "(", "'lern.notify.class'", ")", ";", "$", "class", "=", "!", "empty", "(", "$", "class", ")", "?", "$", "class", ":", "Notifier", "::", "class", ";", "if", "(", "empty", "(", "$", "notifier", ")", ")", "{", "$", "notifier", "=", "new", "$", "class", "(", ")", ";", "}", "if", "(", "$", "notifier", "instanceof", "Notifier", ")", "{", "return", "$", "notifier", ";", "}", "else", "{", "throw", "new", "NotifierFailedException", "(", "\"LERN was expecting an instance of \"", ".", "Notifier", "::", "class", ")", ";", "}", "}" ]
Constructs a Notifier @param Notifier $notifier @return Notifier
[ "Constructs", "a", "Notifier" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/LERN.php#L174-L186
30,594
tylercd100/lern
src/LERN.php
LERN.buildRecorder
protected function buildRecorder(Recorder $recorder = null) { $class = config('lern.record.class'); $class = !empty($class) ? $class : Recorder::class; if (empty($recorder)) { $recorder = new $class(); } if ($recorder instanceof Recorder) { return $recorder; } else { throw new RecorderFailedException("LERN was expecting an instance of ".Recorder::class); } }
php
protected function buildRecorder(Recorder $recorder = null) { $class = config('lern.record.class'); $class = !empty($class) ? $class : Recorder::class; if (empty($recorder)) { $recorder = new $class(); } if ($recorder instanceof Recorder) { return $recorder; } else { throw new RecorderFailedException("LERN was expecting an instance of ".Recorder::class); } }
[ "protected", "function", "buildRecorder", "(", "Recorder", "$", "recorder", "=", "null", ")", "{", "$", "class", "=", "config", "(", "'lern.record.class'", ")", ";", "$", "class", "=", "!", "empty", "(", "$", "class", ")", "?", "$", "class", ":", "Recorder", "::", "class", ";", "if", "(", "empty", "(", "$", "recorder", ")", ")", "{", "$", "recorder", "=", "new", "$", "class", "(", ")", ";", "}", "if", "(", "$", "recorder", "instanceof", "Recorder", ")", "{", "return", "$", "recorder", ";", "}", "else", "{", "throw", "new", "RecorderFailedException", "(", "\"LERN was expecting an instance of \"", ".", "Recorder", "::", "class", ")", ";", "}", "}" ]
Constructs a Recorder @param Recorder $recorder @return Recorder
[ "Constructs", "a", "Recorder" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/LERN.php#L194-L206
30,595
tylercd100/lern
src/Components/Component.php
Component.shouldntHandle
protected function shouldntHandle(Exception $e) { $dontHandle = array_merge($this->dontHandle, $this->absolutelyDontHandle); foreach ($dontHandle as $type) { if ($e instanceof $type) { return true; } } $sent_at = Cache::get($this->getCacheKey($e)); if (empty($sent_at) || $sent_at->addSeconds(config('lern.ratelimit', 1))->lte(Carbon::now())) { return false; // The cache is empty or enough time has passed, so lets continue } else { return true; } }
php
protected function shouldntHandle(Exception $e) { $dontHandle = array_merge($this->dontHandle, $this->absolutelyDontHandle); foreach ($dontHandle as $type) { if ($e instanceof $type) { return true; } } $sent_at = Cache::get($this->getCacheKey($e)); if (empty($sent_at) || $sent_at->addSeconds(config('lern.ratelimit', 1))->lte(Carbon::now())) { return false; // The cache is empty or enough time has passed, so lets continue } else { return true; } }
[ "protected", "function", "shouldntHandle", "(", "Exception", "$", "e", ")", "{", "$", "dontHandle", "=", "array_merge", "(", "$", "this", "->", "dontHandle", ",", "$", "this", "->", "absolutelyDontHandle", ")", ";", "foreach", "(", "$", "dontHandle", "as", "$", "type", ")", "{", "if", "(", "$", "e", "instanceof", "$", "type", ")", "{", "return", "true", ";", "}", "}", "$", "sent_at", "=", "Cache", "::", "get", "(", "$", "this", "->", "getCacheKey", "(", "$", "e", ")", ")", ";", "if", "(", "empty", "(", "$", "sent_at", ")", "||", "$", "sent_at", "->", "addSeconds", "(", "config", "(", "'lern.ratelimit'", ",", "1", ")", ")", "->", "lte", "(", "Carbon", "::", "now", "(", ")", ")", ")", "{", "return", "false", ";", "// The cache is empty or enough time has passed, so lets continue", "}", "else", "{", "return", "true", ";", "}", "}" ]
Determine if the exception is in the "do not handle" list. @param \Exception $e @return bool
[ "Determine", "if", "the", "exception", "is", "in", "the", "do", "not", "handle", "list", "." ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Component.php#L29-L44
30,596
tylercd100/lern
src/Components/Recorder.php
Recorder.record
public function record(Exception $e) { if ($this->shouldntHandle($e)) { return false; } $opts = [ 'class' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'code' => (is_int($e->getCode()) ? $e->getCode() : 0), 'message' => $e->getMessage(), 'trace' => $e->getTraceAsString(), ]; $configDependant = array_keys($this->config['collect']); foreach ($configDependant as $key) { if ($this->canCollect($key)) { $value = $this->collect($key, $e); if ($value !== null) { $opts[$key] = $value; } } } $class = config('lern.recorder.model'); $class = !empty($class) ? $class : ExceptionModel::class; $model = new $class(); foreach($opts as $key => $value) { $model->{$key} = $value; } $model->save(); Cache::forever($this->getCacheKey($e), Carbon::now()); return $model; }
php
public function record(Exception $e) { if ($this->shouldntHandle($e)) { return false; } $opts = [ 'class' => get_class($e), 'file' => $e->getFile(), 'line' => $e->getLine(), 'code' => (is_int($e->getCode()) ? $e->getCode() : 0), 'message' => $e->getMessage(), 'trace' => $e->getTraceAsString(), ]; $configDependant = array_keys($this->config['collect']); foreach ($configDependant as $key) { if ($this->canCollect($key)) { $value = $this->collect($key, $e); if ($value !== null) { $opts[$key] = $value; } } } $class = config('lern.recorder.model'); $class = !empty($class) ? $class : ExceptionModel::class; $model = new $class(); foreach($opts as $key => $value) { $model->{$key} = $value; } $model->save(); Cache::forever($this->getCacheKey($e), Carbon::now()); return $model; }
[ "public", "function", "record", "(", "Exception", "$", "e", ")", "{", "if", "(", "$", "this", "->", "shouldntHandle", "(", "$", "e", ")", ")", "{", "return", "false", ";", "}", "$", "opts", "=", "[", "'class'", "=>", "get_class", "(", "$", "e", ")", ",", "'file'", "=>", "$", "e", "->", "getFile", "(", ")", ",", "'line'", "=>", "$", "e", "->", "getLine", "(", ")", ",", "'code'", "=>", "(", "is_int", "(", "$", "e", "->", "getCode", "(", ")", ")", "?", "$", "e", "->", "getCode", "(", ")", ":", "0", ")", ",", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", ",", "'trace'", "=>", "$", "e", "->", "getTraceAsString", "(", ")", ",", "]", ";", "$", "configDependant", "=", "array_keys", "(", "$", "this", "->", "config", "[", "'collect'", "]", ")", ";", "foreach", "(", "$", "configDependant", "as", "$", "key", ")", "{", "if", "(", "$", "this", "->", "canCollect", "(", "$", "key", ")", ")", "{", "$", "value", "=", "$", "this", "->", "collect", "(", "$", "key", ",", "$", "e", ")", ";", "if", "(", "$", "value", "!==", "null", ")", "{", "$", "opts", "[", "$", "key", "]", "=", "$", "value", ";", "}", "}", "}", "$", "class", "=", "config", "(", "'lern.recorder.model'", ")", ";", "$", "class", "=", "!", "empty", "(", "$", "class", ")", "?", "$", "class", ":", "ExceptionModel", "::", "class", ";", "$", "model", "=", "new", "$", "class", "(", ")", ";", "foreach", "(", "$", "opts", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "model", "->", "{", "$", "key", "}", "=", "$", "value", ";", "}", "$", "model", "->", "save", "(", ")", ";", "Cache", "::", "forever", "(", "$", "this", "->", "getCacheKey", "(", "$", "e", ")", ",", "Carbon", "::", "now", "(", ")", ")", ";", "return", "$", "model", ";", "}" ]
Records an Exception to the database @param Exception $e The exception you want to record @return false|ExceptionModel @throws RecorderFailedException
[ "Records", "an", "Exception", "to", "the", "database" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Recorder.php#L43-L82
30,597
tylercd100/lern
src/Components/Recorder.php
Recorder.canCollect
private function canCollect($type) { if (!empty($this->config) && !empty($this->config['collect']) && !empty($this->config['collect'][$type])) { return $this->config['collect'][$type] === true; } return false; }
php
private function canCollect($type) { if (!empty($this->config) && !empty($this->config['collect']) && !empty($this->config['collect'][$type])) { return $this->config['collect'][$type] === true; } return false; }
[ "private", "function", "canCollect", "(", "$", "type", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "config", ")", "&&", "!", "empty", "(", "$", "this", "->", "config", "[", "'collect'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "config", "[", "'collect'", "]", "[", "$", "type", "]", ")", ")", "{", "return", "$", "this", "->", "config", "[", "'collect'", "]", "[", "$", "type", "]", "===", "true", ";", "}", "return", "false", ";", "}" ]
Checks the config to see if you can collect certain information @param string $type the config value you want to check @return boolean
[ "Checks", "the", "config", "to", "see", "if", "you", "can", "collect", "certain", "information" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Recorder.php#L89-L94
30,598
tylercd100/lern
src/Components/Recorder.php
Recorder.getUserId
protected function getUserId() { $user = Auth::user(); if (is_object($user) && !empty($user->id)) { return $user->id; } else { return null; } }
php
protected function getUserId() { $user = Auth::user(); if (is_object($user) && !empty($user->id)) { return $user->id; } else { return null; } }
[ "protected", "function", "getUserId", "(", ")", "{", "$", "user", "=", "Auth", "::", "user", "(", ")", ";", "if", "(", "is_object", "(", "$", "user", ")", "&&", "!", "empty", "(", "$", "user", "->", "id", ")", ")", "{", "return", "$", "user", "->", "id", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets the ID of the User that is logged in @return integer|null The ID of the User or Null if not logged in
[ "Gets", "the", "ID", "of", "the", "User", "that", "is", "logged", "in" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Recorder.php#L128-L135
30,599
tylercd100/lern
src/Components/Recorder.php
Recorder.getData
protected function getData() { $data = Input::all(); if (is_array($data)) { return $this->excludeKeys($data); } else { return null; } }
php
protected function getData() { $data = Input::all(); if (is_array($data)) { return $this->excludeKeys($data); } else { return null; } }
[ "protected", "function", "getData", "(", ")", "{", "$", "data", "=", "Input", "::", "all", "(", ")", ";", "if", "(", "is_array", "(", "$", "data", ")", ")", "{", "return", "$", "this", "->", "excludeKeys", "(", "$", "data", ")", ";", "}", "else", "{", "return", "null", ";", "}", "}" ]
Gets the input data of the Request @return array|null The Input data or null
[ "Gets", "the", "input", "data", "of", "the", "Request" ]
ab6b602d11447d305770aa8cbb79278428dd2244
https://github.com/tylercd100/lern/blob/ab6b602d11447d305770aa8cbb79278428dd2244/src/Components/Recorder.php#L154-L161