repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
praxisnetau/silverware
src/Extensions/Lists/ListViewExtension.php
ListViewExtension.hideFields
protected function hideFields(FieldList $fields) { if ($this->owner->ListInherit) { foreach ($fields as $field) { $field->addExtraClass('hidden'); } } return $fields; }
php
protected function hideFields(FieldList $fields) { if ($this->owner->ListInherit) { foreach ($fields as $field) { $field->addExtraClass('hidden'); } } return $fields; }
[ "protected", "function", "hideFields", "(", "FieldList", "$", "fields", ")", "{", "if", "(", "$", "this", "->", "owner", "->", "ListInherit", ")", "{", "foreach", "(", "$", "fields", "as", "$", "field", ")", "{", "$", "field", "->", "addExtraClass", "(...
Hides the given list of fields if the extended object inherits the list component. @param FieldList $fields @return FieldList
[ "Hides", "the", "given", "list", "of", "fields", "if", "the", "extended", "object", "inherits", "the", "list", "component", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListViewExtension.php#L813-L824
train
praxisnetau/silverware
src/Extensions/Lists/ListViewExtension.php
ListViewExtension.nest
protected function nest(FieldList $fields) { // Iterate Data Fields: foreach ($fields->dataFields() as $field) { $field->setName($this->nestName($field->getName())); } // Answer Fields: return $fields; }
php
protected function nest(FieldList $fields) { // Iterate Data Fields: foreach ($fields->dataFields() as $field) { $field->setName($this->nestName($field->getName())); } // Answer Fields: return $fields; }
[ "protected", "function", "nest", "(", "FieldList", "$", "fields", ")", "{", "// Iterate Data Fields:", "foreach", "(", "$", "fields", "->", "dataFields", "(", ")", "as", "$", "field", ")", "{", "$", "field", "->", "setName", "(", "$", "this", "->", "nest...
Nests the names of the given fields within the list config wrapper. @param FieldList $fields @return FieldList
[ "Nests", "the", "names", "of", "the", "given", "fields", "within", "the", "list", "config", "wrapper", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListViewExtension.php#L846-L857
train
praxisnetau/silverware
src/Extensions/Lists/ListViewExtension.php
ListViewExtension.nestName
protected function nestName($name) { // Obtain Bracket Position: $bpos = strpos($name, '['); // Has Bracket? if ($bpos !== false) { // Answer Bracketed Name: return sprintf('%s[%s]%s', self::FIELD_WRAPPER, substr($name, 0, $bpos), substr($name, $bpos)); } else { // Answer Regular Name: return sprintf('%s[%s]', self::FIELD_WRAPPER, $name); } }
php
protected function nestName($name) { // Obtain Bracket Position: $bpos = strpos($name, '['); // Has Bracket? if ($bpos !== false) { // Answer Bracketed Name: return sprintf('%s[%s]%s', self::FIELD_WRAPPER, substr($name, 0, $bpos), substr($name, $bpos)); } else { // Answer Regular Name: return sprintf('%s[%s]', self::FIELD_WRAPPER, $name); } }
[ "protected", "function", "nestName", "(", "$", "name", ")", "{", "// Obtain Bracket Position:", "$", "bpos", "=", "strpos", "(", "$", "name", ",", "'['", ")", ";", "// Has Bracket?", "if", "(", "$", "bpos", "!==", "false", ")", "{", "// Answer Bracketed Name...
Nests the given field name within the list config wrapper. @param string $name @return string
[ "Nests", "the", "given", "field", "name", "within", "the", "list", "config", "wrapper", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Lists/ListViewExtension.php#L866-L887
train
praxisnetau/silverware
src/Extensions/StyleExtension.php
StyleExtension.updateCustomCSS
public function updateCustomCSS(&$css) { $template = $this->owner->getStyleExtensionTemplate(static::class); if (SSViewer::hasTemplate($template)) { $css = ViewTools::singleton()->renderCSS($this->owner, $template, $css); } }
php
public function updateCustomCSS(&$css) { $template = $this->owner->getStyleExtensionTemplate(static::class); if (SSViewer::hasTemplate($template)) { $css = ViewTools::singleton()->renderCSS($this->owner, $template, $css); } }
[ "public", "function", "updateCustomCSS", "(", "&", "$", "css", ")", "{", "$", "template", "=", "$", "this", "->", "owner", "->", "getStyleExtensionTemplate", "(", "static", "::", "class", ")", ";", "if", "(", "SSViewer", "::", "hasTemplate", "(", "$", "t...
Updates the array of custom CSS for the extended object. @param array $css @return void
[ "Updates", "the", "array", "of", "custom", "CSS", "for", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/StyleExtension.php#L82-L89
train
praxisnetau/silverware
src/Extensions/StyleExtension.php
StyleExtension.getAppliedStyles
protected function getAppliedStyles() { $applyStyles = $this->owner->config()->apply_styles; if (is_array($applyStyles)) { return $applyStyles; } elseif ($applyStyles == 'none') { return []; } }
php
protected function getAppliedStyles() { $applyStyles = $this->owner->config()->apply_styles; if (is_array($applyStyles)) { return $applyStyles; } elseif ($applyStyles == 'none') { return []; } }
[ "protected", "function", "getAppliedStyles", "(", ")", "{", "$", "applyStyles", "=", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "apply_styles", ";", "if", "(", "is_array", "(", "$", "applyStyles", ")", ")", "{", "return", "$", "applyStyl...
Answers an array of the style extension classes to be applied to the extended object. @return array
[ "Answers", "an", "array", "of", "the", "style", "extension", "classes", "to", "be", "applied", "to", "the", "extended", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/StyleExtension.php#L138-L147
train
sop/crypto-encoding
lib/CryptoEncoding/PEM.php
PEM.fromString
public static function fromString(string $str): self { if (!preg_match(self::PEM_REGEX, $str, $match)) { throw new \UnexpectedValueException("Not a PEM formatted string."); } $payload = preg_replace('/\s+/', "", $match[2]); $data = base64_decode($payload, true); if (false === $data) { throw new \UnexpectedValueException("Failed to decode PEM data."); } return new self($match[1], $data); }
php
public static function fromString(string $str): self { if (!preg_match(self::PEM_REGEX, $str, $match)) { throw new \UnexpectedValueException("Not a PEM formatted string."); } $payload = preg_replace('/\s+/', "", $match[2]); $data = base64_decode($payload, true); if (false === $data) { throw new \UnexpectedValueException("Failed to decode PEM data."); } return new self($match[1], $data); }
[ "public", "static", "function", "fromString", "(", "string", "$", "str", ")", ":", "self", "{", "if", "(", "!", "preg_match", "(", "self", "::", "PEM_REGEX", ",", "$", "str", ",", "$", "match", ")", ")", "{", "throw", "new", "\\", "UnexpectedValueExcep...
Initialize from a PEM-formatted string. @param string $str @throws \UnexpectedValueException If string is not valid PEM @return self
[ "Initialize", "from", "a", "PEM", "-", "formatted", "string", "." ]
b5958cc213d3092cb9fa7be179adf760a8fde1f6
https://github.com/sop/crypto-encoding/blob/b5958cc213d3092cb9fa7be179adf760a8fde1f6/lib/CryptoEncoding/PEM.php#L73-L84
train
EcomDev/cache-key
src/InvalidArgumentException.php
InvalidArgumentException.generateMessage
private function generateMessage($value) { if (is_object($value)) { return sprintf('An instance of "%s" is not suitable as cache key data', get_class($value)); } return sprintf('A variable of type "%s" is not suitable as cache key data', gettype($value)); }
php
private function generateMessage($value) { if (is_object($value)) { return sprintf('An instance of "%s" is not suitable as cache key data', get_class($value)); } return sprintf('A variable of type "%s" is not suitable as cache key data', gettype($value)); }
[ "private", "function", "generateMessage", "(", "$", "value", ")", "{", "if", "(", "is_object", "(", "$", "value", ")", ")", "{", "return", "sprintf", "(", "'An instance of \"%s\" is not suitable as cache key data'", ",", "get_class", "(", "$", "value", ")", ")",...
Generates message based on variable type @param mixed $value @return string
[ "Generates", "message", "based", "on", "variable", "type" ]
5f90f5a013100ec57d7f3a842f48222ba8a4ccf9
https://github.com/EcomDev/cache-key/blob/5f90f5a013100ec57d7f3a842f48222ba8a4ccf9/src/InvalidArgumentException.php#L35-L42
train
praxisnetau/silverware
src/Extensions/Assets/RenderInlineExtension.php
RenderInlineExtension.getRenderInline
public function getRenderInline() { // Check File Exists / File Extension: if ($this->owner->exists() && $this->owner->getExtension() == 'svg') { // Create DOM Document: $dom = new DOMDocument(); // Load SVG Data into DOM: $dom->load(BASE_PATH . $this->owner->URL); // Normalise SVG Data: $dom->normalizeDocument(); // Render SVG as HTML: return DBField::create_field('HTMLFragment', $dom->saveHTML($dom->documentElement)); } }
php
public function getRenderInline() { // Check File Exists / File Extension: if ($this->owner->exists() && $this->owner->getExtension() == 'svg') { // Create DOM Document: $dom = new DOMDocument(); // Load SVG Data into DOM: $dom->load(BASE_PATH . $this->owner->URL); // Normalise SVG Data: $dom->normalizeDocument(); // Render SVG as HTML: return DBField::create_field('HTMLFragment', $dom->saveHTML($dom->documentElement)); } }
[ "public", "function", "getRenderInline", "(", ")", "{", "// Check File Exists / File Extension:", "if", "(", "$", "this", "->", "owner", "->", "exists", "(", ")", "&&", "$", "this", "->", "owner", "->", "getExtension", "(", ")", "==", "'svg'", ")", "{", "/...
Renders the content of the extended object inline. @return DBHTMLText
[ "Renders", "the", "content", "of", "the", "extended", "object", "inline", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Assets/RenderInlineExtension.php#L40-L63
train
praxisnetau/silverware
src/Extensions/Model/URLSegmentExtension.php
URLSegmentExtension.validURLSegment
public function validURLSegment() { $list = DataList::create(get_class($this->owner))->filter(['URLSegment' => $this->owner->URLSegment]); if ($id = $this->owner->ID) { $list = $list->exclude(['ID' => $id]); } return !$list->exists(); }
php
public function validURLSegment() { $list = DataList::create(get_class($this->owner))->filter(['URLSegment' => $this->owner->URLSegment]); if ($id = $this->owner->ID) { $list = $list->exclude(['ID' => $id]); } return !$list->exists(); }
[ "public", "function", "validURLSegment", "(", ")", "{", "$", "list", "=", "DataList", "::", "create", "(", "get_class", "(", "$", "this", "->", "owner", ")", ")", "->", "filter", "(", "[", "'URLSegment'", "=>", "$", "this", "->", "owner", "->", "URLSeg...
Answers true if the extended object has a valid URL segment. @return boolean
[ "Answers", "true", "if", "the", "extended", "object", "has", "a", "valid", "URL", "segment", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/URLSegmentExtension.php#L95-L104
train
praxisnetau/silverware
src/Extensions/Model/URLSegmentExtension.php
URLSegmentExtension.generateURLSegment
public function generateURLSegment($string) { if (!$string) { $class = ClassTools::singleton()->getClassWithoutNamespace(get_class($this->owner)); $string = sprintf('%s-%s', $class, $this->owner->ID); } $segment = URLSegmentFilter::create()->filter($string); $this->owner->extend('updateURLSegment', $segment, $string); return $segment; }
php
public function generateURLSegment($string) { if (!$string) { $class = ClassTools::singleton()->getClassWithoutNamespace(get_class($this->owner)); $string = sprintf('%s-%s', $class, $this->owner->ID); } $segment = URLSegmentFilter::create()->filter($string); $this->owner->extend('updateURLSegment', $segment, $string); return $segment; }
[ "public", "function", "generateURLSegment", "(", "$", "string", ")", "{", "if", "(", "!", "$", "string", ")", "{", "$", "class", "=", "ClassTools", "::", "singleton", "(", ")", "->", "getClassWithoutNamespace", "(", "get_class", "(", "$", "this", "->", "...
Generates a URL segment for the extended object based on the given string. @param string $string @return string
[ "Generates", "a", "URL", "segment", "for", "the", "extended", "object", "based", "on", "the", "given", "string", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/URLSegmentExtension.php#L113-L125
train
praxisnetau/silverware
src/Extensions/Model/URLSegmentExtension.php
URLSegmentExtension.generateValidURLSegment
public function generateValidURLSegment($string) { // Generate URL Segment: $this->owner->URLSegment = $this->owner->generateURLSegment($string); // Check for Duplicates: $count = 2; while (!$this->owner->validURLSegment()) { $this->owner->URLSegment = sprintf( '%s-%d', preg_replace('/-[0-9]+$/', '', $this->owner->URLSegment), $count ); $count++; } }
php
public function generateValidURLSegment($string) { // Generate URL Segment: $this->owner->URLSegment = $this->owner->generateURLSegment($string); // Check for Duplicates: $count = 2; while (!$this->owner->validURLSegment()) { $this->owner->URLSegment = sprintf( '%s-%d', preg_replace('/-[0-9]+$/', '', $this->owner->URLSegment), $count ); $count++; } }
[ "public", "function", "generateValidURLSegment", "(", "$", "string", ")", "{", "// Generate URL Segment:", "$", "this", "->", "owner", "->", "URLSegment", "=", "$", "this", "->", "owner", "->", "generateURLSegment", "(", "$", "string", ")", ";", "// Check for Du...
Generates a valid URL segment for the extended object based on the given string. @param string $string @return string
[ "Generates", "a", "valid", "URL", "segment", "for", "the", "extended", "object", "based", "on", "the", "given", "string", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Model/URLSegmentExtension.php#L134-L155
train
EcomDev/cache-key
src/Generator.php
Generator.generate
public function generate($data) { if ($data instanceof InfoProviderInterface) { $data = $data->getCacheKeyInfo(); } if ($this->converter && !is_string($data)) { $convertedData = $this->converter->convert($data); if ($convertedData === false) { throw new InvalidArgumentException($data); } $data = $convertedData; } elseif (!is_string($data)) { throw new InvalidArgumentException($data); } $cacheKey = $this->normalizer->normalize($data); if ($this->prefix) { return $this->prefix . $cacheKey; } return $cacheKey; }
php
public function generate($data) { if ($data instanceof InfoProviderInterface) { $data = $data->getCacheKeyInfo(); } if ($this->converter && !is_string($data)) { $convertedData = $this->converter->convert($data); if ($convertedData === false) { throw new InvalidArgumentException($data); } $data = $convertedData; } elseif (!is_string($data)) { throw new InvalidArgumentException($data); } $cacheKey = $this->normalizer->normalize($data); if ($this->prefix) { return $this->prefix . $cacheKey; } return $cacheKey; }
[ "public", "function", "generate", "(", "$", "data", ")", "{", "if", "(", "$", "data", "instanceof", "InfoProviderInterface", ")", "{", "$", "data", "=", "$", "data", "->", "getCacheKeyInfo", "(", ")", ";", "}", "if", "(", "$", "this", "->", "converter"...
Generates a cache key based on provided data @param mixed $data @return string @throws InvalidArgumentException in case if value was not converted
[ "Generates", "a", "cache", "key", "based", "on", "provided", "data" ]
5f90f5a013100ec57d7f3a842f48222ba8a4ccf9
https://github.com/EcomDev/cache-key/blob/5f90f5a013100ec57d7f3a842f48222ba8a4ccf9/src/Generator.php#L60-L84
train
praxisnetau/silverware
src/Components/ContentComponent.php
ContentComponent.getLinkModeOptions
public function getLinkModeOptions() { return [ self::LINK_MODE_TITLE => _t(__CLASS__ . '.TITLE', 'Title'), self::LINK_MODE_BUTTON => _t(__CLASS__ . '.BUTTON', 'Button'), self::LINK_MODE_BOTH => _t(__CLASS__ . '.BOTHTITLEANDBUTTON', 'Both Title and Button') ]; }
php
public function getLinkModeOptions() { return [ self::LINK_MODE_TITLE => _t(__CLASS__ . '.TITLE', 'Title'), self::LINK_MODE_BUTTON => _t(__CLASS__ . '.BUTTON', 'Button'), self::LINK_MODE_BOTH => _t(__CLASS__ . '.BOTHTITLEANDBUTTON', 'Both Title and Button') ]; }
[ "public", "function", "getLinkModeOptions", "(", ")", "{", "return", "[", "self", "::", "LINK_MODE_TITLE", "=>", "_t", "(", "__CLASS__", ".", "'.TITLE'", ",", "'Title'", ")", ",", "self", "::", "LINK_MODE_BUTTON", "=>", "_t", "(", "__CLASS__", ".", "'.BUTTON...
Answers an array of options for the link mode field. @return array
[ "Answers", "an", "array", "of", "options", "for", "the", "link", "mode", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/ContentComponent.php#L318-L325
train
kuzzleio/sdk-php
src/Security/Security.php
Security.createProfile
public function createProfile($id, array $policies, array $options = []) { $action = 'createProfile'; $data = [ '_id' => $id, 'body' => [ 'policies' => $policies ] ]; if (array_key_exists('replaceIfExist', $options)) { $action = 'createOrReplaceProfile'; } $response = $this->kuzzle->query( $this->buildQueryArgs($action), $data, $options ); return new Profile($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function createProfile($id, array $policies, array $options = []) { $action = 'createProfile'; $data = [ '_id' => $id, 'body' => [ 'policies' => $policies ] ]; if (array_key_exists('replaceIfExist', $options)) { $action = 'createOrReplaceProfile'; } $response = $this->kuzzle->query( $this->buildQueryArgs($action), $data, $options ); return new Profile($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "createProfile", "(", "$", "id", ",", "array", "$", "policies", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "action", "=", "'createProfile'", ";", "$", "data", "=", "[", "'_id'", "=>", "$", "id", ",", "'body'", ...
Create a new profile in Kuzzle. @param string $id Unique profile identifier @param array $policies List of policies to apply to this profile @param array $options Optional arguments @return Profile
[ "Create", "a", "new", "profile", "in", "Kuzzle", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L60-L79
train
kuzzleio/sdk-php
src/Security/Security.php
Security.createRole
public function createRole($id, array $content, array $options = []) { $action = 'createRole'; $data = [ '_id' => $id, 'body' => $content ]; if (array_key_exists('replaceIfExist', $options)) { $action = 'createOrReplaceRole'; } $response = $this->kuzzle->query( $this->buildQueryArgs($action), $data, $options ); return new Role($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function createRole($id, array $content, array $options = []) { $action = 'createRole'; $data = [ '_id' => $id, 'body' => $content ]; if (array_key_exists('replaceIfExist', $options)) { $action = 'createOrReplaceRole'; } $response = $this->kuzzle->query( $this->buildQueryArgs($action), $data, $options ); return new Role($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "createRole", "(", "$", "id", ",", "array", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "action", "=", "'createRole'", ";", "$", "data", "=", "[", "'_id'", "=>", "$", "id", ",", "'body'", "=>", ...
Create a new role in Kuzzle. @param integer $id Unique role identifier @param array $content Data representing the role @param array $options Optional arguments @return Role
[ "Create", "a", "new", "role", "in", "Kuzzle", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L89-L108
train
kuzzleio/sdk-php
src/Security/Security.php
Security.createUser
public function createUser($id, array $content, array $options = []) { $action = 'createUser'; $data = [ '_id' => $id, 'body' => $content ]; $response = $this->kuzzle->query( $this->buildQueryArgs($action), $data, $options ); return new User($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function createUser($id, array $content, array $options = []) { $action = 'createUser'; $data = [ '_id' => $id, 'body' => $content ]; $response = $this->kuzzle->query( $this->buildQueryArgs($action), $data, $options ); return new User($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "createUser", "(", "$", "id", ",", "array", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "action", "=", "'createUser'", ";", "$", "data", "=", "[", "'_id'", "=>", "$", "id", ",", "'body'", "=>", ...
Create a new user in Kuzzle. @param integer $id Unique user identifier, will be used as username @param array $content Data representing the user @param array $options Optional arguments @return User
[ "Create", "a", "new", "user", "in", "Kuzzle", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L118-L133
train
kuzzleio/sdk-php
src/Security/Security.php
Security.scrollProfiles
public function scrollProfiles($scrollId, array $options = []) { $options['httpParams'] = [':scrollId' => $scrollId]; $data = []; if (!$scrollId) { throw new InvalidArgumentException('Security.scrollProfiles: scrollId is required'); } if (isset($options['scroll'])) { $data['scroll'] = $options['scroll']; } $response = $this->kuzzle->query( $this->kuzzle->buildQueryArgs('security', 'scrollProfiles'), $data, $options ); $response['result']['hits'] = array_map(function ($document) { return new Profile($this, $document['_id'], $document['_source'], $document['_meta']); }, $response['result']['hits']); return new ProfilesSearchResult( $response['result']['total'], $response['result']['hits'], $scrollId ); }
php
public function scrollProfiles($scrollId, array $options = []) { $options['httpParams'] = [':scrollId' => $scrollId]; $data = []; if (!$scrollId) { throw new InvalidArgumentException('Security.scrollProfiles: scrollId is required'); } if (isset($options['scroll'])) { $data['scroll'] = $options['scroll']; } $response = $this->kuzzle->query( $this->kuzzle->buildQueryArgs('security', 'scrollProfiles'), $data, $options ); $response['result']['hits'] = array_map(function ($document) { return new Profile($this, $document['_id'], $document['_source'], $document['_meta']); }, $response['result']['hits']); return new ProfilesSearchResult( $response['result']['total'], $response['result']['hits'], $scrollId ); }
[ "public", "function", "scrollProfiles", "(", "$", "scrollId", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'httpParams'", "]", "=", "[", "':scrollId'", "=>", "$", "scrollId", "]", ";", "$", "data", "=", "[", "]", ";", ...
Returns the next profiles result set with scroll query. @param string $scrollId @param array $options (optional) arguments @return ProfilesSearchResult @throws \Exception
[ "Returns", "the", "next", "profiles", "result", "set", "with", "scroll", "query", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L215-L244
train
kuzzleio/sdk-php
src/Security/Security.php
Security.scrollUsers
public function scrollUsers($scrollId, array $options = []) { $options['httpParams'] = [':scrollId' => $scrollId]; $data = []; if (!$scrollId) { throw new InvalidArgumentException('Security.scrollUsers: scrollId is required'); } if (isset($options['scroll'])) { $data['scroll'] = $options['scroll']; } $response = $this->kuzzle->query( $this->kuzzle->buildQueryArgs('security', 'scrollUsers'), $data, $options ); $response['result']['hits'] = array_map(function ($document) { return new User($this, $document['_id'], $document['_source'], $document['_meta']); }, $response['result']['hits']); return new UsersSearchResult( $response['result']['total'], $response['result']['hits'], $scrollId ); }
php
public function scrollUsers($scrollId, array $options = []) { $options['httpParams'] = [':scrollId' => $scrollId]; $data = []; if (!$scrollId) { throw new InvalidArgumentException('Security.scrollUsers: scrollId is required'); } if (isset($options['scroll'])) { $data['scroll'] = $options['scroll']; } $response = $this->kuzzle->query( $this->kuzzle->buildQueryArgs('security', 'scrollUsers'), $data, $options ); $response['result']['hits'] = array_map(function ($document) { return new User($this, $document['_id'], $document['_source'], $document['_meta']); }, $response['result']['hits']); return new UsersSearchResult( $response['result']['total'], $response['result']['hits'], $scrollId ); }
[ "public", "function", "scrollUsers", "(", "$", "scrollId", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "options", "[", "'httpParams'", "]", "=", "[", "':scrollId'", "=>", "$", "scrollId", "]", ";", "$", "data", "=", "[", "]", ";", "...
Returns the next users result set with scroll query. @param string $scrollId @param array $options (optional) arguments @return UsersSearchResult @throws \Exception
[ "Returns", "the", "next", "users", "result", "set", "with", "scroll", "query", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L298-L327
train
kuzzleio/sdk-php
src/Security/Security.php
Security.fetchProfile
public function fetchProfile($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getProfile'), $data, $options ); return new Profile($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function fetchProfile($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getProfile'), $data, $options ); return new Profile($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "fetchProfile", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", "]", ";", "$", "response", "=", "$", "this", "->", "kuzzle", "->", "query", "(", "$", ...
Retrieves a single stored profile using its unique ID. @param integer $id Unique profile identifier @param array $options Optional arguments @return Profile
[ "Retrieves", "a", "single", "stored", "profile", "using", "its", "unique", "ID", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L336-L349
train
kuzzleio/sdk-php
src/Security/Security.php
Security.fetchRole
public function fetchRole($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getRole'), $data, $options ); return new Role($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function fetchRole($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getRole'), $data, $options ); return new Role($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "fetchRole", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", "]", ";", "$", "response", "=", "$", "this", "->", "kuzzle", "->", "query", "(", "$", "th...
Retrieves a single stored role using its unique ID. @param integer $id Unique role identifier @param array $options Optional arguments @return Role
[ "Retrieves", "a", "single", "stored", "role", "using", "its", "unique", "ID", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L358-L371
train
kuzzleio/sdk-php
src/Security/Security.php
Security.fetchUser
public function fetchUser($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getUser'), $data, $options ); return new User($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
php
public function fetchUser($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getUser'), $data, $options ); return new User($this, $response['result']['_id'], $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "fetchUser", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", "]", ";", "$", "response", "=", "$", "this", "->", "kuzzle", "->", "query", "(", "$", "th...
Retrieves a single stored user using its unique ID. @param integer $id Unique user identifier @param array $options Optional arguments @return User
[ "Retrieves", "a", "single", "stored", "user", "using", "its", "unique", "ID", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L380-L393
train
kuzzleio/sdk-php
src/Security/Security.php
Security.getUserRights
public function getUserRights($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getUserRights'), $data, $options ); return $response['result']['hits']; }
php
public function getUserRights($id, array $options = []) { $data = [ '_id' => $id ]; $response = $this->kuzzle->query( $this->buildQueryArgs('getUserRights'), $data, $options ); return $response['result']['hits']; }
[ "public", "function", "getUserRights", "(", "$", "id", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", "]", ";", "$", "response", "=", "$", "this", "->", "kuzzle", "->", "query", "(", "$", ...
Gets the rights of given user. @param integer $id Id of the user @param array $options Optional arguments @return array
[ "Gets", "the", "rights", "of", "given", "user", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L402-L415
train
kuzzleio/sdk-php
src/Security/Security.php
Security.isActionAllowed
public function isActionAllowed(array $rights, $controller, $action, $index = '', $collection = '') { // We filter in all the rights that match the request (including wildcards). $filteredRights = array_filter($rights, function (array $right) use ($controller) { return array_key_exists('controller', $right) && ($right['controller'] === $controller || $right['controller'] === '*'); }); $filteredRights = array_filter($filteredRights, function (array $right) use ($action) { return array_key_exists('action', $right) && ($right['action'] === $action || $right['action'] === '*'); }); $filteredRights = array_filter($filteredRights, function (array $right) use ($index) { return array_key_exists('index', $right) && ($right['index'] === $index || $right['index'] === '*'); }); $filteredRights = array_filter($filteredRights, function (array $right) use ($collection) { return array_key_exists('collection', $right) && ($right['collection'] === $collection || $right['collection'] === '*'); }); $rightsValues = array_map(function ($element) { return $element['value']; }, $filteredRights); // Then, if at least one right allows the action, we return Security::ACTION_ALLOWED if (array_search(Security::ACTION_ALLOWED, $rightsValues) !== false) { return Security::ACTION_ALLOWED; } // If no right allows the action, we check for Security::ACTION_CONDITIONAL. elseif (array_search(Security::ACTION_CONDITIONAL, $rightsValues) !== false) { return Security::ACTION_CONDITIONAL; } // Otherwise we return Security::ACTION_DENIED. return Security::ACTION_DENIED; }
php
public function isActionAllowed(array $rights, $controller, $action, $index = '', $collection = '') { // We filter in all the rights that match the request (including wildcards). $filteredRights = array_filter($rights, function (array $right) use ($controller) { return array_key_exists('controller', $right) && ($right['controller'] === $controller || $right['controller'] === '*'); }); $filteredRights = array_filter($filteredRights, function (array $right) use ($action) { return array_key_exists('action', $right) && ($right['action'] === $action || $right['action'] === '*'); }); $filteredRights = array_filter($filteredRights, function (array $right) use ($index) { return array_key_exists('index', $right) && ($right['index'] === $index || $right['index'] === '*'); }); $filteredRights = array_filter($filteredRights, function (array $right) use ($collection) { return array_key_exists('collection', $right) && ($right['collection'] === $collection || $right['collection'] === '*'); }); $rightsValues = array_map(function ($element) { return $element['value']; }, $filteredRights); // Then, if at least one right allows the action, we return Security::ACTION_ALLOWED if (array_search(Security::ACTION_ALLOWED, $rightsValues) !== false) { return Security::ACTION_ALLOWED; } // If no right allows the action, we check for Security::ACTION_CONDITIONAL. elseif (array_search(Security::ACTION_CONDITIONAL, $rightsValues) !== false) { return Security::ACTION_CONDITIONAL; } // Otherwise we return Security::ACTION_DENIED. return Security::ACTION_DENIED; }
[ "public", "function", "isActionAllowed", "(", "array", "$", "rights", ",", "$", "controller", ",", "$", "action", ",", "$", "index", "=", "''", ",", "$", "collection", "=", "''", ")", "{", "// We filter in all the rights that match the request (including wildcards)....
Tells whether an action is allowed, denied or conditional based on the rights provided as the first argument @param array $rights Rights list (@see Security::getUserRights) @param string $controller The controller @param string $action The action @param string $index Optional index @param string $collection Optional collection @return string Security::ACTION_ALLOWED Security::ACTION_DENIED Security::ACTION_CONDITIONAL @throws ErrorException
[ "Tells", "whether", "an", "action", "is", "allowed", "denied", "or", "conditional", "based", "on", "the", "rights", "provided", "as", "the", "first", "argument" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L432-L465
train
kuzzleio/sdk-php
src/Security/Security.php
Security.searchProfiles
public function searchProfiles(array $filters, array $options = []) { $data = [ 'body' => $filters ]; $scrollId = null; $response = $this->kuzzle->query( $this->buildQueryArgs('searchProfiles'), $data, $options ); $response['result']['hits'] = array_map(function ($profile) { return new Profile($this, $profile['_id'], $profile['_source'], $profile['_meta']); }, $response['result']['hits']); if (isset($response['result']['scrollId'])) { $scrollId = $response['result']['scrollId']; } return new ProfilesSearchResult($response['result']['total'], $response['result']['hits'], $scrollId); }
php
public function searchProfiles(array $filters, array $options = []) { $data = [ 'body' => $filters ]; $scrollId = null; $response = $this->kuzzle->query( $this->buildQueryArgs('searchProfiles'), $data, $options ); $response['result']['hits'] = array_map(function ($profile) { return new Profile($this, $profile['_id'], $profile['_source'], $profile['_meta']); }, $response['result']['hits']); if (isset($response['result']['scrollId'])) { $scrollId = $response['result']['scrollId']; } return new ProfilesSearchResult($response['result']['total'], $response['result']['hits'], $scrollId); }
[ "public", "function", "searchProfiles", "(", "array", "$", "filters", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'body'", "=>", "$", "filters", "]", ";", "$", "scrollId", "=", "null", ";", "$", "response", "=", "...
Executes a search on profiles according to a filter @param array $filters List of filters to retrieves profiles @param array $options Optional arguments @return ProfilesSearchResult
[ "Executes", "a", "search", "on", "profiles", "according", "to", "a", "filter" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L513-L536
train
kuzzleio/sdk-php
src/Security/Security.php
Security.searchRoles
public function searchRoles(array $filters, array $options = []) { $data = [ 'body' => $filters ]; $response = $this->kuzzle->query( $this->buildQueryArgs('searchRoles'), $data, $options ); $response['result']['hits'] = array_map(function ($role) { return new Role($this, $role['_id'], $role['_source'], $role['_meta']); }, $response['result']['hits']); return new RolesSearchResult($response['result']['total'], $response['result']['hits']); }
php
public function searchRoles(array $filters, array $options = []) { $data = [ 'body' => $filters ]; $response = $this->kuzzle->query( $this->buildQueryArgs('searchRoles'), $data, $options ); $response['result']['hits'] = array_map(function ($role) { return new Role($this, $role['_id'], $role['_source'], $role['_meta']); }, $response['result']['hits']); return new RolesSearchResult($response['result']['total'], $response['result']['hits']); }
[ "public", "function", "searchRoles", "(", "array", "$", "filters", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'body'", "=>", "$", "filters", "]", ";", "$", "response", "=", "$", "this", "->", "kuzzle", "->", "que...
Executes a search on roles according to a filter @param array $filters List of filters to retrieves roles @param array $options Optional arguments @return RolesSearchResult
[ "Executes", "a", "search", "on", "roles", "according", "to", "a", "filter" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L545-L562
train
kuzzleio/sdk-php
src/Security/Security.php
Security.searchUsers
public function searchUsers(array $filters, array $options = []) { $data = [ 'body' => $filters ]; $scrollId = null; $response = $this->kuzzle->query( $this->buildQueryArgs('searchUsers'), $data, $options ); $response['result']['hits'] = array_map(function ($user) { return new User($this, $user['_id'], $user['_source'], $user['_meta']); }, $response['result']['hits']); if (isset($response['result']['scrollId'])) { $scrollId = $response['result']['scrollId']; } return new UsersSearchResult($response['result']['total'], $response['result']['hits'], $scrollId); }
php
public function searchUsers(array $filters, array $options = []) { $data = [ 'body' => $filters ]; $scrollId = null; $response = $this->kuzzle->query( $this->buildQueryArgs('searchUsers'), $data, $options ); $response['result']['hits'] = array_map(function ($user) { return new User($this, $user['_id'], $user['_source'], $user['_meta']); }, $response['result']['hits']); if (isset($response['result']['scrollId'])) { $scrollId = $response['result']['scrollId']; } return new UsersSearchResult($response['result']['total'], $response['result']['hits'], $scrollId); }
[ "public", "function", "searchUsers", "(", "array", "$", "filters", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'body'", "=>", "$", "filters", "]", ";", "$", "scrollId", "=", "null", ";", "$", "response", "=", "$",...
Executes a search on users according to a filter @param array $filters List of filters to retrieves users @param array $options Optional arguments @return UsersSearchResult
[ "Executes", "a", "search", "on", "users", "according", "to", "a", "filter" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L571-L594
train
kuzzleio/sdk-php
src/Security/Security.php
Security.updateProfile
public function updateProfile($id, array $policies, array $options = []) { $data = [ '_id' => $id, 'body' => [ 'policies' => $policies ] ]; $response = $this->kuzzle->query( $this->buildQueryArgs('updateProfile'), $data, $options ); return new Profile($this, $id, $response['result']['_source'], $response['result']['_meta']); }
php
public function updateProfile($id, array $policies, array $options = []) { $data = [ '_id' => $id, 'body' => [ 'policies' => $policies ] ]; $response = $this->kuzzle->query( $this->buildQueryArgs('updateProfile'), $data, $options ); return new Profile($this, $id, $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "updateProfile", "(", "$", "id", ",", "array", "$", "policies", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", ",", "'body'", "=>", "[", "'policies'", "=>", "$", "polici...
Performs a partial update on an existing profile. @param string $id Unique profile identifier @param array $policies List of policies to apply to this profile @param array $options Optional arguments @return Profile
[ "Performs", "a", "partial", "update", "on", "an", "existing", "profile", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L604-L618
train
kuzzleio/sdk-php
src/Security/Security.php
Security.updateRole
public function updateRole($id, array $content, array $options = []) { $data = [ '_id' => $id, 'body' => $content ]; $response = $this->kuzzle->query( $this->buildQueryArgs('updateRole'), $data, $options ); return new Role($this, $id, $response['result']['_source'], $response['result']['_meta']); }
php
public function updateRole($id, array $content, array $options = []) { $data = [ '_id' => $id, 'body' => $content ]; $response = $this->kuzzle->query( $this->buildQueryArgs('updateRole'), $data, $options ); return new Role($this, $id, $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "updateRole", "(", "$", "id", ",", "array", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", ",", "'body'", "=>", "$", "content", "]", ";", "$", "respons...
Performs a partial update on an existing role. @param string $id Unique role identifier @param array $content Data representing the role @param array $options Optional arguments @return Role
[ "Performs", "a", "partial", "update", "on", "an", "existing", "role", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L628-L642
train
kuzzleio/sdk-php
src/Security/Security.php
Security.updateUser
public function updateUser($id, array $content, array $options = []) { $data = [ '_id' => $id, 'body' => $content ]; $response = $this->kuzzle->query( $this->buildQueryArgs('updateUser'), $data, $options ); return new User($this, $id, $response['result']['_source'], $response['result']['_meta']); }
php
public function updateUser($id, array $content, array $options = []) { $data = [ '_id' => $id, 'body' => $content ]; $response = $this->kuzzle->query( $this->buildQueryArgs('updateUser'), $data, $options ); return new User($this, $id, $response['result']['_source'], $response['result']['_meta']); }
[ "public", "function", "updateUser", "(", "$", "id", ",", "array", "$", "content", ",", "array", "$", "options", "=", "[", "]", ")", "{", "$", "data", "=", "[", "'_id'", "=>", "$", "id", ",", "'body'", "=>", "$", "content", "]", ";", "$", "respons...
Performs a partial update on an existing user. @param string $id Unique user identifier @param array $content Data representing the user @param array $options Optional arguments @return User
[ "Performs", "a", "partial", "update", "on", "an", "existing", "user", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Security/Security.php#L652-L666
train
wallstreetio/ontraport
src/Response.php
Response.item
public function item() { if (!empty($this->response['data'])) { return new Fluent($this->resource, $this->response['data']); } // On a valid response that does not have a data field, we can assume that // the request is an update/delete type of request that does not return an object. return true; }
php
public function item() { if (!empty($this->response['data'])) { return new Fluent($this->resource, $this->response['data']); } // On a valid response that does not have a data field, we can assume that // the request is an update/delete type of request that does not return an object. return true; }
[ "public", "function", "item", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "response", "[", "'data'", "]", ")", ")", "{", "return", "new", "Fluent", "(", "$", "this", "->", "resource", ",", "$", "this", "->", "response", "[", "...
Retrieve an item from the Ontraport response. @return bool|\Wsio\Ontraport\Fluent
[ "Retrieve", "an", "item", "from", "the", "Ontraport", "response", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Response.php#L35-L45
train
wallstreetio/ontraport
src/Response.php
Response.collection
public function collection() { if (!empty($this->response['data'])) { $data = []; foreach ($this->response['data'] as $object) { $data[] = new Fluent($this->resource, $object); } return $data; } return []; }
php
public function collection() { if (!empty($this->response['data'])) { $data = []; foreach ($this->response['data'] as $object) { $data[] = new Fluent($this->resource, $object); } return $data; } return []; }
[ "public", "function", "collection", "(", ")", "{", "if", "(", "!", "empty", "(", "$", "this", "->", "response", "[", "'data'", "]", ")", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "response", "[", "'data'", "]",...
Retrieve an array of items from the Ontraport response. @return array
[ "Retrieve", "an", "array", "of", "items", "from", "the", "Ontraport", "response", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Response.php#L52-L65
train
joomla-framework/facebook-api
src/User.php
User.createPhoto
public function createPhoto($user, $source, $message = null, $place = null, $noStory = null) { // Set POST request parameters. $data = array(); $data[basename($source)] = '@' . realpath($source); $data['message'] = $message; $data['place'] = $place; $data['no_story'] = $noStory; return $this->createConnection($user, 'photos', $data, array('Content-Type' => 'multipart/form-data')); }
php
public function createPhoto($user, $source, $message = null, $place = null, $noStory = null) { // Set POST request parameters. $data = array(); $data[basename($source)] = '@' . realpath($source); $data['message'] = $message; $data['place'] = $place; $data['no_story'] = $noStory; return $this->createConnection($user, 'photos', $data, array('Content-Type' => 'multipart/form-data')); }
[ "public", "function", "createPhoto", "(", "$", "user", ",", "$", "source", ",", "$", "message", "=", "null", ",", "$", "place", "=", "null", ",", "$", "noStory", "=", "null", ")", "{", "// Set POST request parameters.", "$", "data", "=", "array", "(", ...
Method to post a photo on user's wall. Requires authentication and publish_stream permission, user_groups or friends_groups permission. @param mixed $user Either an integer containing the user ID or a string containing the username. @param string $source Path to photo. @param string $message Photo description. @param string $place Facebook ID of the place associated with the photo. @param boolean $noStory If set to 1, optionally suppresses the feed story that is automatically generated on a user’s profile when they upload a photo using your application. @return mixed The decoded JSON response or false if the client is not authenticated. @since 1.0
[ "Method", "to", "post", "a", "photo", "on", "user", "s", "wall", ".", "Requires", "authentication", "and", "publish_stream", "permission", "user_groups", "or", "friends_groups", "permission", "." ]
e7666ec1e9516f288a6f55f23a43a3d4a4edc76d
https://github.com/joomla-framework/facebook-api/blob/e7666ec1e9516f288a6f55f23a43a3d4a4edc76d/src/User.php#L646-L656
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.loadRequirements
public function loadRequirements() { // Load Required Themed JavaScript: if (ContentController::config()->load_themed_js) { foreach ($this->getRequiredThemedJS() as $js) { Requirements::themedJavascript($js); } } // Load Required Themed CSS: if (ContentController::config()->load_themed_css) { foreach ($this->getRequiredThemedCSS() as $css => $media) { Requirements::themedCSS($css, $media); } } // Load Required JavaScript: if (ContentController::config()->load_js) { foreach ($this->getRequiredJS() as $js) { Requirements::javascript($js); } } // Load Required CSS: if (ContentController::config()->load_css) { foreach ($this->getRequiredCSS() as $css => $media) { Requirements::css($css, $media); } } // Load Required Custom CSS: if (ContentController::config()->load_custom_css) { if ($css = $this->getCustomCSSAsString()) { Requirements::customCSS($css, $this->HTMLID); } } // Load Required JavaScript Templates: foreach ($this->getRequiredJSTemplates() as $file => $params) { ViewTools::singleton()->loadJSTemplate($file, $params['vars'], $params['id']); } }
php
public function loadRequirements() { // Load Required Themed JavaScript: if (ContentController::config()->load_themed_js) { foreach ($this->getRequiredThemedJS() as $js) { Requirements::themedJavascript($js); } } // Load Required Themed CSS: if (ContentController::config()->load_themed_css) { foreach ($this->getRequiredThemedCSS() as $css => $media) { Requirements::themedCSS($css, $media); } } // Load Required JavaScript: if (ContentController::config()->load_js) { foreach ($this->getRequiredJS() as $js) { Requirements::javascript($js); } } // Load Required CSS: if (ContentController::config()->load_css) { foreach ($this->getRequiredCSS() as $css => $media) { Requirements::css($css, $media); } } // Load Required Custom CSS: if (ContentController::config()->load_custom_css) { if ($css = $this->getCustomCSSAsString()) { Requirements::customCSS($css, $this->HTMLID); } } // Load Required JavaScript Templates: foreach ($this->getRequiredJSTemplates() as $file => $params) { ViewTools::singleton()->loadJSTemplate($file, $params['vars'], $params['id']); } }
[ "public", "function", "loadRequirements", "(", ")", "{", "// Load Required Themed JavaScript:", "if", "(", "ContentController", "::", "config", "(", ")", "->", "load_themed_js", ")", "{", "foreach", "(", "$", "this", "->", "getRequiredThemedJS", "(", ")", "as", ...
Loads the requirements for the object. @return void
[ "Loads", "the", "requirements", "for", "the", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L124-L181
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getRequiredCSS
public function getRequiredCSS() { $css = $this->config()->required_css; $this->extend('updateRequiredCSS', $css); return $this->processCSSConfig($css); }
php
public function getRequiredCSS() { $css = $this->config()->required_css; $this->extend('updateRequiredCSS', $css); return $this->processCSSConfig($css); }
[ "public", "function", "getRequiredCSS", "(", ")", "{", "$", "css", "=", "$", "this", "->", "config", "(", ")", "->", "required_css", ";", "$", "this", "->", "extend", "(", "'updateRequiredCSS'", ",", "$", "css", ")", ";", "return", "$", "this", "->", ...
Answers an array of CSS files required by the object. @return array
[ "Answers", "an", "array", "of", "CSS", "files", "required", "by", "the", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L202-L209
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getRequiredThemedCSS
public function getRequiredThemedCSS() { $css = $this->config()->required_themed_css; $this->extend('updateRequiredThemedCSS', $css); return $this->processCSSConfig($css); }
php
public function getRequiredThemedCSS() { $css = $this->config()->required_themed_css; $this->extend('updateRequiredThemedCSS', $css); return $this->processCSSConfig($css); }
[ "public", "function", "getRequiredThemedCSS", "(", ")", "{", "$", "css", "=", "$", "this", "->", "config", "(", ")", "->", "required_themed_css", ";", "$", "this", "->", "extend", "(", "'updateRequiredThemedCSS'", ",", "$", "css", ")", ";", "return", "$", ...
Answers an array of themed CSS files required by the object. @return array
[ "Answers", "an", "array", "of", "themed", "CSS", "files", "required", "by", "the", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L230-L237
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getRequiredJSTemplates
public function getRequiredJSTemplates() { $js = $this->config()->required_js_templates; $this->extend('updateRequiredJSTemplates', $js); return $this->processJSTemplateConfig($js); }
php
public function getRequiredJSTemplates() { $js = $this->config()->required_js_templates; $this->extend('updateRequiredJSTemplates', $js); return $this->processJSTemplateConfig($js); }
[ "public", "function", "getRequiredJSTemplates", "(", ")", "{", "$", "js", "=", "$", "this", "->", "config", "(", ")", "->", "required_js_templates", ";", "$", "this", "->", "extend", "(", "'updateRequiredJSTemplates'", ",", "$", "js", ")", ";", "return", "...
Answers an array of JavaScript templates required by the object. @return array
[ "Answers", "an", "array", "of", "JavaScript", "templates", "required", "by", "the", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L244-L251
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getAttributesHTML
public function getAttributesHTML($attributes = null) { // Initialise: $remove = []; // Detect Excluded Attributes: if (is_string($attributes)) { $remove = func_get_args(); } // Detect Passed Attributes: if (!$attributes || is_string($attributes)) { $attributes = $this->getAttributes(); } // Ensure Array Data Type: $attributes = (array) $attributes; // Remove Excluded Attributes: if (!empty($remove)) { $attributes = array_diff_key($attributes, array_flip($remove)); } // Answer Markup: return ViewTools::singleton()->getAttributesHTML($attributes); }
php
public function getAttributesHTML($attributes = null) { // Initialise: $remove = []; // Detect Excluded Attributes: if (is_string($attributes)) { $remove = func_get_args(); } // Detect Passed Attributes: if (!$attributes || is_string($attributes)) { $attributes = $this->getAttributes(); } // Ensure Array Data Type: $attributes = (array) $attributes; // Remove Excluded Attributes: if (!empty($remove)) { $attributes = array_diff_key($attributes, array_flip($remove)); } // Answer Markup: return ViewTools::singleton()->getAttributesHTML($attributes); }
[ "public", "function", "getAttributesHTML", "(", "$", "attributes", "=", "null", ")", "{", "// Initialise:", "$", "remove", "=", "[", "]", ";", "// Detect Excluded Attributes:", "if", "(", "is_string", "(", "$", "attributes", ")", ")", "{", "$", "remove", "="...
Answers the HTML tag attributes of the object as a string. If $attributes is a string, all arguments act as named attributes to exclude from rendering. @param array|string $attributes @return string
[ "Answers", "the", "HTML", "tag", "attributes", "of", "the", "object", "as", "a", "string", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L460-L491
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.setStyleIDFrom
public function setStyleIDFrom(DataObject $object, $suffix = null) { $this->StyleID = sprintf( '%s_%s', ClassTools::singleton()->getClassWithoutNamespace(get_class($object)), ClassTools::singleton()->getClassWithoutNamespace(get_class($this)) ); if (!is_null($suffix)) { $this->StyleID = sprintf( '%s_%s', $this->StyleID, $suffix ); } $this->StyleID = $this->cleanStyleID($this->StyleID); return $this; }
php
public function setStyleIDFrom(DataObject $object, $suffix = null) { $this->StyleID = sprintf( '%s_%s', ClassTools::singleton()->getClassWithoutNamespace(get_class($object)), ClassTools::singleton()->getClassWithoutNamespace(get_class($this)) ); if (!is_null($suffix)) { $this->StyleID = sprintf( '%s_%s', $this->StyleID, $suffix ); } $this->StyleID = $this->cleanStyleID($this->StyleID); return $this; }
[ "public", "function", "setStyleIDFrom", "(", "DataObject", "$", "object", ",", "$", "suffix", "=", "null", ")", "{", "$", "this", "->", "StyleID", "=", "sprintf", "(", "'%s_%s'", ",", "ClassTools", "::", "singleton", "(", ")", "->", "getClassWithoutNamespace...
Defines the style ID of the receiver from the given data object and optional suffix. @param DataObject $object @param string $suffix @return $this
[ "Defines", "the", "style", "ID", "of", "the", "receiver", "from", "the", "given", "data", "object", "and", "optional", "suffix", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L543-L562
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getClassNameWithID
public function getClassNameWithID($includeNamespace = false) { $className = static::class; if (!$includeNamespace) { $className = ClassTools::singleton()->getClassWithoutNamespace($className); } return sprintf( '%s_%s', $className, $this->ID ); }
php
public function getClassNameWithID($includeNamespace = false) { $className = static::class; if (!$includeNamespace) { $className = ClassTools::singleton()->getClassWithoutNamespace($className); } return sprintf( '%s_%s', $className, $this->ID ); }
[ "public", "function", "getClassNameWithID", "(", "$", "includeNamespace", "=", "false", ")", "{", "$", "className", "=", "static", "::", "class", ";", "if", "(", "!", "$", "includeNamespace", ")", "{", "$", "className", "=", "ClassTools", "::", "singleton", ...
Answers the class name and ID of the object as a string. @param boolean $includeNamespace If true, also include the namespace of the object. @return string
[ "Answers", "the", "class", "name", "and", "ID", "of", "the", "object", "as", "a", "string", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L571-L584
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getCustomCSS
public function getCustomCSS() { // Create CSS Array: $css = []; // Merge Custom CSS from Template: foreach (ClassTools::singleton()->getObjectAncestry($this, self::class) as $class) { $template = $this->getCustomCSSTemplate($class); if (SSViewer::hasTemplate($template)) { $css = ViewTools::singleton()->renderCSS($this, $template, $css); } } // Update CSS via Extensions: $this->extend('updateCustomCSS', $css); // Filter CSS Array: $css = array_filter($css); // Answer CSS Array: return $css; }
php
public function getCustomCSS() { // Create CSS Array: $css = []; // Merge Custom CSS from Template: foreach (ClassTools::singleton()->getObjectAncestry($this, self::class) as $class) { $template = $this->getCustomCSSTemplate($class); if (SSViewer::hasTemplate($template)) { $css = ViewTools::singleton()->renderCSS($this, $template, $css); } } // Update CSS via Extensions: $this->extend('updateCustomCSS', $css); // Filter CSS Array: $css = array_filter($css); // Answer CSS Array: return $css; }
[ "public", "function", "getCustomCSS", "(", ")", "{", "// Create CSS Array:", "$", "css", "=", "[", "]", ";", "// Merge Custom CSS from Template:", "foreach", "(", "ClassTools", "::", "singleton", "(", ")", "->", "getObjectAncestry", "(", "$", "this", ",", "self"...
Answers an array of custom CSS required for the template. @return array
[ "Answers", "an", "array", "of", "custom", "CSS", "required", "for", "the", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L611-L640
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.render
public function render($layout = null, $title = null) { // Initialise: $html = ''; // Load Requirements: $this->loadRequirements(); // Obtain Cached HTML (if enabled): if ($this->isCacheEnabled()) { $html = self::getRenderCache()->get($this->getRenderCacheID()); } // Render HTML: if (!$html) { // Render Self: $html = (string) $this->renderSelf($layout, $title); // Cache Rendered HTML: if ($this->isCacheEnabled()) { self::getRenderCache()->set($this->getRenderCacheID(), $html, $this->getRenderCacheLifetime()); } } elseif (isset($_REQUEST['debug_cache'])) { // Output Debug Information: Debug::message( sprintf( 'Rendered from cache: "%s" [%s]; lifetime: %d second(s)', $this->getTitle(), $this->getRenderCacheID(), $this->getRenderCacheLifetime() ), false ); } // Answer HTML: return $html; }
php
public function render($layout = null, $title = null) { // Initialise: $html = ''; // Load Requirements: $this->loadRequirements(); // Obtain Cached HTML (if enabled): if ($this->isCacheEnabled()) { $html = self::getRenderCache()->get($this->getRenderCacheID()); } // Render HTML: if (!$html) { // Render Self: $html = (string) $this->renderSelf($layout, $title); // Cache Rendered HTML: if ($this->isCacheEnabled()) { self::getRenderCache()->set($this->getRenderCacheID(), $html, $this->getRenderCacheLifetime()); } } elseif (isset($_REQUEST['debug_cache'])) { // Output Debug Information: Debug::message( sprintf( 'Rendered from cache: "%s" [%s]; lifetime: %d second(s)', $this->getTitle(), $this->getRenderCacheID(), $this->getRenderCacheLifetime() ), false ); } // Answer HTML: return $html; }
[ "public", "function", "render", "(", "$", "layout", "=", "null", ",", "$", "title", "=", "null", ")", "{", "// Initialise:", "$", "html", "=", "''", ";", "// Load Requirements:", "$", "this", "->", "loadRequirements", "(", ")", ";", "// Obtain Cached HTML (i...
Renders the object for the HTML template. @param string $layout Page layout passed from template. @param string $title Page title passed from template. @return DBHTMLText|string
[ "Renders", "the", "object", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L778-L827
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.processCSSConfig
protected function processCSSConfig($config) { if (!ArrayLib::is_associative($config)) { return array_fill_keys(array_values($config), null); } return $config; }
php
protected function processCSSConfig($config) { if (!ArrayLib::is_associative($config)) { return array_fill_keys(array_values($config), null); } return $config; }
[ "protected", "function", "processCSSConfig", "(", "$", "config", ")", "{", "if", "(", "!", "ArrayLib", "::", "is_associative", "(", "$", "config", ")", ")", "{", "return", "array_fill_keys", "(", "array_values", "(", "$", "config", ")", ",", "null", ")", ...
Processes the given CSS config and answers an array suitable for loading requirements. @param array $config @return array
[ "Processes", "the", "given", "CSS", "config", "and", "answers", "an", "array", "suitable", "for", "loading", "requirements", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L836-L843
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.processJSTemplateConfig
protected function processJSTemplateConfig($config) { $templates = []; foreach ($config as $key => $value) { if (is_integer($key)) { $templates[$value] = [ 'vars' => $this->getJSVars(), 'id' => $this->getHTMLID() ]; } else { $templates[$key] = [ 'vars' => $this->getJSTemplateVars(array_shift($value)), 'id' => $this->getJSTemplateID(array_shift($value)) ]; } } return $templates; }
php
protected function processJSTemplateConfig($config) { $templates = []; foreach ($config as $key => $value) { if (is_integer($key)) { $templates[$value] = [ 'vars' => $this->getJSVars(), 'id' => $this->getHTMLID() ]; } else { $templates[$key] = [ 'vars' => $this->getJSTemplateVars(array_shift($value)), 'id' => $this->getJSTemplateID(array_shift($value)) ]; } } return $templates; }
[ "protected", "function", "processJSTemplateConfig", "(", "$", "config", ")", "{", "$", "templates", "=", "[", "]", ";", "foreach", "(", "$", "config", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_integer", "(", "$", "key", ")", ")",...
Processes the given JavaScript template config and answers an array suitable for loading requirements. @param array $config @return array
[ "Processes", "the", "given", "JavaScript", "template", "config", "and", "answers", "an", "array", "suitable", "for", "loading", "requirements", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L852-L877
train
praxisnetau/silverware
src/View/Renderable.php
Renderable.getJSTemplateVars
protected function getJSTemplateVars($vars) { if (is_array($vars)) { return $vars; } if ($this->hasMethod($vars)) { return $this->{$vars}(); } return []; }
php
protected function getJSTemplateVars($vars) { if (is_array($vars)) { return $vars; } if ($this->hasMethod($vars)) { return $this->{$vars}(); } return []; }
[ "protected", "function", "getJSTemplateVars", "(", "$", "vars", ")", "{", "if", "(", "is_array", "(", "$", "vars", ")", ")", "{", "return", "$", "vars", ";", "}", "if", "(", "$", "this", "->", "hasMethod", "(", "$", "vars", ")", ")", "{", "return",...
Answers an array of variables for a required JavaScript template. @param string|array $vars Array of variables or method name. @return array
[ "Answers", "an", "array", "of", "variables", "for", "a", "required", "JavaScript", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/View/Renderable.php#L886-L897
train
EcomDev/cache-key
src/Converter/HashConverter.php
HashConverter.convert
public function convert($value) { if (!is_array($value)) { return false; } $value = json_encode($value); return md5($value); }
php
public function convert($value) { if (!is_array($value)) { return false; } $value = json_encode($value); return md5($value); }
[ "public", "function", "convert", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "$", "value", "=", "json_encode", "(", "$", "value", ")", ";", "return", "md5", "(", "$", "va...
Converts array values into hash @param mixed $value @return bool
[ "Converts", "array", "values", "into", "hash" ]
5f90f5a013100ec57d7f3a842f48222ba8a4ccf9
https://github.com/EcomDev/cache-key/blob/5f90f5a013100ec57d7f3a842f48222ba8a4ccf9/src/Converter/HashConverter.php#L19-L27
train
i-am-tom/schemer
src/Formatter/Collection.php
Collection.sort
public function sort(callable $comparator = null) : Collection { return $this->pipe( function (array $value) use ($comparator) : array { $comparator !== null ? usort($value, $comparator) : sort($value); return $value; } ); }
php
public function sort(callable $comparator = null) : Collection { return $this->pipe( function (array $value) use ($comparator) : array { $comparator !== null ? usort($value, $comparator) : sort($value); return $value; } ); }
[ "public", "function", "sort", "(", "callable", "$", "comparator", "=", "null", ")", ":", "Collection", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "array", "$", "value", ")", "use", "(", "$", "comparator", ")", ":", "array", "{", ...
THe array will be sorted, possibly by a given function. @param callable $comparator @return Schemer\Formatter\Collection
[ "THe", "array", "will", "be", "sorted", "possibly", "by", "a", "given", "function", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Collection.php#L32-L43
train
i-am-tom/schemer
src/Formatter/Collection.php
Collection.truncate
public function truncate(int $maximum) : Collection { return $this->pipe( function (array $value) use ($maximum) : array { return count($value) > $maximum ? array_slice($value, 0, $maximum) : $value; } ); }
php
public function truncate(int $maximum) : Collection { return $this->pipe( function (array $value) use ($maximum) : array { return count($value) > $maximum ? array_slice($value, 0, $maximum) : $value; } ); }
[ "public", "function", "truncate", "(", "int", "$", "maximum", ")", ":", "Collection", "{", "return", "$", "this", "->", "pipe", "(", "function", "(", "array", "$", "value", ")", "use", "(", "$", "maximum", ")", ":", "array", "{", "return", "count", "...
The array will have no more than a given number of elements. @param int $maximum @return Schemer\Formatter\Collection
[ "The", "array", "will", "have", "no", "more", "than", "a", "given", "number", "of", "elements", "." ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/Formatter/Collection.php#L50-L59
train
hakito/php-wirecard-checkout-seamless
src/Api/ConfirmationResponse.php
ConfirmationResponse.InitFromArrayWithSecret
public function InitFromArrayWithSecret($data, $secret) { if (!isset($data['paymentState'])) { throw new \InvalidArgumentException('No paymentState provided.'); } $validStates = array('CANCEL', 'PENDING', 'FAILURE', 'SUCCESS'); $paymentState = $data['paymentState']; if (!in_array($paymentState, $validStates)) { throw new \InvalidArgumentException('Invalid paymentState "' . $paymentState . '".'); } $this->InitFromArray($data); if ($this->GetPaymentState() != 'SUCCESS') { return; } $this->CheckFingerprint($secret); }
php
public function InitFromArrayWithSecret($data, $secret) { if (!isset($data['paymentState'])) { throw new \InvalidArgumentException('No paymentState provided.'); } $validStates = array('CANCEL', 'PENDING', 'FAILURE', 'SUCCESS'); $paymentState = $data['paymentState']; if (!in_array($paymentState, $validStates)) { throw new \InvalidArgumentException('Invalid paymentState "' . $paymentState . '".'); } $this->InitFromArray($data); if ($this->GetPaymentState() != 'SUCCESS') { return; } $this->CheckFingerprint($secret); }
[ "public", "function", "InitFromArrayWithSecret", "(", "$", "data", ",", "$", "secret", ")", "{", "if", "(", "!", "isset", "(", "$", "data", "[", "'paymentState'", "]", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentException", "(", "'No paymentState pr...
Initializes from data array. In case of success the fields will be validated using the fingerprint and the secret. @param type $data Normally you should forward the $_POST array here @param type $secret Your wirecard secret @throws \InvalidArgumentException when mandatory fields are missing @throws InvalidFingerprintException when fingerprint validation fails
[ "Initializes", "from", "data", "array", ".", "In", "case", "of", "success", "the", "fields", "will", "be", "validated", "using", "the", "fingerprint", "and", "the", "secret", "." ]
cdea47abb2fdcc2a4f7de7cafd64e3ba1a1b28ce
https://github.com/hakito/php-wirecard-checkout-seamless/blob/cdea47abb2fdcc2a4f7de7cafd64e3ba1a1b28ce/src/Api/ConfirmationResponse.php#L19-L42
train
crisu83/yii-sentry
components/SentryClient.php
SentryClient.captureException
public function captureException($exception, $options = array(), $logger = '', $context = null) { if (!$this->isEnvironmentEnabled()) { return null; } $this->processOptions($options); try { $eventId = $this->_client->getIdent( $this->_client->captureException($exception, $options, $logger, $context) ); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to log exception: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to log exception.', (int)$e->getCode()); } } $this->_loggedEventIds[] = $eventId; $this->log(sprintf('Exception logged to Sentry with event id: %d', $eventId), CLogger::LEVEL_INFO); return $eventId; }
php
public function captureException($exception, $options = array(), $logger = '', $context = null) { if (!$this->isEnvironmentEnabled()) { return null; } $this->processOptions($options); try { $eventId = $this->_client->getIdent( $this->_client->captureException($exception, $options, $logger, $context) ); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to log exception: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to log exception.', (int)$e->getCode()); } } $this->_loggedEventIds[] = $eventId; $this->log(sprintf('Exception logged to Sentry with event id: %d', $eventId), CLogger::LEVEL_INFO); return $eventId; }
[ "public", "function", "captureException", "(", "$", "exception", ",", "$", "options", "=", "array", "(", ")", ",", "$", "logger", "=", "''", ",", "$", "context", "=", "null", ")", "{", "if", "(", "!", "$", "this", "->", "isEnvironmentEnabled", "(", "...
Logs an exception to Sentry. @param Exception $exception exception to log. @param array $options capture options that can contain the following structure: culprit: (string) function call that caused the event extra: (array) additional metadata to store with the event @param string $logger name of the logger. @param mixed $context exception context. @return string event id (or null if not captured). @throws CException if logging the exception fails.
[ "Logs", "an", "exception", "to", "Sentry", "." ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryClient.php#L111-L132
train
crisu83/yii-sentry
components/SentryClient.php
SentryClient.captureMessage
public function captureMessage($message, $params = array(), $options = array(), $stack = false, $context = null) { if (strlen($message) > self::MAX_MESSAGE_LENGTH) { throw new CException(sprintf( 'SentryClient cannot send messages that contain more than %d characters.', self::MAX_MESSAGE_LENGTH )); } if (!$this->isEnvironmentEnabled()) { return null; } $this->processOptions($options); try { $eventId = $this->_client->getIdent( $this->_client->captureMessage($message, $params, $options, $stack, $context) ); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to log message: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to log message.', (int)$e->getCode()); } } $this->_loggedEventIds[] = $eventId; $this->log(sprintf('Message logged to Sentry with event id: %d', $eventId), CLogger::LEVEL_INFO); return $eventId; }
php
public function captureMessage($message, $params = array(), $options = array(), $stack = false, $context = null) { if (strlen($message) > self::MAX_MESSAGE_LENGTH) { throw new CException(sprintf( 'SentryClient cannot send messages that contain more than %d characters.', self::MAX_MESSAGE_LENGTH )); } if (!$this->isEnvironmentEnabled()) { return null; } $this->processOptions($options); try { $eventId = $this->_client->getIdent( $this->_client->captureMessage($message, $params, $options, $stack, $context) ); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to log message: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to log message.', (int)$e->getCode()); } } $this->_loggedEventIds[] = $eventId; $this->log(sprintf('Message logged to Sentry with event id: %d', $eventId), CLogger::LEVEL_INFO); return $eventId; }
[ "public", "function", "captureMessage", "(", "$", "message", ",", "$", "params", "=", "array", "(", ")", ",", "$", "options", "=", "array", "(", ")", ",", "$", "stack", "=", "false", ",", "$", "context", "=", "null", ")", "{", "if", "(", "strlen", ...
Logs a message to Sentry. @param string $message message to log. @param array $params message parameters. @param array $options capture options that can contain the following structure: culprit: (string) function call that caused the event extra: (array) additional metadata to store with the event @param bool $stack whether to send the stack trace. @param mixed $context message context. @return string event id (or null if not captured). @throws CException if logging the message fails.
[ "Logs", "a", "message", "to", "Sentry", "." ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryClient.php#L146-L173
train
crisu83/yii-sentry
components/SentryClient.php
SentryClient.captureQuery
public function captureQuery($query, $level = CLogger::LEVEL_INFO, $engine = '') { if (!$this->isEnvironmentEnabled()) { return null; } try { $eventId = $this->_client->getIdent( $this->_client->captureQuery($query, $level, $engine) ); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to log query: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to log query.', (int)$e->getCode()); } } $this->_loggedEventIds[] = $eventId; $this->log(sprintf('Query logged to Sentry with event id: %d', $eventId), CLogger::LEVEL_INFO); return $eventId; }
php
public function captureQuery($query, $level = CLogger::LEVEL_INFO, $engine = '') { if (!$this->isEnvironmentEnabled()) { return null; } try { $eventId = $this->_client->getIdent( $this->_client->captureQuery($query, $level, $engine) ); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to log query: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to log query.', (int)$e->getCode()); } } $this->_loggedEventIds[] = $eventId; $this->log(sprintf('Query logged to Sentry with event id: %d', $eventId), CLogger::LEVEL_INFO); return $eventId; }
[ "public", "function", "captureQuery", "(", "$", "query", ",", "$", "level", "=", "CLogger", "::", "LEVEL_INFO", ",", "$", "engine", "=", "''", ")", "{", "if", "(", "!", "$", "this", "->", "isEnvironmentEnabled", "(", ")", ")", "{", "return", "null", ...
Logs a query to Sentry. @param string $query query to log. @param string $level log level. @param string $engine name of the sql driver. @return string event id (or null if not captured). @throws CException if logging the query fails.
[ "Logs", "a", "query", "to", "Sentry", "." ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryClient.php#L183-L203
train
crisu83/yii-sentry
components/SentryClient.php
SentryClient.processOptions
protected function processOptions(&$options) { if (!isset($options['extra'])) { $options['extra'] = array(); } $options['extra'] = CMap::mergeArray($this->extraVariables, $options['extra']); }
php
protected function processOptions(&$options) { if (!isset($options['extra'])) { $options['extra'] = array(); } $options['extra'] = CMap::mergeArray($this->extraVariables, $options['extra']); }
[ "protected", "function", "processOptions", "(", "&", "$", "options", ")", "{", "if", "(", "!", "isset", "(", "$", "options", "[", "'extra'", "]", ")", ")", "{", "$", "options", "[", "'extra'", "]", "=", "array", "(", ")", ";", "}", "$", "options", ...
Processes the given options. @param array $options the options to process.
[ "Processes", "the", "given", "options", "." ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryClient.php#L218-L224
train
crisu83/yii-sentry
components/SentryClient.php
SentryClient.createClient
protected function createClient() { $options = CMap::mergeArray( array( 'logger' => 'yii', 'tags' => array( 'environment' => $this->environment, 'php_version' => phpversion(), ), ), $this->options ); try { $this->checkTags($options['tags']); return new Raven_Client($this->dns, $options); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to create client: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to create client.', (int)$e->getCode()); } } }
php
protected function createClient() { $options = CMap::mergeArray( array( 'logger' => 'yii', 'tags' => array( 'environment' => $this->environment, 'php_version' => phpversion(), ), ), $this->options ); try { $this->checkTags($options['tags']); return new Raven_Client($this->dns, $options); } catch (Exception $e) { if (YII_DEBUG) { throw new CException('SentryClient failed to create client: ' . $e->getMessage(), (int)$e->getCode()); } else { $this->log($e->getMessage(), CLogger::LEVEL_ERROR); throw new CException('SentryClient failed to create client.', (int)$e->getCode()); } } }
[ "protected", "function", "createClient", "(", ")", "{", "$", "options", "=", "CMap", "::", "mergeArray", "(", "array", "(", "'logger'", "=>", "'yii'", ",", "'tags'", "=>", "array", "(", "'environment'", "=>", "$", "this", "->", "environment", ",", "'php_ve...
Creates a Raven client @return Raven_Client client instance. @throws CException if the client could not be created.
[ "Creates", "a", "Raven", "client" ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryClient.php#L241-L264
train
crisu83/yii-sentry
components/SentryClient.php
SentryClient.checkTags
protected function checkTags($tags) { foreach ($tags as $key => $value) { if (strlen($key) > self::MAX_TAG_KEY_LENGTH) { throw new CException(sprintf( 'SentryClient does not allow tag keys that contain more than %d characters.', self::MAX_TAG_KEY_LENGTH )); } if (strlen($value) > self::MAX_TAG_VALUE_LENGTH) { throw new CException(sprintf( 'SentryClient does not allow tag values that contain more than %d characters.', self::MAX_TAG_VALUE_LENGTH )); } } }
php
protected function checkTags($tags) { foreach ($tags as $key => $value) { if (strlen($key) > self::MAX_TAG_KEY_LENGTH) { throw new CException(sprintf( 'SentryClient does not allow tag keys that contain more than %d characters.', self::MAX_TAG_KEY_LENGTH )); } if (strlen($value) > self::MAX_TAG_VALUE_LENGTH) { throw new CException(sprintf( 'SentryClient does not allow tag values that contain more than %d characters.', self::MAX_TAG_VALUE_LENGTH )); } } }
[ "protected", "function", "checkTags", "(", "$", "tags", ")", "{", "foreach", "(", "$", "tags", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "strlen", "(", "$", "key", ")", ">", "self", "::", "MAX_TAG_KEY_LENGTH", ")", "{", "throw", "n...
Checks that the given tags are valid. @param array $tags tags to check. @throws CException if a tag is invalid.
[ "Checks", "that", "the", "given", "tags", "are", "valid", "." ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryClient.php#L271-L287
train
crisu83/yii-sentry
components/SentryLogRoute.php
SentryLogRoute.processLogs
protected function processLogs($logs) { foreach ($logs as $log) { $this->getSentryClient()->captureMessage( $log[0], array(), array( 'extra' => array( 'message' => $log[0], 'level' => $log[1], 'category' => $log[2], 'log_time' => date('Y-m-d H:i:s', $log[3]), ), ) ); } }
php
protected function processLogs($logs) { foreach ($logs as $log) { $this->getSentryClient()->captureMessage( $log[0], array(), array( 'extra' => array( 'message' => $log[0], 'level' => $log[1], 'category' => $log[2], 'log_time' => date('Y-m-d H:i:s', $log[3]), ), ) ); } }
[ "protected", "function", "processLogs", "(", "$", "logs", ")", "{", "foreach", "(", "$", "logs", "as", "$", "log", ")", "{", "$", "this", "->", "getSentryClient", "(", ")", "->", "captureMessage", "(", "$", "log", "[", "0", "]", ",", "array", "(", ...
Processes log messages and sends them to specific destination. Derived child classes must implement this method. @param array $logs list of messages. Each array element represents one message with the following structure: array( [0] => message (string) [1] => level (string) [2] => category (string) [3] => timestamp (float, obtained by microtime(true) );
[ "Processes", "log", "messages", "and", "sends", "them", "to", "specific", "destination", ".", "Derived", "child", "classes", "must", "implement", "this", "method", "." ]
beacc88e06a0eb32903e4eae63cc6cddea901524
https://github.com/crisu83/yii-sentry/blob/beacc88e06a0eb32903e4eae63cc6cddea901524/components/SentryLogRoute.php#L32-L48
train
praxisnetau/silverware
src/Forms/GridField/GridFieldConfig_MultiClassEditor.php
GridFieldConfig_MultiClassEditor.setClasses
public function setClasses($classes, $default = null) { if ($component = $this->getComponentByType(GridFieldAddNewMultiClass::class)) { $component->setClasses($classes, $default); } return $this; }
php
public function setClasses($classes, $default = null) { if ($component = $this->getComponentByType(GridFieldAddNewMultiClass::class)) { $component->setClasses($classes, $default); } return $this; }
[ "public", "function", "setClasses", "(", "$", "classes", ",", "$", "default", "=", "null", ")", "{", "if", "(", "$", "component", "=", "$", "this", "->", "getComponentByType", "(", "GridFieldAddNewMultiClass", "::", "class", ")", ")", "{", "$", "component"...
Defines the classes that can be created using the grid field. @param array $classes Class names optionally mapped to titles. @param string $default Optional default class name. @return $this
[ "Defines", "the", "classes", "that", "can", "be", "created", "using", "the", "grid", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/GridField/GridFieldConfig_MultiClassEditor.php#L69-L76
train
kuzzleio/sdk-php
src/Document.php
Document.delete
public function delete(array $options = []) { if (!$this->id) { throw new InvalidArgumentException('Kuzzle\Document::delete: cannot delete a document without a document ID'); } $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'delete'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); return $this->id; }
php
public function delete(array $options = []) { if (!$this->id) { throw new InvalidArgumentException('Kuzzle\Document::delete: cannot delete a document without a document ID'); } $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'delete'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); return $this->id; }
[ "public", "function", "delete", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "id", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Kuzzle\\Document::delete: cannot delete a document without a document ID'", ...
Deletes this document in Kuzzle @param array $options Optional parameters @return integer Id of document deleted @throws InvalidArgumentException
[ "Deletes", "this", "document", "in", "Kuzzle" ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Document.php#L88-L101
train
kuzzleio/sdk-php
src/Document.php
Document.exists
public function exists(array $options = []) { if (!$this->id) { throw new InvalidArgumentException('Kuzzle\Document::exists: cannot check if the document exists without a document ID'); } $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'exists'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); return $response['result']; }
php
public function exists(array $options = []) { if (!$this->id) { throw new InvalidArgumentException('Kuzzle\Document::exists: cannot check if the document exists without a document ID'); } $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'exists'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); return $response['result']; }
[ "public", "function", "exists", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "id", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Kuzzle\\Document::exists: cannot check if the document exists without a docum...
Checks if this document exists in Kuzzle. @param array $options @return boolean @throws InvalidArgumentException
[ "Checks", "if", "this", "document", "exists", "in", "Kuzzle", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Document.php#L111-L124
train
kuzzleio/sdk-php
src/Document.php
Document.refresh
public function refresh(array $options = []) { if (!$this->id) { throw new InvalidArgumentException('Kuzzle\Document::refresh: cannot retrieve a document without a document ID'); } $data = [ '_id' => $this->id ]; $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'get'), $this->collection->getKuzzle()->addHeaders($data, $this->headers), $options ); $documentContent = $response['result']['_source']; $documentContent['_version'] = $response['result']['_version']; $documentMeta = $response['result']['_meta']; return new Document($this->collection, $response['result']['_id'], $documentContent, $documentMeta); }
php
public function refresh(array $options = []) { if (!$this->id) { throw new InvalidArgumentException('Kuzzle\Document::refresh: cannot retrieve a document without a document ID'); } $data = [ '_id' => $this->id ]; $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'get'), $this->collection->getKuzzle()->addHeaders($data, $this->headers), $options ); $documentContent = $response['result']['_source']; $documentContent['_version'] = $response['result']['_version']; $documentMeta = $response['result']['_meta']; return new Document($this->collection, $response['result']['_id'], $documentContent, $documentMeta); }
[ "public", "function", "refresh", "(", "array", "$", "options", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "id", ")", "{", "throw", "new", "InvalidArgumentException", "(", "'Kuzzle\\Document::refresh: cannot retrieve a document without a document ID'...
Creates a new KuzzleDocument object with the last version of this document stored in Kuzzle. @param array $options Optional parameters @return Document @throws InvalidArgumentException
[ "Creates", "a", "new", "KuzzleDocument", "object", "with", "the", "last", "version", "of", "this", "document", "stored", "in", "Kuzzle", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Document.php#L134-L155
train
kuzzleio/sdk-php
src/Document.php
Document.save
public function save(array $options = []) { $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'createOrReplace'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); $this->id = $response['result']['_id']; $this->version = $response['result']['_version']; return $this; }
php
public function save(array $options = []) { $response = $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('document', 'createOrReplace'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); $this->id = $response['result']['_id']; $this->version = $response['result']['_version']; return $this; }
[ "public", "function", "save", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "response", "=", "$", "this", "->", "collection", "->", "getKuzzle", "(", ")", "->", "query", "(", "$", "this", "->", "collection", "->", "buildQueryArgs", "(", ...
Saves this document into Kuzzle. If this is a new document, this function will create it in Kuzzle and the id property will be made available. Otherwise, this method will replace the latest version of this document in Kuzzle by the current content of this object. @param array $options Optional parameters @return Document
[ "Saves", "this", "document", "into", "Kuzzle", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Document.php#L166-L178
train
kuzzleio/sdk-php
src/Document.php
Document.publish
public function publish(array $options = []) { $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('realtime', 'publish'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); return $this; }
php
public function publish(array $options = []) { $this->collection->getKuzzle()->query( $this->collection->buildQueryArgs('realtime', 'publish'), $this->collection->getKuzzle()->addHeaders($this->serialize(), $this->headers), $options ); return $this; }
[ "public", "function", "publish", "(", "array", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "collection", "->", "getKuzzle", "(", ")", "->", "query", "(", "$", "this", "->", "collection", "->", "buildQueryArgs", "(", "'realtime'", ",", "...
Sends the content of this document as a realtime message. Takes an optional argument object with the following properties: - volatile (object, default: null): Additional information passed to notifications to other users @param array $options @return Document
[ "Sends", "the", "content", "of", "this", "document", "as", "a", "realtime", "message", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Document.php#L190-L199
train
kuzzleio/sdk-php
src/Document.php
Document.setContent
public function setContent(array $content, $replace = false) { if ($replace) { $this->content = $content; } else { foreach ($content as $key => $value) { $this->content[$key] = $value; } } return $this; }
php
public function setContent(array $content, $replace = false) { if ($replace) { $this->content = $content; } else { foreach ($content as $key => $value) { $this->content[$key] = $value; } } return $this; }
[ "public", "function", "setContent", "(", "array", "$", "content", ",", "$", "replace", "=", "false", ")", "{", "if", "(", "$", "replace", ")", "{", "$", "this", "->", "content", "=", "$", "content", ";", "}", "else", "{", "foreach", "(", "$", "cont...
Replaces the current content with new data. This is a helper function returning itself, allowing to easily chain calls. @param array $content @param bool $replace true: replace the current content with the provided data, false: merge it @return Document
[ "Replaces", "the", "current", "content", "with", "new", "data", ".", "This", "is", "a", "helper", "function", "returning", "itself", "allowing", "to", "easily", "chain", "calls", "." ]
b1e76cafaa9c7cc08d619c838c6208489e94565b
https://github.com/kuzzleio/sdk-php/blob/b1e76cafaa9c7cc08d619c838c6208489e94565b/src/Document.php#L210-L221
train
praxisnetau/silverware
src/Extensions/Style/ThemeStyle.php
ThemeStyle.getDropdownOptions
public function getDropdownOptions($name) { $config = Config::inst()->get(static::class, 'theme_styles'); return (isset($config[$name]) && is_array($config[$name])) ? $config[$name] : []; }
php
public function getDropdownOptions($name) { $config = Config::inst()->get(static::class, 'theme_styles'); return (isset($config[$name]) && is_array($config[$name])) ? $config[$name] : []; }
[ "public", "function", "getDropdownOptions", "(", "$", "name", ")", "{", "$", "config", "=", "Config", "::", "inst", "(", ")", "->", "get", "(", "static", "::", "class", ",", "'theme_styles'", ")", ";", "return", "(", "isset", "(", "$", "config", "[", ...
Answers an array of options with the given style name for a dropdown field. @param string $name @return array
[ "Answers", "an", "array", "of", "options", "with", "the", "given", "style", "name", "for", "a", "dropdown", "field", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Extensions/Style/ThemeStyle.php#L153-L158
train
praxisnetau/silverware
src/Model/Component.php
Component.setParentInstance
public function setParentInstance(SiteTree $parent) { $this->parentInstance = $parent; $this->setStyleIDFrom($parent); return $this; }
php
public function setParentInstance(SiteTree $parent) { $this->parentInstance = $parent; $this->setStyleIDFrom($parent); return $this; }
[ "public", "function", "setParentInstance", "(", "SiteTree", "$", "parent", ")", "{", "$", "this", "->", "parentInstance", "=", "$", "parent", ";", "$", "this", "->", "setStyleIDFrom", "(", "$", "parent", ")", ";", "return", "$", "this", ";", "}" ]
Defines the parent instance of the receiver. @param SiteTree $parent @return $this
[ "Defines", "the", "parent", "instance", "of", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L270-L277
train
praxisnetau/silverware
src/Model/Component.php
Component.getDefaultStyleID
public function getDefaultStyleID() { $ids = [$this->getTitleID()]; $parent = $this->getParent(); while ($parent instanceof Component) { $ids[] = $parent->getTitleID(); $parent = $parent->getParent(); } return implode('_', array_reverse($ids)); }
php
public function getDefaultStyleID() { $ids = [$this->getTitleID()]; $parent = $this->getParent(); while ($parent instanceof Component) { $ids[] = $parent->getTitleID(); $parent = $parent->getParent(); } return implode('_', array_reverse($ids)); }
[ "public", "function", "getDefaultStyleID", "(", ")", "{", "$", "ids", "=", "[", "$", "this", "->", "getTitleID", "(", ")", "]", ";", "$", "parent", "=", "$", "this", "->", "getParent", "(", ")", ";", "while", "(", "$", "parent", "instanceof", "Compon...
Answers the default style ID for the HTML template. @return string
[ "Answers", "the", "default", "style", "ID", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L488-L500
train
praxisnetau/silverware
src/Model/Component.php
Component.getAllChildren
public function getAllChildren() { // Answer Cached Children (if available): if ($this->cacheAllChildren) { return $this->cacheAllChildren; } // Obtain Child Objects: $this->cacheAllChildren = $this->stageChildren(true); // Answer Child Objects: return $this->cacheAllChildren; }
php
public function getAllChildren() { // Answer Cached Children (if available): if ($this->cacheAllChildren) { return $this->cacheAllChildren; } // Obtain Child Objects: $this->cacheAllChildren = $this->stageChildren(true); // Answer Child Objects: return $this->cacheAllChildren; }
[ "public", "function", "getAllChildren", "(", ")", "{", "// Answer Cached Children (if available):", "if", "(", "$", "this", "->", "cacheAllChildren", ")", "{", "return", "$", "this", "->", "cacheAllChildren", ";", "}", "// Obtain Child Objects:", "$", "this", "->", ...
Answers a list of all children within the receiver. @return DataList
[ "Answers", "a", "list", "of", "all", "children", "within", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L517-L532
train
praxisnetau/silverware
src/Model/Component.php
Component.getAllComponents
public function getAllComponents() { // Answer Cached Components (if available): if ($this->cacheAllComponents) { return $this->cacheAllComponents; } // Obtain Component Objects: $components = ArrayList::create(); foreach ($this->getAllChildren() as $child) { $components->push($child); $components->merge($child->getAllComponents()); } $this->cacheAllComponents = $components; // Answer Component Objects: return $this->cacheAllComponents; }
php
public function getAllComponents() { // Answer Cached Components (if available): if ($this->cacheAllComponents) { return $this->cacheAllComponents; } // Obtain Component Objects: $components = ArrayList::create(); foreach ($this->getAllChildren() as $child) { $components->push($child); $components->merge($child->getAllComponents()); } $this->cacheAllComponents = $components; // Answer Component Objects: return $this->cacheAllComponents; }
[ "public", "function", "getAllComponents", "(", ")", "{", "// Answer Cached Components (if available):", "if", "(", "$", "this", "->", "cacheAllComponents", ")", "{", "return", "$", "this", "->", "cacheAllComponents", ";", "}", "// Obtain Component Objects:", "$", "com...
Answers a list of all components within the receiver. @return ArrayList
[ "Answers", "a", "list", "of", "all", "components", "within", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L551-L573
train
praxisnetau/silverware
src/Model/Component.php
Component.getEnabledChildren
public function getEnabledChildren() { // Answer Cached Children (if available): if ($this->cacheEnabledChildren) { return $this->cacheEnabledChildren; } // Obtain Child Objects: $this->cacheEnabledChildren = $this->getAllChildren()->filterByCallback(function ($child) { return ($child instanceof Component) ? $child->isEnabled() : false; }); // Answer Child Objects: return $this->cacheEnabledChildren; }
php
public function getEnabledChildren() { // Answer Cached Children (if available): if ($this->cacheEnabledChildren) { return $this->cacheEnabledChildren; } // Obtain Child Objects: $this->cacheEnabledChildren = $this->getAllChildren()->filterByCallback(function ($child) { return ($child instanceof Component) ? $child->isEnabled() : false; }); // Answer Child Objects: return $this->cacheEnabledChildren; }
[ "public", "function", "getEnabledChildren", "(", ")", "{", "// Answer Cached Children (if available):", "if", "(", "$", "this", "->", "cacheEnabledChildren", ")", "{", "return", "$", "this", "->", "cacheEnabledChildren", ";", "}", "// Obtain Child Objects:", "$", "thi...
Answers a list of the enabled children within the receiver. @return DataList
[ "Answers", "a", "list", "of", "the", "enabled", "children", "within", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L592-L609
train
praxisnetau/silverware
src/Model/Component.php
Component.getEnabledComponents
public function getEnabledComponents() { // Answer Cached Components (if available): if ($this->cacheEnabledComponents) { return $this->cacheEnabledComponents; } // Obtain Component Objects: $components = ArrayList::create(); foreach ($this->getEnabledChildren() as $child) { $components->push($child); $components->merge($child->getEnabledComponents()); } $this->cacheEnabledComponents = $components; // Answer Component Objects: return $this->cacheEnabledComponents; }
php
public function getEnabledComponents() { // Answer Cached Components (if available): if ($this->cacheEnabledComponents) { return $this->cacheEnabledComponents; } // Obtain Component Objects: $components = ArrayList::create(); foreach ($this->getEnabledChildren() as $child) { $components->push($child); $components->merge($child->getEnabledComponents()); } $this->cacheEnabledComponents = $components; // Answer Component Objects: return $this->cacheEnabledComponents; }
[ "public", "function", "getEnabledComponents", "(", ")", "{", "// Answer Cached Components (if available):", "if", "(", "$", "this", "->", "cacheEnabledComponents", ")", "{", "return", "$", "this", "->", "cacheEnabledComponents", ";", "}", "// Obtain Component Objects:", ...
Answers a list of all the enabled components within the receiver. @return ArrayList
[ "Answers", "a", "list", "of", "all", "the", "enabled", "components", "within", "the", "receiver", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L616-L638
train
praxisnetau/silverware
src/Model/Component.php
Component.renderChildren
public function renderChildren($layout = null, $title = null) { $html = ''; foreach ($this->getEnabledChildren() as $child) { $html .= $child->render($layout, $title); } return $html; }
php
public function renderChildren($layout = null, $title = null) { $html = ''; foreach ($this->getEnabledChildren() as $child) { $html .= $child->render($layout, $title); } return $html; }
[ "public", "function", "renderChildren", "(", "$", "layout", "=", "null", ",", "$", "title", "=", "null", ")", "{", "$", "html", "=", "''", ";", "foreach", "(", "$", "this", "->", "getEnabledChildren", "(", ")", "as", "$", "child", ")", "{", "$", "h...
Renders the enabled children within the component for the HTML template. @param string $layout Page layout passed from template. @param string $title Page title passed from template. @return DBHTMLText|string
[ "Renders", "the", "enabled", "children", "within", "the", "component", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Component.php#L909-L918
train
praxisnetau/silverware
src/Components/ImageComponent.php
ImageComponent.getImageAttributes
public function getImageAttributes() { $attributes = [ 'src' => $this->ImageURL, 'class' => $this->ImageClass, 'title' => $this->ImageTitleText, 'alt' => $this->ImageAltText ]; if ($this->hasVectorImage()) { if ($width = $this->ImageResizeWidth) { $attributes['width'] = $width; } if ($height = $this->ImageResizeHeight) { $attributes['height'] = $height; } } $this->extend('updateImageAttributes', $attributes); return $attributes; }
php
public function getImageAttributes() { $attributes = [ 'src' => $this->ImageURL, 'class' => $this->ImageClass, 'title' => $this->ImageTitleText, 'alt' => $this->ImageAltText ]; if ($this->hasVectorImage()) { if ($width = $this->ImageResizeWidth) { $attributes['width'] = $width; } if ($height = $this->ImageResizeHeight) { $attributes['height'] = $height; } } $this->extend('updateImageAttributes', $attributes); return $attributes; }
[ "public", "function", "getImageAttributes", "(", ")", "{", "$", "attributes", "=", "[", "'src'", "=>", "$", "this", "->", "ImageURL", ",", "'class'", "=>", "$", "this", "->", "ImageClass", ",", "'title'", "=>", "$", "this", "->", "ImageTitleText", ",", "...
Answers an array of attributes for the image element. @return array
[ "Answers", "an", "array", "of", "attributes", "for", "the", "image", "element", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Components/ImageComponent.php#L344-L368
train
wallstreetio/ontraport
src/Objects.php
Objects.set
public function set($object, $id = null) { if (is_array($object)) { return $this->setAll($object); } $this->objects[$object] = $id; }
php
public function set($object, $id = null) { if (is_array($object)) { return $this->setAll($object); } $this->objects[$object] = $id; }
[ "public", "function", "set", "(", "$", "object", ",", "$", "id", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "object", ")", ")", "{", "return", "$", "this", "->", "setAll", "(", "$", "object", ")", ";", "}", "$", "this", "->", "obje...
Set an Ontraport object by its name and id. @param string $object @param mixed $id @return void
[ "Set", "an", "Ontraport", "object", "by", "its", "name", "and", "id", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Objects.php#L34-L41
train
wallstreetio/ontraport
src/Objects.php
Objects.get
public function get($name = null) { if (is_null($name)) { return $this->all(); } return $this->find($name); }
php
public function get($name = null) { if (is_null($name)) { return $this->all(); } return $this->find($name); }
[ "public", "function", "get", "(", "$", "name", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "name", ")", ")", "{", "return", "$", "this", "->", "all", "(", ")", ";", "}", "return", "$", "this", "->", "find", "(", "$", "name", ")", "...
Retrieve all Ontraport objects. @param string $name @return mixed
[ "Retrieve", "all", "Ontraport", "objects", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Objects.php#L70-L77
train
wallstreetio/ontraport
src/Objects.php
Objects.find
public function find($name) { $name = strtolower($name); if (isset($this->objects[$name])) { return $this->objects[$name]; } throw new InvalidCustomObject("The object [{$name}] does not exist."); }
php
public function find($name) { $name = strtolower($name); if (isset($this->objects[$name])) { return $this->objects[$name]; } throw new InvalidCustomObject("The object [{$name}] does not exist."); }
[ "public", "function", "find", "(", "$", "name", ")", "{", "$", "name", "=", "strtolower", "(", "$", "name", ")", ";", "if", "(", "isset", "(", "$", "this", "->", "objects", "[", "$", "name", "]", ")", ")", "{", "return", "$", "this", "->", "obj...
Find an Ontraport object by its name. @param string $name @return void
[ "Find", "an", "Ontraport", "object", "by", "its", "name", "." ]
55467fd63637083f76e497897af4aee13fc2c8b1
https://github.com/wallstreetio/ontraport/blob/55467fd63637083f76e497897af4aee13fc2c8b1/src/Objects.php#L85-L93
train
slimphp-api/slim-phinx
src/Module.php
Module.loadDependencies
public function loadDependencies() { $config = []; $files = glob(dirname(__DIR__).'/config/*.config.php', GLOB_BRACE); foreach ($files as $file) { $config = array_merge($config, (require $file)); } return $config; }
php
public function loadDependencies() { $config = []; $files = glob(dirname(__DIR__).'/config/*.config.php', GLOB_BRACE); foreach ($files as $file) { $config = array_merge($config, (require $file)); } return $config; }
[ "public", "function", "loadDependencies", "(", ")", "{", "$", "config", "=", "[", "]", ";", "$", "files", "=", "glob", "(", "dirname", "(", "__DIR__", ")", ".", "'/config/*.config.php'", ",", "GLOB_BRACE", ")", ";", "foreach", "(", "$", "files", "as", ...
load the dependencies for the module.
[ "load", "the", "dependencies", "for", "the", "module", "." ]
48560f6083e0651389ef0790e59325c751e6574e
https://github.com/slimphp-api/slim-phinx/blob/48560f6083e0651389ef0790e59325c751e6574e/src/Module.php#L9-L17
train
terra-ops/terra-cli
src/terra/Command/Environment/EnvironmentDomains.php
EnvironmentDomains.executeAddDomain
protected function executeAddDomain(InputInterface $input, OutputInterface $output) { // Ask for a domain $domain_question = new Question('What domain would you like to add as a VIRTUAL_HOST for the server? (Do NOT include http://) '); $name = $this->getAnswer($input, $output, $domain_question, 'domain', 'argument', TRUE); // Add the domain to the domain property. $output->writeln("Adding domain: <info>{$name}</info>"); $this->environment->domains[] = $name; $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("Add the domain <comment>$name</comment> to the environment <info>{$this->app->name}:{$this->environment->name}</info> [y/N]? ", FALSE); if (!$helper->ask($input, $output, $question)) { $output->writeln("<fg=red>Domain not added.</>"); $output->writeln(''); exit; } // Save the new version to the config. $this->getApplication()->getTerra()->getConfig()->add('apps', array($this->app->name, 'environments', $this->environment->name), (array) $this->environment); $this->getApplication()->getTerra()->getConfig()->save(); $output->writeln("<info>Domain added!</info> Changes won't take effect until the environment is restarted."); $output->writeln(''); }
php
protected function executeAddDomain(InputInterface $input, OutputInterface $output) { // Ask for a domain $domain_question = new Question('What domain would you like to add as a VIRTUAL_HOST for the server? (Do NOT include http://) '); $name = $this->getAnswer($input, $output, $domain_question, 'domain', 'argument', TRUE); // Add the domain to the domain property. $output->writeln("Adding domain: <info>{$name}</info>"); $this->environment->domains[] = $name; $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("Add the domain <comment>$name</comment> to the environment <info>{$this->app->name}:{$this->environment->name}</info> [y/N]? ", FALSE); if (!$helper->ask($input, $output, $question)) { $output->writeln("<fg=red>Domain not added.</>"); $output->writeln(''); exit; } // Save the new version to the config. $this->getApplication()->getTerra()->getConfig()->add('apps', array($this->app->name, 'environments', $this->environment->name), (array) $this->environment); $this->getApplication()->getTerra()->getConfig()->save(); $output->writeln("<info>Domain added!</info> Changes won't take effect until the environment is restarted."); $output->writeln(''); }
[ "protected", "function", "executeAddDomain", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// Ask for a domain", "$", "domain_question", "=", "new", "Question", "(", "'What domain would you like to add as a VIRTUAL_HOST for the server?...
Add a domain. @param InputInterface $input @param OutputInterface $output
[ "Add", "a", "domain", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Environment/EnvironmentDomains.php#L118-L143
train
terra-ops/terra-cli
src/terra/Command/Environment/EnvironmentDomains.php
EnvironmentDomains.executeRemoveDomain
protected function executeRemoveDomain(InputInterface $input, OutputInterface $output) { // If no domains are left, exit if (empty($this->environment->domains)) { $output->writeln('<comment>There are no domains assigned to this environment!</comment>'); exit; } // Ask for a domain if ($input->getArgument('domain') == NULL) { $helper = $this->getHelper('question'); $domains = $this->environment->domains; $question = new ChoiceQuestion( 'Which domain would you like to remove? ', $domains, null ); $name = $helper->ask($input, $output, $question); } // Confirm removal. $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("Remove the domain <comment>$name</comment> from the environment <info>{$this->app->name}:{$this->environment->name}</info> [y/N]? ", FALSE); if (!$helper->ask($input, $output, $question)) { $output->writeln("<fg=red>Domain not removed.</>"); $output->writeln(''); exit; } // Find and remove the domain from the config. $key = array_search($name, $this->environment->domains); unset($this->environment->domains[$key]); // Save the new version to the config. $this->getApplication()->getTerra()->getConfig()->add('apps', array($this->app->name, 'environments', $this->environment->name), (array) $this->environment); $this->getApplication()->getTerra()->getConfig()->save(); $output->writeln("<info>Domain removed.</info> Changes won't take effect until the environment is restarted."); $output->writeln(''); }
php
protected function executeRemoveDomain(InputInterface $input, OutputInterface $output) { // If no domains are left, exit if (empty($this->environment->domains)) { $output->writeln('<comment>There are no domains assigned to this environment!</comment>'); exit; } // Ask for a domain if ($input->getArgument('domain') == NULL) { $helper = $this->getHelper('question'); $domains = $this->environment->domains; $question = new ChoiceQuestion( 'Which domain would you like to remove? ', $domains, null ); $name = $helper->ask($input, $output, $question); } // Confirm removal. $helper = $this->getHelper('question'); $question = new ConfirmationQuestion("Remove the domain <comment>$name</comment> from the environment <info>{$this->app->name}:{$this->environment->name}</info> [y/N]? ", FALSE); if (!$helper->ask($input, $output, $question)) { $output->writeln("<fg=red>Domain not removed.</>"); $output->writeln(''); exit; } // Find and remove the domain from the config. $key = array_search($name, $this->environment->domains); unset($this->environment->domains[$key]); // Save the new version to the config. $this->getApplication()->getTerra()->getConfig()->add('apps', array($this->app->name, 'environments', $this->environment->name), (array) $this->environment); $this->getApplication()->getTerra()->getConfig()->save(); $output->writeln("<info>Domain removed.</info> Changes won't take effect until the environment is restarted."); $output->writeln(''); }
[ "protected", "function", "executeRemoveDomain", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// If no domains are left, exit", "if", "(", "empty", "(", "$", "this", "->", "environment", "->", "domains", ")", ")", "{", "$...
Remove a domain. @param InputInterface $input @param OutputInterface $output
[ "Remove", "a", "domain", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Environment/EnvironmentDomains.php#L150-L189
train
i-am-tom/schemer
src/NestableResult.php
NestableResult.isError
public function isError() : bool { if ($this->outer->isError()) { return true; } foreach ($this as $inner) { if ($inner->isError()) { return true; } } return false; }
php
public function isError() : bool { if ($this->outer->isError()) { return true; } foreach ($this as $inner) { if ($inner->isError()) { return true; } } return false; }
[ "public", "function", "isError", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "outer", "->", "isError", "(", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "as", "$", "inner", ")", "{", "if", "(", "$", "inn...
Are there any errors within this result? @return boolean
[ "Are", "there", "any", "errors", "within", "this", "result?" ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/NestableResult.php#L110-L123
train
i-am-tom/schemer
src/NestableResult.php
NestableResult.isFatal
public function isFatal() : bool { if ($this->outer->isFatal()) { return true; } foreach ($this as $inner) { if ($inner->isFatal()) { return true; } } return false; }
php
public function isFatal() : bool { if ($this->outer->isFatal()) { return true; } foreach ($this as $inner) { if ($inner->isFatal()) { return true; } } return false; }
[ "public", "function", "isFatal", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "outer", "->", "isFatal", "(", ")", ")", "{", "return", "true", ";", "}", "foreach", "(", "$", "this", "as", "$", "inner", ")", "{", "if", "(", "$", "inn...
Are there any fatals within this result? @return boolean
[ "Are", "there", "any", "fatals", "within", "this", "result?" ]
aa4ff458eae636ca61ada07d05859e27d3b4584d
https://github.com/i-am-tom/schemer/blob/aa4ff458eae636ca61ada07d05859e27d3b4584d/src/NestableResult.php#L129-L142
train
praxisnetau/silverware
src/Tools/StringTools.php
StringTools.getContentSummary
public function getContentSummary(DBHTMLText $content, $maxWords = 50, $add = '...') { // Get Plain Text Version: $value = $this->getContentAsPlainText($content); // Bail Early (if empty): if (!$value) { return ''; } // Split on Sentences (do not remove period): $sentences = array_filter(array_map(function ($str) { return trim($str); }, preg_split('@(?<=\.)@', $value))); $wordCount = count(preg_split('#\s+#u', $sentences[0])); // If the First Sentence is Too Long, Show Only the First $maxWords Words: if ($wordCount > $maxWords) { return implode(' ', array_slice(explode(' ', $sentences[0]), 0, $maxWords)) . $add; } // Add Each Sentence (while there are enough words to do so): $result = ''; do { // Add Next Sentence: $result .= ' ' . array_shift($sentences); // If More Sentences, Count Number of Words: if ($sentences) { $wordCount += count(preg_split('#\s+#u', $sentences[0])); } } while ($wordCount < $maxWords && $sentences && trim($sentences[0])); // Answer Result String: return trim($result); }
php
public function getContentSummary(DBHTMLText $content, $maxWords = 50, $add = '...') { // Get Plain Text Version: $value = $this->getContentAsPlainText($content); // Bail Early (if empty): if (!$value) { return ''; } // Split on Sentences (do not remove period): $sentences = array_filter(array_map(function ($str) { return trim($str); }, preg_split('@(?<=\.)@', $value))); $wordCount = count(preg_split('#\s+#u', $sentences[0])); // If the First Sentence is Too Long, Show Only the First $maxWords Words: if ($wordCount > $maxWords) { return implode(' ', array_slice(explode(' ', $sentences[0]), 0, $maxWords)) . $add; } // Add Each Sentence (while there are enough words to do so): $result = ''; do { // Add Next Sentence: $result .= ' ' . array_shift($sentences); // If More Sentences, Count Number of Words: if ($sentences) { $wordCount += count(preg_split('#\s+#u', $sentences[0])); } } while ($wordCount < $maxWords && $sentences && trim($sentences[0])); // Answer Result String: return trim($result); }
[ "public", "function", "getContentSummary", "(", "DBHTMLText", "$", "content", ",", "$", "maxWords", "=", "50", ",", "$", "add", "=", "'...'", ")", "{", "// Get Plain Text Version:", "$", "value", "=", "$", "this", "->", "getContentAsPlainText", "(", "$", "co...
Answers a summary of the given content field using an improved method of removing tags. @param DBHTMLText $content @param integer $maxWords @param string $add @return string
[ "Answers", "a", "summary", "of", "the", "given", "content", "field", "using", "an", "improved", "method", "of", "removing", "tags", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/StringTools.php#L46-L93
train
praxisnetau/silverware
src/Tools/StringTools.php
StringTools.getContentAsPlainText
public function getContentAsPlainText(DBHTMLText $content) { // Preserve Line Breaks: $text = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $content->RAW()); // Convert Paragraph Breaks to Multi-Lines: $text = preg_replace('/\<\/p\>/i', "\n\n", $text); // Remove HTML Tags: $text = $this->removeTags($text); // Implode >3 Consecutive Linebreaks into 2: $text = preg_replace('~(\R){2,}~', "\n\n", $text); // Decode HTML Entities Back to Plain Text: return trim(Convert::xml2raw($text)); }
php
public function getContentAsPlainText(DBHTMLText $content) { // Preserve Line Breaks: $text = preg_replace('/\<br(\s*)?\/?\>/i', "\n", $content->RAW()); // Convert Paragraph Breaks to Multi-Lines: $text = preg_replace('/\<\/p\>/i', "\n\n", $text); // Remove HTML Tags: $text = $this->removeTags($text); // Implode >3 Consecutive Linebreaks into 2: $text = preg_replace('~(\R){2,}~', "\n\n", $text); // Decode HTML Entities Back to Plain Text: return trim(Convert::xml2raw($text)); }
[ "public", "function", "getContentAsPlainText", "(", "DBHTMLText", "$", "content", ")", "{", "// Preserve Line Breaks:", "$", "text", "=", "preg_replace", "(", "'/\\<br(\\s*)?\\/?\\>/i'", ",", "\"\\n\"", ",", "$", "content", "->", "RAW", "(", ")", ")", ";", "// C...
Converts the given content field to a plain text string using an improved method of removing tags. @param DBHTMLText $content @return string
[ "Converts", "the", "given", "content", "field", "to", "a", "plain", "text", "string", "using", "an", "improved", "method", "of", "removing", "tags", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/StringTools.php#L102-L123
train
praxisnetau/silverware
src/Tools/StringTools.php
StringTools.removeTags
public function removeTags($string) { // Remove HTML Tags: $string = preg_replace('/<[^>]*>/', ' ', $string); // Remove Control Characters: $string = str_replace("\r", '', $string); // replace with empty space $string = str_replace("\n", ' ', $string); // replace with single space $string = str_replace("\t", ' ', $string); // replace with single space // Remove Multiple Spaces: $string = trim(preg_replace('/ {2,}/', ' ', $string)); // Answer String: return $string; }
php
public function removeTags($string) { // Remove HTML Tags: $string = preg_replace('/<[^>]*>/', ' ', $string); // Remove Control Characters: $string = str_replace("\r", '', $string); // replace with empty space $string = str_replace("\n", ' ', $string); // replace with single space $string = str_replace("\t", ' ', $string); // replace with single space // Remove Multiple Spaces: $string = trim(preg_replace('/ {2,}/', ' ', $string)); // Answer String: return $string; }
[ "public", "function", "removeTags", "(", "$", "string", ")", "{", "// Remove HTML Tags:", "$", "string", "=", "preg_replace", "(", "'/<[^>]*>/'", ",", "' '", ",", "$", "string", ")", ";", "// Remove Control Characters:", "$", "string", "=", "str_replace", "(", ...
Removes HTML tags from the given string while maintaining whitespace. @param string $string @return string
[ "Removes", "HTML", "tags", "from", "the", "given", "string", "while", "maintaining", "whitespace", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Tools/StringTools.php#L132-L151
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getSlideAttributes
public function getSlideAttributes($isFirst = false, $isMiddle = false, $isLast = false) { $attributes = ['class' => $this->getSlideClass($isFirst, $isMiddle, $isLast)]; if ($this->getParent()->hasMethod('getSlideAttributes')) { $attributes = array_merge( $attributes, $this->getParent()->getSlideAttributes( $this, $isFirst, $isMiddle, $isLast ) ); } $this->extend('updateSlideAttributes', $attributes); return $attributes; }
php
public function getSlideAttributes($isFirst = false, $isMiddle = false, $isLast = false) { $attributes = ['class' => $this->getSlideClass($isFirst, $isMiddle, $isLast)]; if ($this->getParent()->hasMethod('getSlideAttributes')) { $attributes = array_merge( $attributes, $this->getParent()->getSlideAttributes( $this, $isFirst, $isMiddle, $isLast ) ); } $this->extend('updateSlideAttributes', $attributes); return $attributes; }
[ "public", "function", "getSlideAttributes", "(", "$", "isFirst", "=", "false", ",", "$", "isMiddle", "=", "false", ",", "$", "isLast", "=", "false", ")", "{", "$", "attributes", "=", "[", "'class'", "=>", "$", "this", "->", "getSlideClass", "(", "$", "...
Answers an array of HTML tag attributes for the slide. @param boolean $isFirst Slide is first in the list. @param boolean $isMiddle Slide is in the middle of the list. @param boolean $isLast Slide is last in the list. @return array
[ "Answers", "an", "array", "of", "HTML", "tag", "attributes", "for", "the", "slide", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L381-L402
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getSlideAttributesHTML
public function getSlideAttributesHTML($isFirst = false, $isMiddle = false, $isLast = false) { return $this->getAttributesHTML($this->getSlideAttributes($isFirst, $isMiddle, $isLast)); }
php
public function getSlideAttributesHTML($isFirst = false, $isMiddle = false, $isLast = false) { return $this->getAttributesHTML($this->getSlideAttributes($isFirst, $isMiddle, $isLast)); }
[ "public", "function", "getSlideAttributesHTML", "(", "$", "isFirst", "=", "false", ",", "$", "isMiddle", "=", "false", ",", "$", "isLast", "=", "false", ")", "{", "return", "$", "this", "->", "getAttributesHTML", "(", "$", "this", "->", "getSlideAttributes",...
Answers the HTML tag attributes for the slide as a string. @param boolean $isFirst Slide is first in the list. @param boolean $isMiddle Slide is in the middle of the list. @param boolean $isLast Slide is last in the list. @return string
[ "Answers", "the", "HTML", "tag", "attributes", "for", "the", "slide", "as", "a", "string", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L413-L416
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getSlideClass
public function getSlideClass($isFirst = false, $isMiddle = false, $isLast = false) { return ViewTools::singleton()->array2att($this->getSlideClassNames($isFirst, $isMiddle, $isLast)); }
php
public function getSlideClass($isFirst = false, $isMiddle = false, $isLast = false) { return ViewTools::singleton()->array2att($this->getSlideClassNames($isFirst, $isMiddle, $isLast)); }
[ "public", "function", "getSlideClass", "(", "$", "isFirst", "=", "false", ",", "$", "isMiddle", "=", "false", ",", "$", "isLast", "=", "false", ")", "{", "return", "ViewTools", "::", "singleton", "(", ")", "->", "array2att", "(", "$", "this", "->", "ge...
Answers a string of slide class names for the HTML template. @param boolean $isFirst Slide is first in the list. @param boolean $isMiddle Slide is in the middle of the list. @param boolean $isLast Slide is last in the list. @return string
[ "Answers", "a", "string", "of", "slide", "class", "names", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L427-L430
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getImageClassNames
public function getImageClassNames() { $classes = ['slide-image']; if ($this->getParent()->hasMethod('getImageClassNames')) { $classes = array_merge($classes, $this->getParent()->getImageClassNames($this)); } $this->extend('updateImageClassNames', $classes); return $classes; }
php
public function getImageClassNames() { $classes = ['slide-image']; if ($this->getParent()->hasMethod('getImageClassNames')) { $classes = array_merge($classes, $this->getParent()->getImageClassNames($this)); } $this->extend('updateImageClassNames', $classes); return $classes; }
[ "public", "function", "getImageClassNames", "(", ")", "{", "$", "classes", "=", "[", "'slide-image'", "]", ";", "if", "(", "$", "this", "->", "getParent", "(", ")", "->", "hasMethod", "(", "'getImageClassNames'", ")", ")", "{", "$", "classes", "=", "arra...
Answers an array of image class names for the HTML template. @return array
[ "Answers", "an", "array", "of", "image", "class", "names", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L471-L482
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getSlideImage
public function getSlideImage() { if ($this->hasImage()) { if ($this->Image()->exists()) { return $this->Image(); } elseif ($this->LinkPage()->hasMetaImage()) { return $this->LinkPage()->getMetaImage(); } } }
php
public function getSlideImage() { if ($this->hasImage()) { if ($this->Image()->exists()) { return $this->Image(); } elseif ($this->LinkPage()->hasMetaImage()) { return $this->LinkPage()->getMetaImage(); } } }
[ "public", "function", "getSlideImage", "(", ")", "{", "if", "(", "$", "this", "->", "hasImage", "(", ")", ")", "{", "if", "(", "$", "this", "->", "Image", "(", ")", "->", "exists", "(", ")", ")", "{", "return", "$", "this", "->", "Image", "(", ...
Answers the image for the slide. @return Image
[ "Answers", "the", "image", "for", "the", "slide", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L577-L588
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getImageResized
public function getImageResized($width = null, $height = null, $method = null) { if ($this->hasImage()) { $image = $this->getSlideImage(); if ($width || $height || $method) { return ImageTools::singleton()->resize($image, $width, $height, $method); } if ($this->getParent()->hasMethod('performImageResize')) { return $this->getParent()->performImageResize($image); } return $image; } }
php
public function getImageResized($width = null, $height = null, $method = null) { if ($this->hasImage()) { $image = $this->getSlideImage(); if ($width || $height || $method) { return ImageTools::singleton()->resize($image, $width, $height, $method); } if ($this->getParent()->hasMethod('performImageResize')) { return $this->getParent()->performImageResize($image); } return $image; } }
[ "public", "function", "getImageResized", "(", "$", "width", "=", "null", ",", "$", "height", "=", "null", ",", "$", "method", "=", "null", ")", "{", "if", "(", "$", "this", "->", "hasImage", "(", ")", ")", "{", "$", "image", "=", "$", "this", "->...
Answers a resized image using the dimensions and resize method from the parent object. @param integer $width @param integer $height @param string $method @return Image
[ "Answers", "a", "resized", "image", "using", "the", "dimensions", "and", "resize", "method", "from", "the", "parent", "object", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L599-L616
train
praxisnetau/silverware
src/Model/Slide.php
Slide.getLinkClassNames
public function getLinkClassNames() { if ($this->isButtonLink() || !$this->LinkInFooter) { return []; } $classes = [ $this->style('button'), $this->ButtonTypeClass ]; if ($this->ButtonExtraClass) { $classes[] = $this->ButtonExtraClass; } return $classes; }
php
public function getLinkClassNames() { if ($this->isButtonLink() || !$this->LinkInFooter) { return []; } $classes = [ $this->style('button'), $this->ButtonTypeClass ]; if ($this->ButtonExtraClass) { $classes[] = $this->ButtonExtraClass; } return $classes; }
[ "public", "function", "getLinkClassNames", "(", ")", "{", "if", "(", "$", "this", "->", "isButtonLink", "(", ")", "||", "!", "$", "this", "->", "LinkInFooter", ")", "{", "return", "[", "]", ";", "}", "$", "classes", "=", "[", "$", "this", "->", "st...
Answers an array of link class names for the template. @return array
[ "Answers", "an", "array", "of", "link", "class", "names", "for", "the", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L673-L689
train
praxisnetau/silverware
src/Model/Slide.php
Slide.renderSlide
public function renderSlide($isFirst = false, $isMiddle = false, $isLast = false) { return $this->customise([ 'isFirst' => $isFirst, 'isMiddle' => $isMiddle, 'isLast' => $isLast ])->renderWith($this->getTemplate()); }
php
public function renderSlide($isFirst = false, $isMiddle = false, $isLast = false) { return $this->customise([ 'isFirst' => $isFirst, 'isMiddle' => $isMiddle, 'isLast' => $isLast ])->renderWith($this->getTemplate()); }
[ "public", "function", "renderSlide", "(", "$", "isFirst", "=", "false", ",", "$", "isMiddle", "=", "false", ",", "$", "isLast", "=", "false", ")", "{", "return", "$", "this", "->", "customise", "(", "[", "'isFirst'", "=>", "$", "isFirst", ",", "'isMidd...
Renders the object as a slide for the HTML template. @param boolean $isFirst Slide is first in the list. @param boolean $isMiddle Slide is in the middle of the list. @param boolean $isLast Slide is last in the list. @return DBHTMLText
[ "Renders", "the", "object", "as", "a", "slide", "for", "the", "HTML", "template", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Model/Slide.php#L760-L767
train
praxisnetau/silverware
src/Forms/HasOneField.php
HasOneField.getDataDefault
public function getDataDefault($name) { return isset($this->dataDefaults[$name]) ? $this->dataDefaults[$name] : null; }
php
public function getDataDefault($name) { return isset($this->dataDefaults[$name]) ? $this->dataDefaults[$name] : null; }
[ "public", "function", "getDataDefault", "(", "$", "name", ")", "{", "return", "isset", "(", "$", "this", "->", "dataDefaults", "[", "$", "name", "]", ")", "?", "$", "this", "->", "dataDefaults", "[", "$", "name", "]", ":", "null", ";", "}" ]
Answers the value of an individual data default. @param string $name @return mixed
[ "Answers", "the", "value", "of", "an", "individual", "data", "default", "." ]
2fa731c7f0737b350e0cbc676e93ac5beb430792
https://github.com/praxisnetau/silverware/blob/2fa731c7f0737b350e0cbc676e93ac5beb430792/src/Forms/HasOneField.php#L165-L168
train
terra-ops/terra-cli
src/terra/Command/Command.php
Command.initialize
protected function initialize(InputInterface $input, OutputInterface $output) { // Determine app and environment from path. $cwd = getcwd(); $config = $this->getApplication()->getTerra()->getConfig(); foreach ($config->get('apps') as $app) { if (!isset($app['environments'])) { $app['environments'] = array(); } foreach ($app['environments'] as $environment) { if (strpos($cwd, $environment['path']) === 0) { if ($input->hasArgument('app_name')) { $input->setArgument('app_name', $app['name']); } if ($input->hasArgument('environment_name')) { $input->setArgument('environment_name', $environment['name']); } $environment_string = $app['name'] . ':' . $environment['name']; $output->writeln("Using environment <question>$environment_string</question>"); } } } }
php
protected function initialize(InputInterface $input, OutputInterface $output) { // Determine app and environment from path. $cwd = getcwd(); $config = $this->getApplication()->getTerra()->getConfig(); foreach ($config->get('apps') as $app) { if (!isset($app['environments'])) { $app['environments'] = array(); } foreach ($app['environments'] as $environment) { if (strpos($cwd, $environment['path']) === 0) { if ($input->hasArgument('app_name')) { $input->setArgument('app_name', $app['name']); } if ($input->hasArgument('environment_name')) { $input->setArgument('environment_name', $environment['name']); } $environment_string = $app['name'] . ':' . $environment['name']; $output->writeln("Using environment <question>$environment_string</question>"); } } } }
[ "protected", "function", "initialize", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "// Determine app and environment from path.", "$", "cwd", "=", "getcwd", "(", ")", ";", "$", "config", "=", "$", "this", "->", "getAppli...
Detect app and environment from current path. @param InputInterface $input An InputInterface instance @param OutputInterface $output An OutputInterface instance
[ "Detect", "app", "and", "environment", "from", "current", "path", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Command.php#L28-L55
train
terra-ops/terra-cli
src/terra/Command/Command.php
Command.getAnswer
public function getAnswer(InputInterface $input, OutputInterface $output, Question $question, $argument_name, $type = 'argument', $required = FALSE) { $helper = $this->getHelper('question'); if ($type == 'argument') { $value = $input->getArgument($argument_name); } elseif ($type == 'option') { $value = $input->getOption($argument_name); } if (empty($value)) { // If we are in non-interactive mode, we have no choice but to return nothing. if ($input->getOption('yes')) { return ''; } if ($required) { while (empty($value)) { $value = $helper->ask($input, $output, $question); } } else { $value = $helper->ask($input, $output, $question); } } return $value; }
php
public function getAnswer(InputInterface $input, OutputInterface $output, Question $question, $argument_name, $type = 'argument', $required = FALSE) { $helper = $this->getHelper('question'); if ($type == 'argument') { $value = $input->getArgument($argument_name); } elseif ($type == 'option') { $value = $input->getOption($argument_name); } if (empty($value)) { // If we are in non-interactive mode, we have no choice but to return nothing. if ($input->getOption('yes')) { return ''; } if ($required) { while (empty($value)) { $value = $helper->ask($input, $output, $question); } } else { $value = $helper->ask($input, $output, $question); } } return $value; }
[ "public", "function", "getAnswer", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ",", "Question", "$", "question", ",", "$", "argument_name", ",", "$", "type", "=", "'argument'", ",", "$", "required", "=", "FALSE", ")", "{", "...
Helper to ask a question only if a default argument is not present. @param InputInterface $input @param OutputInterface $output @param Question $question A Question object @param $argument_name Name of the argument or option to default to. @param string $type Either "argument" (default) or "option" @return mixed The value derived from either the argument/option or the value.
[ "Helper", "to", "ask", "a", "question", "only", "if", "a", "default", "argument", "is", "not", "present", "." ]
b176cca562534c1d65efbcef6c128f669a2ebed8
https://github.com/terra-ops/terra-cli/blob/b176cca562534c1d65efbcef6c128f669a2ebed8/src/terra/Command/Command.php#L72-L99
train
ejsmont-artur/php-circuit-breaker-bundle
Factory.php
Factory.getDoctrineCacheInstance
public static function getDoctrineCacheInstance(Cache $doctrineCache, $maxFailures = 20, $retryTimeout = 30) { $storage = new ArrayDecorator(new DoctrineCacheAdapter($doctrineCache)); return new CircuitBreaker($storage, $maxFailures, $retryTimeout); }
php
public static function getDoctrineCacheInstance(Cache $doctrineCache, $maxFailures = 20, $retryTimeout = 30) { $storage = new ArrayDecorator(new DoctrineCacheAdapter($doctrineCache)); return new CircuitBreaker($storage, $maxFailures, $retryTimeout); }
[ "public", "static", "function", "getDoctrineCacheInstance", "(", "Cache", "$", "doctrineCache", ",", "$", "maxFailures", "=", "20", ",", "$", "retryTimeout", "=", "30", ")", "{", "$", "storage", "=", "new", "ArrayDecorator", "(", "new", "DoctrineCacheAdapter", ...
Creates a circuit breaker instance using doctrine cache adapter. @param Cache $doctrineCache instance of a doctrine cache backend to use @param int $maxFailures how many times do we allow service to fail before considering it offline @param int $retryTimeout how many seconds should we wait before attempting retry @return CircuitBreakerInterface
[ "Creates", "a", "circuit", "breaker", "instance", "using", "doctrine", "cache", "adapter", "." ]
3327b0fff0c5f87154376eb3b0d8984358a3e033
https://github.com/ejsmont-artur/php-circuit-breaker-bundle/blob/3327b0fff0c5f87154376eb3b0d8984358a3e033/Factory.php#L24-L27
train
digiaonline/paytrail-php
src/Http/Client.php
Client.processPayment
public function processPayment(Payment $payment) { $response = $this->postRequest('/api-payment/create', $payment->toJson()); if ( ! in_array('application/json', $response->getHeader('Content-Type'))) { throw new PaymentFailed('Server returned a non-JSON result.'); } $body = json_decode((string)$response->getBody()); if ($response->getStatusCode() !== 201) { throw new PaymentFailed( sprintf('Paytrail request failed: %s (%d)', $body->errorMessage, $body->errorCode) ); } $result = new Result; $result->configure( array( 'orderNumber' => $body->orderNumber, 'token' => $body->token, 'url' => $body->url, ) ); return $result; }
php
public function processPayment(Payment $payment) { $response = $this->postRequest('/api-payment/create', $payment->toJson()); if ( ! in_array('application/json', $response->getHeader('Content-Type'))) { throw new PaymentFailed('Server returned a non-JSON result.'); } $body = json_decode((string)$response->getBody()); if ($response->getStatusCode() !== 201) { throw new PaymentFailed( sprintf('Paytrail request failed: %s (%d)', $body->errorMessage, $body->errorCode) ); } $result = new Result; $result->configure( array( 'orderNumber' => $body->orderNumber, 'token' => $body->token, 'url' => $body->url, ) ); return $result; }
[ "public", "function", "processPayment", "(", "Payment", "$", "payment", ")", "{", "$", "response", "=", "$", "this", "->", "postRequest", "(", "'/api-payment/create'", ",", "$", "payment", "->", "toJson", "(", ")", ")", ";", "if", "(", "!", "in_array", "...
Processes the payment. @param Payment $payment The payment object. @return \Paytrail\Http\Result @throws \Paytrail\Exception\PaymentFailed
[ "Processes", "the", "payment", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L135-L161
train
digiaonline/paytrail-php
src/Http/Client.php
Client.validateChecksum
public function validateChecksum($checksum, $orderNumber, $timestamp, $paid = null, $method = null) { return $checksum === $this->calculateChecksum($orderNumber, $timestamp, $paid, $method); }
php
public function validateChecksum($checksum, $orderNumber, $timestamp, $paid = null, $method = null) { return $checksum === $this->calculateChecksum($orderNumber, $timestamp, $paid, $method); }
[ "public", "function", "validateChecksum", "(", "$", "checksum", ",", "$", "orderNumber", ",", "$", "timestamp", ",", "$", "paid", "=", "null", ",", "$", "method", "=", "null", ")", "{", "return", "$", "checksum", "===", "$", "this", "->", "calculateCheck...
Validates the given checksum against the order. @param string $checksum Checksum to validate. @param string $orderNumber The order number. @param int $timestamp The timestamp of the order. @param string|null $paid Payment paid. @param int|null $method The method. @return bool
[ "Validates", "the", "given", "checksum", "against", "the", "order", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L174-L177
train
digiaonline/paytrail-php
src/Http/Client.php
Client.calculateChecksum
protected function calculateChecksum($orderNumber, $timestamp, $paid = null, $method = null) { $data = array($orderNumber, $timestamp); if ($paid !== null) { $data[] = $paid; } if ($method !== null) { $data[] = $method; } $data[] = $this->_apiSecret; return strtoupper(md5(implode('|', $data))); }
php
protected function calculateChecksum($orderNumber, $timestamp, $paid = null, $method = null) { $data = array($orderNumber, $timestamp); if ($paid !== null) { $data[] = $paid; } if ($method !== null) { $data[] = $method; } $data[] = $this->_apiSecret; return strtoupper(md5(implode('|', $data))); }
[ "protected", "function", "calculateChecksum", "(", "$", "orderNumber", ",", "$", "timestamp", ",", "$", "paid", "=", "null", ",", "$", "method", "=", "null", ")", "{", "$", "data", "=", "array", "(", "$", "orderNumber", ",", "$", "timestamp", ")", ";",...
Calculates the checksum. @param string $orderNumber The order number. @param int $timestamp The timestamp of the order. @param string|null $paid Payment paid. @param int|null $method The method. @return string
[ "Calculates", "the", "checksum", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L189-L201
train
digiaonline/paytrail-php
src/Http/Client.php
Client.postRequest
protected function postRequest($uri, $body = null, $options = array()) { if ($this->testMode) { $options['debug'] = true; } $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Verkkomaksut-Api-Version' => $this->apiVersion, ); $options = array_merge( array( 'auth' => array($this->_apiKey, $this->_apiSecret), 'timeout' => 30, 'connect_timeout' => 10, ), $options ); $request = new Request('POST', $uri, $headers, $body); return $this->_client->send($request, $options); }
php
protected function postRequest($uri, $body = null, $options = array()) { if ($this->testMode) { $options['debug'] = true; } $headers = array( 'Content-Type' => 'application/json', 'Accept' => 'application/json', 'X-Verkkomaksut-Api-Version' => $this->apiVersion, ); $options = array_merge( array( 'auth' => array($this->_apiKey, $this->_apiSecret), 'timeout' => 30, 'connect_timeout' => 10, ), $options ); $request = new Request('POST', $uri, $headers, $body); return $this->_client->send($request, $options); }
[ "protected", "function", "postRequest", "(", "$", "uri", ",", "$", "body", "=", "null", ",", "$", "options", "=", "array", "(", ")", ")", "{", "if", "(", "$", "this", "->", "testMode", ")", "{", "$", "options", "[", "'debug'", "]", "=", "true", "...
Runs a POST request. @param string $uri The URI to post to. @param string|null $body The body to post. @param array $options The options. @return \Psr\Http\Message\ResponseInterface
[ "Runs", "a", "POST", "request", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L212-L236
train
digiaonline/paytrail-php
src/Http/Client.php
Client.setApiVersion
public function setApiVersion($apiVersion) { if ( ! in_array($apiVersion, self::$supportedApiVersions)) { throw new ApiVersionNotSupported(sprintf('API version %d is not supported.', $apiVersion)); } $this->apiVersion = $apiVersion; }
php
public function setApiVersion($apiVersion) { if ( ! in_array($apiVersion, self::$supportedApiVersions)) { throw new ApiVersionNotSupported(sprintf('API version %d is not supported.', $apiVersion)); } $this->apiVersion = $apiVersion; }
[ "public", "function", "setApiVersion", "(", "$", "apiVersion", ")", "{", "if", "(", "!", "in_array", "(", "$", "apiVersion", ",", "self", "::", "$", "supportedApiVersions", ")", ")", "{", "throw", "new", "ApiVersionNotSupported", "(", "sprintf", "(", "'API v...
Set the Paytrail API version. @param int $apiVersion The API version. @throws \Paytrail\Exception\ApiVersionNotSupported
[ "Set", "the", "Paytrail", "API", "version", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L275-L281
train
digiaonline/paytrail-php
src/Http/Client.php
Client.getLogoUrl
public function getLogoUrl() { $params = [ 'id' => $this->_apiKey, 'type' => $this->logoType, 'cols' => (int)$this->logoCols, 'text' => (int)$this->logoText, 'auth' => $this->calculateLogoAuth(), ]; return self::LOGO_BASE_URL . '?' . http_build_query($params); }
php
public function getLogoUrl() { $params = [ 'id' => $this->_apiKey, 'type' => $this->logoType, 'cols' => (int)$this->logoCols, 'text' => (int)$this->logoText, 'auth' => $this->calculateLogoAuth(), ]; return self::LOGO_BASE_URL . '?' . http_build_query($params); }
[ "public", "function", "getLogoUrl", "(", ")", "{", "$", "params", "=", "[", "'id'", "=>", "$", "this", "->", "_apiKey", ",", "'type'", "=>", "$", "this", "->", "logoType", ",", "'cols'", "=>", "(", "int", ")", "$", "this", "->", "logoCols", ",", "'...
Get the URL to the dynamic Paytrail logo. @return string
[ "Get", "the", "URL", "to", "the", "dynamic", "Paytrail", "logo", "." ]
a49c5e6742c42907fe329ff9b070fe7b21add74a
https://github.com/digiaonline/paytrail-php/blob/a49c5e6742c42907fe329ff9b070fe7b21add74a/src/Http/Client.php#L288-L299
train