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
FrozenNode/Laravel-Administrator
src/Frozennode/Administrator/Includes/Resize.php
Resize.open_image
private function open_image( $file ) { $sfile = new SFile($file); // If $file isn't an array, we'll turn it into one if ( !is_array($file) ) { $file = array( 'type' => $sfile->getMimeType(), 'tmp_name' => $file ); } $mime = $file['type']; $file_path = $file['tmp_name']; switch ( $mime )...
php
private function open_image( $file ) { $sfile = new SFile($file); // If $file isn't an array, we'll turn it into one if ( !is_array($file) ) { $file = array( 'type' => $sfile->getMimeType(), 'tmp_name' => $file ); } $mime = $file['type']; $file_path = $file['tmp_name']; switch ( $mime )...
[ "private", "function", "open_image", "(", "$", "file", ")", "{", "$", "sfile", "=", "new", "SFile", "(", "$", "file", ")", ";", "// If $file isn't an array, we'll turn it into one", "if", "(", "!", "is_array", "(", "$", "file", ")", ")", "{", "$", "file", ...
Open a file, detect its mime-type and create an image resrource from it. @param array $file Attributes of file from the $_FILES array @return mixed
[ "Open", "a", "file", "detect", "its", "mime", "-", "type", "and", "create", "an", "image", "resrource", "from", "it", "." ]
train
https://github.com/FrozenNode/Laravel-Administrator/blob/34d604c2029ce2b11f93599baf4ec909501fd356/src/Frozennode/Administrator/Includes/Resize.php#L172-L197
FrozenNode/Laravel-Administrator
src/Frozennode/Administrator/Includes/Resize.php
Resize.get_optimal_crop
private function get_optimal_crop( $new_width , $new_height ) { $height_ratio = $this->height / $new_height; $width_ratio = $this->width / $new_width; if ( $height_ratio < $width_ratio ) { $optimal_ratio = $height_ratio; } else { $optimal_ratio = $width_ratio; } $optimal_height = $this->height / $...
php
private function get_optimal_crop( $new_width , $new_height ) { $height_ratio = $this->height / $new_height; $width_ratio = $this->width / $new_width; if ( $height_ratio < $width_ratio ) { $optimal_ratio = $height_ratio; } else { $optimal_ratio = $width_ratio; } $optimal_height = $this->height / $...
[ "private", "function", "get_optimal_crop", "(", "$", "new_width", ",", "$", "new_height", ")", "{", "$", "height_ratio", "=", "$", "this", "->", "height", "/", "$", "new_height", ";", "$", "width_ratio", "=", "$", "this", "->", "width", "/", "$", "new_wi...
Attempts to find the best way to crop. Whether crop is based on the image being portrait or landscape. @param int $new_width The width of the image @param int $new_height The height of the image @return array
[ "Attempts", "to", "find", "the", "best", "way", "to", "crop", ".", "Whether", "crop", "is", "based", "on", "the", "image", "being", "portrait", "or", "landscape", "." ]
train
https://github.com/FrozenNode/Laravel-Administrator/blob/34d604c2029ce2b11f93599baf4ec909501fd356/src/Frozennode/Administrator/Includes/Resize.php#L345-L363
FrozenNode/Laravel-Administrator
src/Frozennode/Administrator/Actions/Action.php
Action.validateOptions
public function validateOptions() { //override the config $this->validator->override($this->suppliedOptions, $this->rules); //if the validator failed, throw an exception if ($this->validator->fails()) { throw new \InvalidArgumentException("There are problems with your '" . $this->suppliedOptions['action_...
php
public function validateOptions() { //override the config $this->validator->override($this->suppliedOptions, $this->rules); //if the validator failed, throw an exception if ($this->validator->fails()) { throw new \InvalidArgumentException("There are problems with your '" . $this->suppliedOptions['action_...
[ "public", "function", "validateOptions", "(", ")", "{", "//override the config", "$", "this", "->", "validator", "->", "override", "(", "$", "this", "->", "suppliedOptions", ",", "$", "this", "->", "rules", ")", ";", "//if the validator failed, throw an exception", ...
Validates the supplied options @return void
[ "Validates", "the", "supplied", "options" ]
train
https://github.com/FrozenNode/Laravel-Administrator/blob/34d604c2029ce2b11f93599baf4ec909501fd356/src/Frozennode/Administrator/Actions/Action.php#L84-L95
FrozenNode/Laravel-Administrator
src/Frozennode/Administrator/Actions/Action.php
Action.buildStringOrCallable
public function buildStringOrCallable(array &$options, array $keys) { $model = $this->config->getDataModel(); //iterate over the keys foreach ($keys as $key) { //check if the key's value was supplied $suppliedValue = $this->validator->arrayGet($options, $key); //if it's a string, simply set it if...
php
public function buildStringOrCallable(array &$options, array $keys) { $model = $this->config->getDataModel(); //iterate over the keys foreach ($keys as $key) { //check if the key's value was supplied $suppliedValue = $this->validator->arrayGet($options, $key); //if it's a string, simply set it if...
[ "public", "function", "buildStringOrCallable", "(", "array", "&", "$", "options", ",", "array", "$", "keys", ")", "{", "$", "model", "=", "$", "this", "->", "config", "->", "getDataModel", "(", ")", ";", "//iterate over the keys", "foreach", "(", "$", "key...
Sets up the values of all the options that can be either strings or closures @param array $options //the passed-by-reference array on which to do the transformation @param array $keys //the keys to check @return void
[ "Sets", "up", "the", "values", "of", "all", "the", "options", "that", "can", "be", "either", "strings", "or", "closures" ]
train
https://github.com/FrozenNode/Laravel-Administrator/blob/34d604c2029ce2b11f93599baf4ec909501fd356/src/Frozennode/Administrator/Actions/Action.php#L126-L147
Herzult/php-ssh
src/Ssh/Sftp.php
Sftp.mkdir
public function mkdir($dirname, $mod = 0777, $recursive = false) { return ssh2_sftp_mkdir($this->getResource(), $dirname, $mod, $recursive); }
php
public function mkdir($dirname, $mod = 0777, $recursive = false) { return ssh2_sftp_mkdir($this->getResource(), $dirname, $mod, $recursive); }
[ "public", "function", "mkdir", "(", "$", "dirname", ",", "$", "mod", "=", "0777", ",", "$", "recursive", "=", "false", ")", "{", "return", "ssh2_sftp_mkdir", "(", "$", "this", "->", "getResource", "(", ")", ",", "$", "dirname", ",", "$", "mod", ",", ...
Creates a directory @param string $dirname The name of the new directory @param int $mod The permissions on the new directory @param Boolean $recursive Whether to automatically create any required parent directory @return Boolean
[ "Creates", "a", "directory" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Sftp.php#L36-L39
Herzult/php-ssh
src/Ssh/Sftp.php
Sftp.listDirectory
public function listDirectory($directory, $recursive = false) { $results = $this->scanDirectory($directory, $recursive); if (false === $results) { throw new \RuntimeException(sprintf( 'Unable to list directory "%s", maybe it is not a directory '. 'or it d...
php
public function listDirectory($directory, $recursive = false) { $results = $this->scanDirectory($directory, $recursive); if (false === $results) { throw new \RuntimeException(sprintf( 'Unable to list directory "%s", maybe it is not a directory '. 'or it d...
[ "public", "function", "listDirectory", "(", "$", "directory", ",", "$", "recursive", "=", "false", ")", "{", "$", "results", "=", "$", "this", "->", "scanDirectory", "(", "$", "directory", ",", "$", "recursive", ")", ";", "if", "(", "false", "===", "$"...
Lists files and directories of the specified directory The returned array is of the form: array( 'files' => array(...), 'directories' => array(...) ) @param string $directory @param Boolean $recursive @return array
[ "Lists", "files", "and", "directories", "of", "the", "specified", "directory" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Sftp.php#L223-L239
Herzult/php-ssh
src/Ssh/Sftp.php
Sftp.createResource
protected function createResource() { $resource = ssh2_sftp($this->getSessionResource()); if (!is_resource($resource)) { throw new RuntimeException('The initialization of the SFTP subsystem failed.'); } $this->resource = $resource; }
php
protected function createResource() { $resource = ssh2_sftp($this->getSessionResource()); if (!is_resource($resource)) { throw new RuntimeException('The initialization of the SFTP subsystem failed.'); } $this->resource = $resource; }
[ "protected", "function", "createResource", "(", ")", "{", "$", "resource", "=", "ssh2_sftp", "(", "$", "this", "->", "getSessionResource", "(", ")", ")", ";", "if", "(", "!", "is_resource", "(", "$", "resource", ")", ")", "{", "throw", "new", "RuntimeExc...
{@inheritDoc}
[ "{" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Sftp.php#L244-L253
Herzult/php-ssh
src/Ssh/Sftp.php
Sftp.scanDirectory
private function scanDirectory($directory, $recursive) { if (!$results = @scandir($this->getUrl($directory))) { return false; } $files = array(); $directories = array(); foreach ($results as $result) { if (in_array($result, array('.', '..'))) {...
php
private function scanDirectory($directory, $recursive) { if (!$results = @scandir($this->getUrl($directory))) { return false; } $files = array(); $directories = array(); foreach ($results as $result) { if (in_array($result, array('.', '..'))) {...
[ "private", "function", "scanDirectory", "(", "$", "directory", ",", "$", "recursive", ")", "{", "if", "(", "!", "$", "results", "=", "@", "scandir", "(", "$", "this", "->", "getUrl", "(", "$", "directory", ")", ")", ")", "{", "return", "false", ";", ...
Scans a directory Unfortunately, using a (recursive) directory iterator is not possible over SFTP: see https://bugs.php.net/bug.php?id=57378. Also, is_dir() is unreliable and often returns false for valid directories. Therefore, I use @scandir() instead. @param string $directory @param Boolean $recursive @return ...
[ "Scans", "a", "directory" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Sftp.php#L268-L300
Herzult/php-ssh
src/Ssh/Session.php
Session.setAuthentication
public function setAuthentication(Authentication $authentication) { $firstAuthentication = null === $this->authentication; $this->authentication = $authentication; if ($firstAuthentication && is_resource($this->resource)) { $this->authenticate(); } }
php
public function setAuthentication(Authentication $authentication) { $firstAuthentication = null === $this->authentication; $this->authentication = $authentication; if ($firstAuthentication && is_resource($this->resource)) { $this->authenticate(); } }
[ "public", "function", "setAuthentication", "(", "Authentication", "$", "authentication", ")", "{", "$", "firstAuthentication", "=", "null", "===", "$", "this", "->", "authentication", ";", "$", "this", "->", "authentication", "=", "$", "authentication", ";", "if...
Defines the authentication. If the @param Authentication $authentication
[ "Defines", "the", "authentication", ".", "If", "the" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Session.php#L36-L45
Herzult/php-ssh
src/Ssh/Session.php
Session.getSubsystem
public function getSubsystem($name) { if (!isset($this->subsystems[$name])) { $this->createSubsystem($name); } return $this->subsystems[$name]; }
php
public function getSubsystem($name) { if (!isset($this->subsystems[$name])) { $this->createSubsystem($name); } return $this->subsystems[$name]; }
[ "public", "function", "getSubsystem", "(", "$", "name", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "subsystems", "[", "$", "name", "]", ")", ")", "{", "$", "this", "->", "createSubsystem", "(", "$", "name", ")", ";", "}", "return", ...
Returns the specified subsystem If the subsystem does not exists, it will create it @param string $name The subsystem's name @return Subsystem
[ "Returns", "the", "specified", "subsystem" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Session.php#L86-L93
Herzult/php-ssh
src/Ssh/Session.php
Session.createSubsystem
protected function createSubsystem($name) { switch ($name) { case 'sftp': $subsystem = new Sftp($this); break; case 'publickey': $subsystem = new Publickey($this); break; case 'exec': $subsyst...
php
protected function createSubsystem($name) { switch ($name) { case 'sftp': $subsystem = new Sftp($this); break; case 'publickey': $subsystem = new Publickey($this); break; case 'exec': $subsyst...
[ "protected", "function", "createSubsystem", "(", "$", "name", ")", "{", "switch", "(", "$", "name", ")", "{", "case", "'sftp'", ":", "$", "subsystem", "=", "new", "Sftp", "(", "$", "this", ")", ";", "break", ";", "case", "'publickey'", ":", "$", "sub...
Creates the specified subsystem @param string $name The subsystem's name @throws InvalidArgumentException if the specified subsystem is no supported (e.g does not exist)
[ "Creates", "the", "specified", "subsystem" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Session.php#L103-L120
Herzult/php-ssh
src/Ssh/Session.php
Session.createResource
protected function createResource() { $resource = $this->connect($this->configuration->asArguments()); if (!is_resource($resource)) { throw new RuntimeException('The SSH connection failed.'); } $this->resource = $resource; if (null !== $this->authentication) { ...
php
protected function createResource() { $resource = $this->connect($this->configuration->asArguments()); if (!is_resource($resource)) { throw new RuntimeException('The SSH connection failed.'); } $this->resource = $resource; if (null !== $this->authentication) { ...
[ "protected", "function", "createResource", "(", ")", "{", "$", "resource", "=", "$", "this", "->", "connect", "(", "$", "this", "->", "configuration", "->", "asArguments", "(", ")", ")", ";", "if", "(", "!", "is_resource", "(", "$", "resource", ")", ")...
Creates the session resource If there is a defined authentication, it will authenticate the session @throws RuntimeException if the connection fail
[ "Creates", "the", "session", "resource" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Session.php#L129-L142
Herzult/php-ssh
src/Ssh/Authentication/PublicKeyFile.php
PublicKeyFile.authenticate
public function authenticate($session) { return ssh2_auth_pubkey_file( $session, $this->username, $this->publicKeyFile, $this->privateKeyFile, $this->passPhrase ); }
php
public function authenticate($session) { return ssh2_auth_pubkey_file( $session, $this->username, $this->publicKeyFile, $this->privateKeyFile, $this->passPhrase ); }
[ "public", "function", "authenticate", "(", "$", "session", ")", "{", "return", "ssh2_auth_pubkey_file", "(", "$", "session", ",", "$", "this", "->", "username", ",", "$", "this", "->", "publicKeyFile", ",", "$", "this", "->", "privateKeyFile", ",", "$", "t...
{@inheritDoc}
[ "{" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Authentication/PublicKeyFile.php#L38-L47
Herzult/php-ssh
src/Ssh/SshConfigFileConfiguration.php
SshConfigFileConfiguration.parseSshConfigFile
protected function parseSshConfigFile($file) { if (!file_exists($file) || !is_readable($file)) { throw new RuntimeException("The file '$file' does not exist or is not readable"); } $contents = file_get_contents($file); $configs = array(); $lineNumber = 1; ...
php
protected function parseSshConfigFile($file) { if (!file_exists($file) || !is_readable($file)) { throw new RuntimeException("The file '$file' does not exist or is not readable"); } $contents = file_get_contents($file); $configs = array(); $lineNumber = 1; ...
[ "protected", "function", "parseSshConfigFile", "(", "$", "file", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", ")", "||", "!", "is_readable", "(", "$", "file", ")", ")", "{", "throw", "new", "RuntimeException", "(", "\"The file '$file' does not ...
Parses the ssh config file into an array of configs for later matching against hosts @param string $file
[ "Parses", "the", "ssh", "config", "file", "into", "an", "array", "of", "configs", "for", "later", "matching", "against", "hosts" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/SshConfigFileConfiguration.php#L61-L108
Herzult/php-ssh
src/Ssh/SshConfigFileConfiguration.php
SshConfigFileConfiguration.getConfigForHost
public function getConfigForHost($host) { $matches = array(); foreach ($this->configs as $config) { if (fnmatch($config['host'], $host)) { $matches[] = $config; } } if (count($matches) == 0) { throw new RuntimeException("Unable to f...
php
public function getConfigForHost($host) { $matches = array(); foreach ($this->configs as $config) { if (fnmatch($config['host'], $host)) { $matches[] = $config; } } if (count($matches) == 0) { throw new RuntimeException("Unable to f...
[ "public", "function", "getConfigForHost", "(", "$", "host", ")", "{", "$", "matches", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "configs", "as", "$", "config", ")", "{", "if", "(", "fnmatch", "(", "$", "config", "[", "'host'", ...
Merges matches of the host in the config file using fnmatch and a length comparison @param string $host @return array
[ "Merges", "matches", "of", "the", "host", "in", "the", "config", "file", "using", "fnmatch", "and", "a", "length", "comparison" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/SshConfigFileConfiguration.php#L115-L141
Herzult/php-ssh
src/Ssh/SshConfigFileConfiguration.php
SshConfigFileConfiguration.getAuthentication
public function getAuthentication($passphrase = null, $user = null) { if (is_null($user) && !isset($this->config['user'])) { throw new RuntimeException("Can not authenticate for '{$this->host}' could not find user to authenticate as"); } $user = $user ?: $this->config['user']; ...
php
public function getAuthentication($passphrase = null, $user = null) { if (is_null($user) && !isset($this->config['user'])) { throw new RuntimeException("Can not authenticate for '{$this->host}' could not find user to authenticate as"); } $user = $user ?: $this->config['user']; ...
[ "public", "function", "getAuthentication", "(", "$", "passphrase", "=", "null", ",", "$", "user", "=", "null", ")", "{", "if", "(", "is_null", "(", "$", "user", ")", "&&", "!", "isset", "(", "$", "this", "->", "config", "[", "'user'", "]", ")", ")"...
Return an authentication mechanism based on the configuration file @param string|null $passphrase @param string|null $user @return PublicKeyFile|None
[ "Return", "an", "authentication", "mechanism", "based", "on", "the", "configuration", "file" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/SshConfigFileConfiguration.php#L149-L167
Herzult/php-ssh
src/Ssh/Publickey.php
Publickey.add
public function add($algoname, $blob, $overwrite = false, array $attributes = array()) { return ssh2_publickey_add($this->getResource(), $algoname, $blob, $overwrite, $attributes); }
php
public function add($algoname, $blob, $overwrite = false, array $attributes = array()) { return ssh2_publickey_add($this->getResource(), $algoname, $blob, $overwrite, $attributes); }
[ "public", "function", "add", "(", "$", "algoname", ",", "$", "blob", ",", "$", "overwrite", "=", "false", ",", "array", "$", "attributes", "=", "array", "(", ")", ")", "{", "return", "ssh2_publickey_add", "(", "$", "this", "->", "getResource", "(", ")"...
Adds an authorized publickey @param string $algoname The algorithm (e.g: ssh-dss, ssh-rsa) @param string $blob The blob as binary data @param Boolean $overwrite Whether to overwrite the key if it already exist @param array $attributes An associative array of attributes to assign to the publickey. To m...
[ "Adds", "an", "authorized", "publickey" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Publickey.php#L30-L33
Herzult/php-ssh
src/Ssh/Publickey.php
Publickey.createResource
public function createResource() { $resource = ssh2_publickey_init($this->getSessionResource()); if (!is_resource($resource)) { throw new RuntimeException('The initialization of the publickey subsystem failed.'); } $this->resource = $resource; }
php
public function createResource() { $resource = ssh2_publickey_init($this->getSessionResource()); if (!is_resource($resource)) { throw new RuntimeException('The initialization of the publickey subsystem failed.'); } $this->resource = $resource; }
[ "public", "function", "createResource", "(", ")", "{", "$", "resource", "=", "ssh2_publickey_init", "(", "$", "this", "->", "getSessionResource", "(", ")", ")", ";", "if", "(", "!", "is_resource", "(", "$", "resource", ")", ")", "{", "throw", "new", "Run...
{@inheritDoc}
[ "{" ]
train
https://github.com/Herzult/php-ssh/blob/c56875c7d6a6ef070dee8db2b5e77d6f36a02b55/src/Ssh/Publickey.php#L63-L72
sonata-project/SonataFormatterBundle
src/Controller/CkeditorAdminController.php
CkeditorAdminController.setFormTheme
private function setFormTheme(FormView $formView, array $theme): void { $this->get('twig')->getRuntime(FormRenderer::class)->setTheme($formView, $theme); }
php
private function setFormTheme(FormView $formView, array $theme): void { $this->get('twig')->getRuntime(FormRenderer::class)->setTheme($formView, $theme); }
[ "private", "function", "setFormTheme", "(", "FormView", "$", "formView", ",", "array", "$", "theme", ")", ":", "void", "{", "$", "this", "->", "get", "(", "'twig'", ")", "->", "getRuntime", "(", "FormRenderer", "::", "class", ")", "->", "setTheme", "(", ...
Sets the admin form theme to form view. Used for compatibility between Symfony versions.
[ "Sets", "the", "admin", "form", "theme", "to", "form", "view", ".", "Used", "for", "compatibility", "between", "Symfony", "versions", "." ]
train
https://github.com/sonata-project/SonataFormatterBundle/blob/4302302d7db0db4cf5ca7ffb724764d37fb95790/src/Controller/CkeditorAdminController.php#L155-L158
sonata-project/SonataFormatterBundle
src/DependencyInjection/SonataFormatterExtension.php
SonataFormatterExtension.load
public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Re...
php
public function load(array $configs, ContainerBuilder $container): void { $processor = new Processor(); $configuration = new Configuration(); $config = $processor->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Re...
[ "public", "function", "load", "(", "array", "$", "configs", ",", "ContainerBuilder", "$", "container", ")", ":", "void", "{", "$", "processor", "=", "new", "Processor", "(", ")", ";", "$", "configuration", "=", "new", "Configuration", "(", ")", ";", "$",...
Loads the url shortener configuration.
[ "Loads", "the", "url", "shortener", "configuration", "." ]
train
https://github.com/sonata-project/SonataFormatterBundle/blob/4302302d7db0db4cf5ca7ffb724764d37fb95790/src/DependencyInjection/SonataFormatterExtension.php#L32-L90
morrisonlevi/Ardent
src/Collection/AbstractSet.php
AbstractSet.difference
function difference(Set $that) { $difference = $this->cloneEmpty(); if ($that === $this) { return $difference; } $this->addIf($difference, $this, negate([$that, 'has'])); $this->addIf($difference, $that, negate([$this, 'has'])); return $difference; }
php
function difference(Set $that) { $difference = $this->cloneEmpty(); if ($that === $this) { return $difference; } $this->addIf($difference, $this, negate([$that, 'has'])); $this->addIf($difference, $that, negate([$this, 'has'])); return $difference; }
[ "function", "difference", "(", "Set", "$", "that", ")", "{", "$", "difference", "=", "$", "this", "->", "cloneEmpty", "(", ")", ";", "if", "(", "$", "that", "===", "$", "this", ")", "{", "return", "$", "difference", ";", "}", "$", "this", "->", "...
Creates the set that contains the items in the current set that are not contained in the provided set, as well as items that are in the provided set that are not in the current set. Formally: A ⊖ B = {x : x ∈ (A \ B) ∨ (B \ A)} @param Set $that @return Set
[ "Creates", "the", "set", "that", "contains", "the", "items", "in", "the", "current", "set", "that", "are", "not", "contained", "in", "the", "provided", "set", "as", "well", "as", "items", "that", "are", "in", "the", "provided", "set", "that", "are", "not...
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AbstractSet.php#L30-L41
morrisonlevi/Ardent
src/Collection/AbstractSet.php
AbstractSet.intersection
function intersection(Set $that) { $intersection = $this->cloneEmpty(); $this->addIf($intersection, $this, [$that, 'has']); return $intersection; }
php
function intersection(Set $that) { $intersection = $this->cloneEmpty(); $this->addIf($intersection, $this, [$that, 'has']); return $intersection; }
[ "function", "intersection", "(", "Set", "$", "that", ")", "{", "$", "intersection", "=", "$", "this", "->", "cloneEmpty", "(", ")", ";", "$", "this", "->", "addIf", "(", "$", "intersection", ",", "$", "this", ",", "[", "$", "that", ",", "'has'", "]...
Creates a new set that contains the items that are in current set that are also contained in the provided set. Formally: A ∩ B = {x : x ∈ A ∧ x ∈ B} @param Set $that @return Set
[ "Creates", "a", "new", "set", "that", "contains", "the", "items", "that", "are", "in", "current", "set", "that", "are", "also", "contained", "in", "the", "provided", "set", "." ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AbstractSet.php#L54-L60
morrisonlevi/Ardent
src/Collection/AbstractSet.php
AbstractSet.complement
function complement(Set $that) { $complement = $this->cloneEmpty(); if ($that === $this) { return $complement; } $this->addIf($complement, $that, negate([$this, 'has'])); return $complement; }
php
function complement(Set $that) { $complement = $this->cloneEmpty(); if ($that === $this) { return $complement; } $this->addIf($complement, $that, negate([$this, 'has'])); return $complement; }
[ "function", "complement", "(", "Set", "$", "that", ")", "{", "$", "complement", "=", "$", "this", "->", "cloneEmpty", "(", ")", ";", "if", "(", "$", "that", "===", "$", "this", ")", "{", "return", "$", "complement", ";", "}", "$", "this", "->", "...
Creates a new set which contains the items that exist in the provided set and do not exist in the current set. Formally: B \ A = {x: x ∈ A ∧ x ∉ B} @param Set $that @return Set
[ "Creates", "a", "new", "set", "which", "contains", "the", "items", "that", "exist", "in", "the", "provided", "set", "and", "do", "not", "exist", "in", "the", "current", "set", "." ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AbstractSet.php#L73-L83
morrisonlevi/Ardent
src/Collection/AbstractSet.php
AbstractSet.union
function union(Set $that) { $union = $this->cloneEmpty(); $this->for_each($this, [$union, 'add']); $this->for_each($that, [$union, 'add']); return $union; }
php
function union(Set $that) { $union = $this->cloneEmpty(); $this->for_each($this, [$union, 'add']); $this->for_each($that, [$union, 'add']); return $union; }
[ "function", "union", "(", "Set", "$", "that", ")", "{", "$", "union", "=", "$", "this", "->", "cloneEmpty", "(", ")", ";", "$", "this", "->", "for_each", "(", "$", "this", ",", "[", "$", "union", ",", "'add'", "]", ")", ";", "$", "this", "->", ...
Creates a new set that contains the items of the current set and the items of the provided set. Formally: A ∪ B = {x: x ∈ A ∨ x ∈ B} @param Set $that @return Set
[ "Creates", "a", "new", "set", "that", "contains", "the", "items", "of", "the", "current", "set", "and", "the", "items", "of", "the", "provided", "set", "." ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AbstractSet.php#L96-L103
morrisonlevi/Ardent
src/Collection/LinkedList.php
LinkedList.tail
function tail() { assert(!$this->isEmpty()); return $this->copyFromContext($this->head->next()->next()); }
php
function tail() { assert(!$this->isEmpty()); return $this->copyFromContext($this->head->next()->next()); }
[ "function", "tail", "(", ")", "{", "assert", "(", "!", "$", "this", "->", "isEmpty", "(", ")", ")", ";", "return", "$", "this", "->", "copyFromContext", "(", "$", "this", "->", "head", "->", "next", "(", ")", "->", "next", "(", ")", ")", ";", "...
Extract the elements after the first of a list, which must be non-empty. @return LinkedList
[ "Extract", "the", "elements", "after", "the", "first", "of", "a", "list", "which", "must", "be", "non", "-", "empty", "." ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/LinkedList.php#L270-L273
morrisonlevi/Ardent
src/Collection/BinaryTree.php
BinaryTree.inOrderPredecessor
function inOrderPredecessor() { $current = $this->left(); while ($current->right() !== null) { $current = $current->right(); } return $current; }
php
function inOrderPredecessor() { $current = $this->left(); while ($current->right() !== null) { $current = $current->right(); } return $current; }
[ "function", "inOrderPredecessor", "(", ")", "{", "$", "current", "=", "$", "this", "->", "left", "(", ")", ";", "while", "(", "$", "current", "->", "right", "(", ")", "!==", "null", ")", "{", "$", "current", "=", "$", "current", "->", "right", "(",...
Note that this function is only safe to call when it has a predecessor. @return BinaryTree
[ "Note", "that", "this", "function", "is", "only", "safe", "to", "call", "when", "it", "has", "a", "predecessor", "." ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/BinaryTree.php#L118-L124
morrisonlevi/Ardent
src/Collection/SortedMap.php
SortedMap.contains
function contains($item, callable $callback = null) { if ($callback === null) { $callback = __NAMESPACE__ . '\\compare'; } foreach ($this->avl as $pair) { /** * @var Pair $pair */ if (call_user_func($callback, $pair->second, $item) ==...
php
function contains($item, callable $callback = null) { if ($callback === null) { $callback = __NAMESPACE__ . '\\compare'; } foreach ($this->avl as $pair) { /** * @var Pair $pair */ if (call_user_func($callback, $pair->second, $item) ==...
[ "function", "contains", "(", "$", "item", ",", "callable", "$", "callback", "=", "null", ")", "{", "if", "(", "$", "callback", "===", "null", ")", "{", "$", "callback", "=", "__NAMESPACE__", ".", "'\\\\compare'", ";", "}", "foreach", "(", "$", "this", ...
@param mixed $item @param callable $callback @return bool
[ "@param", "mixed", "$item", "@param", "callable", "$callback" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/SortedMap.php#L45-L59
morrisonlevi/Ardent
src/Collection/SortedMap.php
SortedMap.get
function get($key) { assert($this->offsetExists($key)); /** * @var Pair $pair */ $pair = $this->avl->get(new Pair($key, null)); return $pair->second; }
php
function get($key) { assert($this->offsetExists($key)); /** * @var Pair $pair */ $pair = $this->avl->get(new Pair($key, null)); return $pair->second; }
[ "function", "get", "(", "$", "key", ")", "{", "assert", "(", "$", "this", "->", "offsetExists", "(", "$", "key", ")", ")", ";", "/**\n * @var Pair $pair\n */", "$", "pair", "=", "$", "this", "->", "avl", "->", "get", "(", "new", "Pair", ...
@param $key @return mixed
[ "@param", "$key" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/SortedMap.php#L140-L149
morrisonlevi/Ardent
src/Collection/HashSet.php
HashSet.has
function has($item) { $hash = call_user_func($this->hashFunction, $item); assert(is_scalar($hash)); return array_key_exists($hash, $this->objects); }
php
function has($item) { $hash = call_user_func($this->hashFunction, $item); assert(is_scalar($hash)); return array_key_exists($hash, $this->objects); }
[ "function", "has", "(", "$", "item", ")", "{", "$", "hash", "=", "call_user_func", "(", "$", "this", "->", "hashFunction", ",", "$", "item", ")", ";", "assert", "(", "is_scalar", "(", "$", "hash", ")", ")", ";", "return", "array_key_exists", "(", "$"...
@param $item @return bool
[ "@param", "$item" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/HashSet.php#L29-L36
morrisonlevi/Ardent
src/Collection/HashSet.php
HashSet.remove
function remove($item) { $hash = call_user_func($this->hashFunction, $item); assert(is_scalar($hash)); unset($this->objects[$hash]); }
php
function remove($item) { $hash = call_user_func($this->hashFunction, $item); assert(is_scalar($hash)); unset($this->objects[$hash]); }
[ "function", "remove", "(", "$", "item", ")", "{", "$", "hash", "=", "call_user_func", "(", "$", "this", "->", "hashFunction", ",", "$", "item", ")", ";", "assert", "(", "is_scalar", "(", "$", "hash", ")", ")", ";", "unset", "(", "$", "this", "->", ...
@param $item @return void
[ "@param", "$item" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/HashSet.php#L86-L92
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.get
function get($element) { $node = $this->findNode($element, $this->root); assert($node != null); return $node->value(); }
php
function get($element) { $node = $this->findNode($element, $this->root); assert($node != null); return $node->value(); }
[ "function", "get", "(", "$", "element", ")", "{", "$", "node", "=", "$", "this", "->", "findNode", "(", "$", "element", ",", "$", "this", "->", "root", ")", ";", "assert", "(", "$", "node", "!=", "null", ")", ";", "return", "$", "node", "->", "...
@param $element @return mixed
[ "@param", "$element" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L64-L70
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.addRecursive
protected function addRecursive($element, BinaryTree $node = null) { $nullAction = [$this, 'createTree']; $matchAction = function (BinaryTree $n) use ($element) { $n->setValue($element); return $n; }; return $this->doRecursive($nullAction, $matchAction, $element, ...
php
protected function addRecursive($element, BinaryTree $node = null) { $nullAction = [$this, 'createTree']; $matchAction = function (BinaryTree $n) use ($element) { $n->setValue($element); return $n; }; return $this->doRecursive($nullAction, $matchAction, $element, ...
[ "protected", "function", "addRecursive", "(", "$", "element", ",", "BinaryTree", "$", "node", "=", "null", ")", "{", "$", "nullAction", "=", "[", "$", "this", ",", "'createTree'", "]", ";", "$", "matchAction", "=", "function", "(", "BinaryTree", "$", "n"...
@param $element @param BinaryTree $node @return BinaryTree
[ "@param", "$element", "@param", "BinaryTree", "$node" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L168-L175
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.removeRecursive
protected function removeRecursive($element, BinaryTree $node = null) { $nullAction = [$this, 'doNothing']; $matchAction = [$this, 'deleteNode']; return $this->doRecursive($nullAction, $matchAction, $element, $node); }
php
protected function removeRecursive($element, BinaryTree $node = null) { $nullAction = [$this, 'doNothing']; $matchAction = [$this, 'deleteNode']; return $this->doRecursive($nullAction, $matchAction, $element, $node); }
[ "protected", "function", "removeRecursive", "(", "$", "element", ",", "BinaryTree", "$", "node", "=", "null", ")", "{", "$", "nullAction", "=", "[", "$", "this", ",", "'doNothing'", "]", ";", "$", "matchAction", "=", "[", "$", "this", ",", "'deleteNode'"...
@param $element @param BinaryTree $node @return BinaryTree|null
[ "@param", "$element", "@param", "BinaryTree", "$node" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L184-L188
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.deleteNode
protected function deleteNode(BinaryTree $node) { $state = $this->deleteSelectState($node); return $this->deleteOptions[$state]($node); }
php
protected function deleteNode(BinaryTree $node) { $state = $this->deleteSelectState($node); return $this->deleteOptions[$state]($node); }
[ "protected", "function", "deleteNode", "(", "BinaryTree", "$", "node", ")", "{", "$", "state", "=", "$", "this", "->", "deleteSelectState", "(", "$", "node", ")", ";", "return", "$", "this", "->", "deleteOptions", "[", "$", "state", "]", "(", "$", "nod...
@param BinaryTree $node @return BinaryTree|null
[ "@param", "BinaryTree", "$node" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L215-L218
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.balance
protected function balance(BinaryTree $node = null) { if ($node === null) { return null; } $diff = $node->leftHeight() - $node->rightHeight(); if ($diff < -1) { // right side is taller $node = $this->rotateLeft($node); } elseif ($diff > 1) { ...
php
protected function balance(BinaryTree $node = null) { if ($node === null) { return null; } $diff = $node->leftHeight() - $node->rightHeight(); if ($diff < -1) { // right side is taller $node = $this->rotateLeft($node); } elseif ($diff > 1) { ...
[ "protected", "function", "balance", "(", "BinaryTree", "$", "node", "=", "null", ")", "{", "if", "(", "$", "node", "===", "null", ")", "{", "return", "null", ";", "}", "$", "diff", "=", "$", "node", "->", "leftHeight", "(", ")", "-", "$", "node", ...
@param BinaryTree $node @return BinaryTree|null
[ "@param", "BinaryTree", "$node" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L226-L242
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.rotateRight
protected function rotateRight(BinaryTree $root) { $leftNode = $root->left(); $leftHeight = $leftNode->leftHeight(); $rightHeight = $leftNode->rightHeight(); $diff = $leftHeight - $rightHeight; if ($diff < 0) { // Left-Right case $pivot = $leftNode->righ...
php
protected function rotateRight(BinaryTree $root) { $leftNode = $root->left(); $leftHeight = $leftNode->leftHeight(); $rightHeight = $leftNode->rightHeight(); $diff = $leftHeight - $rightHeight; if ($diff < 0) { // Left-Right case $pivot = $leftNode->righ...
[ "protected", "function", "rotateRight", "(", "BinaryTree", "$", "root", ")", "{", "$", "leftNode", "=", "$", "root", "->", "left", "(", ")", ";", "$", "leftHeight", "=", "$", "leftNode", "->", "leftHeight", "(", ")", ";", "$", "rightHeight", "=", "$", ...
@param BinaryTree $root @return BinaryTree
[ "@param", "BinaryTree", "$root" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L250-L270
morrisonlevi/Ardent
src/Collection/AvlTree.php
AvlTree.rotateLeft
protected function rotateLeft(BinaryTree $root) { $rightNode = $root->right(); $diff = $rightNode->leftHeight() - $rightNode->rightHeight(); if ($diff >= 0) { // Right-Left case $pivot = $rightNode->left(); $rightNode->setLeft($pivot->right()); $...
php
protected function rotateLeft(BinaryTree $root) { $rightNode = $root->right(); $diff = $rightNode->leftHeight() - $rightNode->rightHeight(); if ($diff >= 0) { // Right-Left case $pivot = $rightNode->left(); $rightNode->setLeft($pivot->right()); $...
[ "protected", "function", "rotateLeft", "(", "BinaryTree", "$", "root", ")", "{", "$", "rightNode", "=", "$", "root", "->", "right", "(", ")", ";", "$", "diff", "=", "$", "rightNode", "->", "leftHeight", "(", ")", "-", "$", "rightNode", "->", "rightHeig...
@param BinaryTree $root @return BinaryTree
[ "@param", "BinaryTree", "$root" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/AvlTree.php#L278-L297
morrisonlevi/Ardent
src/Collection/HashMap.php
HashMap.contains
function contains($item, callable $comparator = null) { $compare = $comparator ?: [$this, 'areEqual']; $storage = $this->storage; for (reset($storage); key($storage) !== null; next($storage)) { /** * @var Pair $pair */ $pair = current($storage);...
php
function contains($item, callable $comparator = null) { $compare = $comparator ?: [$this, 'areEqual']; $storage = $this->storage; for (reset($storage); key($storage) !== null; next($storage)) { /** * @var Pair $pair */ $pair = current($storage);...
[ "function", "contains", "(", "$", "item", ",", "callable", "$", "comparator", "=", "null", ")", "{", "$", "compare", "=", "$", "comparator", "?", ":", "[", "$", "this", ",", "'areEqual'", "]", ";", "$", "storage", "=", "$", "this", "->", "storage", ...
@param $item @param callable $comparator function($a, $b) returns bool @return bool
[ "@param", "$item", "@param", "callable", "$comparator", "function", "(", "$a", "$b", ")", "returns", "bool" ]
train
https://github.com/morrisonlevi/Ardent/blob/972e9eea600edf9d0941c303f3b6a958e40dbb34/src/Collection/HashMap.php#L106-L120
Gregwar/CaptchaBundle
Generator/CaptchaGenerator.php
CaptchaGenerator.getCaptchaCode
public function getCaptchaCode(array &$options) { $this->builder->setPhrase($this->getPhrase($options)); // Randomly execute garbage collection and returns the image filename if ($options['as_file']) { $this->imageFileHandler->collectGarbage(); return $this->generat...
php
public function getCaptchaCode(array &$options) { $this->builder->setPhrase($this->getPhrase($options)); // Randomly execute garbage collection and returns the image filename if ($options['as_file']) { $this->imageFileHandler->collectGarbage(); return $this->generat...
[ "public", "function", "getCaptchaCode", "(", "array", "&", "$", "options", ")", "{", "$", "this", "->", "builder", "->", "setPhrase", "(", "$", "this", "->", "getPhrase", "(", "$", "options", ")", ")", ";", "// Randomly execute garbage collection and returns the...
Get the captcha URL, stream, or filename that will go in the image's src attribute @param array $options @return array
[ "Get", "the", "captcha", "URL", "stream", "or", "filename", "that", "will", "go", "in", "the", "image", "s", "src", "attribute" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Generator/CaptchaGenerator.php#L66-L84
Gregwar/CaptchaBundle
Generator/CaptchaGenerator.php
CaptchaGenerator.generate
public function generate(array &$options) { $this->builder->setDistortion($options['distortion']); $this->builder->setMaxFrontLines($options['max_front_lines']); $this->builder->setMaxBehindLines($options['max_behind_lines']); if (isset($options['text_color']) && $options['text_col...
php
public function generate(array &$options) { $this->builder->setDistortion($options['distortion']); $this->builder->setMaxFrontLines($options['max_front_lines']); $this->builder->setMaxBehindLines($options['max_behind_lines']); if (isset($options['text_color']) && $options['text_col...
[ "public", "function", "generate", "(", "array", "&", "$", "options", ")", "{", "$", "this", "->", "builder", "->", "setDistortion", "(", "$", "options", "[", "'distortion'", "]", ")", ";", "$", "this", "->", "builder", "->", "setMaxFrontLines", "(", "$",...
@param array $options @return string
[ "@param", "array", "$options" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Generator/CaptchaGenerator.php#L99-L150
Gregwar/CaptchaBundle
Generator/CaptchaGenerator.php
CaptchaGenerator.getPhrase
public function getPhrase(array &$options) { // Get the phrase that we'll use for this image if ($options['keep_value'] && isset($options['phrase'])) { $phrase = $options['phrase']; } else { $phrase = $this->phraseBuilder->build($options['length'], $options['charset']...
php
public function getPhrase(array &$options) { // Get the phrase that we'll use for this image if ($options['keep_value'] && isset($options['phrase'])) { $phrase = $options['phrase']; } else { $phrase = $this->phraseBuilder->build($options['length'], $options['charset']...
[ "public", "function", "getPhrase", "(", "array", "&", "$", "options", ")", "{", "// Get the phrase that we'll use for this image", "if", "(", "$", "options", "[", "'keep_value'", "]", "&&", "isset", "(", "$", "options", "[", "'phrase'", "]", ")", ")", "{", "...
@param array $options @return string
[ "@param", "array", "$options" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Generator/CaptchaGenerator.php#L157-L168
Gregwar/CaptchaBundle
Type/CaptchaType.php
CaptchaType.buildForm
public function buildForm(FormBuilderInterface $builder, array $options) { $validator = new CaptchaValidator( $this->translator, $this->session, sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']), $options['invalid_message'], $optio...
php
public function buildForm(FormBuilderInterface $builder, array $options) { $validator = new CaptchaValidator( $this->translator, $this->session, sprintf('%s%s', self::SESSION_KEY_PREFIX, $options['session_key']), $options['invalid_message'], $optio...
[ "public", "function", "buildForm", "(", "FormBuilderInterface", "$", "builder", ",", "array", "$", "options", ")", "{", "$", "validator", "=", "new", "CaptchaValidator", "(", "$", "this", "->", "translator", ",", "$", "this", "->", "session", ",", "sprintf",...
{@inheritdoc}
[ "{" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Type/CaptchaType.php#L65-L77
Gregwar/CaptchaBundle
Type/CaptchaType.php
CaptchaType.buildView
public function buildView(FormView $view, FormInterface $form, array $options) { if ($options['reload'] && !$options['as_url']) { throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information'); } $sessio...
php
public function buildView(FormView $view, FormInterface $form, array $options) { if ($options['reload'] && !$options['as_url']) { throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information'); } $sessio...
[ "public", "function", "buildView", "(", "FormView", "$", "view", ",", "FormInterface", "$", "form", ",", "array", "$", "options", ")", "{", "if", "(", "$", "options", "[", "'reload'", "]", "&&", "!", "$", "options", "[", "'as_url'", "]", ")", "{", "t...
{@inheritdoc}
[ "{" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Type/CaptchaType.php#L82-L124
Gregwar/CaptchaBundle
Validator/CaptchaValidator.php
CaptchaValidator.getExpectedCode
protected function getExpectedCode() { $options = $this->session->get($this->key, array()); if (is_array($options) && isset($options['phrase'])) { return $options['phrase']; } return null; }
php
protected function getExpectedCode() { $options = $this->session->get($this->key, array()); if (is_array($options) && isset($options['phrase'])) { return $options['phrase']; } return null; }
[ "protected", "function", "getExpectedCode", "(", ")", "{", "$", "options", "=", "$", "this", "->", "session", "->", "get", "(", "$", "this", "->", "key", ",", "array", "(", ")", ")", ";", "if", "(", "is_array", "(", "$", "options", ")", "&&", "isse...
Retrieve the expected CAPTCHA code @return mixed|null
[ "Retrieve", "the", "expected", "CAPTCHA", "code" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Validator/CaptchaValidator.php#L105-L114
Gregwar/CaptchaBundle
Validator/CaptchaValidator.php
CaptchaValidator.updateHumanity
protected function updateHumanity($newValue) { if ($newValue > 0) { $this->session->set($this->key . '_humanity', $newValue); } else { $this->session->remove($this->key . '_humanity'); } return null; }
php
protected function updateHumanity($newValue) { if ($newValue > 0) { $this->session->set($this->key . '_humanity', $newValue); } else { $this->session->remove($this->key . '_humanity'); } return null; }
[ "protected", "function", "updateHumanity", "(", "$", "newValue", ")", "{", "if", "(", "$", "newValue", ">", "0", ")", "{", "$", "this", "->", "session", "->", "set", "(", "$", "this", "->", "key", ".", "'_humanity'", ",", "$", "newValue", ")", ";", ...
Updates the humanity
[ "Updates", "the", "humanity" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Validator/CaptchaValidator.php#L129-L138
Gregwar/CaptchaBundle
Validator/CaptchaValidator.php
CaptchaValidator.compare
protected function compare($code, $expectedCode) { return ($expectedCode !== null && is_string($expectedCode) && $this->niceize($code) == $this->niceize($expectedCode)); }
php
protected function compare($code, $expectedCode) { return ($expectedCode !== null && is_string($expectedCode) && $this->niceize($code) == $this->niceize($expectedCode)); }
[ "protected", "function", "compare", "(", "$", "code", ",", "$", "expectedCode", ")", "{", "return", "(", "$", "expectedCode", "!==", "null", "&&", "is_string", "(", "$", "expectedCode", ")", "&&", "$", "this", "->", "niceize", "(", "$", "code", ")", "=...
Run a match comparison on the provided code and the expected code @param $code @param $expectedCode @return bool
[ "Run", "a", "match", "comparison", "on", "the", "provided", "code", "and", "the", "expected", "code" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Validator/CaptchaValidator.php#L160-L163
Gregwar/CaptchaBundle
DependencyInjection/Configuration.php
Configuration.getConfigTreeBuilder
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('gregwar_captcha'); $rootNode ->addDefaultsIfNotSet() ->children() ->scalarNode('length')->defaultValue(5)->end() ->scalarNode('w...
php
public function getConfigTreeBuilder() { $treeBuilder = new TreeBuilder(); $rootNode = $treeBuilder->root('gregwar_captcha'); $rootNode ->addDefaultsIfNotSet() ->children() ->scalarNode('length')->defaultValue(5)->end() ->scalarNode('w...
[ "public", "function", "getConfigTreeBuilder", "(", ")", "{", "$", "treeBuilder", "=", "new", "TreeBuilder", "(", ")", ";", "$", "rootNode", "=", "$", "treeBuilder", "->", "root", "(", "'gregwar_captcha'", ")", ";", "$", "rootNode", "->", "addDefaultsIfNotSet",...
Generates the configuration tree. @return TreeBuilder
[ "Generates", "the", "configuration", "tree", "." ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/DependencyInjection/Configuration.php#L15-L55
Gregwar/CaptchaBundle
Controller/CaptchaController.php
CaptchaController.generateCaptchaAction
public function generateCaptchaAction($key) { $options = $this->container->getParameter('gregwar_captcha.config'); $session = $this->get('session'); $whitelistKey = $options['whitelist_key']; $isOk = false; if ($session->has($whitelistKey)) { $keys = $session->ge...
php
public function generateCaptchaAction($key) { $options = $this->container->getParameter('gregwar_captcha.config'); $session = $this->get('session'); $whitelistKey = $options['whitelist_key']; $isOk = false; if ($session->has($whitelistKey)) { $keys = $session->ge...
[ "public", "function", "generateCaptchaAction", "(", "$", "key", ")", "{", "$", "options", "=", "$", "this", "->", "container", "->", "getParameter", "(", "'gregwar_captcha.config'", ")", ";", "$", "session", "=", "$", "this", "->", "get", "(", "'session'", ...
Action that is used to generate the captcha, save its code, and stream the image @param string $key @return Response @throws NotFoundHttpException
[ "Action", "that", "is", "used", "to", "generate", "the", "captcha", "save", "its", "code", "and", "stream", "the", "image" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Controller/CaptchaController.php#L25-L60
Gregwar/CaptchaBundle
Controller/CaptchaController.php
CaptchaController.error
protected function error($options) { /* @var \Gregwar\CaptchaBundle\Generator\CaptchaGenerator $generator */ $generator = $this->container->get('gregwar_captcha.generator'); $generator->setPhrase(''); $response = new Response($generator->generate($options)); $response->setSt...
php
protected function error($options) { /* @var \Gregwar\CaptchaBundle\Generator\CaptchaGenerator $generator */ $generator = $this->container->get('gregwar_captcha.generator'); $generator->setPhrase(''); $response = new Response($generator->generate($options)); $response->setSt...
[ "protected", "function", "error", "(", "$", "options", ")", "{", "/* @var \\Gregwar\\CaptchaBundle\\Generator\\CaptchaGenerator $generator */", "$", "generator", "=", "$", "this", "->", "container", "->", "get", "(", "'gregwar_captcha.generator'", ")", ";", "$", "genera...
Returns an empty image with status code 428 Precondition Required @param array $options @return Response
[ "Returns", "an", "empty", "image", "with", "status", "code", "428", "Precondition", "Required" ]
train
https://github.com/Gregwar/CaptchaBundle/blob/c2d5468556890dd25e0b53bd345fc205562c86f7/Controller/CaptchaController.php#L69-L82
moonlandsoft/yii2-phpexcel
Excel.php
Excel.init
public function init() { parent::init(); if ($this->formatter == null) { $this->formatter = \Yii::$app->getFormatter(); } elseif (is_array($this->formatter)) { $this->formatter = \Yii::createObject($this->formatter); } if (!$this->formatter instanceof Formatter) { throw new InvalidConfigException('T...
php
public function init() { parent::init(); if ($this->formatter == null) { $this->formatter = \Yii::$app->getFormatter(); } elseif (is_array($this->formatter)) { $this->formatter = \Yii::createObject($this->formatter); } if (!$this->formatter instanceof Formatter) { throw new InvalidConfigException('T...
[ "public", "function", "init", "(", ")", "{", "parent", "::", "init", "(", ")", ";", "if", "(", "$", "this", "->", "formatter", "==", "null", ")", "{", "$", "this", "->", "formatter", "=", "\\", "Yii", "::", "$", "app", "->", "getFormatter", "(", ...
(non-PHPdoc) @see \yii\base\Object::init()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L442-L453
moonlandsoft/yii2-phpexcel
Excel.php
Excel.executeColumns
public function executeColumns(&$activeSheet = null, $models, $columns = [], $headers = []) { if ($activeSheet == null) { $activeSheet = $this->activeSheet; } $hasHeader = false; $row = 1; $char = 26; foreach ($models as $model) { if (empty($columns)) { $columns = $model->attributes(); } if...
php
public function executeColumns(&$activeSheet = null, $models, $columns = [], $headers = []) { if ($activeSheet == null) { $activeSheet = $this->activeSheet; } $hasHeader = false; $row = 1; $char = 26; foreach ($models as $model) { if (empty($columns)) { $columns = $model->attributes(); } if...
[ "public", "function", "executeColumns", "(", "&", "$", "activeSheet", "=", "null", ",", "$", "models", ",", "$", "columns", "=", "[", "]", ",", "$", "headers", "=", "[", "]", ")", "{", "if", "(", "$", "activeSheet", "==", "null", ")", "{", "$", "...
Setting data from models
[ "Setting", "data", "from", "models" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L458-L545
moonlandsoft/yii2-phpexcel
Excel.php
Excel.executeArrayLabel
public function executeArrayLabel($sheetData) { $keys = ArrayHelper::remove($sheetData, '1'); $new_data = []; foreach ($sheetData as $values) { $new_data[] = array_combine($keys, $values); } return $new_data; }
php
public function executeArrayLabel($sheetData) { $keys = ArrayHelper::remove($sheetData, '1'); $new_data = []; foreach ($sheetData as $values) { $new_data[] = array_combine($keys, $values); } return $new_data; }
[ "public", "function", "executeArrayLabel", "(", "$", "sheetData", ")", "{", "$", "keys", "=", "ArrayHelper", "::", "remove", "(", "$", "sheetData", ",", "'1'", ")", ";", "$", "new_data", "=", "[", "]", ";", "foreach", "(", "$", "sheetData", "as", "$", ...
Setting label or keys on every record if setFirstRecordAsKeys is true. @param array $sheetData @return multitype:multitype:array
[ "Setting", "label", "or", "keys", "on", "every", "record", "if", "setFirstRecordAsKeys", "is", "true", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L552-L564
moonlandsoft/yii2-phpexcel
Excel.php
Excel.executeLeaveRecords
public function executeLeaveRecords($sheetData = [], $index = []) { foreach ($sheetData as $key => $data) { if (in_array($key, $index)) { unset($sheetData[$key]); } } return $sheetData; }
php
public function executeLeaveRecords($sheetData = [], $index = []) { foreach ($sheetData as $key => $data) { if (in_array($key, $index)) { unset($sheetData[$key]); } } return $sheetData; }
[ "public", "function", "executeLeaveRecords", "(", "$", "sheetData", "=", "[", "]", ",", "$", "index", "=", "[", "]", ")", "{", "foreach", "(", "$", "sheetData", "as", "$", "key", "=>", "$", "data", ")", "{", "if", "(", "in_array", "(", "$", "key", ...
Leave record with same index number. @param array $sheetData @param array $index @return array
[ "Leave", "record", "with", "same", "index", "number", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L572-L582
moonlandsoft/yii2-phpexcel
Excel.php
Excel.executeGetOnlyRecords
public function executeGetOnlyRecords($sheetData = [], $index = []) { foreach ($sheetData as $key => $data) { if (!in_array($key, $index)) { unset($sheetData[$key]); } } return $sheetData; }
php
public function executeGetOnlyRecords($sheetData = [], $index = []) { foreach ($sheetData as $key => $data) { if (!in_array($key, $index)) { unset($sheetData[$key]); } } return $sheetData; }
[ "public", "function", "executeGetOnlyRecords", "(", "$", "sheetData", "=", "[", "]", ",", "$", "index", "=", "[", "]", ")", "{", "foreach", "(", "$", "sheetData", "as", "$", "key", "=>", "$", "data", ")", "{", "if", "(", "!", "in_array", "(", "$", ...
Read record with same index number. @param array $sheetData @param array $index @return array
[ "Read", "record", "with", "same", "index", "number", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L590-L600
moonlandsoft/yii2-phpexcel
Excel.php
Excel.executeGetColumnData
public function executeGetColumnData($model, $params = []) { $value = null; if (isset($params['value']) && $params['value'] !== null) { if (is_string($params['value'])) { $value = ArrayHelper::getValue($model, $params['value']); } else { $value = call_user_func($params['value'], $model, $this); } ...
php
public function executeGetColumnData($model, $params = []) { $value = null; if (isset($params['value']) && $params['value'] !== null) { if (is_string($params['value'])) { $value = ArrayHelper::getValue($model, $params['value']); } else { $value = call_user_func($params['value'], $model, $this); } ...
[ "public", "function", "executeGetColumnData", "(", "$", "model", ",", "$", "params", "=", "[", "]", ")", "{", "$", "value", "=", "null", ";", "if", "(", "isset", "(", "$", "params", "[", "'value'", "]", ")", "&&", "$", "params", "[", "'value'", "]"...
Getting column value. @param Model $model @param array $params @return Ambigous <NULL, string, mixed>
[ "Getting", "column", "value", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L608-L625
moonlandsoft/yii2-phpexcel
Excel.php
Excel.populateColumns
public function populateColumns($columns = []) { $_columns = []; foreach ($columns as $key => $value) { if (is_string($value)) { $value_log = explode(':', $value); $_columns[$key] = ['attribute' => $value_log[0]]; if (isset($value_log[1]) && $value_log[1] !== null) { $_columns[$key]['form...
php
public function populateColumns($columns = []) { $_columns = []; foreach ($columns as $key => $value) { if (is_string($value)) { $value_log = explode(':', $value); $_columns[$key] = ['attribute' => $value_log[0]]; if (isset($value_log[1]) && $value_log[1] !== null) { $_columns[$key]['form...
[ "public", "function", "populateColumns", "(", "$", "columns", "=", "[", "]", ")", "{", "$", "_columns", "=", "[", "]", ";", "foreach", "(", "$", "columns", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_string", "(", "$", "value", ...
Populating columns for checking the column is string or array. if is string this will be checking have a formatter or header. @param array $columns @throws InvalidParamException @return multitype:multitype:array
[ "Populating", "columns", "for", "checking", "the", "column", "is", "string", "or", "array", ".", "if", "is", "string", "this", "will", "be", "checking", "have", "a", "formatter", "or", "header", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L633-L659
moonlandsoft/yii2-phpexcel
Excel.php
Excel.formatter
public function formatter() { if (!isset($this->formatter)) $this->formatter = \Yii::$app->getFormatter(); return $this->formatter; }
php
public function formatter() { if (!isset($this->formatter)) $this->formatter = \Yii::$app->getFormatter(); return $this->formatter; }
[ "public", "function", "formatter", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "formatter", ")", ")", "$", "this", "->", "formatter", "=", "\\", "Yii", "::", "$", "app", "->", "getFormatter", "(", ")", ";", "return", "$", "this"...
Formatter for i18n. @return Formatter
[ "Formatter", "for", "i18n", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L665-L671
moonlandsoft/yii2-phpexcel
Excel.php
Excel.getFileName
public function getFileName() { $fileName = 'exports.xlsx'; if (isset($this->fileName)) { $fileName = $this->fileName; if (strpos($fileName, '.xlsx') === false) $fileName .= '.xlsx'; } return $fileName; }
php
public function getFileName() { $fileName = 'exports.xlsx'; if (isset($this->fileName)) { $fileName = $this->fileName; if (strpos($fileName, '.xlsx') === false) $fileName .= '.xlsx'; } return $fileName; }
[ "public", "function", "getFileName", "(", ")", "{", "$", "fileName", "=", "'exports.xlsx'", ";", "if", "(", "isset", "(", "$", "this", "->", "fileName", ")", ")", "{", "$", "fileName", "=", "$", "this", "->", "fileName", ";", "if", "(", "strpos", "("...
Getting the file name of exporting xls file @return string
[ "Getting", "the", "file", "name", "of", "exporting", "xls", "file" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L687-L696
moonlandsoft/yii2-phpexcel
Excel.php
Excel.properties
public function properties(&$objectExcel, $properties = []) { foreach ($properties as $key => $value) { $keyname = "set" . ucfirst($key); $objectExcel->getProperties()->{$keyname}($value); } }
php
public function properties(&$objectExcel, $properties = []) { foreach ($properties as $key => $value) { $keyname = "set" . ucfirst($key); $objectExcel->getProperties()->{$keyname}($value); } }
[ "public", "function", "properties", "(", "&", "$", "objectExcel", ",", "$", "properties", "=", "[", "]", ")", "{", "foreach", "(", "$", "properties", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "keyname", "=", "\"set\"", ".", "ucfirst", "(",...
Setting properties for excel file @param PHPExcel $objectExcel @param array $properties
[ "Setting", "properties", "for", "excel", "file" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L703-L710
moonlandsoft/yii2-phpexcel
Excel.php
Excel.writeFile
public function writeFile($sheet) { if (!isset($this->format)) $this->format = 'Xlsx'; $objectwriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($sheet, $this->format); $path = 'php://output'; if (isset($this->savePath) && $this->savePath != null) { $path = $this->savePath . '/' . $this->getFileN...
php
public function writeFile($sheet) { if (!isset($this->format)) $this->format = 'Xlsx'; $objectwriter = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($sheet, $this->format); $path = 'php://output'; if (isset($this->savePath) && $this->savePath != null) { $path = $this->savePath . '/' . $this->getFileN...
[ "public", "function", "writeFile", "(", "$", "sheet", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "format", ")", ")", "$", "this", "->", "format", "=", "'Xlsx'", ";", "$", "objectwriter", "=", "\\", "PhpOffice", "\\", "PhpSpreadsheet", ...
saving the xls file to download or to path
[ "saving", "the", "xls", "file", "to", "download", "or", "to", "path" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L715-L731
moonlandsoft/yii2-phpexcel
Excel.php
Excel.readFile
public function readFile($fileName) { if (!isset($this->format)) $this->format = \PhpOffice\PhpSpreadsheet\IOFactory::identify($fileName); $objectreader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->format); if ($this->format == "Csv") { $objectreader->setDelimiter($this->CSVDelimiter); $ob...
php
public function readFile($fileName) { if (!isset($this->format)) $this->format = \PhpOffice\PhpSpreadsheet\IOFactory::identify($fileName); $objectreader = \PhpOffice\PhpSpreadsheet\IOFactory::createReader($this->format); if ($this->format == "Csv") { $objectreader->setDelimiter($this->CSVDelimiter); $ob...
[ "public", "function", "readFile", "(", "$", "fileName", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "format", ")", ")", "$", "this", "->", "format", "=", "\\", "PhpOffice", "\\", "PhpSpreadsheet", "\\", "IOFactory", "::", "identify", "("...
reading the xls file
[ "reading", "the", "xls", "file" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L736-L799
moonlandsoft/yii2-phpexcel
Excel.php
Excel.run
public function run() { if ($this->mode == 'export') { $sheet = new Spreadsheet(); if (!isset($this->models)) throw new InvalidConfigException('Config models must be set'); if (isset($this->properties)) { ...
php
public function run() { if ($this->mode == 'export') { $sheet = new Spreadsheet(); if (!isset($this->models)) throw new InvalidConfigException('Config models must be set'); if (isset($this->properties)) { ...
[ "public", "function", "run", "(", ")", "{", "if", "(", "$", "this", "->", "mode", "==", "'export'", ")", "{", "$", "sheet", "=", "new", "Spreadsheet", "(", ")", ";", "if", "(", "!", "isset", "(", "$", "this", "->", "models", ")", ")", "throw", ...
(non-PHPdoc) @see \yii\base\Widget::run()
[ "(", "non", "-", "PHPdoc", ")" ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L805-L855
moonlandsoft/yii2-phpexcel
Excel.php
Excel.import
public static function import($fileName, $config=[]) { $config = ArrayHelper::merge(['mode' => 'import', 'fileName' => $fileName, 'asArray' => true], $config); return self::widget($config); }
php
public static function import($fileName, $config=[]) { $config = ArrayHelper::merge(['mode' => 'import', 'fileName' => $fileName, 'asArray' => true], $config); return self::widget($config); }
[ "public", "static", "function", "import", "(", "$", "fileName", ",", "$", "config", "=", "[", "]", ")", "{", "$", "config", "=", "ArrayHelper", "::", "merge", "(", "[", "'mode'", "=>", "'import'", ",", "'fileName'", "=>", "$", "fileName", ",", "'asArra...
Import file excel and return into an array. ~~~ $data = \moonland\phpexcel\Excel::import($fileName, ['setFirstRecordAsKeys' => true]); ~~~ @param string!array $fileName to load. @param array $config is a more configuration. @return string
[ "Import", "file", "excel", "and", "return", "into", "an", "array", "." ]
train
https://github.com/moonlandsoft/yii2-phpexcel/blob/ccf28ff8ce2c665a7769dd6516098b4a35c8c309/Excel.php#L926-L930
beyondcode/laravel-comments
src/Traits/HasComments.php
HasComments.commentAsUser
public function commentAsUser(?Model $user, string $comment) { $commentClass = config('comments.comment_class'); $comment = new $commentClass([ 'comment' => $comment, 'is_approved' => ($user instanceof Commentator) ? ! $user->needsCommentApproval($this) : false, ...
php
public function commentAsUser(?Model $user, string $comment) { $commentClass = config('comments.comment_class'); $comment = new $commentClass([ 'comment' => $comment, 'is_approved' => ($user instanceof Commentator) ? ! $user->needsCommentApproval($this) : false, ...
[ "public", "function", "commentAsUser", "(", "?", "Model", "$", "user", ",", "string", "$", "comment", ")", "{", "$", "commentClass", "=", "config", "(", "'comments.comment_class'", ")", ";", "$", "comment", "=", "new", "$", "commentClass", "(", "[", "'comm...
Attach a comment to this model as a specific user. @param Model|null $user @param string $comment @return \Illuminate\Database\Eloquent\Model
[ "Attach", "a", "comment", "to", "this", "model", "as", "a", "specific", "user", "." ]
train
https://github.com/beyondcode/laravel-comments/blob/c7d599349d6063860280dafb07e9757106428b76/src/Traits/HasComments.php#L40-L53
analogueorm/analogue
src/System/Proxies/ProxyFactory.php
ProxyFactory.makeEntityProxy
protected function makeEntityProxy($entity, $relation, $class) { $proxyPath = Manager::getInstance()->getProxyPath(); if ($proxyPath !== null) { $proxyConfig = new Configuration(); $proxyConfig->setProxiesTargetDir($proxyPath); $factory = new LazyLoadingValueHol...
php
protected function makeEntityProxy($entity, $relation, $class) { $proxyPath = Manager::getInstance()->getProxyPath(); if ($proxyPath !== null) { $proxyConfig = new Configuration(); $proxyConfig->setProxiesTargetDir($proxyPath); $factory = new LazyLoadingValueHol...
[ "protected", "function", "makeEntityProxy", "(", "$", "entity", ",", "$", "relation", ",", "$", "class", ")", "{", "$", "proxyPath", "=", "Manager", "::", "getInstance", "(", ")", "->", "getProxyPath", "(", ")", ";", "if", "(", "$", "proxyPath", "!==", ...
Create an instance of a proxy object, extending the actual related class. @param mixed $entity parent object @param string $relation the name of the relationship method @param string $class the class name of the related object @return mixed
[ "Create", "an", "instance", "of", "a", "proxy", "object", "extending", "the", "actual", "related", "class", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Proxies/ProxyFactory.php#L46-L69
analogueorm/analogue
src/Plugins/SoftDeletes/SoftDeletingScope.php
SoftDeletingScope.apply
public function apply(Query $query) { $entityMap = $query->getMapper()->getEntityMap(); $query->whereNull($entityMap->getQualifiedDeletedAtColumn()); $this->extend($query); }
php
public function apply(Query $query) { $entityMap = $query->getMapper()->getEntityMap(); $query->whereNull($entityMap->getQualifiedDeletedAtColumn()); $this->extend($query); }
[ "public", "function", "apply", "(", "Query", "$", "query", ")", "{", "$", "entityMap", "=", "$", "query", "->", "getMapper", "(", ")", "->", "getEntityMap", "(", ")", ";", "$", "query", "->", "whereNull", "(", "$", "entityMap", "->", "getQualifiedDeleted...
{@inheritdoc}
[ "{" ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Plugins/SoftDeletes/SoftDeletingScope.php#L23-L30
analogueorm/analogue
src/Plugins/SoftDeletes/SoftDeletingScope.php
SoftDeletingScope.remove
public function remove(Query $query) { $column = $query->getMapper()->getEntityMap()->getQualifiedDeletedAtColumn(); $query = $query->getQuery(); foreach ((array) $query->wheres as $key => $where) { // If the where clause is a soft delete date constraint, we will remove it from...
php
public function remove(Query $query) { $column = $query->getMapper()->getEntityMap()->getQualifiedDeletedAtColumn(); $query = $query->getQuery(); foreach ((array) $query->wheres as $key => $where) { // If the where clause is a soft delete date constraint, we will remove it from...
[ "public", "function", "remove", "(", "Query", "$", "query", ")", "{", "$", "column", "=", "$", "query", "->", "getMapper", "(", ")", "->", "getEntityMap", "(", ")", "->", "getQualifiedDeletedAtColumn", "(", ")", ";", "$", "query", "=", "$", "query", "-...
{@inheritdoc}
[ "{" ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Plugins/SoftDeletes/SoftDeletingScope.php#L35-L51
analogueorm/analogue
src/Plugins/SoftDeletes/SoftDeletingScope.php
SoftDeletingScope.addWithTrashed
protected function addWithTrashed(Query $query) { $query->macro('withTrashed', function (Query $query) { $this->remove($query); return $query; }); }
php
protected function addWithTrashed(Query $query) { $query->macro('withTrashed', function (Query $query) { $this->remove($query); return $query; }); }
[ "protected", "function", "addWithTrashed", "(", "Query", "$", "query", ")", "{", "$", "query", "->", "macro", "(", "'withTrashed'", ",", "function", "(", "Query", "$", "query", ")", "{", "$", "this", "->", "remove", "(", "$", "query", ")", ";", "return...
Add the with-trashed extension to the builder. @param \Analogue\ORM\System\Query $query @return void
[ "Add", "the", "with", "-", "trashed", "extension", "to", "the", "builder", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Plugins/SoftDeletes/SoftDeletingScope.php#L74-L81
analogueorm/analogue
src/Plugins/SoftDeletes/SoftDeletingScope.php
SoftDeletingScope.addOnlyTrashed
protected function addOnlyTrashed(Query $query) { $query->macro('onlyTrashed', function (Query $query) { $this->remove($query); $query->getQuery()->whereNotNull($query->getMapper()->getEntityMap()->getQualifiedDeletedAtColumn()); return $query; }); }
php
protected function addOnlyTrashed(Query $query) { $query->macro('onlyTrashed', function (Query $query) { $this->remove($query); $query->getQuery()->whereNotNull($query->getMapper()->getEntityMap()->getQualifiedDeletedAtColumn()); return $query; }); }
[ "protected", "function", "addOnlyTrashed", "(", "Query", "$", "query", ")", "{", "$", "query", "->", "macro", "(", "'onlyTrashed'", ",", "function", "(", "Query", "$", "query", ")", "{", "$", "this", "->", "remove", "(", "$", "query", ")", ";", "$", ...
Add the only-trashed extension to the builder. @param \Analogue\ORM\System\Query $query @return void
[ "Add", "the", "only", "-", "trashed", "extension", "to", "the", "builder", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Plugins/SoftDeletes/SoftDeletingScope.php#L90-L99
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.dehydrate
protected function dehydrate($entity): array { $properties = $this->hydrator->extract($entity); $attributesName = $this->entityMap->getAttributesArrayName(); if (isset($properties[$attributesName])) { $properties[$attributesName] = $this->entityMap->getColumnNamesFromAttributes...
php
protected function dehydrate($entity): array { $properties = $this->hydrator->extract($entity); $attributesName = $this->entityMap->getAttributesArrayName(); if (isset($properties[$attributesName])) { $properties[$attributesName] = $this->entityMap->getColumnNamesFromAttributes...
[ "protected", "function", "dehydrate", "(", "$", "entity", ")", ":", "array", "{", "$", "properties", "=", "$", "this", "->", "hydrator", "->", "extract", "(", "$", "entity", ")", ";", "$", "attributesName", "=", "$", "this", "->", "entityMap", "->", "g...
Extract entity attributes / properties to an array of attributes. @param mixed $entity @throws MappingException @return array
[ "Extract", "entity", "attributes", "/", "properties", "to", "an", "array", "of", "attributes", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L165-L182
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.hydrate
protected function hydrate() { $properties = $this->propertiesFromAttributes() + $this->unmanagedProperties; $attributesName = $this->entityMap->getAttributesArrayName(); if (isset($properties[$attributesName])) { $properties[$attributesName] = $this->entityMap->getAttributeNam...
php
protected function hydrate() { $properties = $this->propertiesFromAttributes() + $this->unmanagedProperties; $attributesName = $this->entityMap->getAttributesArrayName(); if (isset($properties[$attributesName])) { $properties[$attributesName] = $this->entityMap->getAttributeNam...
[ "protected", "function", "hydrate", "(", ")", "{", "$", "properties", "=", "$", "this", "->", "propertiesFromAttributes", "(", ")", "+", "$", "this", "->", "unmanagedProperties", ";", "$", "attributesName", "=", "$", "this", "->", "entityMap", "->", "getAttr...
Hydrate object's properties/attribute from the internal array representation. @return void
[ "Hydrate", "object", "s", "properties", "/", "attribute", "from", "the", "internal", "array", "representation", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L189-L212
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.getManagedProperties
protected function getManagedProperties(): array { $properties = $this->entityMap->getProperties(); $attributesName = $this->entityMap->getAttributesArrayName(); return $attributesName == null ? $properties : array_merge($properties, [$attributesName]); }
php
protected function getManagedProperties(): array { $properties = $this->entityMap->getProperties(); $attributesName = $this->entityMap->getAttributesArrayName(); return $attributesName == null ? $properties : array_merge($properties, [$attributesName]); }
[ "protected", "function", "getManagedProperties", "(", ")", ":", "array", "{", "$", "properties", "=", "$", "this", "->", "entityMap", "->", "getProperties", "(", ")", ";", "$", "attributesName", "=", "$", "this", "->", "entityMap", "->", "getAttributesArrayNam...
Return properties that will be extracted from the entity. @return array
[ "Return", "properties", "that", "will", "be", "extracted", "from", "the", "entity", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L219-L226
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.attributesFromProperties
protected function attributesFromProperties(array $properties): array { // First, we'll only keep the entities that are part of the Entity's // attributes $managedProperties = $this->getManagedProperties(); $properties = array_only($properties, $managedProperties); // If th...
php
protected function attributesFromProperties(array $properties): array { // First, we'll only keep the entities that are part of the Entity's // attributes $managedProperties = $this->getManagedProperties(); $properties = array_only($properties, $managedProperties); // If th...
[ "protected", "function", "attributesFromProperties", "(", "array", "$", "properties", ")", ":", "array", "{", "// First, we'll only keep the entities that are part of the Entity's", "// attributes", "$", "managedProperties", "=", "$", "this", "->", "getManagedProperties", "("...
Convert object's properties to analogue's internal attributes representation. @param array $properties @throws MappingException @return array
[ "Convert", "object", "s", "properties", "to", "analogue", "s", "internal", "attributes", "representation", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L237-L266
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.propertiesFromAttributes
protected function propertiesFromAttributes(): array { // Get all managed properties $propertyNames = $this->entityMap->getProperties(); $propertyAttributes = array_only($this->attributes, $propertyNames); $attributesArray = array_except($this->attributes, $propertyNames); ...
php
protected function propertiesFromAttributes(): array { // Get all managed properties $propertyNames = $this->entityMap->getProperties(); $propertyAttributes = array_only($this->attributes, $propertyNames); $attributesArray = array_except($this->attributes, $propertyNames); ...
[ "protected", "function", "propertiesFromAttributes", "(", ")", ":", "array", "{", "// Get all managed properties", "$", "propertyNames", "=", "$", "this", "->", "entityMap", "->", "getProperties", "(", ")", ";", "$", "propertyAttributes", "=", "array_only", "(", "...
Convert internal representation of attributes to an array of properties that can hydrate the actual object. @return array
[ "Convert", "internal", "representation", "of", "attributes", "to", "an", "array", "of", "properties", "that", "can", "hydrate", "the", "actual", "object", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L274-L289
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.setEntityAttribute
public function setEntityAttribute(string $key, $value) { $this->attributes[$key] = $value; $this->touched = true; $this->hydrate(); }
php
public function setEntityAttribute(string $key, $value) { $this->attributes[$key] = $value; $this->touched = true; $this->hydrate(); }
[ "public", "function", "setEntityAttribute", "(", "string", "$", "key", ",", "$", "value", ")", "{", "$", "this", "->", "attributes", "[", "$", "key", "]", "=", "$", "value", ";", "$", "this", "->", "touched", "=", "true", ";", "$", "this", "->", "h...
{@inheritdoc}
[ "{" ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L311-L318
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.setProxies
public function setProxies(array $relations = null) { $attributes = $this->getEntityAttributes(); $proxies = []; $relations = $this->getRelationsToProxy(); // Before calling the relationship methods, we'll set the relationship // method to null, to avoid hydration error on ...
php
public function setProxies(array $relations = null) { $attributes = $this->getEntityAttributes(); $proxies = []; $relations = $this->getRelationsToProxy(); // Before calling the relationship methods, we'll set the relationship // method to null, to avoid hydration error on ...
[ "public", "function", "setProxies", "(", "array", "$", "relations", "=", "null", ")", "{", "$", "attributes", "=", "$", "this", "->", "getEntityAttributes", "(", ")", ";", "$", "proxies", "=", "[", "]", ";", "$", "relations", "=", "$", "this", "->", ...
Set the lazy loading proxies on the wrapped entity objet. @param array $relations list of relations to be lazy loaded @return void
[ "Set", "the", "lazy", "loading", "proxies", "on", "the", "wrapped", "entity", "objet", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L345-L378
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.getClassToProxy
protected function getClassToProxy($relation, array $attributes) { if ($this->entityMap->isPolymorphic($relation)) { $localTypeAttribute = $this->entityMap->getLocalKeys($relation)['type']; return $attributes[$localTypeAttribute]; } return $this->entityMap->getTarge...
php
protected function getClassToProxy($relation, array $attributes) { if ($this->entityMap->isPolymorphic($relation)) { $localTypeAttribute = $this->entityMap->getLocalKeys($relation)['type']; return $attributes[$localTypeAttribute]; } return $this->entityMap->getTarge...
[ "protected", "function", "getClassToProxy", "(", "$", "relation", ",", "array", "$", "attributes", ")", "{", "if", "(", "$", "this", "->", "entityMap", "->", "isPolymorphic", "(", "$", "relation", ")", ")", "{", "$", "localTypeAttribute", "=", "$", "this",...
Get Target class to proxy for a one to one. @param string $relation @param array $attributes @return string
[ "Get", "Target", "class", "to", "proxy", "for", "a", "one", "to", "one", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L388-L397
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.getRelationsToProxy
protected function getRelationsToProxy() { $proxies = []; $attributes = $this->getEntityAttributes(); foreach ($this->entityMap->getNonEmbeddedRelationships() as $relation) { //foreach ($this->entityMap->getRelationships() as $relation) { if (!array_key_exists($rela...
php
protected function getRelationsToProxy() { $proxies = []; $attributes = $this->getEntityAttributes(); foreach ($this->entityMap->getNonEmbeddedRelationships() as $relation) { //foreach ($this->entityMap->getRelationships() as $relation) { if (!array_key_exists($rela...
[ "protected", "function", "getRelationsToProxy", "(", ")", "{", "$", "proxies", "=", "[", "]", ";", "$", "attributes", "=", "$", "this", "->", "getEntityAttributes", "(", ")", ";", "foreach", "(", "$", "this", "->", "entityMap", "->", "getNonEmbeddedRelations...
Determine which relations we have to build proxy for, by parsing attributes and finding methods that aren't set. @return array
[ "Determine", "which", "relations", "we", "have", "to", "build", "proxy", "for", "by", "parsing", "attributes", "and", "finding", "methods", "that", "aren", "t", "set", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L405-L419
analogueorm/analogue
src/System/Wrappers/ObjectWrapper.php
ObjectWrapper.relationNeedsProxy
protected function relationNeedsProxy($relation, $attributes) { if (in_array($relation, $this->entityMap->getRelationshipsWithoutProxy())) { return false; } $localKey = $this->entityMap->getLocalKeys($relation); if (is_null($localKey)) { return true; ...
php
protected function relationNeedsProxy($relation, $attributes) { if (in_array($relation, $this->entityMap->getRelationshipsWithoutProxy())) { return false; } $localKey = $this->entityMap->getLocalKeys($relation); if (is_null($localKey)) { return true; ...
[ "protected", "function", "relationNeedsProxy", "(", "$", "relation", ",", "$", "attributes", ")", "{", "if", "(", "in_array", "(", "$", "relation", ",", "$", "this", "->", "entityMap", "->", "getRelationshipsWithoutProxy", "(", ")", ")", ")", "{", "return", ...
Determine if the relation needs a proxy or not. @param string $relation @param array $attributes @return bool
[ "Determine", "if", "the", "relation", "needs", "a", "proxy", "or", "not", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Wrappers/ObjectWrapper.php#L429-L450
analogueorm/analogue
src/System/Query.php
Query.findMany
public function findMany($id, $columns = ['*']) { if (empty($id)) { return new EntityCollection(); } $this->query->whereIn($this->entityMap->getKeyName(), $id); return $this->get($columns); }
php
public function findMany($id, $columns = ['*']) { if (empty($id)) { return new EntityCollection(); } $this->query->whereIn($this->entityMap->getKeyName(), $id); return $this->get($columns); }
[ "public", "function", "findMany", "(", "$", "id", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "if", "(", "empty", "(", "$", "id", ")", ")", "{", "return", "new", "EntityCollection", "(", ")", ";", "}", "$", "this", "->", "query", "->", ...
Find many entities by their primary keys. @param array $id @param array $columns @return \Illuminate\Support\Collection
[ "Find", "many", "entities", "by", "their", "primary", "keys", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L167-L176
analogueorm/analogue
src/System/Query.php
Query.findOrFail
public function findOrFail($id, $columns = ['*']) { if (!is_null($entity = $this->find($id, $columns))) { return $entity; } throw (new EntityNotFoundException())->setEntity(get_class($this->entityMap)); }
php
public function findOrFail($id, $columns = ['*']) { if (!is_null($entity = $this->find($id, $columns))) { return $entity; } throw (new EntityNotFoundException())->setEntity(get_class($this->entityMap)); }
[ "public", "function", "findOrFail", "(", "$", "id", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "if", "(", "!", "is_null", "(", "$", "entity", "=", "$", "this", "->", "find", "(", "$", "id", ",", "$", "columns", ")", ")", ")", "{", "...
Find a model by its primary key or throw an exception. @param mixed $id @param array $columns @throws \Analogue\ORM\Exceptions\EntityNotFoundException @return mixed|self
[ "Find", "a", "model", "by", "its", "primary", "key", "or", "throw", "an", "exception", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L188-L195
analogueorm/analogue
src/System/Query.php
Query.firstOrFail
public function firstOrFail($columns = ['*']) { if (!is_null($entity = $this->first($columns))) { return $entity; } throw (new EntityNotFoundException())->setEntity(get_class($this->entityMap)); }
php
public function firstOrFail($columns = ['*']) { if (!is_null($entity = $this->first($columns))) { return $entity; } throw (new EntityNotFoundException())->setEntity(get_class($this->entityMap)); }
[ "public", "function", "firstOrFail", "(", "$", "columns", "=", "[", "'*'", "]", ")", "{", "if", "(", "!", "is_null", "(", "$", "entity", "=", "$", "this", "->", "first", "(", "$", "columns", ")", ")", ")", "{", "return", "$", "entity", ";", "}", ...
Execute the query and get the first result or throw an exception. @param array $columns @throws EntityNotFoundException @return \Analogue\ORM\Entity
[ "Execute", "the", "query", "and", "get", "the", "first", "result", "or", "throw", "an", "exception", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L218-L225
analogueorm/analogue
src/System/Query.php
Query.paginate
public function paginate($perPage = null, $columns = ['*']) { $total = $this->query->getCountForPagination(); $this->query->forPage( $page = Paginator::resolveCurrentPage(), $perPage = $perPage ?: $this->entityMap->getPerPage() ); return new LengthAwareEntit...
php
public function paginate($perPage = null, $columns = ['*']) { $total = $this->query->getCountForPagination(); $this->query->forPage( $page = Paginator::resolveCurrentPage(), $perPage = $perPage ?: $this->entityMap->getPerPage() ); return new LengthAwareEntit...
[ "public", "function", "paginate", "(", "$", "perPage", "=", "null", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "total", "=", "$", "this", "->", "query", "->", "getCountForPagination", "(", ")", ";", "$", "this", "->", "query", "->", ...
Get a paginator for the "select" statement. @param int $perPage @param array $columns @return LengthAwareEntityPaginator
[ "Get", "a", "paginator", "for", "the", "select", "statement", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L272-L284
analogueorm/analogue
src/System/Query.php
Query.ungroupedPaginate
protected function ungroupedPaginate($paginator, $perPage, $columns) { $total = $this->query->getPaginationCount(); // Once we have the paginator we need to set the limit and offset values for // the query so we can get the properly paginated items. Once we have an // array of items...
php
protected function ungroupedPaginate($paginator, $perPage, $columns) { $total = $this->query->getPaginationCount(); // Once we have the paginator we need to set the limit and offset values for // the query so we can get the properly paginated items. Once we have an // array of items...
[ "protected", "function", "ungroupedPaginate", "(", "$", "paginator", ",", "$", "perPage", ",", "$", "columns", ")", "{", "$", "total", "=", "$", "this", "->", "query", "->", "getPaginationCount", "(", ")", ";", "// Once we have the paginator we need to set the lim...
Get a paginator for an ungrouped statement. @param \Illuminate\Pagination\Factory $paginator @param int $perPage @param array $columns @return \Illuminate\Pagination\Paginator
[ "Get", "a", "paginator", "for", "an", "ungrouped", "statement", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L311-L323
analogueorm/analogue
src/System/Query.php
Query.simplePaginate
public function simplePaginate($perPage = null, $columns = ['*']) { $page = Paginator::resolveCurrentPage(); $perPage = $perPage ?: $this->entityMap->getPerPage(); $this->skip(($page - 1) * $perPage)->take($perPage + 1); return new Paginator($this->get($columns)->all(), $perPage, ...
php
public function simplePaginate($perPage = null, $columns = ['*']) { $page = Paginator::resolveCurrentPage(); $perPage = $perPage ?: $this->entityMap->getPerPage(); $this->skip(($page - 1) * $perPage)->take($perPage + 1); return new Paginator($this->get($columns)->all(), $perPage, ...
[ "public", "function", "simplePaginate", "(", "$", "perPage", "=", "null", ",", "$", "columns", "=", "[", "'*'", "]", ")", "{", "$", "page", "=", "Paginator", "::", "resolveCurrentPage", "(", ")", ";", "$", "perPage", "=", "$", "perPage", "?", ":", "$...
Paginate the given query into a simple paginator. @param int $perPage @param array $columns @return \Illuminate\Contracts\Pagination\Paginator
[ "Paginate", "the", "given", "query", "into", "a", "simple", "paginator", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L333-L342
analogueorm/analogue
src/System/Query.php
Query.has
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) { $entity = $this->mapper->newInstance(); $relation = $this->getHasRelationQuery($relation, $entity); $query = $relation->getRelationCountQuery($relation->getRelatedMapper()->getQuery(), $this)...
php
public function has($relation, $operator = '>=', $count = 1, $boolean = 'and', $callback = null) { $entity = $this->mapper->newInstance(); $relation = $this->getHasRelationQuery($relation, $entity); $query = $relation->getRelationCountQuery($relation->getRelatedMapper()->getQuery(), $this)...
[ "public", "function", "has", "(", "$", "relation", ",", "$", "operator", "=", "'>='", ",", "$", "count", "=", "1", ",", "$", "boolean", "=", "'and'", ",", "$", "callback", "=", "null", ")", "{", "$", "entity", "=", "$", "this", "->", "mapper", "-...
Add a relationship count condition to the query. @param string $relation @param string $operator @param int $count @param string $boolean @param \Closure $callback @return \Analogue\ORM\System\Query
[ "Add", "a", "relationship", "count", "condition", "to", "the", "query", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L394-L407
analogueorm/analogue
src/System/Query.php
Query.addHasWhere
protected function addHasWhere(self $hasQuery, Relationship $relation, $operator, $count, $boolean) { $this->mergeWheresToHas($hasQuery, $relation); if (is_numeric($count)) { $count = new Expression($count); } return $this->where(new Expression('('.$hasQuery->toSql().')...
php
protected function addHasWhere(self $hasQuery, Relationship $relation, $operator, $count, $boolean) { $this->mergeWheresToHas($hasQuery, $relation); if (is_numeric($count)) { $count = new Expression($count); } return $this->where(new Expression('('.$hasQuery->toSql().')...
[ "protected", "function", "addHasWhere", "(", "self", "$", "hasQuery", ",", "Relationship", "$", "relation", ",", "$", "operator", ",", "$", "count", ",", "$", "boolean", ")", "{", "$", "this", "->", "mergeWheresToHas", "(", "$", "hasQuery", ",", "$", "re...
Add the "has" condition where clause to the query. @param \Analogue\ORM\System\Query $hasQuery @param \Analogue\ORM\Relationships\Relationship $relation @param string $operator @param int $count @param string ...
[ "Add", "the", "has", "condition", "where", "clause", "to", "the", "query", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L464-L473
analogueorm/analogue
src/System/Query.php
Query.mergeWheresToHas
protected function mergeWheresToHas(self $hasQuery, Relationship $relation) { // Here we have the "has" query and the original relation. We need to copy over any // where clauses the developer may have put in the relationship function over to // the has query, and then copy the bindings from...
php
protected function mergeWheresToHas(self $hasQuery, Relationship $relation) { // Here we have the "has" query and the original relation. We need to copy over any // where clauses the developer may have put in the relationship function over to // the has query, and then copy the bindings from...
[ "protected", "function", "mergeWheresToHas", "(", "self", "$", "hasQuery", ",", "Relationship", "$", "relation", ")", "{", "// Here we have the \"has\" query and the original relation. We need to copy over any", "// where clauses the developer may have put in the relationship function ov...
Merge the "wheres" from a relation query to a has query. @param \Analogue\ORM\System\Query $hasQuery @param \Analogue\ORM\Relationships\Relationship $relation @return void
[ "Merge", "the", "wheres", "from", "a", "relation", "query", "to", "a", "has", "query", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L483-L496
analogueorm/analogue
src/System/Query.php
Query.getHasRelationQuery
protected function getHasRelationQuery($relation, $entity) { return Relationship::noConstraints(function () use ($relation, $entity) { return $this->entityMap->$relation($entity); }); }
php
protected function getHasRelationQuery($relation, $entity) { return Relationship::noConstraints(function () use ($relation, $entity) { return $this->entityMap->$relation($entity); }); }
[ "protected", "function", "getHasRelationQuery", "(", "$", "relation", ",", "$", "entity", ")", "{", "return", "Relationship", "::", "noConstraints", "(", "function", "(", ")", "use", "(", "$", "relation", ",", "$", "entity", ")", "{", "return", "$", "this"...
Get the "has relation" base query instance. @param string $relation @param $entity @return \Analogue\ORM\System\Query
[ "Get", "the", "has", "relation", "base", "query", "instance", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L506-L511
analogueorm/analogue
src/System/Query.php
Query.enforceIdColumn
protected function enforceIdColumn($columns) { if (!in_array($this->entityMap->getKeyName(), $columns)) { $columns[] = $this->entityMap->getKeyName(); } return $columns; }
php
protected function enforceIdColumn($columns) { if (!in_array($this->entityMap->getKeyName(), $columns)) { $columns[] = $this->entityMap->getKeyName(); } return $columns; }
[ "protected", "function", "enforceIdColumn", "(", "$", "columns", ")", "{", "if", "(", "!", "in_array", "(", "$", "this", "->", "entityMap", "->", "getKeyName", "(", ")", ",", "$", "columns", ")", ")", "{", "$", "columns", "[", "]", "=", "$", "this", ...
Add the Entity primary key if not in requested columns. @param array $columns @return array
[ "Add", "the", "Entity", "primary", "key", "if", "not", "in", "requested", "columns", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L584-L591
analogueorm/analogue
src/System/Query.php
Query.getEntities
public function getEntities($columns = ['*']) { // As we need the primary key to feed the // entity cache, we need it loaded on each // request if ($columns !== ['*']) { $columns = $this->enforceIdColumn($columns); } // Run the query $results = $t...
php
public function getEntities($columns = ['*']) { // As we need the primary key to feed the // entity cache, we need it loaded on each // request if ($columns !== ['*']) { $columns = $this->enforceIdColumn($columns); } // Run the query $results = $t...
[ "public", "function", "getEntities", "(", "$", "columns", "=", "[", "'*'", "]", ")", "{", "// As we need the primary key to feed the", "// entity cache, we need it loaded on each", "// request", "if", "(", "$", "columns", "!==", "[", "'*'", "]", ")", "{", "$", "co...
Get the hydrated models without eager loading. @param array $columns @return \Illuminate\Support\Collection
[ "Get", "the", "hydrated", "models", "without", "eager", "loading", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L600-L614
analogueorm/analogue
src/System/Query.php
Query.newQuery
public function newQuery() { $builder = new self($this->mapper, $this->adapter); return $this->applyGlobalScopes($builder); }
php
public function newQuery() { $builder = new self($this->mapper, $this->adapter); return $this->applyGlobalScopes($builder); }
[ "public", "function", "newQuery", "(", ")", "{", "$", "builder", "=", "new", "self", "(", "$", "this", "->", "mapper", ",", "$", "this", "->", "adapter", ")", ";", "return", "$", "this", "->", "applyGlobalScopes", "(", "$", "builder", ")", ";", "}" ]
Get a new query builder for the model's table. @return \Analogue\ORM\System\Query
[ "Get", "a", "new", "query", "builder", "for", "the", "model", "s", "table", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/System/Query.php#L646-L651
analogueorm/analogue
src/Relationships/EmbeddedRelationship.php
EmbeddedRelationship.getEmbeddedObjectAttributes
protected function getEmbeddedObjectAttributes() : array { $entityMap = $this->getRelatedMapper()->getEntityMap(); $attributes = $entityMap->getAttributes(); $properties = $entityMap->getProperties(); return array_merge($attributes, $properties); }
php
protected function getEmbeddedObjectAttributes() : array { $entityMap = $this->getRelatedMapper()->getEntityMap(); $attributes = $entityMap->getAttributes(); $properties = $entityMap->getProperties(); return array_merge($attributes, $properties); }
[ "protected", "function", "getEmbeddedObjectAttributes", "(", ")", ":", "array", "{", "$", "entityMap", "=", "$", "this", "->", "getRelatedMapper", "(", ")", "->", "getEntityMap", "(", ")", ";", "$", "attributes", "=", "$", "entityMap", "->", "getAttributes", ...
Get the embedded object's attributes that will be hydrated using parent's entity attributes. @return array
[ "Get", "the", "embedded", "object", "s", "attributes", "that", "will", "be", "hydrated", "using", "parent", "s", "entity", "attributes", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/EmbeddedRelationship.php#L152-L160
analogueorm/analogue
src/Relationships/EmbeddedRelationship.php
EmbeddedRelationship.getMappedParentAttribute
protected function getMappedParentAttribute(string $key) : string { if (array_key_exists($key, $this->columnMap)) { return $this->columnMap[$key]; } else { return $key; } }
php
protected function getMappedParentAttribute(string $key) : string { if (array_key_exists($key, $this->columnMap)) { return $this->columnMap[$key]; } else { return $key; } }
[ "protected", "function", "getMappedParentAttribute", "(", "string", "$", "key", ")", ":", "string", "{", "if", "(", "array_key_exists", "(", "$", "key", ",", "$", "this", "->", "columnMap", ")", ")", "{", "return", "$", "this", "->", "columnMap", "[", "$...
Get attribute name from the parent, if a map has been defined. @param string $key @return string
[ "Get", "attribute", "name", "from", "the", "parent", "if", "a", "map", "has", "been", "defined", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/EmbeddedRelationship.php#L182-L189
analogueorm/analogue
src/Relationships/EmbeddedRelationship.php
EmbeddedRelationship.buildEmbeddedObject
protected function buildEmbeddedObject(array $attributes) { $resultBuilder = new ResultBuilder($this->getRelatedMapper(), true); // TODO : find a way to support eager load within an embedded // object. $eagerLoads = []; return $resultBuilder->build([$attributes], $eagerLoad...
php
protected function buildEmbeddedObject(array $attributes) { $resultBuilder = new ResultBuilder($this->getRelatedMapper(), true); // TODO : find a way to support eager load within an embedded // object. $eagerLoads = []; return $resultBuilder->build([$attributes], $eagerLoad...
[ "protected", "function", "buildEmbeddedObject", "(", "array", "$", "attributes", ")", "{", "$", "resultBuilder", "=", "new", "ResultBuilder", "(", "$", "this", "->", "getRelatedMapper", "(", ")", ",", "true", ")", ";", "// TODO : find a way to support eager load wit...
Build an embedded object instance. @param array $attributes @return mixed
[ "Build", "an", "embedded", "object", "instance", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/EmbeddedRelationship.php#L218-L227
analogueorm/analogue
src/Plugins/SoftDeletes/Restore.php
Restore.execute
public function execute() { $aggregate = $this->aggregate; $entity = $aggregate->getEntityObject(); $mapper = $aggregate->getMapper(); $entityMap = $mapper->getEntityMap(); if ($mapper->fireEvent('restoring', $entity) === false) { return false; } ...
php
public function execute() { $aggregate = $this->aggregate; $entity = $aggregate->getEntityObject(); $mapper = $aggregate->getMapper(); $entityMap = $mapper->getEntityMap(); if ($mapper->fireEvent('restoring', $entity) === false) { return false; } ...
[ "public", "function", "execute", "(", ")", "{", "$", "aggregate", "=", "$", "this", "->", "aggregate", ";", "$", "entity", "=", "$", "aggregate", "->", "getEntityObject", "(", ")", ";", "$", "mapper", "=", "$", "aggregate", "->", "getMapper", "(", ")",...
@throws \InvalidArgumentException @return false|mixed
[ "@throws", "\\", "InvalidArgumentException" ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Plugins/SoftDeletes/Restore.php#L14-L40
analogueorm/analogue
src/Relationships/MorphToMany.php
MorphToMany.setWhere
protected function setWhere() { parent::setWhere(); $this->query->where($this->table.'.'.$this->morphType, $this->morphClass); return $this; }
php
protected function setWhere() { parent::setWhere(); $this->query->where($this->table.'.'.$this->morphType, $this->morphClass); return $this; }
[ "protected", "function", "setWhere", "(", ")", "{", "parent", "::", "setWhere", "(", ")", ";", "$", "this", "->", "query", "->", "where", "(", "$", "this", "->", "table", ".", "'.'", ".", "$", "this", "->", "morphType", ",", "$", "this", "->", "mor...
Set the where clause for the relation query. @return self
[ "Set", "the", "where", "clause", "for", "the", "relation", "query", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/MorphToMany.php#L63-L70
analogueorm/analogue
src/Relationships/MorphToMany.php
MorphToMany.getRelationCountQuery
public function getRelationCountQuery(Query $query, Query $parent) { $query = parent::getRelationCountQuery($query, $parent); return $query->where($this->table.'.'.$this->morphType, $this->morphClass); }
php
public function getRelationCountQuery(Query $query, Query $parent) { $query = parent::getRelationCountQuery($query, $parent); return $query->where($this->table.'.'.$this->morphType, $this->morphClass); }
[ "public", "function", "getRelationCountQuery", "(", "Query", "$", "query", ",", "Query", "$", "parent", ")", "{", "$", "query", "=", "parent", "::", "getRelationCountQuery", "(", "$", "query", ",", "$", "parent", ")", ";", "return", "$", "query", "->", "...
Add the constraints for a relationship count query. @param Query $query @param Query $parent @return Query
[ "Add", "the", "constraints", "for", "a", "relationship", "count", "query", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/MorphToMany.php#L80-L85
analogueorm/analogue
src/Relationships/MorphToMany.php
MorphToMany.createAttachRecord
protected function createAttachRecord($id, $timed) { $record = parent::createAttachRecord($id, $timed); return array_add($record, $this->morphType, $this->morphClass); }
php
protected function createAttachRecord($id, $timed) { $record = parent::createAttachRecord($id, $timed); return array_add($record, $this->morphType, $this->morphClass); }
[ "protected", "function", "createAttachRecord", "(", "$", "id", ",", "$", "timed", ")", "{", "$", "record", "=", "parent", "::", "createAttachRecord", "(", "$", "id", ",", "$", "timed", ")", ";", "return", "array_add", "(", "$", "record", ",", "$", "thi...
Create a new pivot attachment record. @param int $id @param bool $timed @return array
[ "Create", "a", "new", "pivot", "attachment", "record", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/MorphToMany.php#L109-L114
analogueorm/analogue
src/Relationships/MorphToMany.php
MorphToMany.newPivotQuery
protected function newPivotQuery() { $query = parent::newPivotQuery(); return $query->where($this->morphType, $this->morphClass); }
php
protected function newPivotQuery() { $query = parent::newPivotQuery(); return $query->where($this->morphType, $this->morphClass); }
[ "protected", "function", "newPivotQuery", "(", ")", "{", "$", "query", "=", "parent", "::", "newPivotQuery", "(", ")", ";", "return", "$", "query", "->", "where", "(", "$", "this", "->", "morphType", ",", "$", "this", "->", "morphClass", ")", ";", "}" ...
Create a new query builder for the pivot table. @throws \InvalidArgumentException @return \Illuminate\Database\Query\Builder
[ "Create", "a", "new", "query", "builder", "for", "the", "pivot", "table", "." ]
train
https://github.com/analogueorm/analogue/blob/b12cdea1d78d33923b9986f5413ca6e133302c87/src/Relationships/MorphToMany.php#L123-L128