repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
MW-Peachy/Peachy
Includes/XMLParse.php
XMLParse.load
public static function load( $data ) { $http = HTTP::getDefaultInstance(); if( !function_exists( 'simplexml_load_string' ) ) { throw new DependencyError( "SimpleXML", "http://us.php.net/manual/en/book.simplexml.php" ); } libxml_use_internal_errors( true ); if( in_string( "<?xml", $data ) ) { $xmlout = $data; } else { $xmlout = $http->get( $data ); } Hooks::runHook( 'PreSimpleXMLLoad', array( &$xmlout ) ); $xml = simplexml_load_string( $xmlout ); Hooks::runHook( 'PostSimpleXMLLoad', array( &$xml ) ); if( !$xml ) { foreach( libxml_get_errors() as $error ){ throw new XMLError( $error ); } } $outArr = array(); $namespaces = $xml->getNamespaces( true ); $namespaces['default'] = ''; self::recurse( $xml, $outArr, $namespaces ); libxml_clear_errors(); return $outArr; }
php
public static function load( $data ) { $http = HTTP::getDefaultInstance(); if( !function_exists( 'simplexml_load_string' ) ) { throw new DependencyError( "SimpleXML", "http://us.php.net/manual/en/book.simplexml.php" ); } libxml_use_internal_errors( true ); if( in_string( "<?xml", $data ) ) { $xmlout = $data; } else { $xmlout = $http->get( $data ); } Hooks::runHook( 'PreSimpleXMLLoad', array( &$xmlout ) ); $xml = simplexml_load_string( $xmlout ); Hooks::runHook( 'PostSimpleXMLLoad', array( &$xml ) ); if( !$xml ) { foreach( libxml_get_errors() as $error ){ throw new XMLError( $error ); } } $outArr = array(); $namespaces = $xml->getNamespaces( true ); $namespaces['default'] = ''; self::recurse( $xml, $outArr, $namespaces ); libxml_clear_errors(); return $outArr; }
[ "public", "static", "function", "load", "(", "$", "data", ")", "{", "$", "http", "=", "HTTP", "::", "getDefaultInstance", "(", ")", ";", "if", "(", "!", "function_exists", "(", "'simplexml_load_string'", ")", ")", "{", "throw", "new", "DependencyError", "(...
Converts an XML url or string to a PHP array format @static @access public @param string $data Either an url to an xml file, or a raw XML string. Peachy will autodetect which is which. @return array Parsed XML @throws BadEntryError @throws DependencyError @throws HookError @throws XMLError
[ "Converts", "an", "XML", "url", "or", "string", "to", "a", "PHP", "array", "format" ]
train
https://github.com/MW-Peachy/Peachy/blob/2cd3f93fd48e06c8a9f9eaaf17c5547947f9613c/Includes/XMLParse.php#L34-L71
Cenotia/yii2-remote-modal
RemoteModal.php
RemoteModal.registerAssets
public function registerAssets() { $view = $this->getView(); RemoteModalAsset::register($view); $uuid = uniqid(); $js = "rm_$uuid = new RemoteModal('#$this->id');\n"; $js .= "$(document).on('click', '[role=\"$this->id\"]', function (event){ \n "; $js .= "event.preventDefault(); \n"; $js.= "rm_$uuid.open(this, null);\n"; $js .="});\n"; $view->registerJs($js,\yii\web\View::POS_READY); }
php
public function registerAssets() { $view = $this->getView(); RemoteModalAsset::register($view); $uuid = uniqid(); $js = "rm_$uuid = new RemoteModal('#$this->id');\n"; $js .= "$(document).on('click', '[role=\"$this->id\"]', function (event){ \n "; $js .= "event.preventDefault(); \n"; $js.= "rm_$uuid.open(this, null);\n"; $js .="});\n"; $view->registerJs($js,\yii\web\View::POS_READY); }
[ "public", "function", "registerAssets", "(", ")", "{", "$", "view", "=", "$", "this", "->", "getView", "(", ")", ";", "RemoteModalAsset", "::", "register", "(", "$", "view", ")", ";", "$", "uuid", "=", "uniqid", "(", ")", ";", "$", "js", "=", "\"rm...
Registers the needed assets
[ "Registers", "the", "needed", "assets" ]
train
https://github.com/Cenotia/yii2-remote-modal/blob/7affebc92e8bf391ed3b5bc94d67e346ac6efc63/RemoteModal.php#L24-L36
kaliop-uk/kueueingbundle
Service/MessageProducer.php
MessageProducer.encodeMessageBody
protected function encodeMessageBody($data) { switch ($this->contentType) { case 'application/json': return json_encode($data); case 'application/x-httpd-php-source': return var_export($data, true); case 'vnd.php.serialized': return serialize($data); default: throw new \UnexpectedValueException("Serialization format unsupported: " . $this->contentType); } }
php
protected function encodeMessageBody($data) { switch ($this->contentType) { case 'application/json': return json_encode($data); case 'application/x-httpd-php-source': return var_export($data, true); case 'vnd.php.serialized': return serialize($data); default: throw new \UnexpectedValueException("Serialization format unsupported: " . $this->contentType); } }
[ "protected", "function", "encodeMessageBody", "(", "$", "data", ")", "{", "switch", "(", "$", "this", "->", "contentType", ")", "{", "case", "'application/json'", ":", "return", "json_encode", "(", "$", "data", ")", ";", "case", "'application/x-httpd-php-source'...
Encodes data according to current content type. If you reimplement this in a subclass, do not forget to also add new types to self::$knownContentTypes @param mixed $data @return string @throws \UnexpectedValueException
[ "Encodes", "data", "according", "to", "current", "content", "type", ".", "If", "you", "reimplement", "this", "in", "a", "subclass", "do", "not", "forget", "to", "also", "add", "new", "types", "to", "self", "::", "$knownContentTypes" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageProducer.php#L110-L122
kaliop-uk/kueueingbundle
Service/MessageProducer.php
MessageProducer.doPublish
protected function doPublish($data, $routingKey = '', $extras = array()) { $producer = $this->getProducerService(); $producer->setContentType($this->getContentType()); $producer->publish($this->encodeMessageBody($data), $routingKey, $extras); }
php
protected function doPublish($data, $routingKey = '', $extras = array()) { $producer = $this->getProducerService(); $producer->setContentType($this->getContentType()); $producer->publish($this->encodeMessageBody($data), $routingKey, $extras); }
[ "protected", "function", "doPublish", "(", "$", "data", ",", "$", "routingKey", "=", "''", ",", "$", "extras", "=", "array", "(", ")", ")", "{", "$", "producer", "=", "$", "this", "->", "getProducerService", "(", ")", ";", "$", "producer", "->", "set...
Some sugar for subclasses NB: the "extras" parameter only works as long as our customized class is used instead of Kaliop\QueueingBundle\RabbitMq\Producer (this happens naturally when this bundle is properly configured, as it is out of the box) @param mixed $data @param string $routingKey @param array $extras
[ "Some", "sugar", "for", "subclasses" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Service/MessageProducer.php#L134-L139
skrz/meta
gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithStringPropertyMeta.php
ClassWithStringPropertyMeta.create
public static function create() { switch (func_num_args()) { case 0: return new ClassWithStringProperty(); case 1: return new ClassWithStringProperty(func_get_arg(0)); case 2: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
php
public static function create() { switch (func_num_args()) { case 0: return new ClassWithStringProperty(); case 1: return new ClassWithStringProperty(func_get_arg(0)); case 2: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1)); case 3: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2)); case 4: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3)); case 5: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4)); case 6: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5)); case 7: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6)); case 8: return new ClassWithStringProperty(func_get_arg(0), func_get_arg(1), func_get_arg(2), func_get_arg(3), func_get_arg(4), func_get_arg(5), func_get_arg(6), func_get_arg(7)); default: throw new \InvalidArgumentException('More than 8 arguments supplied, please be reasonable.'); } }
[ "public", "static", "function", "create", "(", ")", "{", "switch", "(", "func_num_args", "(", ")", ")", "{", "case", "0", ":", "return", "new", "ClassWithStringProperty", "(", ")", ";", "case", "1", ":", "return", "new", "ClassWithStringProperty", "(", "fu...
Creates new instance of \Skrz\Meta\Fixtures\Protobuf\ClassWithStringProperty @throws \InvalidArgumentException @return ClassWithStringProperty
[ "Creates", "new", "instance", "of", "\\", "Skrz", "\\", "Meta", "\\", "Fixtures", "\\", "Protobuf", "\\", "ClassWithStringProperty" ]
train
https://github.com/skrz/meta/blob/013af6435d3885ab5b2e91fb8ebb051d0f874ab2/gen-src/Skrz/Meta/Fixtures/Protobuf/Meta/ClassWithStringPropertyMeta.php#L66-L90
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.getOptions
public function getOptions() { // Create Options List: $options = ArrayList::create(); // Iterate Source Items: foreach ($this->getSourceEmpty() as $value => $title) { $options->push($this->getFieldOption($value, $title)); } // Handle Tags: if ($this->usesTags()) { // Obtain Source Values: $values = $this->getSourceValues(); // Iterate Value Array: foreach ($this->getValueArray() as $value) { // Handle Tag Values: if (!in_array($value, $values)) { $options->push($this->getFieldOption($value, $value)); } } } // Apply Extensions: $this->extend('updateOptions', $options); // Answer Options List: return $options; }
php
public function getOptions() { // Create Options List: $options = ArrayList::create(); // Iterate Source Items: foreach ($this->getSourceEmpty() as $value => $title) { $options->push($this->getFieldOption($value, $title)); } // Handle Tags: if ($this->usesTags()) { // Obtain Source Values: $values = $this->getSourceValues(); // Iterate Value Array: foreach ($this->getValueArray() as $value) { // Handle Tag Values: if (!in_array($value, $values)) { $options->push($this->getFieldOption($value, $value)); } } } // Apply Extensions: $this->extend('updateOptions', $options); // Answer Options List: return $options; }
[ "public", "function", "getOptions", "(", ")", "{", "// Create Options List:", "$", "options", "=", "ArrayList", "::", "create", "(", ")", ";", "// Iterate Source Items:", "foreach", "(", "$", "this", "->", "getSourceEmpty", "(", ")", "as", "$", "value", "=>", ...
Answers an array list containing the options for the field. @return ArrayList
[ "Answers", "an", "array", "list", "containing", "the", "options", "for", "the", "field", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L121-L162
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.getAttributes
public function getAttributes() { $attributes = array_merge( parent::getAttributes(), $this->getDataAttributes() ); if ($this->isMultiple()) { $attributes['multiple'] = true; $attributes['name'] = $this->getMultipleName(); } if (!isset($attributes['data-placeholder'])) { $attributes['data-placeholder'] = $this->getEmptyString(); } return $attributes; }
php
public function getAttributes() { $attributes = array_merge( parent::getAttributes(), $this->getDataAttributes() ); if ($this->isMultiple()) { $attributes['multiple'] = true; $attributes['name'] = $this->getMultipleName(); } if (!isset($attributes['data-placeholder'])) { $attributes['data-placeholder'] = $this->getEmptyString(); } return $attributes; }
[ "public", "function", "getAttributes", "(", ")", "{", "$", "attributes", "=", "array_merge", "(", "parent", "::", "getAttributes", "(", ")", ",", "$", "this", "->", "getDataAttributes", "(", ")", ")", ";", "if", "(", "$", "this", "->", "isMultiple", "(",...
Answers an array of HTML attributes for the field. @return array
[ "Answers", "an", "array", "of", "HTML", "attributes", "for", "the", "field", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L260-L277
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.getDataAttributes
public function getDataAttributes() { $attributes = []; foreach ($this->getFieldConfig() as $key => $value) { $attributes[sprintf('data-%s', $key)] = $this->getDataValue($value); } return $attributes; }
php
public function getDataAttributes() { $attributes = []; foreach ($this->getFieldConfig() as $key => $value) { $attributes[sprintf('data-%s', $key)] = $this->getDataValue($value); } return $attributes; }
[ "public", "function", "getDataAttributes", "(", ")", "{", "$", "attributes", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "getFieldConfig", "(", ")", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "attributes", "[", "sprintf", "(", "'...
Answers an array of data attributes for the field. @return array
[ "Answers", "an", "array", "of", "data", "attributes", "for", "the", "field", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L284-L293
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.setValue
public function setValue($value, $data = null) { if ($data instanceof DataObject) { $this->loadFrom($data); return $this; } return parent::setValue($value); }
php
public function setValue($value, $data = null) { if ($data instanceof DataObject) { $this->loadFrom($data); return $this; } return parent::setValue($value); }
[ "public", "function", "setValue", "(", "$", "value", ",", "$", "data", "=", "null", ")", "{", "if", "(", "$", "data", "instanceof", "DataObject", ")", "{", "$", "this", "->", "loadFrom", "(", "$", "data", ")", ";", "return", "$", "this", ";", "}", ...
Defines the value of the field. @param mixed $value @param array|DataObject $data @return $this
[ "Defines", "the", "value", "of", "the", "field", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L303-L311
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.isSelectedValue
public function isSelectedValue($dataValue, $userValue) { if (!$this->isMultiple() || !is_array($userValue)) { return parent::isSelectedValue($dataValue, $userValue); } return in_array($dataValue, $userValue); }
php
public function isSelectedValue($dataValue, $userValue) { if (!$this->isMultiple() || !is_array($userValue)) { return parent::isSelectedValue($dataValue, $userValue); } return in_array($dataValue, $userValue); }
[ "public", "function", "isSelectedValue", "(", "$", "dataValue", ",", "$", "userValue", ")", "{", "if", "(", "!", "$", "this", "->", "isMultiple", "(", ")", "||", "!", "is_array", "(", "$", "userValue", ")", ")", "{", "return", "parent", "::", "isSelect...
Answers true if the current value of this field matches the given option value. @param mixed $dataValue @param mixed $userValue @return boolean
[ "Answers", "true", "if", "the", "current", "value", "of", "this", "field", "matches", "the", "given", "option", "value", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L321-L328
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.loadFrom
public function loadFrom(DataObjectInterface $record) { // Obtain Field Name: $fieldName = $this->getName(); // Bail Early (if needed): if (empty($fieldName) || empty($record)) { return; } // Determine Value Mode: if (!$this->isMultiple()) { // Load Singular Value: parent::setValue($record->$fieldName); } else { // Load Multiple Value: $relation = $this->getNamedRelation($record); if ($relation instanceof Relation) { $this->loadFromRelation($relation); } elseif ($record->hasField($fieldName)) { parent::setValue($this->stringDecode($record->$fieldName)); } } }
php
public function loadFrom(DataObjectInterface $record) { // Obtain Field Name: $fieldName = $this->getName(); // Bail Early (if needed): if (empty($fieldName) || empty($record)) { return; } // Determine Value Mode: if (!$this->isMultiple()) { // Load Singular Value: parent::setValue($record->$fieldName); } else { // Load Multiple Value: $relation = $this->getNamedRelation($record); if ($relation instanceof Relation) { $this->loadFromRelation($relation); } elseif ($record->hasField($fieldName)) { parent::setValue($this->stringDecode($record->$fieldName)); } } }
[ "public", "function", "loadFrom", "(", "DataObjectInterface", "$", "record", ")", "{", "// Obtain Field Name:", "$", "fieldName", "=", "$", "this", "->", "getName", "(", ")", ";", "// Bail Early (if needed):", "if", "(", "empty", "(", "$", "fieldName", ")", "|...
Loads the value of the field from the given data object. @param DataObjectInterface $record @return void
[ "Loads", "the", "value", "of", "the", "field", "from", "the", "given", "data", "object", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L347-L380
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.saveInto
public function saveInto(DataObjectInterface $record) { // Obtain Field Name: $fieldName = $this->getName(); // Bail Early (if needed): if (empty($fieldName) || empty($record)) { return; } // Determine Value Mode: if (!$this->isMultiple()) { // Save Singular Value: parent::saveInto($record); } else { // Save Multiple Value: $relation = $this->getNamedRelation($record); if ($relation instanceof Relation) { $this->saveIntoRelation($relation); } elseif ($record->hasField($fieldName)) { $record->$fieldName = $this->stringEncode($this->getValueArray()); } } }
php
public function saveInto(DataObjectInterface $record) { // Obtain Field Name: $fieldName = $this->getName(); // Bail Early (if needed): if (empty($fieldName) || empty($record)) { return; } // Determine Value Mode: if (!$this->isMultiple()) { // Save Singular Value: parent::saveInto($record); } else { // Save Multiple Value: $relation = $this->getNamedRelation($record); if ($relation instanceof Relation) { $this->saveIntoRelation($relation); } elseif ($record->hasField($fieldName)) { $record->$fieldName = $this->stringEncode($this->getValueArray()); } } }
[ "public", "function", "saveInto", "(", "DataObjectInterface", "$", "record", ")", "{", "// Obtain Field Name:", "$", "fieldName", "=", "$", "this", "->", "getName", "(", ")", ";", "// Bail Early (if needed):", "if", "(", "empty", "(", "$", "fieldName", ")", "|...
Saves the value of the field into the given data object. @param DataObjectInterface $record @return void
[ "Saves", "the", "value", "of", "the", "field", "into", "the", "given", "data", "object", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L389-L422
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.validate
public function validate($validator) { // Baily Early (if tags are used): if ($this->usesTags()) { return true; } // Call Parent Method (if not multiple): if (!$this->isMultiple()) { return parent::validate($validator); } // Obtain User Values: $values = $this->getValueArray(); // Detect Invalid Values: $invalid = array_filter( $values, function ($userValue) { foreach ($this->getValidValues() as $formValue) { if ($this->isSelectedValue($formValue, $userValue)) { return false; } } return true; } ); // Answer Success (if none invalid): if (empty($invalid)) { return true; } // Define Validation Error: $validator->validationError( $this->getName(), _t( __CLASS__ . '.INVALIDOPTIONS', 'Please select values within the list provided. Invalid option(s) {values} given.', [ 'values' => implode(', ', $invalid) ] ), 'validation' ); // Answer Failure (invalid values detected): return false; }
php
public function validate($validator) { // Baily Early (if tags are used): if ($this->usesTags()) { return true; } // Call Parent Method (if not multiple): if (!$this->isMultiple()) { return parent::validate($validator); } // Obtain User Values: $values = $this->getValueArray(); // Detect Invalid Values: $invalid = array_filter( $values, function ($userValue) { foreach ($this->getValidValues() as $formValue) { if ($this->isSelectedValue($formValue, $userValue)) { return false; } } return true; } ); // Answer Success (if none invalid): if (empty($invalid)) { return true; } // Define Validation Error: $validator->validationError( $this->getName(), _t( __CLASS__ . '.INVALIDOPTIONS', 'Please select values within the list provided. Invalid option(s) {values} given.', [ 'values' => implode(', ', $invalid) ] ), 'validation' ); // Answer Failure (invalid values detected): return false; }
[ "public", "function", "validate", "(", "$", "validator", ")", "{", "// Baily Early (if tags are used):", "if", "(", "$", "this", "->", "usesTags", "(", ")", ")", "{", "return", "true", ";", "}", "// Call Parent Method (if not multiple):", "if", "(", "!", "$", ...
Performs validation on the receiver. @param Validator $validator @return boolean
[ "Performs", "validation", "on", "the", "receiver", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L455-L510
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.getDataValue
protected function getDataValue($value) { if (is_bool($value)) { return $value ? 'true' : 'false'; } elseif (is_array($value)) { return Convert::array2json($value); } else { return Convert::raw2att($value); } }
php
protected function getDataValue($value) { if (is_bool($value)) { return $value ? 'true' : 'false'; } elseif (is_array($value)) { return Convert::array2json($value); } else { return Convert::raw2att($value); } }
[ "protected", "function", "getDataValue", "(", "$", "value", ")", "{", "if", "(", "is_bool", "(", "$", "value", ")", ")", "{", "return", "$", "value", "?", "'true'", ":", "'false'", ";", "}", "elseif", "(", "is_array", "(", "$", "value", ")", ")", "...
Converts the given data value to a string suitable for a data attribute. @param mixed $value @return string
[ "Converts", "the", "given", "data", "value", "to", "a", "string", "suitable", "for", "a", "data", "attribute", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L543-L552
praxisnetau/silverware-select2
src/Forms/Select2Field.php
Select2Field.getNamedRelation
protected function getNamedRelation(DataObjectInterface $record) { return $record->hasMethod($this->Name) ? $record->{$this->Name}() : null; }
php
protected function getNamedRelation(DataObjectInterface $record) { return $record->hasMethod($this->Name) ? $record->{$this->Name}() : null; }
[ "protected", "function", "getNamedRelation", "(", "DataObjectInterface", "$", "record", ")", "{", "return", "$", "record", "->", "hasMethod", "(", "$", "this", "->", "Name", ")", "?", "$", "record", "->", "{", "$", "this", "->", "Name", "}", "(", ")", ...
Answers the relation with the field name from the given data object. @param DataObjectInterface $record @return Relation
[ "Answers", "the", "relation", "with", "the", "field", "name", "from", "the", "given", "data", "object", "." ]
train
https://github.com/praxisnetau/silverware-select2/blob/81f3efe7f40eb87e1390f038c3c9eed415be7bc3/src/Forms/Select2Field.php#L577-L580
budde377/Part
lib/util/traits/EncryptionTrait.php
EncryptionTrait.encrypt
protected function encrypt($string, $key){ return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); }
php
protected function encrypt($string, $key){ return base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, md5($key), $string, MCRYPT_MODE_CBC, md5(md5($key)))); }
[ "protected", "function", "encrypt", "(", "$", "string", ",", "$", "key", ")", "{", "return", "base64_encode", "(", "mcrypt_encrypt", "(", "MCRYPT_RIJNDAEL_256", ",", "md5", "(", "$", "key", ")", ",", "$", "string", ",", "MCRYPT_MODE_CBC", ",", "md5", "(", ...
Will encrypt string and return encrypted string. The encryption will be an two-way function, so not as secure as could be, but secure enough to hide passwords in database, and is highly encouraged to be used to that. @param string $string @param string $key @return string
[ "Will", "encrypt", "string", "and", "return", "encrypted", "string", ".", "The", "encryption", "will", "be", "an", "two", "-", "way", "function", "so", "not", "as", "secure", "as", "could", "be", "but", "secure", "enough", "to", "hide", "passwords", "in", ...
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/traits/EncryptionTrait.php#L20-L22
budde377/Part
lib/util/traits/EncryptionTrait.php
EncryptionTrait.decrypt
protected function decrypt($string, $key){ return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); }
php
protected function decrypt($string, $key){ return rtrim(mcrypt_decrypt(MCRYPT_RIJNDAEL_256, md5($key), base64_decode($string), MCRYPT_MODE_CBC, md5(md5($key))), "\0"); }
[ "protected", "function", "decrypt", "(", "$", "string", ",", "$", "key", ")", "{", "return", "rtrim", "(", "mcrypt_decrypt", "(", "MCRYPT_RIJNDAEL_256", ",", "md5", "(", "$", "key", ")", ",", "base64_decode", "(", "$", "string", ")", ",", "MCRYPT_MODE_CBC"...
Will decrypt an encrypted string with an given key. The encryption which must be encoded with encrypt() in this trait. @param string $string @param string $key @return string
[ "Will", "decrypt", "an", "encrypted", "string", "with", "an", "given", "key", ".", "The", "encryption", "which", "must", "be", "encoded", "with", "encrypt", "()", "in", "this", "trait", "." ]
train
https://github.com/budde377/Part/blob/9ab5ce43dd809f9c563040ae0f7dcb7f56a52c5d/lib/util/traits/EncryptionTrait.php#L32-L34
kaliop-uk/kueueingbundle
Adapter/DriverManager.php
DriverManager.getDrivers
public function getDrivers() { $drivers = array(); foreach($this->aliases as $alias => $service) { $drivers[$alias] = $this->container->get($service); } return $drivers; }
php
public function getDrivers() { $drivers = array(); foreach($this->aliases as $alias => $service) { $drivers[$alias] = $this->container->get($service); } return $drivers; }
[ "public", "function", "getDrivers", "(", ")", "{", "$", "drivers", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "aliases", "as", "$", "alias", "=>", "$", "service", ")", "{", "$", "drivers", "[", "$", "alias", "]", "=", "$", "t...
returns all drivers @return array key is alias, value is the service
[ "returns", "all", "drivers" ]
train
https://github.com/kaliop-uk/kueueingbundle/blob/6a4f9b01ef1f5b8e5cdfad78f7c82b35f1007987/Adapter/DriverManager.php#L84-L91
baleen/migrations
src/Service/MigrationBus/MigrateHandler.php
MigrateHandler.execute
public function execute($command, callable $next) { $migration = $command->getMigration(); $direction = $command->getOptions()->getDirection()->isUp() ? 'up' : 'down'; $migration->$direction(); }
php
public function execute($command, callable $next) { $migration = $command->getMigration(); $direction = $command->getOptions()->getDirection()->isUp() ? 'up' : 'down'; $migration->$direction(); }
[ "public", "function", "execute", "(", "$", "command", ",", "callable", "$", "next", ")", "{", "$", "migration", "=", "$", "command", "->", "getMigration", "(", ")", ";", "$", "direction", "=", "$", "command", "->", "getOptions", "(", ")", "->", "getDir...
execute @param MigrateCommand $command @param callable $next @return void
[ "execute" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/MigrationBus/MigrateHandler.php#L40-L46
amphp/http-server-session
src/Session.php
Session.isEmpty
public function isEmpty(): bool { if ($this->status & self::STATUS_READ === 0) { throw new \Error('The session has not been read'); } return empty($this->data); }
php
public function isEmpty(): bool { if ($this->status & self::STATUS_READ === 0) { throw new \Error('The session has not been read'); } return empty($this->data); }
[ "public", "function", "isEmpty", "(", ")", ":", "bool", "{", "if", "(", "$", "this", "->", "status", "&", "self", "::", "STATUS_READ", "===", "0", ")", "{", "throw", "new", "\\", "Error", "(", "'The session has not been read'", ")", ";", "}", "return", ...
@return bool `true` if the session is empty. @throws \Error If the session has not been read.
[ "@return", "bool", "true", "if", "the", "session", "is", "empty", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L70-L77
amphp/http-server-session
src/Session.php
Session.regenerate
public function regenerate(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if ($this->id === null || !$this->isLocked()) { throw new \Error('Cannot save an unlocked session'); } $newId = yield $this->storage->create(); yield $this->storage->save($newId, $this->data); yield $this->storage->save($this->id, []); $this->id = $newId; $this->status = self::STATUS_READ | self::STATUS_LOCKED; return $this->id; }); }
php
public function regenerate(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if ($this->id === null || !$this->isLocked()) { throw new \Error('Cannot save an unlocked session'); } $newId = yield $this->storage->create(); yield $this->storage->save($newId, $this->data); yield $this->storage->save($this->id, []); $this->id = $newId; $this->status = self::STATUS_READ | self::STATUS_LOCKED; return $this->id; }); }
[ "public", "function", "regenerate", "(", ")", ":", "Promise", "{", "return", "$", "this", "->", "pending", "=", "call", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "pending", ")", "{", "yield", "$", "this", "->", "pending", ";", "...
Regenerates a session identifier and locks the session. @return Promise Resolving with the new session identifier.
[ "Regenerates", "a", "session", "identifier", "and", "locks", "the", "session", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L84-L105
amphp/http-server-session
src/Session.php
Session.read
public function read(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if ($this->id !== null) { $this->data = yield $this->storage->read($this->id); } $this->status |= self::STATUS_READ; return $this; }); }
php
public function read(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if ($this->id !== null) { $this->data = yield $this->storage->read($this->id); } $this->status |= self::STATUS_READ; return $this; }); }
[ "public", "function", "read", "(", ")", ":", "Promise", "{", "return", "$", "this", "->", "pending", "=", "call", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "pending", ")", "{", "yield", "$", "this", "->", "pending", ";", "}", ...
Reads the session data without opening (locking) the session. @return Promise Resolved with the session.
[ "Reads", "the", "session", "data", "without", "opening", "(", "locking", ")", "the", "session", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L112-L127
amphp/http-server-session
src/Session.php
Session.open
public function open(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if ($this->id === null) { $this->id = yield $this->storage->create(); } else { $this->data = yield $this->storage->lock($this->id); } ++$this->openCount; $this->status = self::STATUS_READ | self::STATUS_LOCKED; return $this; }); }
php
public function open(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if ($this->id === null) { $this->id = yield $this->storage->create(); } else { $this->data = yield $this->storage->lock($this->id); } ++$this->openCount; $this->status = self::STATUS_READ | self::STATUS_LOCKED; return $this; }); }
[ "public", "function", "open", "(", ")", ":", "Promise", "{", "return", "$", "this", "->", "pending", "=", "call", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "pending", ")", "{", "yield", "$", "this", "->", "pending", ";", "}", ...
Opens the session for writing. @return Promise Resolved with the session.
[ "Opens", "the", "session", "for", "writing", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L134-L153
amphp/http-server-session
src/Session.php
Session.save
public function save(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if (!$this->isLocked()) { throw new \Error('Cannot save an unlocked session'); } if ($this->data === []) { yield $this->storage->save($this->id, []); } else { yield $this->storage->save($this->id, $this->data); } if ($this->openCount === 1) { yield $this->storage->unlock($this->id); $this->status &= ~self::STATUS_LOCKED; if ($this->data === []) { $this->id = null; } } --$this->openCount; }); }
php
public function save(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if (!$this->isLocked()) { throw new \Error('Cannot save an unlocked session'); } if ($this->data === []) { yield $this->storage->save($this->id, []); } else { yield $this->storage->save($this->id, $this->data); } if ($this->openCount === 1) { yield $this->storage->unlock($this->id); $this->status &= ~self::STATUS_LOCKED; if ($this->data === []) { $this->id = null; } } --$this->openCount; }); }
[ "public", "function", "save", "(", ")", ":", "Promise", "{", "return", "$", "this", "->", "pending", "=", "call", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "pending", ")", "{", "yield", "$", "this", "->", "pending", ";", "}", ...
Saves the given data in the session. The session must be locked with either open() before calling this method. @return Promise
[ "Saves", "the", "given", "data", "in", "the", "session", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L162-L190
amphp/http-server-session
src/Session.php
Session.unlock
public function unlock(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if (!$this->isLocked()) { return; } if ($this->openCount === 1) { yield $this->storage->unlock($this->id); $this->status &= ~self::STATUS_LOCKED; } --$this->openCount; }); }
php
public function unlock(): Promise { return $this->pending = call(function () { if ($this->pending) { yield $this->pending; } if (!$this->isLocked()) { return; } if ($this->openCount === 1) { yield $this->storage->unlock($this->id); $this->status &= ~self::STATUS_LOCKED; } --$this->openCount; }); }
[ "public", "function", "unlock", "(", ")", ":", "Promise", "{", "return", "$", "this", "->", "pending", "=", "call", "(", "function", "(", ")", "{", "if", "(", "$", "this", "->", "pending", ")", "{", "yield", "$", "this", "->", "pending", ";", "}", ...
Unlocks the session. @return Promise
[ "Unlocks", "the", "session", "." ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L213-L231
amphp/http-server-session
src/Session.php
Session.has
public function has(string $key): bool { $this->assertRead(); return \array_key_exists($key, $this->data); }
php
public function has(string $key): bool { $this->assertRead(); return \array_key_exists($key, $this->data); }
[ "public", "function", "has", "(", "string", "$", "key", ")", ":", "bool", "{", "$", "this", "->", "assertRead", "(", ")", ";", "return", "\\", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "data", ")", ";", "}" ]
@param string $key @return bool @throws \Error If the session has not been read.
[ "@param", "string", "$key" ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L240-L245
amphp/http-server-session
src/Session.php
Session.set
public function set(string $key, $data) { $this->assertLocked(); $this->data[$key] = $data; }
php
public function set(string $key, $data) { $this->assertLocked(); $this->data[$key] = $data; }
[ "public", "function", "set", "(", "string", "$", "key", ",", "$", "data", ")", "{", "$", "this", "->", "assertLocked", "(", ")", ";", "$", "this", "->", "data", "[", "$", "key", "]", "=", "$", "data", ";", "}" ]
@param string $key @param mixed $data @throws \Error If the session has not been opened for writing.
[ "@param", "string", "$key", "@param", "mixed", "$data" ]
train
https://github.com/amphp/http-server-session/blob/c9117a378637d170d4dc4333b9a1e646fbbd03e7/src/Session.php#L267-L272
baleen/migrations
src/Delta/Comparator/NamespacesAwareComparator.php
NamespacesAwareComparator.compare
public function compare(DeltaInterface $version1, DeltaInterface $version2) { $class1 = $version1->getMigrationClassName(); $class2 = $version2->getMigrationClassName(); if ($class1 === $class2) { // exit early in this case return 0; } $res = $this->compareNamespaces($class1, $class2); // null = could not determine order | zero = both orders are equal if (empty($res)) { // delegate sorting to the fallback comparator $res = call_user_func($this->fallbackComparator, $version1, $version2); } return $res; }
php
public function compare(DeltaInterface $version1, DeltaInterface $version2) { $class1 = $version1->getMigrationClassName(); $class2 = $version2->getMigrationClassName(); if ($class1 === $class2) { // exit early in this case return 0; } $res = $this->compareNamespaces($class1, $class2); // null = could not determine order | zero = both orders are equal if (empty($res)) { // delegate sorting to the fallback comparator $res = call_user_func($this->fallbackComparator, $version1, $version2); } return $res; }
[ "public", "function", "compare", "(", "DeltaInterface", "$", "version1", ",", "DeltaInterface", "$", "version2", ")", "{", "$", "class1", "=", "$", "version1", "->", "getMigrationClassName", "(", ")", ";", "$", "class2", "=", "$", "version2", "->", "getMigra...
{@inheritdoc} Given the following $namespaces passed in the constructor: - Taz (lowest priority) - Bar - Foo (highest priority) Will produce the following results based on the migration's FQCN: - (Foo\v200012, Bar\v201612) => -1 - (Taz\v201612, Foo\v200012) => 1 - (FooBar\v201612, Taz\v200012) => 1 - (Taz\v201612, Taz\v201601) => delegate to fallback - (FooBar\v201612, FooBar\v200012) => delegate to fallback @param DeltaInterface $version1 @param DeltaInterface $version2 @return int @throws InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Comparator/NamespacesAwareComparator.php#L93-L111
baleen/migrations
src/Delta/Comparator/NamespacesAwareComparator.php
NamespacesAwareComparator.compareNamespaces
private function compareNamespaces($class1, $class2) { $res = null; // loop from highest namespace priority to lowest foreach ($this->namespaces as $namespace) { if (strpos($class1, $namespace) === 0) { $res = 1; } if (strpos($class2, $namespace) === 0) { // subtract 1 from $res, setting it to either -1 or 0 $res = (int) $res - 1; } if (null !== $res) { break; // exit as soon as we found a sort order } } return $res; }
php
private function compareNamespaces($class1, $class2) { $res = null; // loop from highest namespace priority to lowest foreach ($this->namespaces as $namespace) { if (strpos($class1, $namespace) === 0) { $res = 1; } if (strpos($class2, $namespace) === 0) { // subtract 1 from $res, setting it to either -1 or 0 $res = (int) $res - 1; } if (null !== $res) { break; // exit as soon as we found a sort order } } return $res; }
[ "private", "function", "compareNamespaces", "(", "$", "class1", ",", "$", "class2", ")", "{", "$", "res", "=", "null", ";", "// loop from highest namespace priority to lowest", "foreach", "(", "$", "this", "->", "namespaces", "as", "$", "namespace", ")", "{", ...
Compare using namespaces @param $class1 @param $class2 @return int|null
[ "Compare", "using", "namespaces" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Delta/Comparator/NamespacesAwareComparator.php#L120-L137
meare/juggler
src/Imposter/Builder/AbstractImposterBuilder.php
AbstractImposterBuilder.build
public function build($json) { $contract = \GuzzleHttp\json_decode($json, true); if (!isset($contract['protocol'])) { throw new \InvalidArgumentException('Invalid contract; Protocol is not specified'); } return $this->getBuilder($contract['protocol'])->build($contract); }
php
public function build($json) { $contract = \GuzzleHttp\json_decode($json, true); if (!isset($contract['protocol'])) { throw new \InvalidArgumentException('Invalid contract; Protocol is not specified'); } return $this->getBuilder($contract['protocol'])->build($contract); }
[ "public", "function", "build", "(", "$", "json", ")", "{", "$", "contract", "=", "\\", "GuzzleHttp", "\\", "json_decode", "(", "$", "json", ",", "true", ")", ";", "if", "(", "!", "isset", "(", "$", "contract", "[", "'protocol'", "]", ")", ")", "{",...
Builds Imposter object from JSON contract using appropriate Builder @param string $json @return \Meare\Juggler\Imposter\Imposter @throws \InvalidArgumentException if contract has no protocol or no appropriate Builder found
[ "Builds", "Imposter", "object", "from", "JSON", "contract", "using", "appropriate", "Builder" ]
train
https://github.com/meare/juggler/blob/11ec398c16e01c986679f53f8ece2c1e97ba4e29/src/Imposter/Builder/AbstractImposterBuilder.php#L23-L31
Cocolabs-SAS/CocoricoSwiftReaderBundle
DTO/MessageListDTO.php
MessageListDTO.fill
public function fill(Finder $files) { /** @var SplFileInfo $file */ foreach ($files as $file) { preg_match("/(\d+)_([^']+)_([^']+).json/", $file->getFilename(), $matches); array_push( $this->messages, array( 'date' => (new \DateTime(sprintf('@%d', $matches[1])))->format('Y-m-d H:i:s'), 'subject' => base64_decode($matches[2]), 'filename' => $file->getFilename() ) ); } }
php
public function fill(Finder $files) { /** @var SplFileInfo $file */ foreach ($files as $file) { preg_match("/(\d+)_([^']+)_([^']+).json/", $file->getFilename(), $matches); array_push( $this->messages, array( 'date' => (new \DateTime(sprintf('@%d', $matches[1])))->format('Y-m-d H:i:s'), 'subject' => base64_decode($matches[2]), 'filename' => $file->getFilename() ) ); } }
[ "public", "function", "fill", "(", "Finder", "$", "files", ")", "{", "/** @var SplFileInfo $file */", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "preg_match", "(", "\"/(\\d+)_([^']+)_([^']+).json/\"", ",", "$", "file", "->", "getFilename", "(", ...
MessageListDTO constructor. @param Finder $files
[ "MessageListDTO", "constructor", "." ]
train
https://github.com/Cocolabs-SAS/CocoricoSwiftReaderBundle/blob/ba3df4ccef1bd473e67121112f6a5d7ce0b369aa/DTO/MessageListDTO.php#L26-L42
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/Api/DropzoneController.php
DropzoneController.postIndex
public function postIndex() { if ( ! Input::hasFile('file')) { return Response::json(array('error' => 'File is required'), 400); } $contents = trim(File::get(Input::file('file')->getRealPath())); if (substr($contents, 0, 3) !== '---') { throw new Exception('Bad Markdown Formatting'); } if ( ! ($pos = strpos($contents, '---', 3))) { throw new Exception('Bad Markdown Formatting'); } $frontMatter = trim(substr($contents, 3, $pos - 3)); $contents = trim(substr($contents, $pos + 3)); $yaml = new Parser(); $fields = $yaml->parse($frontMatter); return Response::json(array( 'fields' => $fields, 'content' => $contents )); }
php
public function postIndex() { if ( ! Input::hasFile('file')) { return Response::json(array('error' => 'File is required'), 400); } $contents = trim(File::get(Input::file('file')->getRealPath())); if (substr($contents, 0, 3) !== '---') { throw new Exception('Bad Markdown Formatting'); } if ( ! ($pos = strpos($contents, '---', 3))) { throw new Exception('Bad Markdown Formatting'); } $frontMatter = trim(substr($contents, 3, $pos - 3)); $contents = trim(substr($contents, $pos + 3)); $yaml = new Parser(); $fields = $yaml->parse($frontMatter); return Response::json(array( 'fields' => $fields, 'content' => $contents )); }
[ "public", "function", "postIndex", "(", ")", "{", "if", "(", "!", "Input", "::", "hasFile", "(", "'file'", ")", ")", "{", "return", "Response", "::", "json", "(", "array", "(", "'error'", "=>", "'File is required'", ")", ",", "400", ")", ";", "}", "$...
Display a listing of the resource. @throws Exception @return Response
[ "Display", "a", "listing", "of", "the", "resource", "." ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/Api/DropzoneController.php#L30-L60
wardrobecms/core-archived
src/Wardrobe/Core/Controllers/Api/DropzoneController.php
DropzoneController.postImage
public function postImage() { $file = Input::file('file'); $imageDir = Config::get('core::wardrobe.image_dir'); $destinationPath = public_path(). "/{$imageDir}/"; $filename = $file->getClientOriginalName(); $resizeEnabled = Config::get('core::wardrobe.image_resize.enabled'); if ($resizeEnabled) { $resizeWidth = Config::get('core::wardrobe.image_resize.width'); $resizeHeight = Config::get('core::wardrobe.image_resize.height'); $image = Image::make($file->getRealPath())->resize($resizeWidth, $resizeHeight, true); $image->save($destinationPath.$filename); } else { $file->move($destinationPath, $filename); } if (File::exists($destinationPath.$filename)) { // @note - Using the absolute url so it loads images when ran in sub folder // this will make exporting less portable and may need to re-address at a later point. return Response::json(array('filename' => url("/{$imageDir}/".$filename))); } return Response::json(array('error' => 'Upload failed. Please ensure your public/img directory is writable.')); }
php
public function postImage() { $file = Input::file('file'); $imageDir = Config::get('core::wardrobe.image_dir'); $destinationPath = public_path(). "/{$imageDir}/"; $filename = $file->getClientOriginalName(); $resizeEnabled = Config::get('core::wardrobe.image_resize.enabled'); if ($resizeEnabled) { $resizeWidth = Config::get('core::wardrobe.image_resize.width'); $resizeHeight = Config::get('core::wardrobe.image_resize.height'); $image = Image::make($file->getRealPath())->resize($resizeWidth, $resizeHeight, true); $image->save($destinationPath.$filename); } else { $file->move($destinationPath, $filename); } if (File::exists($destinationPath.$filename)) { // @note - Using the absolute url so it loads images when ran in sub folder // this will make exporting less portable and may need to re-address at a later point. return Response::json(array('filename' => url("/{$imageDir}/".$filename))); } return Response::json(array('error' => 'Upload failed. Please ensure your public/img directory is writable.')); }
[ "public", "function", "postImage", "(", ")", "{", "$", "file", "=", "Input", "::", "file", "(", "'file'", ")", ";", "$", "imageDir", "=", "Config", "::", "get", "(", "'core::wardrobe.image_dir'", ")", ";", "$", "destinationPath", "=", "public_path", "(", ...
Post an image from the admin @return Json
[ "Post", "an", "image", "from", "the", "admin" ]
train
https://github.com/wardrobecms/core-archived/blob/5c0836ea2e6885a428c852dc392073f2a2541c71/src/Wardrobe/Core/Controllers/Api/DropzoneController.php#L67-L94
baleen/migrations
src/Migration/Options.php
Options.withDirection
public function withDirection(Direction $direction) { return new static($direction, $this->forced, $this->dryRun, $this->exceptionOnSkip, $this->custom); }
php
public function withDirection(Direction $direction) { return new static($direction, $this->forced, $this->dryRun, $this->exceptionOnSkip, $this->custom); }
[ "public", "function", "withDirection", "(", "Direction", "$", "direction", ")", "{", "return", "new", "static", "(", "$", "direction", ",", "$", "this", "->", "forced", ",", "$", "this", "->", "dryRun", ",", "$", "this", "->", "exceptionOnSkip", ",", "$"...
@param Direction $direction @return static @throws InvalidArgumentException
[ "@param", "Direction", "$direction" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Options.php#L104-L107
baleen/migrations
src/Migration/Options.php
Options.withForced
public function withForced($forced) { return new static($this->direction, $forced, $this->dryRun, $this->exceptionOnSkip, $this->custom); }
php
public function withForced($forced) { return new static($this->direction, $forced, $this->dryRun, $this->exceptionOnSkip, $this->custom); }
[ "public", "function", "withForced", "(", "$", "forced", ")", "{", "return", "new", "static", "(", "$", "this", "->", "direction", ",", "$", "forced", ",", "$", "this", "->", "dryRun", ",", "$", "this", "->", "exceptionOnSkip", ",", "$", "this", "->", ...
withForced @param $forced @return static
[ "withForced" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Options.php#L122-L125
baleen/migrations
src/Migration/Options.php
Options.withDryRun
public function withDryRun($dryRun) { return new static($this->direction, $this->forced, $dryRun, $this->exceptionOnSkip, $this->custom); }
php
public function withDryRun($dryRun) { return new static($this->direction, $this->forced, $dryRun, $this->exceptionOnSkip, $this->custom); }
[ "public", "function", "withDryRun", "(", "$", "dryRun", ")", "{", "return", "new", "static", "(", "$", "this", "->", "direction", ",", "$", "this", "->", "forced", ",", "$", "dryRun", ",", "$", "this", "->", "exceptionOnSkip", ",", "$", "this", "->", ...
withDryRun @param bool $dryRun @return static
[ "withDryRun" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Options.php#L140-L143
baleen/migrations
src/Migration/Options.php
Options.fromOptionsWithDirection
public static function fromOptionsWithDirection(Direction $direction, OptionsInterface $options = null) { if (null === $options) { $options = (new static($direction))->withExceptionOnSkip(false); } else { $options = $options->withDirection($direction); } return $options; }
php
public static function fromOptionsWithDirection(Direction $direction, OptionsInterface $options = null) { if (null === $options) { $options = (new static($direction))->withExceptionOnSkip(false); } else { $options = $options->withDirection($direction); } return $options; }
[ "public", "static", "function", "fromOptionsWithDirection", "(", "Direction", "$", "direction", ",", "OptionsInterface", "$", "options", "=", "null", ")", "{", "if", "(", "null", "===", "$", "options", ")", "{", "$", "options", "=", "(", "new", "static", "...
fromOptionsWithDirection @param Direction $direction @param OptionsInterface|null $options @return static
[ "fromOptionsWithDirection" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Migration/Options.php#L204-L212
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.initialize
public function initialize(array $config): void { // Set default translations $this->config('translations', [ 'id' => __d('model_history', 'field.id'), 'comment' => __d('model_history', 'field.comment'), 'created' => __d('model_history', 'field.created'), 'modified' => __d('model_history', 'field.modified') ]); $this->ModelHistory = TableRegistry::get('ModelHistory.ModelHistory'); // Dynamically attach the hasMany relationship $this->_table->hasMany('ModelHistory.ModelHistory', [ 'conditions' => [ 'ModelHistory.model' => $this->_table->registryAlias() ], 'order' => ['ModelHistory.revision DESC'], 'foreignKey' => 'foreign_key', 'dependent' => false ]); if (isset($config['ignoreFields'])) { $this->setConfig('ignoreFields', $config['ignoreFields'], false); } $singularUnderscoredTableName = Inflector::singularize(Inflector::underscore($this->_table->getAlias())); $allColumns = $this->_table->getSchema()->columns(); foreach ($allColumns as $columnName) { if (in_array($columnName, $this->getConfig('ignoreFields'))) { continue; } $obfuscated = false; $searchable = true; $type = 'string'; if (substr($columnName, -3) === '_id') { $singular = substr($columnName, 0, -3); $associationName = str_replace('_', '', Inflector::pluralize($singular)); $association = $this->_table->association($associationName); if (!is_null($association)) { switch ($association->type()) { case $association::MANY_TO_MANY: $type = 'association'; break; case $association::ONE_TO_MANY: case $association::MANY_TO_ONE: $type = 'relation'; break; } } } elseif (strpos($columnName, 'password') !== false) { $obfuscated = true; $searchable = false; } else { switch ($this->_table->getSchema()->columnType($columnName)) { case 'boolean': $type = 'bool'; break; case 'json': $type = 'hash'; break; case 'integer': $type = 'number'; break; case 'datetime': $type = 'date'; break; } } $translationIdentifier = $singularUnderscoredTableName . '.' . $columnName; $manualConfig = isset($config['fields'][$columnName]) ? $config['fields'][$columnName] : []; $columnConfig = Hash::merge([ 'name' => $columnName, 'translation' => function () use ($translationIdentifier) { return __($translationIdentifier); }, 'searchable' => $searchable, 'saveable' => true, 'obfuscated' => $obfuscated, 'type' => $type ], $manualConfig); $this->setConfig('fields.' . $columnName, $columnConfig, false); } // fill the config array of fields not in the table schema with default values if (!empty($config['fields'])) { foreach ($config['fields'] as $columnName => $manualConfig) { if (!in_array($columnName, $allColumns)) { if (empty($manualConfig['type'])) { throw new Exception( sprintf('ModelHistory config for field %s is missing a type.', $columnName) ); } $translationIdentifier = $singularUnderscoredTableName . '.' . $columnName; $columnConfig = Hash::merge([ 'name' => $columnName, 'translation' => function () use ($translationIdentifier) { return __($translationIdentifier); }, 'searchable' => true, 'saveable' => true, 'obfuscated' => false, ], $manualConfig); $this->setConfig('fields.' . $columnName, $columnConfig, false); } } } parent::initialize($config); }
php
public function initialize(array $config): void { // Set default translations $this->config('translations', [ 'id' => __d('model_history', 'field.id'), 'comment' => __d('model_history', 'field.comment'), 'created' => __d('model_history', 'field.created'), 'modified' => __d('model_history', 'field.modified') ]); $this->ModelHistory = TableRegistry::get('ModelHistory.ModelHistory'); // Dynamically attach the hasMany relationship $this->_table->hasMany('ModelHistory.ModelHistory', [ 'conditions' => [ 'ModelHistory.model' => $this->_table->registryAlias() ], 'order' => ['ModelHistory.revision DESC'], 'foreignKey' => 'foreign_key', 'dependent' => false ]); if (isset($config['ignoreFields'])) { $this->setConfig('ignoreFields', $config['ignoreFields'], false); } $singularUnderscoredTableName = Inflector::singularize(Inflector::underscore($this->_table->getAlias())); $allColumns = $this->_table->getSchema()->columns(); foreach ($allColumns as $columnName) { if (in_array($columnName, $this->getConfig('ignoreFields'))) { continue; } $obfuscated = false; $searchable = true; $type = 'string'; if (substr($columnName, -3) === '_id') { $singular = substr($columnName, 0, -3); $associationName = str_replace('_', '', Inflector::pluralize($singular)); $association = $this->_table->association($associationName); if (!is_null($association)) { switch ($association->type()) { case $association::MANY_TO_MANY: $type = 'association'; break; case $association::ONE_TO_MANY: case $association::MANY_TO_ONE: $type = 'relation'; break; } } } elseif (strpos($columnName, 'password') !== false) { $obfuscated = true; $searchable = false; } else { switch ($this->_table->getSchema()->columnType($columnName)) { case 'boolean': $type = 'bool'; break; case 'json': $type = 'hash'; break; case 'integer': $type = 'number'; break; case 'datetime': $type = 'date'; break; } } $translationIdentifier = $singularUnderscoredTableName . '.' . $columnName; $manualConfig = isset($config['fields'][$columnName]) ? $config['fields'][$columnName] : []; $columnConfig = Hash::merge([ 'name' => $columnName, 'translation' => function () use ($translationIdentifier) { return __($translationIdentifier); }, 'searchable' => $searchable, 'saveable' => true, 'obfuscated' => $obfuscated, 'type' => $type ], $manualConfig); $this->setConfig('fields.' . $columnName, $columnConfig, false); } // fill the config array of fields not in the table schema with default values if (!empty($config['fields'])) { foreach ($config['fields'] as $columnName => $manualConfig) { if (!in_array($columnName, $allColumns)) { if (empty($manualConfig['type'])) { throw new Exception( sprintf('ModelHistory config for field %s is missing a type.', $columnName) ); } $translationIdentifier = $singularUnderscoredTableName . '.' . $columnName; $columnConfig = Hash::merge([ 'name' => $columnName, 'translation' => function () use ($translationIdentifier) { return __($translationIdentifier); }, 'searchable' => true, 'saveable' => true, 'obfuscated' => false, ], $manualConfig); $this->setConfig('fields.' . $columnName, $columnConfig, false); } } } parent::initialize($config); }
[ "public", "function", "initialize", "(", "array", "$", "config", ")", ":", "void", "{", "// Set default translations", "$", "this", "->", "config", "(", "'translations'", ",", "[", "'id'", "=>", "__d", "(", "'model_history'", ",", "'field.id'", ")", ",", "'c...
Constructor hook method. @param array $config The configuration settings provided to this behavior. @return void
[ "Constructor", "hook", "method", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L65-L182
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.beforeSave
public function beforeSave(Event $event, EntityInterface $entity, \ArrayObject $options): void { if (!$entity->isNew() && $entity->dirty()) { $saveHash = Security::hash(md5(uniqid())); if (empty($entity->save_hash)) { $entity->save_hash = $saveHash; $entity->dirty('save_hash', false); } $this->_dirtyFields[$entity->id] = $this->_extractDirtyFields($entity); $this->_applySaveHash($entity, $saveHash); } }
php
public function beforeSave(Event $event, EntityInterface $entity, \ArrayObject $options): void { if (!$entity->isNew() && $entity->dirty()) { $saveHash = Security::hash(md5(uniqid())); if (empty($entity->save_hash)) { $entity->save_hash = $saveHash; $entity->dirty('save_hash', false); } $this->_dirtyFields[$entity->id] = $this->_extractDirtyFields($entity); $this->_applySaveHash($entity, $saveHash); } }
[ "public", "function", "beforeSave", "(", "Event", "$", "event", ",", "EntityInterface", "$", "entity", ",", "\\", "ArrayObject", "$", "options", ")", ":", "void", "{", "if", "(", "!", "$", "entity", "->", "isNew", "(", ")", "&&", "$", "entity", "->", ...
beforeSave callback @param Event $event CakePHP Event @param Entity $entity Entity to be saved @param ArrayObject $options Additional options @return void
[ "beforeSave", "callback" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L192-L204
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior._extractDirtyFields
protected function _extractDirtyFields(EntityInterface $entity): array { $dirtyFields = []; $fields = array_keys($entity->toArray()); $dirtyFields = $entity->extract($fields, true); unset($dirtyFields['modified']); return array_keys($dirtyFields); }
php
protected function _extractDirtyFields(EntityInterface $entity): array { $dirtyFields = []; $fields = array_keys($entity->toArray()); $dirtyFields = $entity->extract($fields, true); unset($dirtyFields['modified']); return array_keys($dirtyFields); }
[ "protected", "function", "_extractDirtyFields", "(", "EntityInterface", "$", "entity", ")", ":", "array", "{", "$", "dirtyFields", "=", "[", "]", ";", "$", "fields", "=", "array_keys", "(", "$", "entity", "->", "toArray", "(", ")", ")", ";", "$", "dirtyF...
Extract dirty fields of given entity @return array
[ "Extract", "dirty", "fields", "of", "given", "entity" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L211-L219
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior._applySaveHash
protected function _applySaveHash(EntityInterface $entity, string $saveHash): bool { $output = []; if (defined('PHPUNIT_TESTSUITE')) { $associations = [ 'article', 'article.article' ]; } else { $associations = $this->getAssociations(); } if (empty($associations)) { return false; } foreach ($associations as $assoc) { $object = $this->_recursivelyExtractObject($assoc, $entity); if ($object === null) { continue; } $object->save_hash = $saveHash; $object->dirty('save_hash', false); } return true; }
php
protected function _applySaveHash(EntityInterface $entity, string $saveHash): bool { $output = []; if (defined('PHPUNIT_TESTSUITE')) { $associations = [ 'article', 'article.article' ]; } else { $associations = $this->getAssociations(); } if (empty($associations)) { return false; } foreach ($associations as $assoc) { $object = $this->_recursivelyExtractObject($assoc, $entity); if ($object === null) { continue; } $object->save_hash = $saveHash; $object->dirty('save_hash', false); } return true; }
[ "protected", "function", "_applySaveHash", "(", "EntityInterface", "$", "entity", ",", "string", "$", "saveHash", ")", ":", "bool", "{", "$", "output", "=", "[", "]", ";", "if", "(", "defined", "(", "'PHPUNIT_TESTSUITE'", ")", ")", "{", "$", "associations"...
Apply save hash to entity @param EntityInterface $entity Entity look for associated dirty fields @param string $saveHash Hash to identify save process @return bool
[ "Apply", "save", "hash", "to", "entity" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L228-L256
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior._recursivelyExtractObject
protected function _recursivelyExtractObject(string $path, EntityInterface $object): ?EntityInterface { if (stripos($path, '.') !== false) { $split = explode('.', $path); $path = array_shift($split); if (count($split) > 0 && $object->{$path} !== null) { return $this->_recursivelyExtractObject(implode('.', $split), $object->{$path}); } } else { return $object->{$path}; } return null; }
php
protected function _recursivelyExtractObject(string $path, EntityInterface $object): ?EntityInterface { if (stripos($path, '.') !== false) { $split = explode('.', $path); $path = array_shift($split); if (count($split) > 0 && $object->{$path} !== null) { return $this->_recursivelyExtractObject(implode('.', $split), $object->{$path}); } } else { return $object->{$path}; } return null; }
[ "protected", "function", "_recursivelyExtractObject", "(", "string", "$", "path", ",", "EntityInterface", "$", "object", ")", ":", "?", "EntityInterface", "{", "if", "(", "stripos", "(", "$", "path", ",", "'.'", ")", "!==", "false", ")", "{", "$", "split",...
Recursively find object based on given dot-seperated string representing object properties. @param string $path String path @param EntityInterface $object Object to use @return null|object
[ "Recursively", "find", "object", "based", "on", "given", "dot", "-", "seperated", "string", "representing", "object", "properties", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L265-L279
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.afterSave
public function afterSave(Event $event, EntityInterface $entity): void { $action = $entity->isNew() ? ModelHistory::ACTION_CREATE : ModelHistory::ACTION_UPDATE; $dirtyFields = null; if ($action === ModelHistory::ACTION_UPDATE && isset($this->_dirtyFields[$entity->id])) { $dirtyFields = $this->_dirtyFields[$entity->id]; unset($this->_dirtyFields[$entity->id]); } $this->ModelHistory->add($entity, $action, $this->_getUserId(), [ 'dirtyFields' => $dirtyFields ]); }
php
public function afterSave(Event $event, EntityInterface $entity): void { $action = $entity->isNew() ? ModelHistory::ACTION_CREATE : ModelHistory::ACTION_UPDATE; $dirtyFields = null; if ($action === ModelHistory::ACTION_UPDATE && isset($this->_dirtyFields[$entity->id])) { $dirtyFields = $this->_dirtyFields[$entity->id]; unset($this->_dirtyFields[$entity->id]); } $this->ModelHistory->add($entity, $action, $this->_getUserId(), [ 'dirtyFields' => $dirtyFields ]); }
[ "public", "function", "afterSave", "(", "Event", "$", "event", ",", "EntityInterface", "$", "entity", ")", ":", "void", "{", "$", "action", "=", "$", "entity", "->", "isNew", "(", ")", "?", "ModelHistory", "::", "ACTION_CREATE", ":", "ModelHistory", "::", ...
afterSave Callback @param Event $event CakePHP Event @param EntityInterface $entity Entity that was saved @return void
[ "afterSave", "Callback" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L288-L301
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.afterDelete
public function afterDelete(Event $event, EntityInterface $entity, \ArrayObject $options): void { $this->ModelHistory->add($entity, ModelHistory::ACTION_DELETE, $this->_getUserId()); }
php
public function afterDelete(Event $event, EntityInterface $entity, \ArrayObject $options): void { $this->ModelHistory->add($entity, ModelHistory::ACTION_DELETE, $this->_getUserId()); }
[ "public", "function", "afterDelete", "(", "Event", "$", "event", ",", "EntityInterface", "$", "entity", ",", "\\", "ArrayObject", "$", "options", ")", ":", "void", "{", "$", "this", "->", "ModelHistory", "->", "add", "(", "$", "entity", ",", "ModelHistory"...
afterDelete Callback @param Event $event CakePHP Event @param Entity $entity Entity that was deleted @param ArrayObject $options Additional options @return void
[ "afterDelete", "Callback" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L311-L314
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.addCommentToHistory
public function addCommentToHistory(EntityInterface $entity, string $comment, string $userId = null): ModelHistory { if (!$userId) { $userId = $this->_getUserId(); } return $this->ModelHistory->addComment($entity, $comment, $userId); }
php
public function addCommentToHistory(EntityInterface $entity, string $comment, string $userId = null): ModelHistory { if (!$userId) { $userId = $this->_getUserId(); } return $this->ModelHistory->addComment($entity, $comment, $userId); }
[ "public", "function", "addCommentToHistory", "(", "EntityInterface", "$", "entity", ",", "string", "$", "comment", ",", "string", "$", "userId", "=", "null", ")", ":", "ModelHistory", "{", "if", "(", "!", "$", "userId", ")", "{", "$", "userId", "=", "$",...
Adds a comment to the model's history @param EntityInterface $entity Entity to add the comment to @param string $comment Comment @param string $userId Commenting User @return ModelHistory
[ "Adds", "a", "comment", "to", "the", "model", "s", "history" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L324-L331
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior._getUserId
protected function _getUserId(): ?string { $userId = null; $callback = $this->config('userIdCallback'); if (is_callable($callback)) { $userId = $callback(); } return $userId; }
php
protected function _getUserId(): ?string { $userId = null; $callback = $this->config('userIdCallback'); if (is_callable($callback)) { $userId = $callback(); } return $userId; }
[ "protected", "function", "_getUserId", "(", ")", ":", "?", "string", "{", "$", "userId", "=", "null", ";", "$", "callback", "=", "$", "this", "->", "config", "(", "'userIdCallback'", ")", ";", "if", "(", "is_callable", "(", "$", "callback", ")", ")", ...
Tries to get a userId to use in the history from the given configuration @return string|null
[ "Tries", "to", "get", "a", "userId", "to", "use", "in", "the", "history", "from", "the", "given", "configuration" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L338-L347
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getRelationLink
public function getRelationLink(string $fieldName, string $fieldValue = null): string { $tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldName))); $fieldConfig = $this->getConfig('fields.' . $fieldName); // reads the url defined for the given behavior (empty array if not defined) $fieldUrl = $this->getUrl(); if (isset($fieldConfig['url'])) { // if url defined in fieldconfig. Overwrites default and behavior url config. $fieldUrl = $fieldConfig['url']; } unset($fieldUrl['controller']); $relationConfig = [ 'model' => $tableName, 'bindingKey' => 'id', 'url' => Hash::merge([ 'plugin' => null, 'controller' => $tableName, 'action' => 'view', ], $fieldUrl) ]; $pass = []; if ($fieldValue !== null) { $pass = [$fieldValue]; } try { $url = Router::url(Hash::merge($relationConfig['url'], $pass)); } catch (Exception $e) { return $fieldValue; } return '<a href="' . $url . '" target="_blank">' . __(strtolower($tableName)) . '</a>'; }
php
public function getRelationLink(string $fieldName, string $fieldValue = null): string { $tableName = Inflector::camelize(Inflector::pluralize(str_replace('_id', '', $fieldName))); $fieldConfig = $this->getConfig('fields.' . $fieldName); // reads the url defined for the given behavior (empty array if not defined) $fieldUrl = $this->getUrl(); if (isset($fieldConfig['url'])) { // if url defined in fieldconfig. Overwrites default and behavior url config. $fieldUrl = $fieldConfig['url']; } unset($fieldUrl['controller']); $relationConfig = [ 'model' => $tableName, 'bindingKey' => 'id', 'url' => Hash::merge([ 'plugin' => null, 'controller' => $tableName, 'action' => 'view', ], $fieldUrl) ]; $pass = []; if ($fieldValue !== null) { $pass = [$fieldValue]; } try { $url = Router::url(Hash::merge($relationConfig['url'], $pass)); } catch (Exception $e) { return $fieldValue; } return '<a href="' . $url . '" target="_blank">' . __(strtolower($tableName)) . '</a>'; }
[ "public", "function", "getRelationLink", "(", "string", "$", "fieldName", ",", "string", "$", "fieldValue", "=", "null", ")", ":", "string", "{", "$", "tableName", "=", "Inflector", "::", "camelize", "(", "Inflector", "::", "pluralize", "(", "str_replace", "...
Get <a /> element for given ID Field @param string $fieldName Fieldname @param string $fieldValue Value @return string
[ "Get", "<a", "/", ">", "element", "for", "given", "ID", "Field" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L356-L394
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getUserNameFields
public function getUserNameFields(bool $withoutModel = false): array { $userNameFields = $this->config('userNameFields'); if ($withoutModel) { foreach ($userNameFields as $key => $value) { $exploded = explode('.', $value); if (count($exploded) === 2) { $userNameFields[$key] = $exploded[1]; } } } return $userNameFields; }
php
public function getUserNameFields(bool $withoutModel = false): array { $userNameFields = $this->config('userNameFields'); if ($withoutModel) { foreach ($userNameFields as $key => $value) { $exploded = explode('.', $value); if (count($exploded) === 2) { $userNameFields[$key] = $exploded[1]; } } } return $userNameFields; }
[ "public", "function", "getUserNameFields", "(", "bool", "$", "withoutModel", "=", "false", ")", ":", "array", "{", "$", "userNameFields", "=", "$", "this", "->", "config", "(", "'userNameFields'", ")", ";", "if", "(", "$", "withoutModel", ")", "{", "foreac...
Get the user fields @param bool $withoutModel set to true to only get the field names without model name @return array
[ "Get", "the", "user", "fields" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L413-L426
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getTranslatedFields
public function getTranslatedFields(): array { return Hash::apply($this->config('fields'), '{*}[searchable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data['translation']; } return Hash::sort($formatted, '{s}', 'asc'); }); }
php
public function getTranslatedFields(): array { return Hash::apply($this->config('fields'), '{*}[searchable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data['translation']; } return Hash::sort($formatted, '{s}', 'asc'); }); }
[ "public", "function", "getTranslatedFields", "(", ")", ":", "array", "{", "return", "Hash", "::", "apply", "(", "$", "this", "->", "config", "(", "'fields'", ")", ",", "'{*}[searchable=true]'", ",", "function", "(", "$", "array", ")", "{", "$", "formatted"...
Get translated fields @return array
[ "Get", "translated", "fields" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L467-L477
scherersoftware/cake-model-history
src/Model/Behavior/HistorizableBehavior.php
HistorizableBehavior.getSaveableFields
public function getSaveableFields(): array { return Hash::apply($this->config('fields'), '{*}[saveable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data; } return $formatted; }); }
php
public function getSaveableFields(): array { return Hash::apply($this->config('fields'), '{*}[saveable=true]', function ($array) { $formatted = []; foreach ($array as $data) { $formatted[$data['name']] = $data; } return $formatted; }); }
[ "public", "function", "getSaveableFields", "(", ")", ":", "array", "{", "return", "Hash", "::", "apply", "(", "$", "this", "->", "config", "(", "'fields'", ")", ",", "'{*}[saveable=true]'", ",", "function", "(", "$", "array", ")", "{", "$", "formatted", ...
Get saveable fields @return array
[ "Get", "saveable", "fields" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/Model/Behavior/HistorizableBehavior.php#L484-L494
fab2s/NodalFlow
src/Flows/FlowRegistry.php
FlowRegistry.load
public function load(FlowInterface $flow, array $entry) { $this->registerFlow($flow); $flowId = $flow->getId(); static::$registry[$flowId] = $entry; foreach ($flow->getNodes() as $node) { $this->registerNode($node); } return $this; }
php
public function load(FlowInterface $flow, array $entry) { $this->registerFlow($flow); $flowId = $flow->getId(); static::$registry[$flowId] = $entry; foreach ($flow->getNodes() as $node) { $this->registerNode($node); } return $this; }
[ "public", "function", "load", "(", "FlowInterface", "$", "flow", ",", "array", "$", "entry", ")", "{", "$", "this", "->", "registerFlow", "(", "$", "flow", ")", ";", "$", "flowId", "=", "$", "flow", "->", "getId", "(", ")", ";", "static", "::", "$"...
Used upon FlowMap un-serialization @param FlowInterface $flow @param array $entry @throws NodalFlowException @return $this
[ "Used", "upon", "FlowMap", "un", "-", "serialization" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowRegistry.php#L57-L68
fab2s/NodalFlow
src/Flows/FlowRegistry.php
FlowRegistry.registerFlow
public function registerFlow(FlowInterface $flow) { $flowId = $flow->getId(); if (isset(static::$flows[$flowId])) { throw new NodalFlowException('Duplicate Flow instances are not allowed', 1, null, [ 'flowClass' => get_class($flow), 'flowId' => $flowId, ]); } static::$flows[$flowId] = $flow; return $this; }
php
public function registerFlow(FlowInterface $flow) { $flowId = $flow->getId(); if (isset(static::$flows[$flowId])) { throw new NodalFlowException('Duplicate Flow instances are not allowed', 1, null, [ 'flowClass' => get_class($flow), 'flowId' => $flowId, ]); } static::$flows[$flowId] = $flow; return $this; }
[ "public", "function", "registerFlow", "(", "FlowInterface", "$", "flow", ")", "{", "$", "flowId", "=", "$", "flow", "->", "getId", "(", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "flows", "[", "$", "flowId", "]", ")", ")", "{", "throw"...
@param FlowInterface $flow @throws NodalFlowException @return $this
[ "@param", "FlowInterface", "$flow" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowRegistry.php#L77-L90
fab2s/NodalFlow
src/Flows/FlowRegistry.php
FlowRegistry.registerNode
public function registerNode(NodeInterface $node) { $nodeId = $node->getId(); if (isset(static::$nodes[$nodeId])) { throw new NodalFlowException('Duplicate Node instances are not allowed', 1, null, [ 'nodeClass' => get_class($node), 'nodeId' => $nodeId, ]); } static::$nodes[$nodeId] = $node; return $this; }
php
public function registerNode(NodeInterface $node) { $nodeId = $node->getId(); if (isset(static::$nodes[$nodeId])) { throw new NodalFlowException('Duplicate Node instances are not allowed', 1, null, [ 'nodeClass' => get_class($node), 'nodeId' => $nodeId, ]); } static::$nodes[$nodeId] = $node; return $this; }
[ "public", "function", "registerNode", "(", "NodeInterface", "$", "node", ")", "{", "$", "nodeId", "=", "$", "node", "->", "getId", "(", ")", ";", "if", "(", "isset", "(", "static", "::", "$", "nodes", "[", "$", "nodeId", "]", ")", ")", "{", "throw"...
@param NodeInterface $node @throws NodalFlowException @return $this
[ "@param", "NodeInterface", "$node" ]
train
https://github.com/fab2s/NodalFlow/blob/da5d458ffea3e6e954d7ee734f938f4be5e46728/src/Flows/FlowRegistry.php#L99-L112
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.build
public function build($query, $params = []) { $query = $query->prepare($this); $params = empty($params) ? $query->params : array_merge($params, $query->params); $clauses = [ $this->buildSelect($query->select, $params, $query->distinct, $query->selectOption, $query), $this->buildFrom($query->from, $params), $this->buildUseKeys($query->useKeys, $params), $this->buildUseIndex($query->useIndex, $params), $this->buildJoin($query->join, $params), $this->buildWhere($query->where, $params), $this->buildGroupBy($query->groupBy, $params), $this->buildHaving($query->having, $params), $this->buildOrderBy($query->orderBy, $params), $this->buildLimitOffset($query->limit, $query->offset), ]; $sql = implode($this->separator, array_filter($clauses)); if (!empty($query->orderBy)) { foreach ($query->orderBy as $expression) { if ($expression instanceof Expression) { $params = array_merge($params, $expression->params); } } } if (!empty($query->groupBy)) { foreach ($query->groupBy as $expression) { if ($expression instanceof Expression) { $params = array_merge($params, $expression->params); } } } $union = $this->buildUnion($query->union, $params); if ($union !== '') { $sql = "($sql){$this->separator}$union"; } return [$sql, $params]; }
php
public function build($query, $params = []) { $query = $query->prepare($this); $params = empty($params) ? $query->params : array_merge($params, $query->params); $clauses = [ $this->buildSelect($query->select, $params, $query->distinct, $query->selectOption, $query), $this->buildFrom($query->from, $params), $this->buildUseKeys($query->useKeys, $params), $this->buildUseIndex($query->useIndex, $params), $this->buildJoin($query->join, $params), $this->buildWhere($query->where, $params), $this->buildGroupBy($query->groupBy, $params), $this->buildHaving($query->having, $params), $this->buildOrderBy($query->orderBy, $params), $this->buildLimitOffset($query->limit, $query->offset), ]; $sql = implode($this->separator, array_filter($clauses)); if (!empty($query->orderBy)) { foreach ($query->orderBy as $expression) { if ($expression instanceof Expression) { $params = array_merge($params, $expression->params); } } } if (!empty($query->groupBy)) { foreach ($query->groupBy as $expression) { if ($expression instanceof Expression) { $params = array_merge($params, $expression->params); } } } $union = $this->buildUnion($query->union, $params); if ($union !== '') { $sql = "($sql){$this->separator}$union"; } return [$sql, $params]; }
[ "public", "function", "build", "(", "$", "query", ",", "$", "params", "=", "[", "]", ")", "{", "$", "query", "=", "$", "query", "->", "prepare", "(", "$", "this", ")", ";", "$", "params", "=", "empty", "(", "$", "params", ")", "?", "$", "query"...
Generates a SELECT SQL statement from a [[Query]] object. @param Query $query the [[Query]] object from which the SQL statement will be generated. @param array $params the parameters to be bound to the generated SQL statement. These parameters will be included in the result with the additional parameters generated during the query building process. @return array the generated SQL statement (the first array element) and the corresponding parameters to be bound to the SQL statement (the second array element). The parameters returned include those provided in `$params`. @throws Exception
[ "Generates", "a", "SELECT", "SQL", "statement", "from", "a", "[[", "Query", "]]", "object", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L99-L143
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.insert
public function insert($bucketName, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "INSERT INTO $bucketName (KEY, VALUE) VALUES (UUID(), $data) " . $this->buildReturning([new Expression('META().id AS `_id`')]); }
php
public function insert($bucketName, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "INSERT INTO $bucketName (KEY, VALUE) VALUES (UUID(), $data) " . $this->buildReturning([new Expression('META().id AS `_id`')]); }
[ "public", "function", "insert", "(", "$", "bucketName", ",", "$", "data", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ";", "$", "data", "=", "Json", "::", "encode", "(", "$", "data"...
Creates an INSERT SQL statement. For example, ```php $sql = $queryBuilder->insert('user', [ 'name' => 'Sam', 'age' => 30, ], $params); ``` The method will properly escape the bucket and column names. @param string $bucketName the bucket that new rows will be inserted into. @param array $data the column data (name => value) to be inserted into the bucket or instance They should be bound to the DB command later. @return string the INSERT SQL
[ "Creates", "an", "INSERT", "SQL", "statement", ".", "For", "example" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L163-L169
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.batchInsert
public function batchInsert($bucketName, $rows) { if (empty($rows)) { return ''; } $values = []; foreach ($rows as $row) { $values[] = 'VALUES (UUID(), ' . Json::encode($row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT) . ')'; } if (empty($values)) { return ''; } return 'INSERT INTO ' . $this->db->quotebucketName($bucketName) . ' (KEY, VALUE) ' . implode(', ', $values) . ' ' . $this->buildReturning([new Expression('META().id AS `_id`')]); }
php
public function batchInsert($bucketName, $rows) { if (empty($rows)) { return ''; } $values = []; foreach ($rows as $row) { $values[] = 'VALUES (UUID(), ' . Json::encode($row, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT) . ')'; } if (empty($values)) { return ''; } return 'INSERT INTO ' . $this->db->quotebucketName($bucketName) . ' (KEY, VALUE) ' . implode(', ', $values) . ' ' . $this->buildReturning([new Expression('META().id AS `_id`')]); }
[ "public", "function", "batchInsert", "(", "$", "bucketName", ",", "$", "rows", ")", "{", "if", "(", "empty", "(", "$", "rows", ")", ")", "{", "return", "''", ";", "}", "$", "values", "=", "[", "]", ";", "foreach", "(", "$", "rows", "as", "$", "...
Generates a batch INSERT SQL statement. For example, ```php $sql = $queryBuilder->batchInsert('user', ['name', 'age'], [ ['Tom', 30], ['Jane', 20], ['Linda', 25], ]); ``` Note that the values in each row must match the corresponding column names. The method will properly escape the column names, and quote the values to be inserted. @param string $bucketName the bucket that new rows will be inserted into. @param array $rows the rows to be batch inserted into the bucket @return string the batch INSERT SQL statement
[ "Generates", "a", "batch", "INSERT", "SQL", "statement", ".", "For", "example" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L191-L210
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.update
public function update($bucketName, $columns, $condition, &$params) { $lines = []; foreach ($columns as $name => $value) { if ($value instanceof Expression) { $lines[] = '`bucket`.' . $this->db->quoteColumnName($name) . '=' . $value->expression; foreach ($value->params as $n => $v) { $params[$n] = $v; } } else { $phName = self::PARAM_PREFIX . count($params); $lines[] = '`bucket`.' .$this->db->quoteColumnName($name) . '=' . $phName; $params[$phName] = $value; } } $sql = 'UPDATE ' . $this->db->quotebucketName($bucketName) . ' AS `bucket` SET ' . implode(', ', $lines); $where = $this->buildWhere($condition, $params); return $where === '' ? $sql : $sql . ' ' . $where; }
php
public function update($bucketName, $columns, $condition, &$params) { $lines = []; foreach ($columns as $name => $value) { if ($value instanceof Expression) { $lines[] = '`bucket`.' . $this->db->quoteColumnName($name) . '=' . $value->expression; foreach ($value->params as $n => $v) { $params[$n] = $v; } } else { $phName = self::PARAM_PREFIX . count($params); $lines[] = '`bucket`.' .$this->db->quoteColumnName($name) . '=' . $phName; $params[$phName] = $value; } } $sql = 'UPDATE ' . $this->db->quotebucketName($bucketName) . ' AS `bucket` SET ' . implode(', ', $lines); $where = $this->buildWhere($condition, $params); return $where === '' ? $sql : $sql . ' ' . $where; }
[ "public", "function", "update", "(", "$", "bucketName", ",", "$", "columns", ",", "$", "condition", ",", "&", "$", "params", ")", "{", "$", "lines", "=", "[", "]", ";", "foreach", "(", "$", "columns", "as", "$", "name", "=>", "$", "value", ")", "...
Creates an UPDATE SQL statement. For example, ```php $params = []; $sql = $queryBuilder->update('user', ['status' => 1], 'age > 30', $params); ``` The method will properly escape the bucket and column names. @param string $bucketName the bucket to be updated. @param array $columns the column data (name => value) to be updated. @param array|string $condition the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition. @param array $params the binding parameters that will be modified by this method so that they can be bound to the DB command later. @return string the UPDATE SQL @throws Exception
[ "Creates", "an", "UPDATE", "SQL", "statement", ".", "For", "example" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L233-L256
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.upsert
public function upsert($bucketName, $id, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $id = $this->db->quoteValue($id); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "UPSERT INTO $bucketName (KEY, VALUE) VALUES ($id, $data) "; }
php
public function upsert($bucketName, $id, $data) { $bucketName = $this->db->quoteBucketName($bucketName); $id = $this->db->quoteValue($id); $data = Json::encode($data, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return "UPSERT INTO $bucketName (KEY, VALUE) VALUES ($id, $data) "; }
[ "public", "function", "upsert", "(", "$", "bucketName", ",", "$", "id", ",", "$", "data", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ";", "$", "id", "=", "$", "this", "->", "db",...
Creates an UPSERT SQL statement. For example, ```php $sql = $queryBuilder->upsert('user', 'my-id', [ 'name' => 'Sam', 'age' => 30, ], $params); ``` The method will properly escape the bucket and column names. @param string $bucketName the bucket that new rows will be inserted into. @param string $id the document id. @param array $data the column data (name => value) to be inserted into the bucket or instance They should be bound to the DB command later. @return string the UPSERT SQL
[ "Creates", "an", "UPSERT", "SQL", "statement", ".", "For", "example" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L277-L284
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.delete
public function delete($bucketName, $condition = '', &$params) { $sql = 'DELETE FROM ' . $this->db->quotebucketName($bucketName); $where = $this->buildWhere($condition, $params); return $where === '' ? $sql : $sql . ' ' . $where; }
php
public function delete($bucketName, $condition = '', &$params) { $sql = 'DELETE FROM ' . $this->db->quotebucketName($bucketName); $where = $this->buildWhere($condition, $params); return $where === '' ? $sql : $sql . ' ' . $where; }
[ "public", "function", "delete", "(", "$", "bucketName", ",", "$", "condition", "=", "''", ",", "&", "$", "params", ")", "{", "$", "sql", "=", "'DELETE FROM '", ".", "$", "this", "->", "db", "->", "quotebucketName", "(", "$", "bucketName", ")", ";", "...
Creates a DELETE SQL statement. For example, ```php $sql = $queryBuilder->delete('user', 'status = 0'); ``` The method will properly escape the bucket and column names. @param string $bucketName the bucket where the data will be deleted from. @param array|string $condition the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition. @param array $params the binding parameters that will be modified by this method so that they can be bound to the DB command later. @return string the DELETE SQL @throws Exception
[ "Creates", "a", "DELETE", "SQL", "statement", ".", "For", "example" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L305-L312
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildIndex
public function buildIndex($bucketName, $indexNames) { $indexNames = is_array($indexNames) ? $indexNames : [$indexNames]; foreach ($indexNames as $i => $indexName) { $indexNames[$i] = $this->db->quoteColumnName($indexName); } return 'BUILD INDEX ' . $this->db->quoteBucketName($bucketName) . '(' . implode(', ', $indexNames) . ') USING GSI'; }
php
public function buildIndex($bucketName, $indexNames) { $indexNames = is_array($indexNames) ? $indexNames : [$indexNames]; foreach ($indexNames as $i => $indexName) { $indexNames[$i] = $this->db->quoteColumnName($indexName); } return 'BUILD INDEX ' . $this->db->quoteBucketName($bucketName) . '(' . implode(', ', $indexNames) . ') USING GSI'; }
[ "public", "function", "buildIndex", "(", "$", "bucketName", ",", "$", "indexNames", ")", "{", "$", "indexNames", "=", "is_array", "(", "$", "indexNames", ")", "?", "$", "indexNames", ":", "[", "$", "indexNames", "]", ";", "foreach", "(", "$", "indexNames...
Builds a SQL statement for build index. @param string $bucketName @param string|string[] $indexNames names of index @return string the BUILD INDEX SQL
[ "Builds", "a", "SQL", "statement", "for", "build", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L350-L359
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.createPrimaryIndex
public function createPrimaryIndex($bucketName, $indexName = null, $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); if ($indexName) { $indexName = $this->db->quoteBucketName($indexName); } $sql = "CREATE PRIMARY INDEX $indexName ON $bucketName"; if (!empty($options)) { $sql .= ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); } return $sql; }
php
public function createPrimaryIndex($bucketName, $indexName = null, $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); if ($indexName) { $indexName = $this->db->quoteBucketName($indexName); } $sql = "CREATE PRIMARY INDEX $indexName ON $bucketName"; if (!empty($options)) { $sql .= ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); } return $sql; }
[ "public", "function", "createPrimaryIndex", "(", "$", "bucketName", ",", "$", "indexName", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ...
Builds a SQL statement for creating a new primary index. @param string $bucketName @param string|null $indexName name of primary index (optional) @param array $options @return string the CREATE PRIMARY INDEX SQL
[ "Builds", "a", "SQL", "statement", "for", "creating", "a", "new", "primary", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L370-L385
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.createIndex
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteBucketName($indexName); foreach ($columns as $i => $column) { if ($column instanceof Expression) { $columns[$i] = $column->expression; } else { $columns[$i] = $this->db->quoteColumnName($column); } } $where = $this->buildWhere($condition, $params); $sql = "CREATE INDEX $indexName ON $bucketName (" . implode(', ', $columns) . ")"; $sql = $where === '' ? $sql : $sql . ' ' . $where; $sql = empty($options) ? $sql : $sql . ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return $sql; }
php
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = []) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteBucketName($indexName); foreach ($columns as $i => $column) { if ($column instanceof Expression) { $columns[$i] = $column->expression; } else { $columns[$i] = $this->db->quoteColumnName($column); } } $where = $this->buildWhere($condition, $params); $sql = "CREATE INDEX $indexName ON $bucketName (" . implode(', ', $columns) . ")"; $sql = $where === '' ? $sql : $sql . ' ' . $where; $sql = empty($options) ? $sql : $sql . ' WITH ' . Json::encode($options, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE | JSON_FORCE_OBJECT); return $sql; }
[ "public", "function", "createIndex", "(", "$", "bucketName", ",", "$", "indexName", ",", "$", "columns", ",", "$", "condition", "=", "null", ",", "&", "$", "params", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "bucketName", "=...
Builds a SQL statement for creating a new index. @param string $bucketName @param string $indexName @param array $columns @param array|null $condition @param array $params @param array $options @return string the CREATE INDEX SQL @throws Exception
[ "Builds", "a", "SQL", "statement", "for", "creating", "a", "new", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L414-L435
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.dropIndex
public function dropIndex($bucketName, $indexName) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteColumnName($indexName); return "DROP INDEX $bucketName.$indexName"; }
php
public function dropIndex($bucketName, $indexName) { $bucketName = $this->db->quoteBucketName($bucketName); $indexName = $this->db->quoteColumnName($indexName); return "DROP INDEX $bucketName.$indexName"; }
[ "public", "function", "dropIndex", "(", "$", "bucketName", ",", "$", "indexName", ")", "{", "$", "bucketName", "=", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ")", ";", "$", "indexName", "=", "$", "this", "->", "db", "->"...
Builds a SQL statement for dropping an index. @param string $bucketName @param string $indexName @return string the DROP INDEX SQL
[ "Builds", "a", "SQL", "statement", "for", "dropping", "an", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L445-L451
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildSelect
public function buildSelect($columns, &$params, $distinct = false, $selectOption = null, $query) { $select = $distinct ? 'SELECT DISTINCT' : 'SELECT'; if ($selectOption !== null) { $select .= ' ' . $selectOption; } if (empty($columns)) { return $select . ' *'; } $columns = is_array($columns) ? $columns : [$columns]; foreach ($columns as $i => $column) { if ($column instanceof Expression) { if (is_int($i)) { $columns[$i] = $column->expression; } else { $columns[$i] = $column->expression . ' AS ' . $this->db->quoteColumnName($i); } $params = array_merge($params, $column->params); } elseif ($column instanceof Query) { list($sql, $params) = $this->build($column, $params); $columns[$i] = "($sql) AS " . $this->db->quoteColumnName($i); } elseif (is_string($i)) { if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } $columns[$i] = "$column AS " . $this->db->quoteColumnName($i); } elseif (strpos($column, '(') === false) { if (preg_match('/^(.*?)(?i:\s+as\s+|\s+)([\w\-_\.]+)$/', $column, $matches)) { $columns[$i] = $this->db->quoteColumnName($matches[1]) . ' AS ' . $this->db->quoteColumnName($matches[2]); } else { $columns[$i] = $this->db->quoteColumnName($column); } } } return $select . ' ' . implode(', ', $columns); }
php
public function buildSelect($columns, &$params, $distinct = false, $selectOption = null, $query) { $select = $distinct ? 'SELECT DISTINCT' : 'SELECT'; if ($selectOption !== null) { $select .= ' ' . $selectOption; } if (empty($columns)) { return $select . ' *'; } $columns = is_array($columns) ? $columns : [$columns]; foreach ($columns as $i => $column) { if ($column instanceof Expression) { if (is_int($i)) { $columns[$i] = $column->expression; } else { $columns[$i] = $column->expression . ' AS ' . $this->db->quoteColumnName($i); } $params = array_merge($params, $column->params); } elseif ($column instanceof Query) { list($sql, $params) = $this->build($column, $params); $columns[$i] = "($sql) AS " . $this->db->quoteColumnName($i); } elseif (is_string($i)) { if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } $columns[$i] = "$column AS " . $this->db->quoteColumnName($i); } elseif (strpos($column, '(') === false) { if (preg_match('/^(.*?)(?i:\s+as\s+|\s+)([\w\-_\.]+)$/', $column, $matches)) { $columns[$i] = $this->db->quoteColumnName($matches[1]) . ' AS ' . $this->db->quoteColumnName($matches[2]); } else { $columns[$i] = $this->db->quoteColumnName($column); } } } return $select . ' ' . implode(', ', $columns); }
[ "public", "function", "buildSelect", "(", "$", "columns", ",", "&", "$", "params", ",", "$", "distinct", "=", "false", ",", "$", "selectOption", "=", "null", ",", "$", "query", ")", "{", "$", "select", "=", "$", "distinct", "?", "'SELECT DISTINCT'", ":...
@param array $columns @param array $params the binding parameters to be populated @param bool $distinct @param string $selectOption @param Query $query @return string the SELECT clause built from [[Query::$select]]. @throws Exception
[ "@param", "array", "$columns", "@param", "array", "$params", "the", "binding", "parameters", "to", "be", "populated", "@param", "bool", "$distinct", "@param", "string", "$selectOption", "@param", "Query", "$query" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L463-L511
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildFrom
public function buildFrom($bucketName, &$params) { if (empty($bucketName)) { return ''; } $bucketName = $this->quoteBucketName($bucketName, $params); return 'FROM ' . $bucketName; }
php
public function buildFrom($bucketName, &$params) { if (empty($bucketName)) { return ''; } $bucketName = $this->quoteBucketName($bucketName, $params); return 'FROM ' . $bucketName; }
[ "public", "function", "buildFrom", "(", "$", "bucketName", ",", "&", "$", "params", ")", "{", "if", "(", "empty", "(", "$", "bucketName", ")", ")", "{", "return", "''", ";", "}", "$", "bucketName", "=", "$", "this", "->", "quoteBucketName", "(", "$",...
@param array $bucketName @param array $params the binding parameters to be populated @return string the FROM clause built from [[Query::$from]]. @throws Exception
[ "@param", "array", "$bucketName", "@param", "array", "$params", "the", "binding", "parameters", "to", "be", "populated" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L520-L529
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.quoteBucketName
private function quoteBucketName($bucketName, &$params) { if (!is_array($bucketName)) { return $this->db->quoteBucketName($bucketName); } foreach ($bucketName as $i => $bucket) { if ($bucket instanceof Query) { list($sql, $params) = $this->build($bucket, $params); $bucketName[$i] = "($sql) " . $this->db->quoteBucketName($i); } elseif (is_string($i)) { if (strpos($bucket, '(') === false) { $bucket = $this->db->quoteBucketName($bucket); } $bucketName[$i] = "$bucket " . $this->db->quoteBucketName($i); } elseif (strpos($bucket, '(') === false) { if (preg_match('/^(.*?)(?i:\s+as|)\s+([^ ]+)$/', $bucket, $matches)) { // with alias $bucketName[$i] = $this->db->quoteBucketName($matches[1]) . ' ' . $this->db->quoteBucketName($matches[2]); } else { $bucketName[$i] = $this->db->quoteBucketName($bucket); } } } return reset($bucketName); }
php
private function quoteBucketName($bucketName, &$params) { if (!is_array($bucketName)) { return $this->db->quoteBucketName($bucketName); } foreach ($bucketName as $i => $bucket) { if ($bucket instanceof Query) { list($sql, $params) = $this->build($bucket, $params); $bucketName[$i] = "($sql) " . $this->db->quoteBucketName($i); } elseif (is_string($i)) { if (strpos($bucket, '(') === false) { $bucket = $this->db->quoteBucketName($bucket); } $bucketName[$i] = "$bucket " . $this->db->quoteBucketName($i); } elseif (strpos($bucket, '(') === false) { if (preg_match('/^(.*?)(?i:\s+as|)\s+([^ ]+)$/', $bucket, $matches)) { // with alias $bucketName[$i] = $this->db->quoteBucketName($matches[1]) . ' ' . $this->db->quoteBucketName($matches[2]); } else { $bucketName[$i] = $this->db->quoteBucketName($bucket); } } } return reset($bucketName); }
[ "private", "function", "quoteBucketName", "(", "$", "bucketName", ",", "&", "$", "params", ")", "{", "if", "(", "!", "is_array", "(", "$", "bucketName", ")", ")", "{", "return", "$", "this", "->", "db", "->", "quoteBucketName", "(", "$", "bucketName", ...
Quotes bucket names passed @param array|string $bucketName @param array $params @return array|string @throws Exception
[ "Quotes", "bucket", "names", "passed" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L607-L637
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildUnion
public function buildUnion($unions, &$params) { if (empty($unions)) { return ''; } $result = ''; foreach ($unions as $i => $union) { $query = $union['query']; if ($query instanceof Query) { list($unions[$i]['query'], $params) = $this->build($query, $params); } $result .= $union['type'] . ' ' . ($union['all'] ? 'ALL ' : '') . '( ' . $unions[$i]['query'] . ' ) '; } return trim($result); }
php
public function buildUnion($unions, &$params) { if (empty($unions)) { return ''; } $result = ''; foreach ($unions as $i => $union) { $query = $union['query']; if ($query instanceof Query) { list($unions[$i]['query'], $params) = $this->build($query, $params); } $result .= $union['type'] . ' ' . ($union['all'] ? 'ALL ' : '') . '( ' . $unions[$i]['query'] . ' ) '; } return trim($result); }
[ "public", "function", "buildUnion", "(", "$", "unions", ",", "&", "$", "params", ")", "{", "if", "(", "empty", "(", "$", "unions", ")", ")", "{", "return", "''", ";", "}", "$", "result", "=", "''", ";", "foreach", "(", "$", "unions", "as", "$", ...
@param array $unions @param array $params the binding parameters to be populated @return string the UNION, INTERSECT and EXCEPT clause built from [[Query::$union]]. @throws Exception
[ "@param", "array", "$unions", "@param", "array", "$params", "the", "binding", "parameters", "to", "be", "populated" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L762-L781
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildCondition
public function buildCondition($condition, &$params) { if ($condition instanceof Expression) { foreach ($condition->params as $n => $v) { $params[$n] = $v; } return $condition->expression; } elseif (!is_array($condition)) { return (string) $condition; } elseif (empty($condition)) { return ''; } if (isset($condition[0])) { // operator format: operator, operand 1, operand 2, ... $operator = strtoupper($condition[0]); if (isset($this->conditionBuilders[$operator])) { $method = $this->conditionBuilders[$operator]; } else { $method = 'buildSimpleCondition'; } array_shift($condition); return $this->$method($operator, $condition, $params); } else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ... return $this->buildHashCondition($condition, $params); } }
php
public function buildCondition($condition, &$params) { if ($condition instanceof Expression) { foreach ($condition->params as $n => $v) { $params[$n] = $v; } return $condition->expression; } elseif (!is_array($condition)) { return (string) $condition; } elseif (empty($condition)) { return ''; } if (isset($condition[0])) { // operator format: operator, operand 1, operand 2, ... $operator = strtoupper($condition[0]); if (isset($this->conditionBuilders[$operator])) { $method = $this->conditionBuilders[$operator]; } else { $method = 'buildSimpleCondition'; } array_shift($condition); return $this->$method($operator, $condition, $params); } else { // hash format: 'column1' => 'value1', 'column2' => 'value2', ... return $this->buildHashCondition($condition, $params); } }
[ "public", "function", "buildCondition", "(", "$", "condition", ",", "&", "$", "params", ")", "{", "if", "(", "$", "condition", "instanceof", "Expression", ")", "{", "foreach", "(", "$", "condition", "->", "params", "as", "$", "n", "=>", "$", "v", ")", ...
Parses the condition specification and generates the corresponding SQL expression. @param string|array|Expression $condition the condition specification. Please refer to [[Query::where()]] on how to specify a condition. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws Exception
[ "Parses", "the", "condition", "specification", "and", "generates", "the", "corresponding", "SQL", "expression", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L822-L855
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildHashCondition
public function buildHashCondition($condition, &$params) { $parts = []; foreach ($condition as $column => $value) { if (ArrayHelper::isTraversable($value) || $value instanceof Query) { // IN condition $parts[] = $this->buildInCondition('IN', [$column, $value], $params); } else { if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if ($value === null) { $parts[] = "$column IS NULL"; } elseif ($value instanceof Expression) { $parts[] = "$column=" . $value->expression; foreach ($value->params as $n => $v) { $params[$n] = $v; } } else { $phName = self::PARAM_PREFIX . count($params); $parts[] = "$column=$phName"; $params[$phName] = $value; } } } return count($parts) === 1 ? $parts[0] : '(' . implode(') AND (', $parts) . ')'; }
php
public function buildHashCondition($condition, &$params) { $parts = []; foreach ($condition as $column => $value) { if (ArrayHelper::isTraversable($value) || $value instanceof Query) { // IN condition $parts[] = $this->buildInCondition('IN', [$column, $value], $params); } else { if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if ($value === null) { $parts[] = "$column IS NULL"; } elseif ($value instanceof Expression) { $parts[] = "$column=" . $value->expression; foreach ($value->params as $n => $v) { $params[$n] = $v; } } else { $phName = self::PARAM_PREFIX . count($params); $parts[] = "$column=$phName"; $params[$phName] = $value; } } } return count($parts) === 1 ? $parts[0] : '(' . implode(') AND (', $parts) . ')'; }
[ "public", "function", "buildHashCondition", "(", "$", "condition", ",", "&", "$", "params", ")", "{", "$", "parts", "=", "[", "]", ";", "foreach", "(", "$", "condition", "as", "$", "column", "=>", "$", "value", ")", "{", "if", "(", "ArrayHelper", "::...
Creates a condition based on column-value pairs. @param array $condition the condition specification. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws Exception
[ "Creates", "a", "condition", "based", "on", "column", "-", "value", "pairs", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L866-L899
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildAndCondition
public function buildAndCondition($operator, $operands, &$params) { $parts = []; foreach ($operands as $operand) { if (is_array($operand)) { $operand = $this->buildCondition($operand, $params); } if ($operand instanceof Expression) { foreach ($operand->params as $n => $v) { $params[$n] = $v; } $operand = $operand->expression; } if ($operand !== '') { $parts[] = $operand; } } if (!empty($parts)) { return '(' . implode(") $operator (", $parts) . ')'; } else { return ''; } }
php
public function buildAndCondition($operator, $operands, &$params) { $parts = []; foreach ($operands as $operand) { if (is_array($operand)) { $operand = $this->buildCondition($operand, $params); } if ($operand instanceof Expression) { foreach ($operand->params as $n => $v) { $params[$n] = $v; } $operand = $operand->expression; } if ($operand !== '') { $parts[] = $operand; } } if (!empty($parts)) { return '(' . implode(") $operator (", $parts) . ')'; } else { return ''; } }
[ "public", "function", "buildAndCondition", "(", "$", "operator", ",", "$", "operands", ",", "&", "$", "params", ")", "{", "$", "parts", "=", "[", "]", ";", "foreach", "(", "$", "operands", "as", "$", "operand", ")", "{", "if", "(", "is_array", "(", ...
Connects two or more SQL expressions with the `AND` or `OR` operator. @param string $operator the operator to use for connecting the given operands @param array $operands the SQL expressions to connect. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws Exception
[ "Connects", "two", "or", "more", "SQL", "expressions", "with", "the", "AND", "or", "OR", "operator", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L911-L939
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildBetweenCondition
public function buildBetweenCondition($operator, $operands, &$params) { if (!isset($operands[0], $operands[1], $operands[2])) { throw new InvalidArgumentException("Operator '$operator' requires three operands."); } list($column, $value1, $value2) = $operands; if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if ($value1 instanceof Expression) { foreach ($value1->params as $n => $v) { $params[$n] = $v; } $phName1 = $value1->expression; } else { $phName1 = self::PARAM_PREFIX . count($params); $params[$phName1] = $value1; } if ($value2 instanceof Expression) { foreach ($value2->params as $n => $v) { $params[$n] = $v; } $phName2 = $value2->expression; } else { $phName2 = self::PARAM_PREFIX . count($params); $params[$phName2] = $value2; } return "$column $operator $phName1 AND $phName2"; }
php
public function buildBetweenCondition($operator, $operands, &$params) { if (!isset($operands[0], $operands[1], $operands[2])) { throw new InvalidArgumentException("Operator '$operator' requires three operands."); } list($column, $value1, $value2) = $operands; if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if ($value1 instanceof Expression) { foreach ($value1->params as $n => $v) { $params[$n] = $v; } $phName1 = $value1->expression; } else { $phName1 = self::PARAM_PREFIX . count($params); $params[$phName1] = $value1; } if ($value2 instanceof Expression) { foreach ($value2->params as $n => $v) { $params[$n] = $v; } $phName2 = $value2->expression; } else { $phName2 = self::PARAM_PREFIX . count($params); $params[$phName2] = $value2; } return "$column $operator $phName1 AND $phName2"; }
[ "public", "function", "buildBetweenCondition", "(", "$", "operator", ",", "$", "operands", ",", "&", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "operands", "[", "0", "]", ",", "$", "operands", "[", "1", "]", ",", "$", "operands", "...
Creates an SQL expressions with the `BETWEEN` operator. @param string $operator the operator to use (e.g. `BETWEEN` or `NOT BETWEEN`) @param array $operands the first operand is the column name. The second and third operands describe the interval that column value should be in. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws InvalidArgumentException if wrong number of operands have been given.
[ "Creates", "an", "SQL", "expressions", "with", "the", "BETWEEN", "operator", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L979-L1016
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildInCondition
public function buildInCondition($operator, $operands, &$params) { if (!isset($operands[0], $operands[1])) { throw new Exception("Operator '$operator' requires two operands."); } list($column, $values) = $operands; if ($column === []) { // no columns to test against return $operator === 'IN' ? '0=1' : ''; } if ($values instanceof Query) { return $this->buildSubqueryInCondition($operator, $column, $values, $params); } if (!is_array($values) && !$values instanceof \Traversable) { // ensure values is an array $values = (array) $values; } if ($column instanceof \Traversable || count($column) > 1) { return $this->buildCompositeInCondition($operator, $column, $values, $params); } elseif (is_array($column)) { $column = reset($column); } $sqlValues = []; foreach ($values as $i => $value) { if (is_array($value) || $value instanceof \ArrayAccess) { $value = isset($value[$column]) ? $value[$column] : null; } if ($value === null) { $sqlValues[$i] = 'NULL'; } elseif ($value instanceof Expression) { $sqlValues[$i] = $value->expression; foreach ($value->params as $n => $v) { $params[$n] = $v; } } else { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value; $sqlValues[$i] = $phName; } } if (empty($sqlValues)) { return $operator === 'IN' ? '0=1' : ''; } if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if (count($sqlValues) > 1) { return "$column $operator [" . implode(', ', $sqlValues) . ']'; } else { $operator = $operator === 'IN' ? '=' : '<>'; return $column . $operator . reset($sqlValues); } }
php
public function buildInCondition($operator, $operands, &$params) { if (!isset($operands[0], $operands[1])) { throw new Exception("Operator '$operator' requires two operands."); } list($column, $values) = $operands; if ($column === []) { // no columns to test against return $operator === 'IN' ? '0=1' : ''; } if ($values instanceof Query) { return $this->buildSubqueryInCondition($operator, $column, $values, $params); } if (!is_array($values) && !$values instanceof \Traversable) { // ensure values is an array $values = (array) $values; } if ($column instanceof \Traversable || count($column) > 1) { return $this->buildCompositeInCondition($operator, $column, $values, $params); } elseif (is_array($column)) { $column = reset($column); } $sqlValues = []; foreach ($values as $i => $value) { if (is_array($value) || $value instanceof \ArrayAccess) { $value = isset($value[$column]) ? $value[$column] : null; } if ($value === null) { $sqlValues[$i] = 'NULL'; } elseif ($value instanceof Expression) { $sqlValues[$i] = $value->expression; foreach ($value->params as $n => $v) { $params[$n] = $v; } } else { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value; $sqlValues[$i] = $phName; } } if (empty($sqlValues)) { return $operator === 'IN' ? '0=1' : ''; } if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if (count($sqlValues) > 1) { return "$column $operator [" . implode(', ', $sqlValues) . ']'; } else { $operator = $operator === 'IN' ? '=' : '<>'; return $column . $operator . reset($sqlValues); } }
[ "public", "function", "buildInCondition", "(", "$", "operator", ",", "$", "operands", ",", "&", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "operands", "[", "0", "]", ",", "$", "operands", "[", "1", "]", ")", ")", "{", "throw", "n...
Creates an SQL expressions with the `IN` operator. @param string $operator the operator to use (e.g. `IN` or `NOT IN`) @param array $operands the first operand is the column name. If it is an array a composite IN condition will be generated. The second operand is an array of values that column value should be among. If it is an empty array the generated expression will be a `false` value if operator is `IN` and empty if operator is `NOT IN`. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws Exception if wrong number of operands have been given.
[ "Creates", "an", "SQL", "expressions", "with", "the", "IN", "operator", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L1030-L1099
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildCompositeInCondition
protected function buildCompositeInCondition($operator, $columns, $values, &$params) { $vss = []; foreach ($values as $value) { $vs = []; foreach ($columns as $column) { if (isset($value[$column])) { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value[$column]; $vs[] = $phName; } else { $vs[] = 'NULL'; } } $vss[] = '(' . implode(', ', $vs) . ')'; } if (empty($vss)) { return $operator === 'IN' ? '0=1' : ''; } $sqlColumns = []; foreach ($columns as $i => $column) { $sqlColumns[] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column; } return '(' . implode(', ', $sqlColumns) . ") $operator (" . implode(', ', $vss) . ')'; }
php
protected function buildCompositeInCondition($operator, $columns, $values, &$params) { $vss = []; foreach ($values as $value) { $vs = []; foreach ($columns as $column) { if (isset($value[$column])) { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value[$column]; $vs[] = $phName; } else { $vs[] = 'NULL'; } } $vss[] = '(' . implode(', ', $vs) . ')'; } if (empty($vss)) { return $operator === 'IN' ? '0=1' : ''; } $sqlColumns = []; foreach ($columns as $i => $column) { $sqlColumns[] = strpos($column, '(') === false ? $this->db->quoteColumnName($column) : $column; } return '(' . implode(', ', $sqlColumns) . ") $operator (" . implode(', ', $vss) . ')'; }
[ "protected", "function", "buildCompositeInCondition", "(", "$", "operator", ",", "$", "columns", ",", "$", "values", ",", "&", "$", "params", ")", "{", "$", "vss", "=", "[", "]", ";", "foreach", "(", "$", "values", "as", "$", "value", ")", "{", "$", ...
Builds SQL for IN condition @param string $operator @param array|\Traversable $columns @param array $values @param array $params @return string SQL
[ "Builds", "SQL", "for", "IN", "condition" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L1143-L1175
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildLikeCondition
public function buildLikeCondition($operator, $operands, &$params) { if (!isset($operands[0], $operands[1])) { throw new InvalidArgumentException("Operator '$operator' requires two operands."); } $escape = isset($operands[2]) ? $operands[2] : $this->likeEscapingReplacements; unset($operands[2]); if (!preg_match('/^(AND |OR |)(((NOT |))I?LIKE)/', $operator, $matches)) { throw new InvalidArgumentException("Invalid operator '$operator'."); } $andor = ' ' . (!empty($matches[1]) ? $matches[1] : 'AND '); $not = !empty($matches[3]); $operator = $matches[2]; list($column, $values) = $operands; if (!is_array($values)) { $values = [$values]; } if (empty($values)) { return $not ? '' : '0=1'; } if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } $parts = []; foreach ($values as $value) { if ($value instanceof Expression) { foreach ($value->params as $n => $v) { $params[$n] = $v; } $phName = $value->expression; } else { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = empty($escape) ? $value : ('%' . strtr($value, $escape) . '%'); } $escapeSql = ''; if ($this->likeEscapeCharacter !== null) { $escapeSql = " ESCAPE '{$this->likeEscapeCharacter}'"; } $parts[] = "{$column} {$operator} {$phName}{$escapeSql}"; } return implode($andor, $parts); }
php
public function buildLikeCondition($operator, $operands, &$params) { if (!isset($operands[0], $operands[1])) { throw new InvalidArgumentException("Operator '$operator' requires two operands."); } $escape = isset($operands[2]) ? $operands[2] : $this->likeEscapingReplacements; unset($operands[2]); if (!preg_match('/^(AND |OR |)(((NOT |))I?LIKE)/', $operator, $matches)) { throw new InvalidArgumentException("Invalid operator '$operator'."); } $andor = ' ' . (!empty($matches[1]) ? $matches[1] : 'AND '); $not = !empty($matches[3]); $operator = $matches[2]; list($column, $values) = $operands; if (!is_array($values)) { $values = [$values]; } if (empty($values)) { return $not ? '' : '0=1'; } if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } $parts = []; foreach ($values as $value) { if ($value instanceof Expression) { foreach ($value->params as $n => $v) { $params[$n] = $v; } $phName = $value->expression; } else { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = empty($escape) ? $value : ('%' . strtr($value, $escape) . '%'); } $escapeSql = ''; if ($this->likeEscapeCharacter !== null) { $escapeSql = " ESCAPE '{$this->likeEscapeCharacter}'"; } $parts[] = "{$column} {$operator} {$phName}{$escapeSql}"; } return implode($andor, $parts); }
[ "public", "function", "buildLikeCondition", "(", "$", "operator", ",", "$", "operands", ",", "&", "$", "params", ")", "{", "if", "(", "!", "isset", "(", "$", "operands", "[", "0", "]", ",", "$", "operands", "[", "1", "]", ")", ")", "{", "throw", ...
Creates an SQL expressions with the `LIKE` operator. @param string $operator the operator to use (e.g. `LIKE`, `NOT LIKE`, `OR LIKE` or `OR NOT LIKE`) @param array $operands an array of two or three operands - The first operand is the column name. - The second operand is a single value or an array of values that column value should be compared with. If it is an empty array the generated expression will be a `false` value if operator is `LIKE` or `OR LIKE`, and empty if operator is `NOT LIKE` or `OR NOT LIKE`. - An optional third operand can also be provided to specify how to escape special characters in the value(s). The operand should be an array of mappings from the special characters to their escaped counterparts. If this operand is not provided, a default escape mapping will be used. You may use `false` or an empty array to indicate the values are already escaped and no escape should be applied. Note that when using an escape mapping (or the third operand is not provided), the values will be automatically enclosed within a pair of percentage characters. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws InvalidArgumentException if wrong number of operands have been given.
[ "Creates", "an", "SQL", "expressions", "with", "the", "LIKE", "operator", ".", "@param", "string", "$operator", "the", "operator", "to", "use", "(", "e", ".", "g", ".", "LIKE", "NOT", "LIKE", "OR", "LIKE", "or", "OR", "NOT", "LIKE", ")", "@param", "arr...
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L1197-L1254
matrozov/yii2-couchbase
src/QueryBuilder.php
QueryBuilder.buildSimpleCondition
public function buildSimpleCondition($operator, $operands, &$params) { if (count($operands) !== 2) { throw new InvalidArgumentException("Operator '$operator' requires two operands."); } list($column, $value) = $operands; if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if ($value === null) { return "$column $operator NULL"; } elseif ($value instanceof Expression) { foreach ($value->params as $n => $v) { $params[$n] = $v; } return "$column $operator {$value->expression}"; } elseif ($value instanceof Query) { list($sql, $params) = $this->build($value, $params); return "$column $operator ($sql)"; } else { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value; return "$column $operator $phName"; } }
php
public function buildSimpleCondition($operator, $operands, &$params) { if (count($operands) !== 2) { throw new InvalidArgumentException("Operator '$operator' requires two operands."); } list($column, $value) = $operands; if (strpos($column, '(') === false) { $column = $this->db->quoteColumnName($column); } if ($value === null) { return "$column $operator NULL"; } elseif ($value instanceof Expression) { foreach ($value->params as $n => $v) { $params[$n] = $v; } return "$column $operator {$value->expression}"; } elseif ($value instanceof Query) { list($sql, $params) = $this->build($value, $params); return "$column $operator ($sql)"; } else { $phName = self::PARAM_PREFIX . count($params); $params[$phName] = $value; return "$column $operator $phName"; } }
[ "public", "function", "buildSimpleCondition", "(", "$", "operator", ",", "$", "operands", ",", "&", "$", "params", ")", "{", "if", "(", "count", "(", "$", "operands", ")", "!==", "2", ")", "{", "throw", "new", "InvalidArgumentException", "(", "\"Operator '...
Creates an SQL expressions like `"column" operator value`. @param string $operator the operator to use. Anything could be used e.g. `>`, `<=`, etc. @param array $operands contains two column names. @param array $params the binding parameters to be populated @return string the generated SQL expression @throws Exception
[ "Creates", "an", "SQL", "expressions", "like", "column", "operator", "value", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/QueryBuilder.php#L1266-L1299
baleen/migrations
src/Service/Runner/MigrationRunner.php
MigrationRunner.run
public function run(DeltaInterface $version, OptionsInterface $options) { if (!$this->shouldMigrate($version, $options)) { if ($options->isExceptionOnSkip()) { throw new RunnerException(sprintf( 'Cowardly refusing to run %s() on a delta that is already "%s" (ID: %s).', $options->getDirection(), $options->getDirection(), $version->getId() )); } return false; // skip } // Dispatch MIGRATE_BEFORE $this->getPublisher()->publish(new MigrateBeforeEvent($version, $options, $this->getContext())); $version->migrate($options); // state will be changed // Dispatch MIGRATE_AFTER $event = new MigrateAfterEvent($version, $options, $this->getContext()); $this->getPublisher()->publish($event); return $event; }
php
public function run(DeltaInterface $version, OptionsInterface $options) { if (!$this->shouldMigrate($version, $options)) { if ($options->isExceptionOnSkip()) { throw new RunnerException(sprintf( 'Cowardly refusing to run %s() on a delta that is already "%s" (ID: %s).', $options->getDirection(), $options->getDirection(), $version->getId() )); } return false; // skip } // Dispatch MIGRATE_BEFORE $this->getPublisher()->publish(new MigrateBeforeEvent($version, $options, $this->getContext())); $version->migrate($options); // state will be changed // Dispatch MIGRATE_AFTER $event = new MigrateAfterEvent($version, $options, $this->getContext()); $this->getPublisher()->publish($event); return $event; }
[ "public", "function", "run", "(", "DeltaInterface", "$", "version", ",", "OptionsInterface", "$", "options", ")", "{", "if", "(", "!", "$", "this", "->", "shouldMigrate", "(", "$", "version", ",", "$", "options", ")", ")", "{", "if", "(", "$", "options...
Runs a single version using the specified options @param DeltaInterface $version @param OptionsInterface $options @return false|MigrateAfterEvent @throws RunnerException
[ "Runs", "a", "single", "version", "using", "the", "specified", "options" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/Runner/MigrationRunner.php#L76-L101
baleen/migrations
src/Service/Runner/MigrationRunner.php
MigrationRunner.shouldMigrate
protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options) { return $options->isForced() || ($options->getDirection()->isUp() ^ $version->isMigrated()); // direction is opposite to state }
php
protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options) { return $options->isForced() || ($options->getDirection()->isUp() ^ $version->isMigrated()); // direction is opposite to state }
[ "protected", "function", "shouldMigrate", "(", "DeltaInterface", "$", "version", ",", "OptionsInterface", "$", "options", ")", "{", "return", "$", "options", "->", "isForced", "(", ")", "||", "(", "$", "options", "->", "getDirection", "(", ")", "->", "isUp",...
Returns true if the operation is forced, or if the direction is the opposite to the state of the migration. @param DeltaInterface $version @param OptionsInterface $options @return bool
[ "Returns", "true", "if", "the", "operation", "is", "forced", "or", "if", "the", "direction", "is", "the", "opposite", "to", "the", "state", "of", "the", "migration", "." ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/Runner/MigrationRunner.php#L111-L115
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.modelHistoryArea
public function modelHistoryArea(EntityInterface $entity, array $options = []): string { $options = Hash::merge([ 'showCommentBox' => false, 'showFilterBox' => false, 'columnClass' => 'col-md-12', 'includeAssociated' => false ], $options); $page = 1; $limit = TableRegistry::get($entity->source())->getEntriesLimit(); $modelHistory = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistory($entity->source(), $entity->id, $limit, $page, [], $options); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($entity->source(), $entity->id, [], $options); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } return $this->_View->element('ModelHistory.model_history_area', [ 'modelHistory' => $modelHistory, 'showNextEntriesButton' => $showNextEntriesButton, 'showPrevEntriesButton' => $showPrevEntriesButton, 'page' => $page, 'model' => $entity->source(), 'foreignKey' => $entity->id, 'limit' => $limit, 'searchableFields' => TableRegistry::get($entity->source())->getTranslatedFields(), 'showCommentBox' => $options['showCommentBox'], 'showFilterBox' => $options['showFilterBox'], 'columnClass' => $options['columnClass'], 'includeAssociated' => $options['includeAssociated'], 'contexts' => $contexts ]); }
php
public function modelHistoryArea(EntityInterface $entity, array $options = []): string { $options = Hash::merge([ 'showCommentBox' => false, 'showFilterBox' => false, 'columnClass' => 'col-md-12', 'includeAssociated' => false ], $options); $page = 1; $limit = TableRegistry::get($entity->source())->getEntriesLimit(); $modelHistory = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistory($entity->source(), $entity->id, $limit, $page, [], $options); $entries = TableRegistry::get('ModelHistory.ModelHistory')->getModelHistoryCount($entity->source(), $entity->id, [], $options); $showNextEntriesButton = $entries > 0 && $limit * $page < $entries; $showPrevEntriesButton = $page > 1; $contexts = []; if (method_exists($entity, 'getContexts')) { $contexts = $entity::getContexts(); } return $this->_View->element('ModelHistory.model_history_area', [ 'modelHistory' => $modelHistory, 'showNextEntriesButton' => $showNextEntriesButton, 'showPrevEntriesButton' => $showPrevEntriesButton, 'page' => $page, 'model' => $entity->source(), 'foreignKey' => $entity->id, 'limit' => $limit, 'searchableFields' => TableRegistry::get($entity->source())->getTranslatedFields(), 'showCommentBox' => $options['showCommentBox'], 'showFilterBox' => $options['showFilterBox'], 'columnClass' => $options['columnClass'], 'includeAssociated' => $options['includeAssociated'], 'contexts' => $contexts ]); }
[ "public", "function", "modelHistoryArea", "(", "EntityInterface", "$", "entity", ",", "array", "$", "options", "=", "[", "]", ")", ":", "string", "{", "$", "options", "=", "Hash", "::", "merge", "(", "[", "'showCommentBox'", "=>", "false", ",", "'showFilte...
Render the model history area where needed @param \Cake\Datasource\EntityInterface $entity One historizable entity @param array $options options array
[ "Render", "the", "model", "history", "area", "where", "needed" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L31-L69
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.actionClass
public function actionClass(string $action): string { switch ($action) { case ModelHistory::ACTION_CREATE: $class = 'success'; break; case ModelHistory::ACTION_DELETE: $class = 'danger'; break; case ModelHistory::ACTION_COMMENT: $class = 'active'; break; case ModelHistory::ACTION_UPDATE: default: $class = 'info'; break; } return $class; }
php
public function actionClass(string $action): string { switch ($action) { case ModelHistory::ACTION_CREATE: $class = 'success'; break; case ModelHistory::ACTION_DELETE: $class = 'danger'; break; case ModelHistory::ACTION_COMMENT: $class = 'active'; break; case ModelHistory::ACTION_UPDATE: default: $class = 'info'; break; } return $class; }
[ "public", "function", "actionClass", "(", "string", "$", "action", ")", ":", "string", "{", "switch", "(", "$", "action", ")", "{", "case", "ModelHistory", "::", "ACTION_CREATE", ":", "$", "class", "=", "'success'", ";", "break", ";", "case", "ModelHistory...
Convert action to bootstrap class @param string $action History Action @return string
[ "Convert", "action", "to", "bootstrap", "class" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L77-L96
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.historyText
public function historyText(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_CREATE: $action = __d('model_history', 'created'); break; case ModelHistory::ACTION_UPDATE: $action = __d('model_history', 'updated'); break; case ModelHistory::ACTION_DELETE: $action = __d('model_history', 'deleted'); break; case ModelHistory::ACTION_COMMENT: $action = __d('model_history', 'commented'); break; default: } if (empty($history->user_id)) { $username = 'Anonymous'; } else { $userNameFields = TableRegistry::get($history->model)->getUserNameFields(true); $firstname = $history->user->{$userNameFields['firstname']}; $lastname = $history->user->{$userNameFields['lastname']}; $username = $firstname . ' ' . $lastname; } return ucfirst($action) . ' ' . __d('model_history', 'by') . ' ' . $username; }
php
public function historyText(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_CREATE: $action = __d('model_history', 'created'); break; case ModelHistory::ACTION_UPDATE: $action = __d('model_history', 'updated'); break; case ModelHistory::ACTION_DELETE: $action = __d('model_history', 'deleted'); break; case ModelHistory::ACTION_COMMENT: $action = __d('model_history', 'commented'); break; default: } if (empty($history->user_id)) { $username = 'Anonymous'; } else { $userNameFields = TableRegistry::get($history->model)->getUserNameFields(true); $firstname = $history->user->{$userNameFields['firstname']}; $lastname = $history->user->{$userNameFields['lastname']}; $username = $firstname . ' ' . $lastname; } return ucfirst($action) . ' ' . __d('model_history', 'by') . ' ' . $username; }
[ "public", "function", "historyText", "(", "ModelHistory", "$", "history", ")", ":", "string", "{", "$", "action", "=", "''", ";", "switch", "(", "$", "history", "->", "action", ")", "{", "case", "ModelHistory", "::", "ACTION_CREATE", ":", "$", "action", ...
Returns the text displayed in the widget @param ModelHistory $history one ModelHistory entity @return string
[ "Returns", "the", "text", "displayed", "in", "the", "widget" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L104-L132
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.historyBadge
public function historyBadge(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_UPDATE: $icon = 'refresh'; break; case ModelHistory::ACTION_DELETE: $icon = 'minus-circle'; break; case ModelHistory::ACTION_COMMENT: $icon = 'comments'; break; default: case ModelHistory::ACTION_CREATE: $icon = 'plus-circle'; break; } return '<i class="fa fa-' . $icon . '"></i>'; }
php
public function historyBadge(ModelHistory $history): string { $action = ''; switch ($history->action) { case ModelHistory::ACTION_UPDATE: $icon = 'refresh'; break; case ModelHistory::ACTION_DELETE: $icon = 'minus-circle'; break; case ModelHistory::ACTION_COMMENT: $icon = 'comments'; break; default: case ModelHistory::ACTION_CREATE: $icon = 'plus-circle'; break; } return '<i class="fa fa-' . $icon . '"></i>'; }
[ "public", "function", "historyBadge", "(", "ModelHistory", "$", "history", ")", ":", "string", "{", "$", "action", "=", "''", ";", "switch", "(", "$", "history", "->", "action", ")", "{", "case", "ModelHistory", "::", "ACTION_UPDATE", ":", "$", "icon", "...
Returns the badge displayed in the widget @param ModelHistory $history one ModelHistory entity @return string
[ "Returns", "the", "badge", "displayed", "in", "the", "widget" ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L140-L160
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.getLocalizedFieldnames
public function getLocalizedFieldnames(ModelHistory $historyEntry): string { $fields = join(', ', array_map(function ($value) use ($historyEntry) { if (!is_string($value)) { return $value; } // Get pre configured translations and return it if found $fields = TableRegistry::get($historyEntry->model)->getFields(); if (isset($fields[$value]['translation'])) { if (is_callable($fields[$value]['translation'])) { return $fields[$value]['translation'](); } return $fields[$value]['translation']; } // Try to get the generic model.field translation string $localeSlug = strtolower(Inflector::singularize(Inflector::delimit($historyEntry->model))) . '.' . strtolower($value); $translatedString = __($localeSlug); // Return original value when no translation was made if ($localeSlug == $translatedString) { return $value; } return $translatedString; }, array_keys($historyEntry->data))); return $fields; }
php
public function getLocalizedFieldnames(ModelHistory $historyEntry): string { $fields = join(', ', array_map(function ($value) use ($historyEntry) { if (!is_string($value)) { return $value; } // Get pre configured translations and return it if found $fields = TableRegistry::get($historyEntry->model)->getFields(); if (isset($fields[$value]['translation'])) { if (is_callable($fields[$value]['translation'])) { return $fields[$value]['translation'](); } return $fields[$value]['translation']; } // Try to get the generic model.field translation string $localeSlug = strtolower(Inflector::singularize(Inflector::delimit($historyEntry->model))) . '.' . strtolower($value); $translatedString = __($localeSlug); // Return original value when no translation was made if ($localeSlug == $translatedString) { return $value; } return $translatedString; }, array_keys($historyEntry->data))); return $fields; }
[ "public", "function", "getLocalizedFieldnames", "(", "ModelHistory", "$", "historyEntry", ")", ":", "string", "{", "$", "fields", "=", "join", "(", "', '", ",", "array_map", "(", "function", "(", "$", "value", ")", "use", "(", "$", "historyEntry", ")", "{"...
Retrieve field names as localized, comma seperated string. @param ModelHistory $historyEntry A History entry @return string
[ "Retrieve", "field", "names", "as", "localized", "comma", "seperated", "string", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L168-L199
scherersoftware/cake-model-history
src/View/Helper/ModelHistoryHelper.php
ModelHistoryHelper.getLocalizedSlug
public function getLocalizedSlug(ModelHistory $historyEntry): string { $slug = $historyEntry->context_slug; if (!empty($historyEntry->context) && !empty($historyEntry->context['namespace'])) { $class = new $historyEntry->context['namespace']; if (method_exists($class, 'typeDescriptions')) { $typeDescriptions = $class::typeDescriptions(); if (isset($typeDescriptions[$slug])) { $slug = $typeDescriptions[$slug]; } } } return $slug; }
php
public function getLocalizedSlug(ModelHistory $historyEntry): string { $slug = $historyEntry->context_slug; if (!empty($historyEntry->context) && !empty($historyEntry->context['namespace'])) { $class = new $historyEntry->context['namespace']; if (method_exists($class, 'typeDescriptions')) { $typeDescriptions = $class::typeDescriptions(); if (isset($typeDescriptions[$slug])) { $slug = $typeDescriptions[$slug]; } } } return $slug; }
[ "public", "function", "getLocalizedSlug", "(", "ModelHistory", "$", "historyEntry", ")", ":", "string", "{", "$", "slug", "=", "$", "historyEntry", "->", "context_slug", ";", "if", "(", "!", "empty", "(", "$", "historyEntry", "->", "context", ")", "&&", "!...
Retrieve localized slug, when translation is available in type descriptions. @param ModelHistory $historyEntry HistoryEntry entity to get data from @return string
[ "Retrieve", "localized", "slug", "when", "translation", "is", "available", "in", "type", "descriptions", "." ]
train
https://github.com/scherersoftware/cake-model-history/blob/4dceac1cc7db0e6d443750dd9d76b960df385931/src/View/Helper/ModelHistoryHelper.php#L207-L221
baleen/migrations
src/Service/MigrationBus/Middleware/SetOptionsMiddleware.php
SetOptionsMiddleware.execute
public function execute($command, callable $next) { $migration = $command->getMigration(); if ($migration instanceof OptionsAwareInterface) { $migration->setOptions($command->getOptions()); } $next($command); }
php
public function execute($command, callable $next) { $migration = $command->getMigration(); if ($migration instanceof OptionsAwareInterface) { $migration->setOptions($command->getOptions()); } $next($command); }
[ "public", "function", "execute", "(", "$", "command", ",", "callable", "$", "next", ")", "{", "$", "migration", "=", "$", "command", "->", "getMigration", "(", ")", ";", "if", "(", "$", "migration", "instanceof", "OptionsAwareInterface", ")", "{", "$", "...
execute @param MigrateCommand $command @param callable $next @return mixed
[ "execute" ]
train
https://github.com/baleen/migrations/blob/cfc8c439858cf4f0d4119af9eb67de493da8d95c/src/Service/MigrationBus/Middleware/SetOptionsMiddleware.php#L42-L50
bigwhoop/sentence-breaker
src/SentenceBreaker.php
SentenceBreaker.addAbbreviations
public function addAbbreviations($values) { if (is_array($values)) { $values = new ArrayProvider($values); } elseif (!($values instanceof ValueProvider)) { throw new InvalidArgumentException('Values argument must either be an array or an instance of '.ValueProvider::class); } $this->abbreviationProviders[] = $values; }
php
public function addAbbreviations($values) { if (is_array($values)) { $values = new ArrayProvider($values); } elseif (!($values instanceof ValueProvider)) { throw new InvalidArgumentException('Values argument must either be an array or an instance of '.ValueProvider::class); } $this->abbreviationProviders[] = $values; }
[ "public", "function", "addAbbreviations", "(", "$", "values", ")", "{", "if", "(", "is_array", "(", "$", "values", ")", ")", "{", "$", "values", "=", "new", "ArrayProvider", "(", "$", "values", ")", ";", "}", "elseif", "(", "!", "(", "$", "values", ...
@param array|ValueProvider $values @throws InvalidArgumentException
[ "@param", "array|ValueProvider", "$values" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/SentenceBreaker.php#L101-L110
bigwhoop/sentence-breaker
src/SentenceBreaker.php
SentenceBreaker.split
public function split($text) { $this->probabilityCalculator->setAbbreviations($this->getAbbreviations()); $tokens = $this->lexer->run($text); $probabilities = $this->probabilityCalculator->calculate($tokens); $sentences = $this->sentenceBuilder->build($probabilities); return $sentences; }
php
public function split($text) { $this->probabilityCalculator->setAbbreviations($this->getAbbreviations()); $tokens = $this->lexer->run($text); $probabilities = $this->probabilityCalculator->calculate($tokens); $sentences = $this->sentenceBuilder->build($probabilities); return $sentences; }
[ "public", "function", "split", "(", "$", "text", ")", "{", "$", "this", "->", "probabilityCalculator", "->", "setAbbreviations", "(", "$", "this", "->", "getAbbreviations", "(", ")", ")", ";", "$", "tokens", "=", "$", "this", "->", "lexer", "->", "run", ...
@param string $text @return string[]
[ "@param", "string", "$text" ]
train
https://github.com/bigwhoop/sentence-breaker/blob/7b3d72ed84082c512cc0335b6e230f033274ea8d/src/SentenceBreaker.php#L117-L126
matrozov/yii2-couchbase
src/Migration.php
Migration.createBucket
public function createBucket($bucketName, $options = []) { $this->beginProfile($token = " > create bucket $bucketName ..."); $this->db->createBucket($bucketName, $options); $this->endProfile($token); }
php
public function createBucket($bucketName, $options = []) { $this->beginProfile($token = " > create bucket $bucketName ..."); $this->db->createBucket($bucketName, $options); $this->endProfile($token); }
[ "public", "function", "createBucket", "(", "$", "bucketName", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > create bucket $bucketName ...\"", ")", ";", "$", "this", "->", "db", "->", "crea...
Creates new bucket with the specified options. @param string $bucketName name of the bucket @param array $options bucket options in format: "name" => "value" @throws Exception @throws \yii\base\InvalidConfigException
[ "Creates", "new", "bucket", "with", "the", "specified", "options", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L63-L70
matrozov/yii2-couchbase
src/Migration.php
Migration.dropBucket
public function dropBucket($bucketName) { $this->beginProfile($token = " > drop bucket $bucketName ..."); $this->db->getBucket($bucketName)->drop(); $this->endProfile($token); }
php
public function dropBucket($bucketName) { $this->beginProfile($token = " > drop bucket $bucketName ..."); $this->db->getBucket($bucketName)->drop(); $this->endProfile($token); }
[ "public", "function", "dropBucket", "(", "$", "bucketName", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > drop bucket $bucketName ...\"", ")", ";", "$", "this", "->", "db", "->", "getBucket", "(", "$", "bucketName", ")", "->",...
Drops existing bucket. @param string $bucketName name of the bucket @throws Exception @throws \yii\base\InvalidConfigException
[ "Drops", "existing", "bucket", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L80-L87
matrozov/yii2-couchbase
src/Migration.php
Migration.insert
public function insert($bucketName, $data) { $this->beginProfile($token = " > insert into $bucketName ..."); $result = $this->db->insert($bucketName, $data); $this->endProfile($token); return $result; }
php
public function insert($bucketName, $data) { $this->beginProfile($token = " > insert into $bucketName ..."); $result = $this->db->insert($bucketName, $data); $this->endProfile($token); return $result; }
[ "public", "function", "insert", "(", "$", "bucketName", ",", "$", "data", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > insert into $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", "insert", ...
Insert record. @param string $bucketName the bucket that new rows will be inserted into. @param array $data the column data (name => value) to be inserted into the bucket or instance @return int|false inserted id @throws Exception @throws \yii\base\InvalidConfigException
[ "Insert", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L99-L108
matrozov/yii2-couchbase
src/Migration.php
Migration.batchInsert
public function batchInsert($bucketName, $rows) { $this->beginProfile($token = " > batch insert into $bucketName ..."); $result = $this->db->batchInsert($bucketName, $rows); $this->endProfile($token); return $result; }
php
public function batchInsert($bucketName, $rows) { $this->beginProfile($token = " > batch insert into $bucketName ..."); $result = $this->db->batchInsert($bucketName, $rows); $this->endProfile($token); return $result; }
[ "public", "function", "batchInsert", "(", "$", "bucketName", ",", "$", "rows", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > batch insert into $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", ...
Batch insert record. @param string $bucketName the bucket that new rows will be inserted into. @param array $rows the rows to be batch inserted into the bucket @return int[]|false inserted ids @throws Exception @throws \yii\base\InvalidConfigException
[ "Batch", "insert", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L120-L129
matrozov/yii2-couchbase
src/Migration.php
Migration.update
public function update($bucketName, $columns, $condition, $params = []) { $this->beginProfile($token = " > update record $bucketName ..."); $result = $this->db->update($bucketName, $columns, $condition, $params); $this->endProfile($token); return $result; }
php
public function update($bucketName, $columns, $condition, $params = []) { $this->beginProfile($token = " > update record $bucketName ..."); $result = $this->db->update($bucketName, $columns, $condition, $params); $this->endProfile($token); return $result; }
[ "public", "function", "update", "(", "$", "bucketName", ",", "$", "columns", ",", "$", "condition", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > update record $bucketName ...\"", ")", ";",...
Update record. @param string $bucketName the bucket to be updated. @param array $columns the column data (name => value) to be updated. @param string|array $condition the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition. @param array $params the parameters to be bound to the command @return int affected rows @throws Exception @throws \yii\base\InvalidConfigException
[ "Update", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L144-L153
matrozov/yii2-couchbase
src/Migration.php
Migration.upsert
public function upsert($bucketName, $id, $data) { $this->beginProfile($token = " > upsert record $bucketName.$id ..."); $result = $this->db->upsert($bucketName, $id, $data); $this->endProfile($token); return $result; }
php
public function upsert($bucketName, $id, $data) { $this->beginProfile($token = " > upsert record $bucketName.$id ..."); $result = $this->db->upsert($bucketName, $id, $data); $this->endProfile($token); return $result; }
[ "public", "function", "upsert", "(", "$", "bucketName", ",", "$", "id", ",", "$", "data", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > upsert record $bucketName.$id ...\"", ")", ";", "$", "result", "=", "$", "this", "->", ...
Upsert record. @param string $bucketName the bucket to be updated. @param string $id the document id. @param array $data the column data (name => value) to be inserted into the bucket or instance. @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "Upsert", "record", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L166-L175
matrozov/yii2-couchbase
src/Migration.php
Migration.delete
public function delete($bucketName, $condition = '', $params = []) { $this->beginProfile($token = " > delete record $bucketName ..."); $result = $this->db->delete($bucketName, $condition, $params); $this->endProfile($token); return $result; }
php
public function delete($bucketName, $condition = '', $params = []) { $this->beginProfile($token = " > delete record $bucketName ..."); $result = $this->db->delete($bucketName, $condition, $params); $this->endProfile($token); return $result; }
[ "public", "function", "delete", "(", "$", "bucketName", ",", "$", "condition", "=", "''", ",", "$", "params", "=", "[", "]", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > delete record $bucketName ...\"", ")", ";", "$", "r...
Delete record @param string $bucketName the bucket where the data will be deleted from. @param string|array $condition the condition that will be put in the WHERE part. Please refer to [[Query::where()]] on how to specify condition. @param array $params the parameters to be bound to the command @return int affected rows @throws Exception @throws \yii\base\InvalidConfigException
[ "Delete", "record" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L189-L198
matrozov/yii2-couchbase
src/Migration.php
Migration.buildIndex
public function buildIndex($bucketName, $indexNames) { $this->beginProfile($token = " > build index $bucketName ..."); $result = $this->db->buildIndex($bucketName, $indexNames); $this->endProfile($token); return $result; }
php
public function buildIndex($bucketName, $indexNames) { $this->beginProfile($token = " > build index $bucketName ..."); $result = $this->db->buildIndex($bucketName, $indexNames); $this->endProfile($token); return $result; }
[ "public", "function", "buildIndex", "(", "$", "bucketName", ",", "$", "indexNames", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > build index $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", "...
Build index. @param string $bucketName @param string|string[] $indexNames names of index @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "Build", "index", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L210-L219
matrozov/yii2-couchbase
src/Migration.php
Migration.createPrimaryIndex
public function createPrimaryIndex($bucketName, $indexName = null, $options = []) { $this->beginProfile($token = " > create primary index $bucketName ..."); $result = $this->db->createPrimaryIndex($bucketName, $indexName, $options); $this->endProfile($token); return $result; }
php
public function createPrimaryIndex($bucketName, $indexName = null, $options = []) { $this->beginProfile($token = " > create primary index $bucketName ..."); $result = $this->db->createPrimaryIndex($bucketName, $indexName, $options); $this->endProfile($token); return $result; }
[ "public", "function", "createPrimaryIndex", "(", "$", "bucketName", ",", "$", "indexName", "=", "null", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > create primary index $bucketName ...\"", "...
@param string $bucketName @param string|null $indexName name of primary index (optional) @param array $options @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "@param", "string", "$bucketName", "@param", "string|null", "$indexName", "name", "of", "primary", "index", "(", "optional", ")", "@param", "array", "$options" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L230-L239
matrozov/yii2-couchbase
src/Migration.php
Migration.dropPrimaryIndex
public function dropPrimaryIndex($bucketName) { $this->beginProfile($token = " > drop index $bucketName ..."); $result = $this->db->dropPrimaryIndex($bucketName); $this->endProfile($token); return $result; }
php
public function dropPrimaryIndex($bucketName) { $this->beginProfile($token = " > drop index $bucketName ..."); $result = $this->db->dropPrimaryIndex($bucketName); $this->endProfile($token); return $result; }
[ "public", "function", "dropPrimaryIndex", "(", "$", "bucketName", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > drop index $bucketName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "->", "dropPrimaryIndex", "(",...
@param string $bucketName @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "@param", "string", "$bucketName" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L248-L257
matrozov/yii2-couchbase
src/Migration.php
Migration.createIndex
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = []) { $this->beginProfile($token = " > create index $bucketName.$indexName ..."); $result = $this->db->createIndex($bucketName, $indexName, $columns, $condition, $params, $options); $this->endProfile($token); return $result; }
php
public function createIndex($bucketName, $indexName, $columns, $condition = null, &$params = [], $options = []) { $this->beginProfile($token = " > create index $bucketName.$indexName ..."); $result = $this->db->createIndex($bucketName, $indexName, $columns, $condition, $params, $options); $this->endProfile($token); return $result; }
[ "public", "function", "createIndex", "(", "$", "bucketName", ",", "$", "indexName", ",", "$", "columns", ",", "$", "condition", "=", "null", ",", "&", "$", "params", "=", "[", "]", ",", "$", "options", "=", "[", "]", ")", "{", "$", "this", "->", ...
@param string $bucketName @param string $indexName @param array $columns @param array|null $condition @param array $params @param array $options @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "@param", "string", "$bucketName", "@param", "string", "$indexName", "@param", "array", "$columns", "@param", "array|null", "$condition", "@param", "array", "$params", "@param", "array", "$options" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L271-L280
matrozov/yii2-couchbase
src/Migration.php
Migration.dropIndex
public function dropIndex($bucketName, $indexName) { $this->beginProfile($token = " > drop index $bucketName.$indexName ..."); $result = $this->db->dropIndex($bucketName, $indexName); $this->endProfile($token); return $result; }
php
public function dropIndex($bucketName, $indexName) { $this->beginProfile($token = " > drop index $bucketName.$indexName ..."); $result = $this->db->dropIndex($bucketName, $indexName); $this->endProfile($token); return $result; }
[ "public", "function", "dropIndex", "(", "$", "bucketName", ",", "$", "indexName", ")", "{", "$", "this", "->", "beginProfile", "(", "$", "token", "=", "\" > drop index $bucketName.$indexName ...\"", ")", ";", "$", "result", "=", "$", "this", "->", "db", "...
@param string $bucketName @param string $indexName @return bool @throws Exception @throws \yii\base\InvalidConfigException
[ "@param", "string", "$bucketName", "@param", "string", "$indexName" ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L290-L299
matrozov/yii2-couchbase
src/Migration.php
Migration.beginProfile
protected function beginProfile($token) { $this->profileTokens[$token] = microtime(true); $this->log($token); }
php
protected function beginProfile($token) { $this->profileTokens[$token] = microtime(true); $this->log($token); }
[ "protected", "function", "beginProfile", "(", "$", "token", ")", "{", "$", "this", "->", "profileTokens", "[", "$", "token", "]", "=", "microtime", "(", "true", ")", ";", "$", "this", "->", "log", "(", "$", "token", ")", ";", "}" ]
Marks the beginning of a code block for profiling. @param string $token token for the code block.
[ "Marks", "the", "beginning", "of", "a", "code", "block", "for", "profiling", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L320-L325
matrozov/yii2-couchbase
src/Migration.php
Migration.endProfile
protected function endProfile($token) { if (isset($this->profileTokens[$token])) { $time = microtime(true) - $this->profileTokens[$token]; unset($this->profileTokens[$token]); } else { $time = 0; } $this->log(" done (time: " . sprintf('%.3f', $time) . "s)\n"); }
php
protected function endProfile($token) { if (isset($this->profileTokens[$token])) { $time = microtime(true) - $this->profileTokens[$token]; unset($this->profileTokens[$token]); } else { $time = 0; } $this->log(" done (time: " . sprintf('%.3f', $time) . "s)\n"); }
[ "protected", "function", "endProfile", "(", "$", "token", ")", "{", "if", "(", "isset", "(", "$", "this", "->", "profileTokens", "[", "$", "token", "]", ")", ")", "{", "$", "time", "=", "microtime", "(", "true", ")", "-", "$", "this", "->", "profil...
Marks the end of a code block for profiling. @param string $token token for the code block.
[ "Marks", "the", "end", "of", "a", "code", "block", "for", "profiling", "." ]
train
https://github.com/matrozov/yii2-couchbase/blob/07c2e9d18cb90f873c0d88dcacf6bb532e9d648c/src/Migration.php#L331-L343