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
kgilden/php-digidoc
src/X509/Signature.php
Signature.isSignedByKey
public function isSignedByKey($key) { $result = openssl_verify($this->bytesSigned, $this->signature, $key, $this->algorithm); if (1 === $result) { return true; } if (0 === $result) { return false; } throw new \RuntimeException(openssl_error_string()); }
php
public function isSignedByKey($key) { $result = openssl_verify($this->bytesSigned, $this->signature, $key, $this->algorithm); if (1 === $result) { return true; } if (0 === $result) { return false; } throw new \RuntimeException(openssl_error_string()); }
[ "public", "function", "isSignedByKey", "(", "$", "key", ")", "{", "$", "result", "=", "openssl_verify", "(", "$", "this", "->", "bytesSigned", ",", "$", "this", "->", "signature", ",", "$", "key", ",", "$", "this", "->", "algorithm", ")", ";", "if", ...
@see http://php.net/manual/en/function.openssl-get-publickey.php @param resource $key Public key corresponding to the private key used for signing @return boolean Whether the signature was signed by the given key @throws \RuntimeException If an error occurred during verification
[ "@see", "http", ":", "//", "php", ".", "net", "/", "manual", "/", "en", "/", "function", ".", "openssl", "-", "get", "-", "publickey", ".", "php" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/X509/Signature.php#L71-L84
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.getAdapterFactoryClass
public function getAdapterFactoryClass() { $config = config('jwt'); if (!isset($config['adapter'])) { $config['adapter'] = 'lcobucci'; } if (class_exists($config['adapter'])) { $factoryClass = $config['adapter']; } else { $factoryClass = 'Canis\Lumen\Jwt\Adapters\\' . ucfirst($config['adapter']) . '\Factory'; if (!class_exists($factoryClass)) { throw new InvalidAdapterException("{$config['adapter']} is not available"); } } return $factoryClass; }
php
public function getAdapterFactoryClass() { $config = config('jwt'); if (!isset($config['adapter'])) { $config['adapter'] = 'lcobucci'; } if (class_exists($config['adapter'])) { $factoryClass = $config['adapter']; } else { $factoryClass = 'Canis\Lumen\Jwt\Adapters\\' . ucfirst($config['adapter']) . '\Factory'; if (!class_exists($factoryClass)) { throw new InvalidAdapterException("{$config['adapter']} is not available"); } } return $factoryClass; }
[ "public", "function", "getAdapterFactoryClass", "(", ")", "{", "$", "config", "=", "config", "(", "'jwt'", ")", ";", "if", "(", "!", "isset", "(", "$", "config", "[", "'adapter'", "]", ")", ")", "{", "$", "config", "[", "'adapter'", "]", "=", "'lcobu...
Returns the adapter class name to use @return string
[ "Returns", "the", "adapter", "class", "name", "to", "use" ]
train
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L65-L80
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.getAdapterFactory
protected function getAdapterFactory() { if (!isset($this->factoryCache[$this->id])) { $config = config('jwt'); if (isset($this->config['adapter'])) { $config = array_merge($config, $this->config['adapter']); } $factoryClass = $this->getAdapterFactoryClass(); $this->factoryCache[$this->id] = new $factoryClass($config); } return $this->factoryCache[$this->id]; }
php
protected function getAdapterFactory() { if (!isset($this->factoryCache[$this->id])) { $config = config('jwt'); if (isset($this->config['adapter'])) { $config = array_merge($config, $this->config['adapter']); } $factoryClass = $this->getAdapterFactoryClass(); $this->factoryCache[$this->id] = new $factoryClass($config); } return $this->factoryCache[$this->id]; }
[ "protected", "function", "getAdapterFactory", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "factoryCache", "[", "$", "this", "->", "id", "]", ")", ")", "{", "$", "config", "=", "config", "(", "'jwt'", ")", ";", "if", "(", "isset"...
Returns the adapter factory object @return AdapterFactoryContract
[ "Returns", "the", "adapter", "factory", "object" ]
train
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L87-L98
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.hasValidCredentials
protected function hasValidCredentials($user, $credentials) { return !is_null($user) && $this->getProvider()->validateCredentials($user, $credentials); }
php
protected function hasValidCredentials($user, $credentials) { return !is_null($user) && $this->getProvider()->validateCredentials($user, $credentials); }
[ "protected", "function", "hasValidCredentials", "(", "$", "user", ",", "$", "credentials", ")", "{", "return", "!", "is_null", "(", "$", "user", ")", "&&", "$", "this", "->", "getProvider", "(", ")", "->", "validateCredentials", "(", "$", "user", ",", "$...
Determine if the user matches the credentials. @param Authenticatable|null $user @param array $credentials @return bool
[ "Determine", "if", "the", "user", "matches", "the", "credentials", "." ]
train
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L183-L186
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.attempt
public function attempt(array $credentials = [], $login = true) { $user = $this->getProvider()->retrieveByCredentials($credentials); if ($user instanceof Authenticatable && $this->hasValidCredentials($user, $credentials)) { if ($login === true) { $this->login($user); } if (!($user instanceof SubjectContract)) { throw new InvalidTokenException("Unable to generate token"); } return $this->generateToken($user); } return false; }
php
public function attempt(array $credentials = [], $login = true) { $user = $this->getProvider()->retrieveByCredentials($credentials); if ($user instanceof Authenticatable && $this->hasValidCredentials($user, $credentials)) { if ($login === true) { $this->login($user); } if (!($user instanceof SubjectContract)) { throw new InvalidTokenException("Unable to generate token"); } return $this->generateToken($user); } return false; }
[ "public", "function", "attempt", "(", "array", "$", "credentials", "=", "[", "]", ",", "$", "login", "=", "true", ")", "{", "$", "user", "=", "$", "this", "->", "getProvider", "(", ")", "->", "retrieveByCredentials", "(", "$", "credentials", ")", ";", ...
Attempt to authenticate a user using the given credentials. @param array $credentials @param boolean $login @return bool|Token
[ "Attempt", "to", "authenticate", "a", "user", "using", "the", "given", "credentials", "." ]
train
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L215-L228
canis-io/lumen-jwt-auth
src/BaseGuard.php
BaseGuard.generateToken
protected function generateToken(SubjectContract $user) { $tokenGenerator = $this->getGenerator(); $claims = $user->getJWTClaims(); $claims['sub'] = $user->getJWTSubject(); $claims[static::JWT_GUARD_CLAIM] = $this->id; if (!($token = $tokenGenerator($claims))) { throw new InvalidTokenException("Unable to generate token"); } return $token; }
php
protected function generateToken(SubjectContract $user) { $tokenGenerator = $this->getGenerator(); $claims = $user->getJWTClaims(); $claims['sub'] = $user->getJWTSubject(); $claims[static::JWT_GUARD_CLAIM] = $this->id; if (!($token = $tokenGenerator($claims))) { throw new InvalidTokenException("Unable to generate token"); } return $token; }
[ "protected", "function", "generateToken", "(", "SubjectContract", "$", "user", ")", "{", "$", "tokenGenerator", "=", "$", "this", "->", "getGenerator", "(", ")", ";", "$", "claims", "=", "$", "user", "->", "getJWTClaims", "(", ")", ";", "$", "claims", "[...
Generate a new token @param SubjectContract $user @return Token
[ "Generate", "a", "new", "token" ]
train
https://github.com/canis-io/lumen-jwt-auth/blob/5e1a76a9878ec58348a76aeea382e6cb9c104ef9/src/BaseGuard.php#L257-L267
tableau-mkt/elomentary
src/Api/Assets/CustomObject.php
CustomObject.show
public function show($id, $depth = 'complete', $extensions = NULL) { return $this->get('assets/customObject/' . rawurlencode($id), array( 'depth' => $depth, )); }
php
public function show($id, $depth = 'complete', $extensions = NULL) { return $this->get('assets/customObject/' . rawurlencode($id), array( 'depth' => $depth, )); }
[ "public", "function", "show", "(", "$", "id", ",", "$", "depth", "=", "'complete'", ",", "$", "extensions", "=", "NULL", ")", "{", "return", "$", "this", "->", "get", "(", "'assets/customObject/'", ".", "rawurlencode", "(", "$", "id", ")", ",", "array"...
{@inheritdoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/CustomObject.php#L42-L46
tableau-mkt/elomentary
src/Api/Assets/CustomObject.php
CustomObject.update
public function update($id, $customObject_meta) { if (!isset($customObject_meta['id']) or $customObject_meta['id'] != $id) { throw new InvalidArgumentException('An id parameter must be included in the custom object definition, and it must match the id passed as the first parameter.'); } return $this->put('assets/customObject/' . rawurldecode($id), $customObject_meta); }
php
public function update($id, $customObject_meta) { if (!isset($customObject_meta['id']) or $customObject_meta['id'] != $id) { throw new InvalidArgumentException('An id parameter must be included in the custom object definition, and it must match the id passed as the first parameter.'); } return $this->put('assets/customObject/' . rawurldecode($id), $customObject_meta); }
[ "public", "function", "update", "(", "$", "id", ",", "$", "customObject_meta", ")", "{", "if", "(", "!", "isset", "(", "$", "customObject_meta", "[", "'id'", "]", ")", "or", "$", "customObject_meta", "[", "'id'", "]", "!=", "$", "id", ")", "{", "thro...
{@inheritdoc} Eloqua will return an object validation error if nothing is changed in the update. Eloqua will return an error if the object->id does not match the $id value in the signature.
[ "{", "@inheritdoc", "}" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/CustomObject.php#L58-L64
tableau-mkt/elomentary
src/Api/Assets/CustomObject.php
CustomObject.create
public function create($customObject_meta) { $this->validateExists($customObject_meta, 'name'); if (isset($customObject_meta['fields'])) { foreach ($customObject_meta['fields'] as $field) { $this->validateExists($field, 'dataType'); $this->validateExists($field, 'name'); } } return $this->post('assets/customObject', $customObject_meta); }
php
public function create($customObject_meta) { $this->validateExists($customObject_meta, 'name'); if (isset($customObject_meta['fields'])) { foreach ($customObject_meta['fields'] as $field) { $this->validateExists($field, 'dataType'); $this->validateExists($field, 'name'); } } return $this->post('assets/customObject', $customObject_meta); }
[ "public", "function", "create", "(", "$", "customObject_meta", ")", "{", "$", "this", "->", "validateExists", "(", "$", "customObject_meta", ",", "'name'", ")", ";", "if", "(", "isset", "(", "$", "customObject_meta", "[", "'fields'", "]", ")", ")", "{", ...
{@inheritdoc} @throws InvalidArgumentException @see http://topliners.eloqua.com/docs/DOC-3097
[ "{", "@inheritdoc", "}" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/CustomObject.php#L72-L83
tableau-mkt/elomentary
src/Api/Assets/CustomObject.php
CustomObject.data
public function data($customObjectId) { if ($this->client->getOption('version') != '1.0') { throw new \Exception("Accessing customObject data is currently only supported with the Rest API v1.0"); } return new \Eloqua\Api\Data\CustomObject($this->client, $customObjectId); }
php
public function data($customObjectId) { if ($this->client->getOption('version') != '1.0') { throw new \Exception("Accessing customObject data is currently only supported with the Rest API v1.0"); } return new \Eloqua\Api\Data\CustomObject($this->client, $customObjectId); }
[ "public", "function", "data", "(", "$", "customObjectId", ")", "{", "if", "(", "$", "this", "->", "client", "->", "getOption", "(", "'version'", ")", "!=", "'1.0'", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Accessing customObject data is currently o...
Gets custom object data API @param number $customObjectId The custom object ID from which you're trying to interface with @throws \Exception Accessing custom object data is currently only possible with the 1.0 API. See http://topliners.eloqua.com/thread/13397 for more information. @return \Eloqua\Api\Data\CustomObject
[ "Gets", "custom", "object", "data", "API" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Assets/CustomObject.php#L104-L110
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setCTA
public function setCTA(\CampaignChain\CoreBundle\Entity\CTA $CTA) { $this->CTA = $CTA; return $this; }
php
public function setCTA(\CampaignChain\CoreBundle\Entity\CTA $CTA) { $this->CTA = $CTA; return $this; }
[ "public", "function", "setCTA", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "CTA", "$", "CTA", ")", "{", "$", "this", "->", "CTA", "=", "$", "CTA", ";", "return", "$", "this", ";", "}" ]
Set CTA @param \CampaignChain\CoreBundle\Entity\CTA $CTA @return ReportCTA
[ "Set", "CTA" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L156-L161
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setOperation
public function setOperation(\CampaignChain\CoreBundle\Entity\Operation $operation) { $this->operation = $operation; return $this; }
php
public function setOperation(\CampaignChain\CoreBundle\Entity\Operation $operation) { $this->operation = $operation; return $this; }
[ "public", "function", "setOperation", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Operation", "$", "operation", ")", "{", "$", "this", "->", "operation", "=", "$", "operation", ";", "return", "$", "this", ";", "}" ]
Set Operation @param \CampaignChain\CoreBundle\Entity\Operation $operation @return ReportCTA
[ "Set", "Operation" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L179-L184
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setActivity
public function setActivity(\CampaignChain\CoreBundle\Entity\Activity $activity) { $this->activity = $activity; return $this; }
php
public function setActivity(\CampaignChain\CoreBundle\Entity\Activity $activity) { $this->activity = $activity; return $this; }
[ "public", "function", "setActivity", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Activity", "$", "activity", ")", "{", "$", "this", "->", "activity", "=", "$", "activity", ";", "return", "$", "this", ";", "}" ]
Set Activity @param \CampaignChain\CoreBundle\Entity\Activity $activity @return ReportCTA
[ "Set", "Activity" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L202-L207
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setChannel
public function setChannel(\CampaignChain\CoreBundle\Entity\Channel $channel) { $this->channel = $channel; return $this; }
php
public function setChannel(\CampaignChain\CoreBundle\Entity\Channel $channel) { $this->channel = $channel; return $this; }
[ "public", "function", "setChannel", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Channel", "$", "channel", ")", "{", "$", "this", "->", "channel", "=", "$", "channel", ";", "return", "$", "this", ";", "}" ]
Set Channel @param \CampaignChain\CoreBundle\Entity\Channel $channel @return ReportCTA
[ "Set", "Channel" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L248-L253
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setSourceLocation
public function setSourceLocation(\CampaignChain\CoreBundle\Entity\Location $sourceLocation) { $this->sourceLocation = $sourceLocation; return $this; }
php
public function setSourceLocation(\CampaignChain\CoreBundle\Entity\Location $sourceLocation) { $this->sourceLocation = $sourceLocation; return $this; }
[ "public", "function", "setSourceLocation", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Location", "$", "sourceLocation", ")", "{", "$", "this", "->", "sourceLocation", "=", "$", "sourceLocation", ";", "return", "$", "this", ";", "}" ...
Set sourceLocation @param \CampaignChain\CoreBundle\Entity\Location $sourceLocation @return ReportCTA
[ "Set", "sourceLocation" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L363-L368
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setTargetLocation
public function setTargetLocation(\CampaignChain\CoreBundle\Entity\Location $targetLocation = null) { $this->targetLocation = $targetLocation; return $this; }
php
public function setTargetLocation(\CampaignChain\CoreBundle\Entity\Location $targetLocation = null) { $this->targetLocation = $targetLocation; return $this; }
[ "public", "function", "setTargetLocation", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Location", "$", "targetLocation", "=", "null", ")", "{", "$", "this", "->", "targetLocation", "=", "$", "targetLocation", ";", "return", "$", "thi...
Set targetLocation @param \CampaignChain\CoreBundle\Entity\Location $targetLocation @return ReportCTA
[ "Set", "targetLocation" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L386-L391
CampaignChain/core
Entity/ReportCTA.php
ReportCTA.setReferrerLocation
public function setReferrerLocation(\CampaignChain\CoreBundle\Entity\Location $referrerLocation) { $this->referrerLocation = $referrerLocation; return $this; }
php
public function setReferrerLocation(\CampaignChain\CoreBundle\Entity\Location $referrerLocation) { $this->referrerLocation = $referrerLocation; return $this; }
[ "public", "function", "setReferrerLocation", "(", "\\", "CampaignChain", "\\", "CoreBundle", "\\", "Entity", "\\", "Location", "$", "referrerLocation", ")", "{", "$", "this", "->", "referrerLocation", "=", "$", "referrerLocation", ";", "return", "$", "this", ";"...
Set referrerLocation @param \CampaignChain\CoreBundle\Entity\Location $referrerLocation @return ReportCTA
[ "Set", "referrerLocation" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/ReportCTA.php#L455-L460
CampaignChain/core
Controller/LocationController.php
LocationController.apiListActivitiesAction
public function apiListActivitiesAction(Request $request, $id){ $location = $this->getDoctrine() ->getRepository('CampaignChainCoreBundle:Location') ->find($id); if (!$location) { throw new \Exception( 'No channel found for id '.$id ); } // Get the modules of type "activity" that are related to the channel. $activityModules = $location->getChannel()->getChannelModule()->getActivityModules(); $response = array(); // TODO: Check whether there are any activity modules. // if($activityModules->count()){ foreach($activityModules as $activityModule){ $response[] = array( 'id' => $activityModule->getId(), 'display_name' => $activityModule->getDisplayName(), 'name' => $activityModule->getIdentifier(), ); } // } $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize($response, 'json')); }
php
public function apiListActivitiesAction(Request $request, $id){ $location = $this->getDoctrine() ->getRepository('CampaignChainCoreBundle:Location') ->find($id); if (!$location) { throw new \Exception( 'No channel found for id '.$id ); } // Get the modules of type "activity" that are related to the channel. $activityModules = $location->getChannel()->getChannelModule()->getActivityModules(); $response = array(); // TODO: Check whether there are any activity modules. // if($activityModules->count()){ foreach($activityModules as $activityModule){ $response[] = array( 'id' => $activityModule->getId(), 'display_name' => $activityModule->getDisplayName(), 'name' => $activityModule->getIdentifier(), ); } // } $serializer = $this->get('campaignchain.core.serializer.default'); return new Response($serializer->serialize($response, 'json')); }
[ "public", "function", "apiListActivitiesAction", "(", "Request", "$", "request", ",", "$", "id", ")", "{", "$", "location", "=", "$", "this", "->", "getDoctrine", "(", ")", "->", "getRepository", "(", "'CampaignChainCoreBundle:Location'", ")", "->", "find", "(...
Get the Activity modules that are available for a Location. @ApiDoc( section = "Core", views = { "private" }, requirements={ { "name"="id", "requirement"="\d+" } } ) @param Request $request @param $id Location ID @return Response @throws \Exception
[ "Get", "the", "Activity", "modules", "that", "are", "available", "for", "a", "Location", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/LocationController.php#L77-L107
prooph/link-process-manager
src/Projection/Log/ProcessLogFinder.php
ProcessLogFinder.getLastLoggedProcesses
public function getLastLoggedProcesses($offset = 0, $limit = 10) { Assertion::integer($offset); Assertion::integer($limit); $query = $this->connection->createQueryBuilder(); $query->select('*')->from(Tables::PROCESS_LOG)->orderBy('started_at', 'DESC')->setFirstResult($offset)->setMaxResults($limit); return $query->execute()->fetchAll(); }
php
public function getLastLoggedProcesses($offset = 0, $limit = 10) { Assertion::integer($offset); Assertion::integer($limit); $query = $this->connection->createQueryBuilder(); $query->select('*')->from(Tables::PROCESS_LOG)->orderBy('started_at', 'DESC')->setFirstResult($offset)->setMaxResults($limit); return $query->execute()->fetchAll(); }
[ "public", "function", "getLastLoggedProcesses", "(", "$", "offset", "=", "0", ",", "$", "limit", "=", "10", ")", "{", "Assertion", "::", "integer", "(", "$", "offset", ")", ";", "Assertion", "::", "integer", "(", "$", "limit", ")", ";", "$", "query", ...
Orders process logs by started_at DESC Returns array of process log entry arrays. Each process log contains the information: - process_id => UUID string - status => running|succeed|failed - start_message => string|null - started_at => \DateTime::ISO8601 formatted - finished_at => \DateTime::ISO8601 formatted @param int $offset @param int $limit @return array
[ "Orders", "process", "logs", "by", "started_at", "DESC", "Returns", "array", "of", "process", "log", "entry", "arrays", ".", "Each", "process", "log", "contains", "the", "information", ":" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Projection/Log/ProcessLogFinder.php#L46-L56
prooph/link-process-manager
src/Projection/Log/ProcessLogFinder.php
ProcessLogFinder.getLogsTriggeredBy
public function getLogsTriggeredBy($startMessage) { $query = $this->connection->createQueryBuilder(); $query->select('*')->from(Tables::PROCESS_LOG) ->where('start_message = :start_message') ->orderBy('started_at', 'DESC') ->setParameter('start_message', $startMessage); return $query->execute()->fetchAll(); }
php
public function getLogsTriggeredBy($startMessage) { $query = $this->connection->createQueryBuilder(); $query->select('*')->from(Tables::PROCESS_LOG) ->where('start_message = :start_message') ->orderBy('started_at', 'DESC') ->setParameter('start_message', $startMessage); return $query->execute()->fetchAll(); }
[ "public", "function", "getLogsTriggeredBy", "(", "$", "startMessage", ")", "{", "$", "query", "=", "$", "this", "->", "connection", "->", "createQueryBuilder", "(", ")", ";", "$", "query", "->", "select", "(", "'*'", ")", "->", "from", "(", "Tables", "::...
Get logs triggered by given start message Orders the logs by started_at DESC @param string $startMessage @return array
[ "Get", "logs", "triggered", "by", "given", "start", "message", "Orders", "the", "logs", "by", "started_at", "DESC" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Projection/Log/ProcessLogFinder.php#L82-L92
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.create
public static function create($transactionID, $sum, $params = []) { $transaction = new self; $transaction->setTransactionID($transactionID) ->setSum($sum) ->setCurrency(PaymentHandlerBase::DEFAULT_CURRENCY) ->setLanguage(PaymentHandlerBase::DEFAULT_LANGUAGE); foreach ($params as $key => $value) { $transaction->params[$key] = $value; } return $transaction; }
php
public static function create($transactionID, $sum, $params = []) { $transaction = new self; $transaction->setTransactionID($transactionID) ->setSum($sum) ->setCurrency(PaymentHandlerBase::DEFAULT_CURRENCY) ->setLanguage(PaymentHandlerBase::DEFAULT_LANGUAGE); foreach ($params as $key => $value) { $transaction->params[$key] = $value; } return $transaction; }
[ "public", "static", "function", "create", "(", "$", "transactionID", ",", "$", "sum", ",", "$", "params", "=", "[", "]", ")", "{", "$", "transaction", "=", "new", "self", ";", "$", "transaction", "->", "setTransactionID", "(", "$", "transactionID", ")", ...
Create a new transaction object @param mixed $transactionID @param float $sum @param array $params @return self
[ "Create", "a", "new", "transaction", "object" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L51-L63
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.setSum
public function setSum($sum) { $sum = (float)str_replace(',', '.', $sum); $this->params['sum'] = $sum; return $this; }
php
public function setSum($sum) { $sum = (float)str_replace(',', '.', $sum); $this->params['sum'] = $sum; return $this; }
[ "public", "function", "setSum", "(", "$", "sum", ")", "{", "$", "sum", "=", "(", "float", ")", "str_replace", "(", "','", ",", "'.'", ",", "$", "sum", ")", ";", "$", "this", "->", "params", "[", "'sum'", "]", "=", "$", "sum", ";", "return", "$"...
Set the transaction sum @param float $sum @return Transaction
[ "Set", "the", "transaction", "sum" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L95-L100
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.setTransactionId
public function setTransactionId($transactionId) { if (is_numeric($transactionId) || $transactionId === false) { $this->params['transactionId'] = $transactionId; return $this; } throw new Exception("Please use a numeric value for transaction ID"); }
php
public function setTransactionId($transactionId) { if (is_numeric($transactionId) || $transactionId === false) { $this->params['transactionId'] = $transactionId; return $this; } throw new Exception("Please use a numeric value for transaction ID"); }
[ "public", "function", "setTransactionId", "(", "$", "transactionId", ")", "{", "if", "(", "is_numeric", "(", "$", "transactionId", ")", "||", "$", "transactionId", "===", "false", ")", "{", "$", "this", "->", "params", "[", "'transactionId'", "]", "=", "$"...
Set the transaction ID @param int $transactionId @throws \opus\payment\Exception If transaction ID is not numeric @return Transaction
[ "Set", "the", "transaction", "ID" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L109-L116
opus-online/yii2-payment
lib/services/payment/Transaction.php
Transaction.setReference
public function setReference($reference = null) { $reference === null && $reference = PaymentHelper::generateReference($this->getTransactionId()); $this->params['reference'] = $reference; return $this; }
php
public function setReference($reference = null) { $reference === null && $reference = PaymentHelper::generateReference($this->getTransactionId()); $this->params['reference'] = $reference; return $this; }
[ "public", "function", "setReference", "(", "$", "reference", "=", "null", ")", "{", "$", "reference", "===", "null", "&&", "$", "reference", "=", "PaymentHelper", "::", "generateReference", "(", "$", "this", "->", "getTransactionId", "(", ")", ")", ";", "$...
Sets the payment reference @param mixed $reference If NULL, the reference will be generated automatically from Transaction ID @return Transaction
[ "Sets", "the", "payment", "reference" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/services/payment/Transaction.php#L144-L149
Deathnerd/php-wtforms
src/fields/core/DateField.php
DateField.processFormData
public function processFormData(array $valuelist) { if ($valuelist) { $date_str = implode(" ", $valuelist); try { $this->data = Carbon::createFromFormat($this->carbon_format, $date_str)->startOfDay(); } catch (\Exception $e) { $this->data = null; // Do not create a process error if this is an optional field if (!empty($date_str) && !$this->flags->optional) { throw new ValueError("Not a valid date value"); } } } }
php
public function processFormData(array $valuelist) { if ($valuelist) { $date_str = implode(" ", $valuelist); try { $this->data = Carbon::createFromFormat($this->carbon_format, $date_str)->startOfDay(); } catch (\Exception $e) { $this->data = null; // Do not create a process error if this is an optional field if (!empty($date_str) && !$this->flags->optional) { throw new ValueError("Not a valid date value"); } } } }
[ "public", "function", "processFormData", "(", "array", "$", "valuelist", ")", "{", "if", "(", "$", "valuelist", ")", "{", "$", "date_str", "=", "implode", "(", "\" \"", ",", "$", "valuelist", ")", ";", "try", "{", "$", "this", "->", "data", "=", "Car...
@param array $valuelist @throws ValueError
[ "@param", "array", "$valuelist" ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/fields/core/DateField.php#L28-L42
ionux/phactor
src/GMP.php
GMP.mod
public function mod($a, $b, $correct = false) { if ($correct === true) { if (gmp_cmp($a, '0') < 0) { return gmp_strval(gmp_sub(gmp_mod($a, $b), $a)); } } return gmp_strval(gmp_mod($a, $b)); }
php
public function mod($a, $b, $correct = false) { if ($correct === true) { if (gmp_cmp($a, '0') < 0) { return gmp_strval(gmp_sub(gmp_mod($a, $b), $a)); } } return gmp_strval(gmp_mod($a, $b)); }
[ "public", "function", "mod", "(", "$", "a", ",", "$", "b", ",", "$", "correct", "=", "false", ")", "{", "if", "(", "$", "correct", "===", "true", ")", "{", "if", "(", "gmp_cmp", "(", "$", "a", ",", "'0'", ")", "<", "0", ")", "{", "return", ...
Calculates the modulo of two numbers. There's a slight quirk in GMP's implementation so this returns a mathematically correct answer if you specify the $correct parameter. @param string $a The first number. @param string $b The second number. @param boolean $correct Flag to calculate mathematically correct modulo. @return string
[ "Calculates", "the", "modulo", "of", "two", "numbers", ".", "There", "s", "a", "slight", "quirk", "in", "GMP", "s", "implementation", "so", "this", "returns", "a", "mathematically", "correct", "answer", "if", "you", "specify", "the", "$correct", "parameter", ...
train
https://github.com/ionux/phactor/blob/667064d3930e043fd78abed9a2324aee52466fa5/src/GMP.php#L96-L105
CampaignChain/core
Util/CommandUtil.php
CommandUtil.createBitlyAccessToken
public function createBitlyAccessToken(array $parameters) { /** @var SystemService $systemService */ $systemService = $this->kernel->getContainer()->get('campaignchain.core.system'); $systemService->updateBitlyAccessToken($parameters['bitly_access_token']); }
php
public function createBitlyAccessToken(array $parameters) { /** @var SystemService $systemService */ $systemService = $this->kernel->getContainer()->get('campaignchain.core.system'); $systemService->updateBitlyAccessToken($parameters['bitly_access_token']); }
[ "public", "function", "createBitlyAccessToken", "(", "array", "$", "parameters", ")", "{", "/** @var SystemService $systemService */", "$", "systemService", "=", "$", "this", "->", "kernel", "->", "getContainer", "(", ")", "->", "get", "(", "'campaignchain.core.system...
/* Write bitly access token to database @param array $parameters
[ "/", "*", "Write", "bitly", "access", "token", "to", "database" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Util/CommandUtil.php#L172-L177
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel.initialize
public function initialize($translate) { $contexts = array(); foreach ($translate as $order => $element) { $this->_validate_element($element, $order); $key = reset($element); if ($key === self::PARAMETER && count($element) === 2 && ($parameter = next($element)) && ! in_array($parameter, $contexts)) { // Special case of 'parameter' definition without default value means that the // context is substituted. $contexts[] = $parameter; } } $this->_context_params = $contexts; $this->_translate = $translate; return $this; }
php
public function initialize($translate) { $contexts = array(); foreach ($translate as $order => $element) { $this->_validate_element($element, $order); $key = reset($element); if ($key === self::PARAMETER && count($element) === 2 && ($parameter = next($element)) && ! in_array($parameter, $contexts)) { // Special case of 'parameter' definition without default value means that the // context is substituted. $contexts[] = $parameter; } } $this->_context_params = $contexts; $this->_translate = $translate; return $this; }
[ "public", "function", "initialize", "(", "$", "translate", ")", "{", "$", "contexts", "=", "array", "(", ")", ";", "foreach", "(", "$", "translate", "as", "$", "order", "=>", "$", "element", ")", "{", "$", "this", "->", "_validate_element", "(", "$", ...
Initialize translation data by validating and then setting `$_translate` property. @param array $translate @return $this
[ "Initialize", "translation", "data", "by", "validating", "and", "then", "setting", "$_translate", "property", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L71-L88
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel._validate_element
private function _validate_element($element, $position) { $key = reset($element); $allowed_keys = array(self::CONTEXT, self::LANG, self::PARAMETER, self::STRING); if ( ! in_array($key, $allowed_keys)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to be one of "'.implode('", "', $allowed_keys).'", "'.$key.'" found.'); } $elements_count = count($element); if ($key !== self::PARAMETER && $elements_count !== 2) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to have 2 elements, '.$elements_count.' found.'); } elseif ($key === self::PARAMETER && ($elements_count < 2 || $elements_count > 3)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" at position '.($position + 1).' expected to have 2 or 3 elements, '.$elements_count.' found.'); } }
php
private function _validate_element($element, $position) { $key = reset($element); $allowed_keys = array(self::CONTEXT, self::LANG, self::PARAMETER, self::STRING); if ( ! in_array($key, $allowed_keys)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to be one of "'.implode('", "', $allowed_keys).'", "'.$key.'" found.'); } $elements_count = count($element); if ($key !== self::PARAMETER && $elements_count !== 2) { throw new \InvalidArgumentException('Translation definition "'.$key.'" expected to have 2 elements, '.$elements_count.' found.'); } elseif ($key === self::PARAMETER && ($elements_count < 2 || $elements_count > 3)) { throw new \InvalidArgumentException('Translation definition "'.$key.'" at position '.($position + 1).' expected to have 2 or 3 elements, '.$elements_count.' found.'); } }
[ "private", "function", "_validate_element", "(", "$", "element", ",", "$", "position", ")", "{", "$", "key", "=", "reset", "(", "$", "element", ")", ";", "$", "allowed_keys", "=", "array", "(", "self", "::", "CONTEXT", ",", "self", "::", "LANG", ",", ...
Validates that translate element conforms to the specification. @param array $element N-th argument definition from `$_translate` property. @param integer $position argument position (N) @throws \InvalidArgumentException
[ "Validates", "that", "translate", "element", "conforms", "to", "the", "specification", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L97-L114
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel.string
public function string($string = NULL) { if (func_num_args() === 0) { return $this->_string; } $this->_string = $string; return $this; }
php
public function string($string = NULL) { if (func_num_args() === 0) { return $this->_string; } $this->_string = $string; return $this; }
[ "public", "function", "string", "(", "$", "string", "=", "NULL", ")", "{", "if", "(", "func_num_args", "(", ")", "===", "0", ")", "{", "return", "$", "this", "->", "_string", ";", "}", "$", "this", "->", "_string", "=", "$", "string", ";", "return"...
Translation string getter and setter. This makes sense here for 'parametrized' translation logic for changing translation string on-the-fly. @param string $string @return $this|string
[ "Translation", "string", "getter", "and", "setter", ".", "This", "makes", "sense", "here", "for", "parametrized", "translation", "logic", "for", "changing", "translation", "string", "on", "-", "the", "-", "fly", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L123-L131
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel.translate
public function translate() { $arguments = func_get_args(); // Default translation parameters. $translate = array( 'context' => $this->context(), 'lang' => $this->lang(), 'parameters' => $this->parameters(), 'string' => $this->string(), ); // Populate `$translate` variable with function arguments and/or model state. foreach ($this->_translate as $i => $element) { $this->_setup_element($translate, $element, $i, $arguments); } // Now that the basic data have been set, parameters that need to have context values. foreach ($this->_context_params as $parameter) { $translate['parameters'][$parameter] = $translate[self::CONTEXT]; } // Translate using the populated data. return $this->i18n() ->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']); }
php
public function translate() { $arguments = func_get_args(); // Default translation parameters. $translate = array( 'context' => $this->context(), 'lang' => $this->lang(), 'parameters' => $this->parameters(), 'string' => $this->string(), ); // Populate `$translate` variable with function arguments and/or model state. foreach ($this->_translate as $i => $element) { $this->_setup_element($translate, $element, $i, $arguments); } // Now that the basic data have been set, parameters that need to have context values. foreach ($this->_context_params as $parameter) { $translate['parameters'][$parameter] = $translate[self::CONTEXT]; } // Translate using the populated data. return $this->i18n() ->translate($translate['string'], $translate['context'], $translate['parameters'], $translate['lang']); }
[ "public", "function", "translate", "(", ")", "{", "$", "arguments", "=", "func_get_args", "(", ")", ";", "// Default translation parameters.", "$", "translate", "=", "array", "(", "'context'", "=>", "$", "this", "->", "context", "(", ")", ",", "'lang'", "=>"...
Parametrized translation method. Provides 'automatic' translation using method arguments, model state and default values. @return string
[ "Parametrized", "translation", "method", ".", "Provides", "automatic", "translation", "using", "method", "arguments", "model", "state", "and", "default", "values", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L139-L165
czukowski/I18n_Plural
classes/I18n/Model/ParameterModel.php
ParameterModel._setup_element
private function _setup_element(&$translate, $element, $position, $arguments) { $key = array_shift($element); $arguments_count = count($arguments); $element_count = count($element); if ($key !== self::PARAMETER) { // The key is 'context', 'lang' or 'string'. They've already been pre-initialized // from the model state and should only be replaced by `translate()` function // direct arguments or translate parameters default values. $translate[$key] = $position < $arguments_count ? $arguments[$position] : ($translate[$key] === NULL ? array_shift($element) : $translate[$key]); } elseif ($key === self::PARAMETER && $element_count === 2) { // If `translate()` function argument at the current position has been passed, then // use it as parameter value, else use set parameter, fallback to preset default. list ($parameter, $default) = $element; $translate['parameters'][$parameter] = $position < $arguments_count ? $arguments[$position] : $this->_parameter_default($parameter, $default); } }
php
private function _setup_element(&$translate, $element, $position, $arguments) { $key = array_shift($element); $arguments_count = count($arguments); $element_count = count($element); if ($key !== self::PARAMETER) { // The key is 'context', 'lang' or 'string'. They've already been pre-initialized // from the model state and should only be replaced by `translate()` function // direct arguments or translate parameters default values. $translate[$key] = $position < $arguments_count ? $arguments[$position] : ($translate[$key] === NULL ? array_shift($element) : $translate[$key]); } elseif ($key === self::PARAMETER && $element_count === 2) { // If `translate()` function argument at the current position has been passed, then // use it as parameter value, else use set parameter, fallback to preset default. list ($parameter, $default) = $element; $translate['parameters'][$parameter] = $position < $arguments_count ? $arguments[$position] : $this->_parameter_default($parameter, $default); } }
[ "private", "function", "_setup_element", "(", "&", "$", "translate", ",", "$", "element", ",", "$", "position", ",", "$", "arguments", ")", "{", "$", "key", "=", "array_shift", "(", "$", "element", ")", ";", "$", "arguments_count", "=", "count", "(", "...
Determine translation property values from `translate()` function arguments and using fallback logic described in the class header. @param array $translate translation parts array that will be used in translation. @param array $element N-th argument definition from `$_translate` property. @param integer $position argument position (N) @param array $arguments `translate()` function arguments.
[ "Determine", "translation", "property", "values", "from", "translate", "()", "function", "arguments", "and", "using", "fallback", "logic", "described", "in", "the", "class", "header", "." ]
train
https://github.com/czukowski/I18n_Plural/blob/6782aeac50e22a194d3840759c9da97d1f9c50d0/classes/I18n/Model/ParameterModel.php#L176-L199
tableau-mkt/elomentary
src/Api/Data/Contact/Segment.php
Segment.searchExcluded
public function searchExcluded($search, array $options = array()) { return $this->get('data/contacts/segment/' . rawurlencode($this->segmentId) . '/excluded', array_merge(array( 'search' => $search, ), $options)); }
php
public function searchExcluded($search, array $options = array()) { return $this->get('data/contacts/segment/' . rawurlencode($this->segmentId) . '/excluded', array_merge(array( 'search' => $search, ), $options)); }
[ "public", "function", "searchExcluded", "(", "$", "search", ",", "array", "$", "options", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "get", "(", "'data/contacts/segment/'", ".", "rawurlencode", "(", "$", "this", "->", "segmentId", ")", ...
Search contacts that are excluded in this segment. @param string $search @param array $options @return \Guzzle\Http\EntityBodyInterface|mixed|string
[ "Search", "contacts", "that", "are", "excluded", "in", "this", "segment", "." ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/Api/Data/Contact/Segment.php#L67-L71
opus-online/yii2-payment
lib/adapters/AbstractIPizza.php
AbstractIPizza.addCommonParams
public function addCommonParams(Dataset $dataset) { $dataset ->setParam('VK_SERVICE', $this->getConfParam('VK_SERVICE', '1011')) ->setParam('VK_VERSION', '008') ->setParam('VK_SND_ID', $this->getConfParam('VK_SND_ID')) ->setParam('VK_ACC', $this->getConfParam('VK_ACC')) ->setParam('VK_NAME', $this->getConfParam('VK_NAME')) ->setParam('VK_RETURN', $this->getReturnUrl()) ->setParam('VK_CANCEL', $this->getCancelUrl()) ->setParam('VK_ENCODING', $this->getConfParam('VK_ENCODING', 'UTF-8')) ->setParam('VK_DATETIME', date(DATE_ISO8601)) ; }
php
public function addCommonParams(Dataset $dataset) { $dataset ->setParam('VK_SERVICE', $this->getConfParam('VK_SERVICE', '1011')) ->setParam('VK_VERSION', '008') ->setParam('VK_SND_ID', $this->getConfParam('VK_SND_ID')) ->setParam('VK_ACC', $this->getConfParam('VK_ACC')) ->setParam('VK_NAME', $this->getConfParam('VK_NAME')) ->setParam('VK_RETURN', $this->getReturnUrl()) ->setParam('VK_CANCEL', $this->getCancelUrl()) ->setParam('VK_ENCODING', $this->getConfParam('VK_ENCODING', 'UTF-8')) ->setParam('VK_DATETIME', date(DATE_ISO8601)) ; }
[ "public", "function", "addCommonParams", "(", "Dataset", "$", "dataset", ")", "{", "$", "dataset", "->", "setParam", "(", "'VK_SERVICE'", ",", "$", "this", "->", "getConfParam", "(", "'VK_SERVICE'", ",", "'1011'", ")", ")", "->", "setParam", "(", "'VK_VERSIO...
This can be overridden by child classes of iPizza if necessary
[ "This", "can", "be", "overridden", "by", "child", "classes", "of", "iPizza", "if", "necessary" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractIPizza.php#L85-L98
opus-online/yii2-payment
lib/adapters/AbstractIPizza.php
AbstractIPizza.addMacSignature
private function addMacSignature(Dataset $dataset) { $macSource = $this->getMacSource($dataset); $keyPath = $this->getPkcKeyPath(); $signature = $this->signWithPrivateKey($keyPath, $macSource); $signature = base64_encode($signature); $dataset->setParam('VK_MAC', $signature); return $signature; }
php
private function addMacSignature(Dataset $dataset) { $macSource = $this->getMacSource($dataset); $keyPath = $this->getPkcKeyPath(); $signature = $this->signWithPrivateKey($keyPath, $macSource); $signature = base64_encode($signature); $dataset->setParam('VK_MAC', $signature); return $signature; }
[ "private", "function", "addMacSignature", "(", "Dataset", "$", "dataset", ")", "{", "$", "macSource", "=", "$", "this", "->", "getMacSource", "(", "$", "dataset", ")", ";", "$", "keyPath", "=", "$", "this", "->", "getPkcKeyPath", "(", ")", ";", "$", "s...
Generates and adds a MAC signature to the dataset (also adds VK_MAC parameter) @param \opus\payment\services\payment\Dataset $dataset @return bool|string
[ "Generates", "and", "adds", "a", "MAC", "signature", "to", "the", "dataset", "(", "also", "adds", "VK_MAC", "parameter", ")" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractIPizza.php#L122-L132
opus-online/yii2-payment
lib/adapters/AbstractIPizza.php
AbstractIPizza.getMacSource
private function getMacSource(Dataset $dataset) { $macParams = $this->getNormalizedMacParams($dataset, $dataset->getParam('VK_SERVICE')); $source = ''; foreach ($macParams as $value) { $length = $this->getParamValueLength($value); $source .= str_pad($length, 3, '0', STR_PAD_LEFT) . $value; } return $source; }
php
private function getMacSource(Dataset $dataset) { $macParams = $this->getNormalizedMacParams($dataset, $dataset->getParam('VK_SERVICE')); $source = ''; foreach ($macParams as $value) { $length = $this->getParamValueLength($value); $source .= str_pad($length, 3, '0', STR_PAD_LEFT) . $value; } return $source; }
[ "private", "function", "getMacSource", "(", "Dataset", "$", "dataset", ")", "{", "$", "macParams", "=", "$", "this", "->", "getNormalizedMacParams", "(", "$", "dataset", ",", "$", "dataset", "->", "getParam", "(", "'VK_SERVICE'", ")", ")", ";", "$", "sourc...
Generates the MAC source string from a dataset @param Dataset $dataset @return string
[ "Generates", "the", "MAC", "source", "string", "from", "a", "dataset" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractIPizza.php#L140-L151
opus-online/yii2-payment
lib/adapters/AbstractIPizza.php
AbstractIPizza.verifyResponseMac
private function verifyResponseMac(Response $response) { $macSource = $this->getMacSource($response); $macValue = $response->getParam('VK_MAC'); $certPath = $this->getPkcCertPath(); $isVerified = $this->verifySignatureWithCertificate($certPath, $macSource, base64_decode($macValue)); return (bool)$isVerified; }
php
private function verifyResponseMac(Response $response) { $macSource = $this->getMacSource($response); $macValue = $response->getParam('VK_MAC'); $certPath = $this->getPkcCertPath(); $isVerified = $this->verifySignatureWithCertificate($certPath, $macSource, base64_decode($macValue)); return (bool)$isVerified; }
[ "private", "function", "verifyResponseMac", "(", "Response", "$", "response", ")", "{", "$", "macSource", "=", "$", "this", "->", "getMacSource", "(", "$", "response", ")", ";", "$", "macValue", "=", "$", "response", "->", "getParam", "(", "'VK_MAC'", ")",...
Verifies if a given MAC in a response object is valid @param Response $response @return bool
[ "Verifies", "if", "a", "given", "MAC", "in", "a", "response", "object", "is", "valid" ]
train
https://github.com/opus-online/yii2-payment/blob/df48093f7ef1368a0992460bc66f12f0f090044c/lib/adapters/AbstractIPizza.php#L193-L202
Deathnerd/php-wtforms
src/csrf/session/SessionCSRF.php
SessionCSRF.generateCSRFToken
public function generateCSRFToken(CSRFTokenField $csrf_token_field) { $meta = $this->form_meta; if (!$meta->csrf_secret) { throw new \Exception("Must set `csrf_secret` on class Meta for SessionCSRF to work"); } if (session_status() !== PHP_SESSION_ACTIVE) { throw new TypeError("Must must have an active session to use SessionCSRF"); } if (!array_key_exists($this->session_key, $_SESSION)) { $_SESSION[$this->session_key] = sha1(openssl_random_pseudo_bytes(64)); } if ($this->time_limit) { $expires = $this->now()->addSeconds($this->time_limit)->format(str_replace('%', '', self::TIME_FORMAT)); $this->now()->subSeconds($this->time_limit); $csrf_build = sprintf("%s%s", $_SESSION[$this->session_key], $expires); } else { $expires = ''; $csrf_build = $_SESSION[$this->session_key]; } $hmac_csrf = hash_hmac('sha1', $csrf_build, $meta->csrf_secret); return "$expires##$hmac_csrf"; }
php
public function generateCSRFToken(CSRFTokenField $csrf_token_field) { $meta = $this->form_meta; if (!$meta->csrf_secret) { throw new \Exception("Must set `csrf_secret` on class Meta for SessionCSRF to work"); } if (session_status() !== PHP_SESSION_ACTIVE) { throw new TypeError("Must must have an active session to use SessionCSRF"); } if (!array_key_exists($this->session_key, $_SESSION)) { $_SESSION[$this->session_key] = sha1(openssl_random_pseudo_bytes(64)); } if ($this->time_limit) { $expires = $this->now()->addSeconds($this->time_limit)->format(str_replace('%', '', self::TIME_FORMAT)); $this->now()->subSeconds($this->time_limit); $csrf_build = sprintf("%s%s", $_SESSION[$this->session_key], $expires); } else { $expires = ''; $csrf_build = $_SESSION[$this->session_key]; } $hmac_csrf = hash_hmac('sha1', $csrf_build, $meta->csrf_secret); return "$expires##$hmac_csrf"; }
[ "public", "function", "generateCSRFToken", "(", "CSRFTokenField", "$", "csrf_token_field", ")", "{", "$", "meta", "=", "$", "this", "->", "form_meta", ";", "if", "(", "!", "$", "meta", "->", "csrf_secret", ")", "{", "throw", "new", "\\", "Exception", "(", ...
Implementations must override this to provide a method with which one can get a CSRF token for this form. A CSRF token is usually a string that is generated deterministically based on some sort of user data, though it can be anything which you can validate on a subsequent request. @param CSRFTokenField $csrf_token_field The field which is being used for CSRF @return string @throws \Exception @throws TypeError
[ "Implementations", "must", "override", "this", "to", "provide", "a", "method", "with", "which", "one", "can", "get", "a", "CSRF", "token", "for", "this", "form", "." ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/csrf/session/SessionCSRF.php#L59-L84
Deathnerd/php-wtforms
src/csrf/session/SessionCSRF.php
SessionCSRF.validate_csrf_token
public function validate_csrf_token(Form $form, CSRFTokenField $field) { $meta = $this->form_meta; if (!$field->data || !str_contains($field->data, "##")) { throw new ValidationError("CSRF token missing"); } list($expires, $hmac_csrf) = explode("##", $field->data); $check_val = strval($_SESSION[$this->session_key] . $expires); $hmac_compare = hash_hmac('sha1', $check_val, $meta->csrf_secret); if ($hmac_compare !== $hmac_csrf) { throw new ValidationError("CSRF failed"); } if ($this->time_limit) { $now_formatted = $this->now()->format(str_replace('%', '', self::TIME_FORMAT)); if ((new \DateTime($now_formatted)) > (new \DateTime($expires))) { throw new ValidationError("CSRF token expired"); } } }
php
public function validate_csrf_token(Form $form, CSRFTokenField $field) { $meta = $this->form_meta; if (!$field->data || !str_contains($field->data, "##")) { throw new ValidationError("CSRF token missing"); } list($expires, $hmac_csrf) = explode("##", $field->data); $check_val = strval($_SESSION[$this->session_key] . $expires); $hmac_compare = hash_hmac('sha1', $check_val, $meta->csrf_secret); if ($hmac_compare !== $hmac_csrf) { throw new ValidationError("CSRF failed"); } if ($this->time_limit) { $now_formatted = $this->now()->format(str_replace('%', '', self::TIME_FORMAT)); if ((new \DateTime($now_formatted)) > (new \DateTime($expires))) { throw new ValidationError("CSRF token expired"); } } }
[ "public", "function", "validate_csrf_token", "(", "Form", "$", "form", ",", "CSRFTokenField", "$", "field", ")", "{", "$", "meta", "=", "$", "this", "->", "form_meta", ";", "if", "(", "!", "$", "field", "->", "data", "||", "!", "str_contains", "(", "$"...
Override this method to provide custom CSRF validation logic. The default CSRF validation logic simply checks if the recently generated token equals the one we received as formdata. @param Form $form The form which has this CSRF token @param CSRFTokenField $field The CSRF token field @throws ValidationError
[ "Override", "this", "method", "to", "provide", "custom", "CSRF", "validation", "logic", "." ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/csrf/session/SessionCSRF.php#L97-L119
tableau-mkt/elomentary
src/HttpClient/HttpClient.php
HttpClient.setOption
public function setOption($name, $value) { $this->options[$name] = $value; $this->client->setBaseUrl($this->options['base_url'] . '/' . $this->options['version']); }
php
public function setOption($name, $value) { $this->options[$name] = $value; $this->client->setBaseUrl($this->options['base_url'] . '/' . $this->options['version']); }
[ "public", "function", "setOption", "(", "$", "name", ",", "$", "value", ")", "{", "$", "this", "->", "options", "[", "$", "name", "]", "=", "$", "value", ";", "$", "this", "->", "client", "->", "setBaseUrl", "(", "$", "this", "->", "options", "[", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/HttpClient/HttpClient.php#L54-L58
tableau-mkt/elomentary
src/HttpClient/HttpClient.php
HttpClient.get
public function get($path, array $parameters = array(), array $headers = array()) { return $this->request($path, null, 'GET', $headers, array('query' => $parameters)); }
php
public function get($path, array $parameters = array(), array $headers = array()) { return $this->request($path, null, 'GET', $headers, array('query' => $parameters)); }
[ "public", "function", "get", "(", "$", "path", ",", "array", "$", "parameters", "=", "array", "(", ")", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "request", "(", "$", "path", ",", "null", ",", "'...
{@inheritDoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/HttpClient/HttpClient.php#L88-L90
tableau-mkt/elomentary
src/HttpClient/HttpClient.php
HttpClient.post
public function post($path, $body = null, array $headers = array()) { return $this->request($path, $body, 'POST', $headers); }
php
public function post($path, $body = null, array $headers = array()) { return $this->request($path, $body, 'POST', $headers); }
[ "public", "function", "post", "(", "$", "path", ",", "$", "body", "=", "null", ",", "array", "$", "headers", "=", "array", "(", ")", ")", "{", "return", "$", "this", "->", "request", "(", "$", "path", ",", "$", "body", ",", "'POST'", ",", "$", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/HttpClient/HttpClient.php#L95-L97
tableau-mkt/elomentary
src/HttpClient/HttpClient.php
HttpClient.authenticate
public function authenticate($site, $login, $password) { $this->addListener('request.before_send', array( new AuthListener($site, $login, $password), 'onRequestBeforeSend' )); }
php
public function authenticate($site, $login, $password) { $this->addListener('request.before_send', array( new AuthListener($site, $login, $password), 'onRequestBeforeSend' )); }
[ "public", "function", "authenticate", "(", "$", "site", ",", "$", "login", ",", "$", "password", ")", "{", "$", "this", "->", "addListener", "(", "'request.before_send'", ",", "array", "(", "new", "AuthListener", "(", "$", "site", ",", "$", "login", ",",...
{@inheritDoc}
[ "{" ]
train
https://github.com/tableau-mkt/elomentary/blob/c9e8e67f8239cfd813fae59fe665ed7130c439d2/src/HttpClient/HttpClient.php#L143-L147
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Thing/Thing.php
Thing.getProperty
public function getProperty($name, VocabularyInterface $vocabulary) { $name = (new PropertyService())->validatePropertyName($name); return $this->properties[$vocabulary->expand($name)]; }
php
public function getProperty($name, VocabularyInterface $vocabulary) { $name = (new PropertyService())->validatePropertyName($name); return $this->properties[$vocabulary->expand($name)]; }
[ "public", "function", "getProperty", "(", "$", "name", ",", "VocabularyInterface", "$", "vocabulary", ")", "{", "$", "name", "=", "(", "new", "PropertyService", "(", ")", ")", "->", "validatePropertyName", "(", "$", "name", ")", ";", "return", "$", "this",...
Return the values of a single property @param string $name Property name @param VocabularyInterface $vocabulary Vocabulary @return array Property values
[ "Return", "the", "values", "of", "a", "single", "property" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Thing/Thing.php#L149-L153
CampaignChain/core
EntityService/SystemService.php
SystemService.updateBitlyAccessToken
public function updateBitlyAccessToken($access_token) { $activeSystem = $this->getActiveSystem(); $activeSystem->setBitlyAccessToken($access_token); $this->em->persist($activeSystem); $this->em->flush(); }
php
public function updateBitlyAccessToken($access_token) { $activeSystem = $this->getActiveSystem(); $activeSystem->setBitlyAccessToken($access_token); $this->em->persist($activeSystem); $this->em->flush(); }
[ "public", "function", "updateBitlyAccessToken", "(", "$", "access_token", ")", "{", "$", "activeSystem", "=", "$", "this", "->", "getActiveSystem", "(", ")", ";", "$", "activeSystem", "->", "setBitlyAccessToken", "(", "$", "access_token", ")", ";", "$", "this"...
/* Update Bitly access token @param string $access_token
[ "/", "*", "Update", "Bitly", "access", "token" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/SystemService.php#L58-L64
cornernote/yii-email-module
email/models/EmailTemplate.php
EmailTemplate.search
public function search() { $criteria = new CDbCriteria; $criteria->compare('t.id', $this->id); $criteria->compare('t.name', $this->name, true); $criteria->compare('t.subject', $this->subject, true); $criteria->compare('t.heading', $this->heading, true); $criteria->compare('t.message', $this->message, true); return new CActiveDataProvider($this, array( 'criteria' => $criteria, 'sort' => array( 'defaultOrder' => 'id DESC', ), )); }
php
public function search() { $criteria = new CDbCriteria; $criteria->compare('t.id', $this->id); $criteria->compare('t.name', $this->name, true); $criteria->compare('t.subject', $this->subject, true); $criteria->compare('t.heading', $this->heading, true); $criteria->compare('t.message', $this->message, true); return new CActiveDataProvider($this, array( 'criteria' => $criteria, 'sort' => array( 'defaultOrder' => 'id DESC', ), )); }
[ "public", "function", "search", "(", ")", "{", "$", "criteria", "=", "new", "CDbCriteria", ";", "$", "criteria", "->", "compare", "(", "'t.id'", ",", "$", "this", "->", "id", ")", ";", "$", "criteria", "->", "compare", "(", "'t.name'", ",", "$", "thi...
Retrieves a list of models based on the current search/filter conditions. @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
[ "Retrieves", "a", "list", "of", "models", "based", "on", "the", "current", "search", "/", "filter", "conditions", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/models/EmailTemplate.php#L81-L97
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseStatusCodeEquals
public function assertResponseStatusCodeEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getStatusCode(), $message); }
php
public function assertResponseStatusCodeEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getStatusCode(), $message); }
[ "public", "function", "assertResponseStatusCodeEquals", "(", "$", "inExpected", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "inExpected", ",", "$", "inResponse", ...
Asserts that the value of the status code is equal to a given value. @param int $inExpected Expected value. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "value", "of", "the", "status", "code", "is", "equal", "to", "a", "given", "value", "." ]
train
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L26-L28
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseBodyEquals
public function assertResponseBodyEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getBody(), $message); }
php
public function assertResponseBodyEquals($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertEquals($inExpected, $inResponse->getBody(), $message); }
[ "public", "function", "assertResponseBodyEquals", "(", "$", "inExpected", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertEquals", "(", "$", "inExpected", ",", "$", "inResponse", "->", ...
Asserts that the body of the response is equal to a given string. @param string $inExpected The expected response's body. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "body", "of", "the", "response", "is", "equal", "to", "a", "given", "string", "." ]
train
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L129-L131
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseHasHeader
public function assertResponseHasHeader($inHeader, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertTrue($inResponse->hasHeader($inHeader), $message); }
php
public function assertResponseHasHeader($inHeader, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertTrue($inResponse->hasHeader($inHeader), $message); }
[ "public", "function", "assertResponseHasHeader", "(", "$", "inHeader", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertTrue", "(", "$", "inResponse", "->", "hasHeader", "(", "$", "inH...
Asserts that the response has a given header. @param string $inHeader Name of the header. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "response", "has", "a", "given", "header", "." ]
train
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L139-L141
dbeurive/slim-phpunit
src/PHPUnit/TraitAssertResponse.php
TraitAssertResponse.assertResponseBodyEqualsFile
public function assertResponseBodyEqualsFile($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertStringEqualsFile($inExpected, $inResponse->getBody(), $message); }
php
public function assertResponseBodyEqualsFile($inExpected, Response $inResponse, $message = '') { \PHPUnit_Framework_Assert::assertStringEqualsFile($inExpected, $inResponse->getBody(), $message); }
[ "public", "function", "assertResponseBodyEqualsFile", "(", "$", "inExpected", ",", "Response", "$", "inResponse", ",", "$", "message", "=", "''", ")", "{", "\\", "PHPUnit_Framework_Assert", "::", "assertStringEqualsFile", "(", "$", "inExpected", ",", "$", "inRespo...
Asserts that the body of the response is equal to the content of a given file. @param string $inExpected Path to the file. @param Response $inResponse HTTP response. @param string $message
[ "Asserts", "that", "the", "body", "of", "the", "response", "is", "equal", "to", "the", "content", "of", "a", "given", "file", "." ]
train
https://github.com/dbeurive/slim-phpunit/blob/aa11dc6da421879b09aa170b7b990711de543395/src/PHPUnit/TraitAssertResponse.php#L149-L151
kgilden/php-digidoc
src/Api.php
Api.create
public function create() { $result = $this->call('startSession', array('', '', true, '')); $result = $this->call('createSignedDoc', array($sessionId = $result['Sesscode'], self::DOC_FORMAT, self::DOC_VERSION)); $envelope = new Envelope(new Session($sessionId)); $this->tracker->add($envelope); return $envelope; }
php
public function create() { $result = $this->call('startSession', array('', '', true, '')); $result = $this->call('createSignedDoc', array($sessionId = $result['Sesscode'], self::DOC_FORMAT, self::DOC_VERSION)); $envelope = new Envelope(new Session($sessionId)); $this->tracker->add($envelope); return $envelope; }
[ "public", "function", "create", "(", ")", "{", "$", "result", "=", "$", "this", "->", "call", "(", "'startSession'", ",", "array", "(", "''", ",", "''", ",", "true", ",", "''", ")", ")", ";", "$", "result", "=", "$", "this", "->", "call", "(", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L56-L66
kgilden/php-digidoc
src/Api.php
Api.fromString
public function fromString($bytes) { $result = $this->call('startSession', array('', $this->encoder->encode($bytes), true, '')); return $this->createEnvelope($result['Sesscode'], $result['SignedDocInfo']); }
php
public function fromString($bytes) { $result = $this->call('startSession', array('', $this->encoder->encode($bytes), true, '')); return $this->createEnvelope($result['Sesscode'], $result['SignedDocInfo']); }
[ "public", "function", "fromString", "(", "$", "bytes", ")", "{", "$", "result", "=", "$", "this", "->", "call", "(", "'startSession'", ",", "array", "(", "''", ",", "$", "this", "->", "encoder", "->", "encode", "(", "$", "bytes", ")", ",", "true", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L71-L76
kgilden/php-digidoc
src/Api.php
Api.open
public function open($path) { $result = $this->call('startSession', array('', $this->encoder->encodeFileContent($path), true, '')); return $this->createEnvelope($result['Sesscode'], $result['SignedDocInfo']); }
php
public function open($path) { $result = $this->call('startSession', array('', $this->encoder->encodeFileContent($path), true, '')); return $this->createEnvelope($result['Sesscode'], $result['SignedDocInfo']); }
[ "public", "function", "open", "(", "$", "path", ")", "{", "$", "result", "=", "$", "this", "->", "call", "(", "'startSession'", ",", "array", "(", "''", ",", "$", "this", "->", "encoder", "->", "encodeFileContent", "(", "$", "path", ")", ",", "true",...
{@inheritDoc}
[ "{" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L81-L86
kgilden/php-digidoc
src/Api.php
Api.createEnvelope
private function createEnvelope($sessionCode, SignedDocInfo $signedDocInfo) { $envelope = new Envelope( new Session($sessionCode), $this->createAndTrack($signedDocInfo->DataFileInfo, 'KG\DigiDoc\File'), $this->createAndTrack($signedDocInfo->SignatureInfo, 'KG\DigiDoc\Signature') ); $this->tracker->add($envelope); return $envelope; }
php
private function createEnvelope($sessionCode, SignedDocInfo $signedDocInfo) { $envelope = new Envelope( new Session($sessionCode), $this->createAndTrack($signedDocInfo->DataFileInfo, 'KG\DigiDoc\File'), $this->createAndTrack($signedDocInfo->SignatureInfo, 'KG\DigiDoc\Signature') ); $this->tracker->add($envelope); return $envelope; }
[ "private", "function", "createEnvelope", "(", "$", "sessionCode", ",", "SignedDocInfo", "$", "signedDocInfo", ")", "{", "$", "envelope", "=", "new", "Envelope", "(", "new", "Session", "(", "$", "sessionCode", ")", ",", "$", "this", "->", "createAndTrack", "(...
Creates a new DigiDoc envelope. @param string $sessionCode @param SignedDocInfo $signedDocInfo @return Envelope
[ "Creates", "a", "new", "DigiDoc", "envelope", "." ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L96-L107
kgilden/php-digidoc
src/Api.php
Api.update
public function update(Envelope $envelope, $merge = false) { if ($merge) { $this->merge($envelope); } else { $this->failIfNotMerged($envelope); } $session = $envelope->getSession(); $this ->addFiles($session, $envelope->getFiles()) ->addSignatures($session, $envelope->getSignatures()) ->sealSignatures($session, $envelope->getSignatures()) ; }
php
public function update(Envelope $envelope, $merge = false) { if ($merge) { $this->merge($envelope); } else { $this->failIfNotMerged($envelope); } $session = $envelope->getSession(); $this ->addFiles($session, $envelope->getFiles()) ->addSignatures($session, $envelope->getSignatures()) ->sealSignatures($session, $envelope->getSignatures()) ; }
[ "public", "function", "update", "(", "Envelope", "$", "envelope", ",", "$", "merge", "=", "false", ")", "{", "if", "(", "$", "merge", ")", "{", "$", "this", "->", "merge", "(", "$", "envelope", ")", ";", "}", "else", "{", "$", "this", "->", "fail...
{@inheritDoc} @param boolean $merge Merges the envelope before updating it (false by default)
[ "{", "@inheritDoc", "}" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L122-L137
kgilden/php-digidoc
src/Api.php
Api.toString
public function toString(Envelope $envelope) { $this->failIfNotMerged($envelope); $result = $this->call('getSignedDoc', array($envelope->getSession()->getId())); return $this->encoder->decode($result['SignedDocData']); }
php
public function toString(Envelope $envelope) { $this->failIfNotMerged($envelope); $result = $this->call('getSignedDoc', array($envelope->getSession()->getId())); return $this->encoder->decode($result['SignedDocData']); }
[ "public", "function", "toString", "(", "Envelope", "$", "envelope", ")", "{", "$", "this", "->", "failIfNotMerged", "(", "$", "envelope", ")", ";", "$", "result", "=", "$", "this", "->", "call", "(", "'getSignedDoc'", ",", "array", "(", "$", "envelope", ...
{@inheritDoc}
[ "{" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L142-L149
kgilden/php-digidoc
src/Api.php
Api.merge
public function merge(Envelope $envelope) { if ($this->tracker->has($envelope)) { return; } $this->tracker->add($envelope); $this->tracker->add($envelope->getFiles()->toArray()); $this->tracker->add($envelope->getSignatures()->toArray()); }
php
public function merge(Envelope $envelope) { if ($this->tracker->has($envelope)) { return; } $this->tracker->add($envelope); $this->tracker->add($envelope->getFiles()->toArray()); $this->tracker->add($envelope->getSignatures()->toArray()); }
[ "public", "function", "merge", "(", "Envelope", "$", "envelope", ")", "{", "if", "(", "$", "this", "->", "tracker", "->", "has", "(", "$", "envelope", ")", ")", "{", "return", ";", "}", "$", "this", "->", "tracker", "->", "add", "(", "$", "envelope...
{@inheritDoc}
[ "{" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L162-L171
kgilden/php-digidoc
src/Api.php
Api.failIfNotMerged
private function failIfNotMerged(Envelope $envelope) { if (!$this->tracker->has($envelope)) { throw ApiException::createNotMerged($envelope); } }
php
private function failIfNotMerged(Envelope $envelope) { if (!$this->tracker->has($envelope)) { throw ApiException::createNotMerged($envelope); } }
[ "private", "function", "failIfNotMerged", "(", "Envelope", "$", "envelope", ")", "{", "if", "(", "!", "$", "this", "->", "tracker", "->", "has", "(", "$", "envelope", ")", ")", "{", "throw", "ApiException", "::", "createNotMerged", "(", "$", "envelope", ...
@param Envelope $envelope @throws ApiException If the DigiDoc envelope is not merged
[ "@param", "Envelope", "$envelope" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Api.php#L281-L286
joomla-framework/twitter-api
src/Favorites.php
Favorites.getFavorites
public function getFavorites($user = null, $count = 20, $sinceId = 0, $maxId = 0, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('favorites', 'list'); // Set the API path. $path = '/favorites/list.json'; // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } // Set the count string $data['count'] = $count; // Check if since_id is specified. if ($sinceId > 0) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId > 0) { $data['max_id'] = $maxId; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
php
public function getFavorites($user = null, $count = 20, $sinceId = 0, $maxId = 0, $entities = null) { // Check the rate limit for remaining hits $this->checkRateLimit('favorites', 'list'); // Set the API path. $path = '/favorites/list.json'; // Determine which type of data was passed for $user if (is_numeric($user)) { $data['user_id'] = $user; } elseif (\is_string($user)) { $data['screen_name'] = $user; } // Set the count string $data['count'] = $count; // Check if since_id is specified. if ($sinceId > 0) { $data['since_id'] = $sinceId; } // Check if max_id is specified. if ($maxId > 0) { $data['max_id'] = $maxId; } // Check if entities is specified. if ($entities !== null) { $data['include_entities'] = $entities; } // Send the request. return $this->sendRequest($path, 'GET', $data); }
[ "public", "function", "getFavorites", "(", "$", "user", "=", "null", ",", "$", "count", "=", "20", ",", "$", "sinceId", "=", "0", ",", "$", "maxId", "=", "0", ",", "$", "entities", "=", "null", ")", "{", "// Check the rate limit for remaining hits", "$",...
Method to get the most recent favorite statuses for the authenticating or specified user. @param mixed $user Either an integer containing the user ID or a string containing the screen name. @param integer $count Specifies the number of tweets to try and retrieve, up to a maximum of 200. Retweets are always included in the count, so it is always suggested to set $include_rts to true @param integer $sinceId Returns results with an ID greater than (that is, more recent than) the specified ID. @param integer $maxId Returns results with an ID less than (that is, older than) the specified ID. @param boolean $entities When set to true, each tweet will include a node called "entities,". This node offers a variety of metadata about the tweet in a discreet structure, including: user_mentions, urls, and hashtags. @return array The decoded JSON response @since 1.0
[ "Method", "to", "get", "the", "most", "recent", "favorite", "statuses", "for", "the", "authenticating", "or", "specified", "user", "." ]
train
https://github.com/joomla-framework/twitter-api/blob/289719bbd67e83c7cfaf515b94b1d5497b1f0525/src/Favorites.php#L34-L75
Nono1971/Doctrine-MetadataGrapher
lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php
YUMLMetadataGrapher.generateFromMetadata
public function generateFromMetadata( array $metadata, $showFieldsDescription = false, $colors = array(), $notes = array() ) { $this->classStore = new ClassStore($metadata); $this->stringGenerator = new StringGenerator($this->classStore); $this->colorManager = new ColorManager($this->stringGenerator, $this->classStore); $this->stringGenerator->setShowFieldsDescription($showFieldsDescription); $annotations = $this->annotationParser->getAnnotations($metadata); $colors = array_merge($colors, $annotations['colors']); $notes = array_merge($notes, $annotations['notes']); foreach ($metadata as $class) { $this->writeParentAssociation($class); $this->dispatchStringWriter($class, $class->getAssociationNames()); } $this->addColors($metadata, $colors); $this->addNotes($notes); return implode(',', $this->str); }
php
public function generateFromMetadata( array $metadata, $showFieldsDescription = false, $colors = array(), $notes = array() ) { $this->classStore = new ClassStore($metadata); $this->stringGenerator = new StringGenerator($this->classStore); $this->colorManager = new ColorManager($this->stringGenerator, $this->classStore); $this->stringGenerator->setShowFieldsDescription($showFieldsDescription); $annotations = $this->annotationParser->getAnnotations($metadata); $colors = array_merge($colors, $annotations['colors']); $notes = array_merge($notes, $annotations['notes']); foreach ($metadata as $class) { $this->writeParentAssociation($class); $this->dispatchStringWriter($class, $class->getAssociationNames()); } $this->addColors($metadata, $colors); $this->addNotes($notes); return implode(',', $this->str); }
[ "public", "function", "generateFromMetadata", "(", "array", "$", "metadata", ",", "$", "showFieldsDescription", "=", "false", ",", "$", "colors", "=", "array", "(", ")", ",", "$", "notes", "=", "array", "(", ")", ")", "{", "$", "this", "->", "classStore"...
Generate a yUML compatible `dsl_text` to describe a given array of entities @param ClassMetadata[] $metadata @param boolean $showFieldsDescription @param array $colors @param array $notes @return string
[ "Generate", "a", "yUML", "compatible", "dsl_text", "to", "describe", "a", "given", "array", "of", "entities" ]
train
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php#L80-L106
Nono1971/Doctrine-MetadataGrapher
lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php
YUMLMetadataGrapher.getInheritanceAssociations
private function getInheritanceAssociations(ClassMetadata $class, $associations = array()) { if ($parent = $this->classStore->getParent($class)) { foreach ($parent->getAssociationNames() as $association) { if (!in_array($association, $associations)) { $associations[] = $association; } } $associations = $this->getInheritanceAssociations($parent, $associations); } return $associations; }
php
private function getInheritanceAssociations(ClassMetadata $class, $associations = array()) { if ($parent = $this->classStore->getParent($class)) { foreach ($parent->getAssociationNames() as $association) { if (!in_array($association, $associations)) { $associations[] = $association; } } $associations = $this->getInheritanceAssociations($parent, $associations); } return $associations; }
[ "private", "function", "getInheritanceAssociations", "(", "ClassMetadata", "$", "class", ",", "$", "associations", "=", "array", "(", ")", ")", "{", "if", "(", "$", "parent", "=", "$", "this", "->", "classStore", "->", "getParent", "(", "$", "class", ")", ...
Recursive function to get all associations in inheritance @param ClassMetadata $class @param array $associations @return array
[ "Recursive", "function", "to", "get", "all", "associations", "in", "inheritance" ]
train
https://github.com/Nono1971/Doctrine-MetadataGrapher/blob/414b95f81d36b6530b083b296c5eeb700679ab3b/lib/Onurb/Doctrine/ORMMetadataGrapher/YUMLMetadataGrapher.php#L187-L199
swoft-cloud/swoft-console
src/Command.php
Command.annotationVars
public function annotationVars(): array { // e.g: `more info see {name}:index` return [ // 'name' => self::getName(), // 'group' => self::getName(), 'workDir' => input()->getPwd(), 'script' => input()->getScript(), // bin/app 'command' => input()->getCommand(), // demo OR home:test 'fullCommand' => input()->getScript() . ' ' . input()->getCommand(), ]; }
php
public function annotationVars(): array { // e.g: `more info see {name}:index` return [ // 'name' => self::getName(), // 'group' => self::getName(), 'workDir' => input()->getPwd(), 'script' => input()->getScript(), // bin/app 'command' => input()->getCommand(), // demo OR home:test 'fullCommand' => input()->getScript() . ' ' . input()->getCommand(), ]; }
[ "public", "function", "annotationVars", "(", ")", ":", "array", "{", "// e.g: `more info see {name}:index`", "return", "[", "// 'name' => self::getName(),", "// 'group' => self::getName(),", "'workDir'", "=>", "input", "(", ")", "->", "getPwd", "(", ")", ",", "'script'"...
为命令注解提供可解析解析变量. 可以在命令的注释中使用 @return array
[ "为命令注解提供可解析解析变量", ".", "可以在命令的注释中使用" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L25-L36
swoft-cloud/swoft-console
src/Command.php
Command.showCommandHelp
private function showCommandHelp(string $controllerClass, string $commandMethod) { // 反射获取方法描述 $reflectionClass = new \ReflectionClass($controllerClass); $reflectionMethod = $reflectionClass->getMethod($commandMethod); $document = $reflectionMethod->getDocComment(); $document = $this->parseAnnotationVars($document, $this->annotationVars()); $docs = DocBlockHelper::getTags($document); $commands = []; // 描述 if (isset($docs['Description'])) { $commands['Description:'] = explode("\n", $docs['Description']); } // 使用 if (isset($docs['Usage'])) { $commands['Usage:'] = $docs['Usage']; } // 参数 if (isset($docs['Arguments'])) { // $arguments = $this->parserKeyAndDesc($docs['Arguments']); $commands['Arguments:'] = $docs['Arguments']; } // 选项 if (isset($docs['Options'])) { // $options = $this->parserKeyAndDesc($docs['Options']); $commands['Options:'] = $docs['Options']; } // 实例 if (isset($docs['Example'])) { $commands['Example:'] = [$docs['Example']]; } \output()->writeList($commands); }
php
private function showCommandHelp(string $controllerClass, string $commandMethod) { // 反射获取方法描述 $reflectionClass = new \ReflectionClass($controllerClass); $reflectionMethod = $reflectionClass->getMethod($commandMethod); $document = $reflectionMethod->getDocComment(); $document = $this->parseAnnotationVars($document, $this->annotationVars()); $docs = DocBlockHelper::getTags($document); $commands = []; // 描述 if (isset($docs['Description'])) { $commands['Description:'] = explode("\n", $docs['Description']); } // 使用 if (isset($docs['Usage'])) { $commands['Usage:'] = $docs['Usage']; } // 参数 if (isset($docs['Arguments'])) { // $arguments = $this->parserKeyAndDesc($docs['Arguments']); $commands['Arguments:'] = $docs['Arguments']; } // 选项 if (isset($docs['Options'])) { // $options = $this->parserKeyAndDesc($docs['Options']); $commands['Options:'] = $docs['Options']; } // 实例 if (isset($docs['Example'])) { $commands['Example:'] = [$docs['Example']]; } \output()->writeList($commands); }
[ "private", "function", "showCommandHelp", "(", "string", "$", "controllerClass", ",", "string", "$", "commandMethod", ")", "{", "// 反射获取方法描述", "$", "reflectionClass", "=", "new", "\\", "ReflectionClass", "(", "$", "controllerClass", ")", ";", "$", "reflectionMetho...
the help of group @param string $controllerClass @param string $commandMethod @throws \ReflectionException
[ "the", "help", "of", "group" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L139-L178
swoft-cloud/swoft-console
src/Command.php
Command.showCommandList
public function showCommandList(bool $showLogo = true) { $commands = $this->parserCmdAndDesc(); $commandList = []; $script = \input()->getFullScript(); $commandList['Usage:'] = ["php $script {command} [arguments] [options]"]; $commandList['Commands:'] = $commands; $commandList['Options:'] = [ '-h, --help' => 'Display help information', '-v, --version' => 'Display version information', ]; // show logo if ($showLogo) { \output()->writeLogo(); } // output list \output()->writeList($commandList, 'comment', 'info'); }
php
public function showCommandList(bool $showLogo = true) { $commands = $this->parserCmdAndDesc(); $commandList = []; $script = \input()->getFullScript(); $commandList['Usage:'] = ["php $script {command} [arguments] [options]"]; $commandList['Commands:'] = $commands; $commandList['Options:'] = [ '-h, --help' => 'Display help information', '-v, --version' => 'Display version information', ]; // show logo if ($showLogo) { \output()->writeLogo(); } // output list \output()->writeList($commandList, 'comment', 'info'); }
[ "public", "function", "showCommandList", "(", "bool", "$", "showLogo", "=", "true", ")", "{", "$", "commands", "=", "$", "this", "->", "parserCmdAndDesc", "(", ")", ";", "$", "commandList", "=", "[", "]", ";", "$", "script", "=", "\\", "input", "(", ...
show all commands for the console app @param bool $showLogo @throws \ReflectionException
[ "show", "all", "commands", "for", "the", "console", "app" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L186-L206
swoft-cloud/swoft-console
src/Command.php
Command.showVersion
private function showVersion() { // 当前版本信息 $swoftVersion = App::version(); $phpVersion = PHP_VERSION; $swooleVersion = SWOOLE_VERSION; // 显示面板 \output()->writeLogo(); \output()->writeln( "swoft: <info>$swoftVersion</info>, php: <info>$phpVersion</info>, swoole: <info>$swooleVersion</info>\n", true ); }
php
private function showVersion() { // 当前版本信息 $swoftVersion = App::version(); $phpVersion = PHP_VERSION; $swooleVersion = SWOOLE_VERSION; // 显示面板 \output()->writeLogo(); \output()->writeln( "swoft: <info>$swoftVersion</info>, php: <info>$phpVersion</info>, swoole: <info>$swooleVersion</info>\n", true ); }
[ "private", "function", "showVersion", "(", ")", "{", "// 当前版本信息", "$", "swoftVersion", "=", "App", "::", "version", "(", ")", ";", "$", "phpVersion", "=", "PHP_VERSION", ";", "$", "swooleVersion", "=", "SWOOLE_VERSION", ";", "// 显示面板", "\\", "output", "(", ...
version
[ "version" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L211-L224
swoft-cloud/swoft-console
src/Command.php
Command.parserCmdAndDesc
private function parserCmdAndDesc(): array { $commands = []; $collector = CommandCollector::getCollector(); /* @var \Swoft\Console\Router\HandlerMapping $route */ $route = App::getBean('commandRoute'); foreach ($collector as $className => $command) { if (!$command['enabled']) { continue; } $rc = new \ReflectionClass($className); $docComment = $rc->getDocComment(); $docAry = DocBlockHelper::getTags($docComment); $prefix = $command['name']; $prefix = $route->getPrefix($prefix, $className); $commands[$prefix] = StringHelper::ucfirst($docAry['Description']); } // sort commands ksort($commands); return $commands; }
php
private function parserCmdAndDesc(): array { $commands = []; $collector = CommandCollector::getCollector(); /* @var \Swoft\Console\Router\HandlerMapping $route */ $route = App::getBean('commandRoute'); foreach ($collector as $className => $command) { if (!$command['enabled']) { continue; } $rc = new \ReflectionClass($className); $docComment = $rc->getDocComment(); $docAry = DocBlockHelper::getTags($docComment); $prefix = $command['name']; $prefix = $route->getPrefix($prefix, $className); $commands[$prefix] = StringHelper::ucfirst($docAry['Description']); } // sort commands ksort($commands); return $commands; }
[ "private", "function", "parserCmdAndDesc", "(", ")", ":", "array", "{", "$", "commands", "=", "[", "]", ";", "$", "collector", "=", "CommandCollector", "::", "getCollector", "(", ")", ";", "/* @var \\Swoft\\Console\\Router\\HandlerMapping $route */", "$", "route", ...
the command list @return array @throws \ReflectionException
[ "the", "command", "list" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L232-L258
swoft-cloud/swoft-console
src/Command.php
Command.parseAnnotationVars
protected function parseAnnotationVars(string $str, array $vars): string { // not use vars if (false === strpos($str, '{')) { return $str; } $map = []; foreach ($vars as $key => $value) { $key = sprintf(self::ANNOTATION_VAR, $key); $map[$key] = $value; } return $map ? strtr($str, $map) : $str; }
php
protected function parseAnnotationVars(string $str, array $vars): string { // not use vars if (false === strpos($str, '{')) { return $str; } $map = []; foreach ($vars as $key => $value) { $key = sprintf(self::ANNOTATION_VAR, $key); $map[$key] = $value; } return $map ? strtr($str, $map) : $str; }
[ "protected", "function", "parseAnnotationVars", "(", "string", "$", "str", ",", "array", "$", "vars", ")", ":", "string", "{", "// not use vars", "if", "(", "false", "===", "strpos", "(", "$", "str", ",", "'{'", ")", ")", "{", "return", "$", "str", ";"...
替换注解中的变量为对应的值 @param string $str @param array $vars @return string
[ "替换注解中的变量为对应的值" ]
train
https://github.com/swoft-cloud/swoft-console/blob/d7153f56505a9be420ebae9eb29f7e45bfb2982e/src/Command.php#L283-L298
notthatbad/silverstripe-rest-api
code/extensions/SlugableExtension.php
SlugableExtension.onBeforeWrite
public function onBeforeWrite() { parent::onBeforeWrite(); $defaults = $this->owner->config()->defaults; $URLSegment = $this->owner->URLSegment; // If there is no URLSegment set, generate one from Title if((!$URLSegment || $URLSegment == $defaults['URLSegment']) && $this->owner->Title != $defaults['Title']) { $URLSegment = $this->generateURLSegment($this->owner->Title); } else if($this->owner->isChanged('URLSegment')) { // Make sure the URLSegment is valid for use in a URL $segment = preg_replace('/[^A-Za-z0-9]+/','-',$this->owner->URLSegment); $segment = preg_replace('/-+/','-',$segment); // If after sanitising there is no URLSegment, give it a reasonable default if(!$segment) { $segment = $this->fallbackUrl(); } $URLSegment = $segment; } // Ensure that this object has a non-conflicting URLSegment value. $count = 2; $ID = $this->owner->ID; while($this->lookForExistingURLSegment($URLSegment, $ID)) { $URLSegment = preg_replace('/-[0-9]+$/', null, $URLSegment) . '-' . $count; $count++; } $this->owner->URLSegment = $URLSegment; }
php
public function onBeforeWrite() { parent::onBeforeWrite(); $defaults = $this->owner->config()->defaults; $URLSegment = $this->owner->URLSegment; // If there is no URLSegment set, generate one from Title if((!$URLSegment || $URLSegment == $defaults['URLSegment']) && $this->owner->Title != $defaults['Title']) { $URLSegment = $this->generateURLSegment($this->owner->Title); } else if($this->owner->isChanged('URLSegment')) { // Make sure the URLSegment is valid for use in a URL $segment = preg_replace('/[^A-Za-z0-9]+/','-',$this->owner->URLSegment); $segment = preg_replace('/-+/','-',$segment); // If after sanitising there is no URLSegment, give it a reasonable default if(!$segment) { $segment = $this->fallbackUrl(); } $URLSegment = $segment; } // Ensure that this object has a non-conflicting URLSegment value. $count = 2; $ID = $this->owner->ID; while($this->lookForExistingURLSegment($URLSegment, $ID)) { $URLSegment = preg_replace('/-[0-9]+$/', null, $URLSegment) . '-' . $count; $count++; } $this->owner->URLSegment = $URLSegment; }
[ "public", "function", "onBeforeWrite", "(", ")", "{", "parent", "::", "onBeforeWrite", "(", ")", ";", "$", "defaults", "=", "$", "this", "->", "owner", "->", "config", "(", ")", "->", "defaults", ";", "$", "URLSegment", "=", "$", "this", "->", "owner",...
Set URLSegment to be unique on write
[ "Set", "URLSegment", "to", "be", "unique", "on", "write" ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/SlugableExtension.php#L33-L60
notthatbad/silverstripe-rest-api
code/extensions/SlugableExtension.php
SlugableExtension.lookForExistingURLSegment
protected function lookForExistingURLSegment($urlSegment, $id) { return $this->owner->get()->filter( 'URLSegment', $urlSegment )->exclude('ID', is_null($id) ? 0 : $id)->exists(); }
php
protected function lookForExistingURLSegment($urlSegment, $id) { return $this->owner->get()->filter( 'URLSegment', $urlSegment )->exclude('ID', is_null($id) ? 0 : $id)->exists(); }
[ "protected", "function", "lookForExistingURLSegment", "(", "$", "urlSegment", ",", "$", "id", ")", "{", "return", "$", "this", "->", "owner", "->", "get", "(", ")", "->", "filter", "(", "'URLSegment'", ",", "$", "urlSegment", ")", "->", "exclude", "(", "...
Check if there is already a database entry with this url segment @param string $urlSegment @param int $id @return bool
[ "Check", "if", "there", "is", "already", "a", "database", "entry", "with", "this", "url", "segment" ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/SlugableExtension.php#L69-L73
notthatbad/silverstripe-rest-api
code/extensions/SlugableExtension.php
SlugableExtension.generateURLSegment
public function generateURLSegment($title) { $filter = \URLSegmentFilter::create(); $t = $filter->filter($title); // Fallback to generic page name if path is empty (= no valid, convertable characters) if(!$t || $t == '-' || $t == '-1') { $t = $this->fallbackUrl(); } // Hook for extensions $this->owner->extend('updateURLSegment', $t, $title); return $t; }
php
public function generateURLSegment($title) { $filter = \URLSegmentFilter::create(); $t = $filter->filter($title); // Fallback to generic page name if path is empty (= no valid, convertable characters) if(!$t || $t == '-' || $t == '-1') { $t = $this->fallbackUrl(); } // Hook for extensions $this->owner->extend('updateURLSegment', $t, $title); return $t; }
[ "public", "function", "generateURLSegment", "(", "$", "title", ")", "{", "$", "filter", "=", "\\", "URLSegmentFilter", "::", "create", "(", ")", ";", "$", "t", "=", "$", "filter", "->", "filter", "(", "$", "title", ")", ";", "// Fallback to generic page na...
Generate a URL segment based on the title provided. If {@link Extension}s wish to alter URL segment generation, they can do so by defining updateURLSegment(&$url, $title). $url will be passed by reference and should be modified. $title will contain the title that was originally used as the source of this generated URL. This lets extensions either start from scratch, or incrementally modify the generated URL. @param string $title the given title @return string generated url segment
[ "Generate", "a", "URL", "segment", "based", "on", "the", "title", "provided", "." ]
train
https://github.com/notthatbad/silverstripe-rest-api/blob/aed8e9812a01d4ab1e7cdfe7c3e0161ca368e621/code/extensions/SlugableExtension.php#L86-L96
CampaignChain/core
Module/BundleLocator.php
BundleLocator.getBundle
private function getBundle($bundleComposer) { if (!file_exists($bundleComposer)) { return false; } $bundleComposerData = file_get_contents($bundleComposer); $normalizer = new GetSetMethodNormalizer(); $normalizer->setIgnoredAttributes(array( 'require', 'keywords', )); $encoder = new JsonEncoder(); $serializer = new Serializer(array($normalizer), array($encoder)); $bundle = $serializer->deserialize($bundleComposerData,'CampaignChain\CoreBundle\Entity\Bundle','json'); // Set the version of the installed bundle. $version = $this->packageService->getVersion($bundle->getName()); /* * If version does not exist, this means two things: * * 1) Either, it is a package in require-dev of composer.json, but * CampaignChain is not in dev mode. Then we don't add this package. * * 2) Or it is a bundle in Symfony's src/ directory. Then we want to * add it. */ if(!$version){ // Check if bundle is in src/ dir. $bundlePath = str_replace($this->rootDir.DIRECTORY_SEPARATOR, '', $bundleComposer); if(strpos($bundlePath, 'src'.DIRECTORY_SEPARATOR) !== 0){ // Not in src/ dir, so don't add this bundle. return false; } else { $version = 'dev-master'; } } $bundle->setVersion($version); // Set relative path of bundle. $bundle->setPath( // Remove the root directory to get the relative path str_replace($this->rootDir.DIRECTORY_SEPARATOR, '', // Remove the composer file from the path str_replace(DIRECTORY_SEPARATOR.'composer.json', '', $bundleComposer) ) ); return $bundle; }
php
private function getBundle($bundleComposer) { if (!file_exists($bundleComposer)) { return false; } $bundleComposerData = file_get_contents($bundleComposer); $normalizer = new GetSetMethodNormalizer(); $normalizer->setIgnoredAttributes(array( 'require', 'keywords', )); $encoder = new JsonEncoder(); $serializer = new Serializer(array($normalizer), array($encoder)); $bundle = $serializer->deserialize($bundleComposerData,'CampaignChain\CoreBundle\Entity\Bundle','json'); // Set the version of the installed bundle. $version = $this->packageService->getVersion($bundle->getName()); /* * If version does not exist, this means two things: * * 1) Either, it is a package in require-dev of composer.json, but * CampaignChain is not in dev mode. Then we don't add this package. * * 2) Or it is a bundle in Symfony's src/ directory. Then we want to * add it. */ if(!$version){ // Check if bundle is in src/ dir. $bundlePath = str_replace($this->rootDir.DIRECTORY_SEPARATOR, '', $bundleComposer); if(strpos($bundlePath, 'src'.DIRECTORY_SEPARATOR) !== 0){ // Not in src/ dir, so don't add this bundle. return false; } else { $version = 'dev-master'; } } $bundle->setVersion($version); // Set relative path of bundle. $bundle->setPath( // Remove the root directory to get the relative path str_replace($this->rootDir.DIRECTORY_SEPARATOR, '', // Remove the composer file from the path str_replace(DIRECTORY_SEPARATOR.'composer.json', '', $bundleComposer) ) ); return $bundle; }
[ "private", "function", "getBundle", "(", "$", "bundleComposer", ")", "{", "if", "(", "!", "file_exists", "(", "$", "bundleComposer", ")", ")", "{", "return", "false", ";", "}", "$", "bundleComposerData", "=", "file_get_contents", "(", "$", "bundleComposer", ...
@param string $bundleComposer @return bool|Bundle
[ "@param", "string", "$bundleComposer" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Module/BundleLocator.php#L99-L151
CampaignChain/core
Controller/REST/ChannelController.php
ChannelController.getLocationsUrlsMetaAction
public function getLocationsUrlsMetaAction() { $qb = $this->getQueryBuilder(); $qb->select('l.url'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.operation IS NULL'); $qb->groupBy(('l.url')); $query = $qb->getQuery(); $urls = $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); return $this->response( VariableUtil::arrayFlatten($urls) ); }
php
public function getLocationsUrlsMetaAction() { $qb = $this->getQueryBuilder(); $qb->select('l.url'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.operation IS NULL'); $qb->groupBy(('l.url')); $query = $qb->getQuery(); $urls = $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY); return $this->response( VariableUtil::arrayFlatten($urls) ); }
[ "public", "function", "getLocationsUrlsMetaAction", "(", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "'l.url'", ")", ";", "$", "qb", "->", "from", "(", "'CampaignChain\\CoreBundle\\Entity\\Ch...
List all URLs of all connected Locations in all Channels. Example Request =============== GET /api/v1/locations/urls Example Response ================ { "1": "http://wordpress.amariki.com", "2": "http://www.slideshare.net/amariki_test", "3": "https://global.gotowebinar.com/webinars.tmpl", "4": "https://twitter.com/AmarikiTest1", "5": "https://www.facebook.com/pages/Amariki/1384145015223372", "6": "https://www.facebook.com/profile.php?id=100008874400259", "7": "https://www.facebook.com/profile.php?id=100008922632416", "8": "https://www.linkedin.com/pub/amariki-software/a1/455/616" } @ApiDoc( section="Core" ) @REST\GET("/locations/urls") @return \Symfony\Component\HttpFoundation\Response
[ "List", "all", "URLs", "of", "all", "connected", "Locations", "in", "all", "Channels", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ChannelController.php#L65-L81
CampaignChain/core
Controller/REST/ChannelController.php
ChannelController.getLocationsUrlsAction
public function getLocationsUrlsAction($url) { $qb = $this->getQueryBuilder(); $qb->select('c.id, c.name AS displayName, l.url, c.trackingId, c.status, c.createdDate'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.url = :url'); $qb->setParameter('url', $url); $qb = $this->getModulePackage($qb, 'c.channelModule'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
php
public function getLocationsUrlsAction($url) { $qb = $this->getQueryBuilder(); $qb->select('c.id, c.name AS displayName, l.url, c.trackingId, c.status, c.createdDate'); $qb->from('CampaignChain\CoreBundle\Entity\Channel', 'c'); $qb->from('CampaignChain\CoreBundle\Entity\Location', 'l'); $qb->where('c.id = l.channel'); $qb->andWhere('l.url = :url'); $qb->setParameter('url', $url); $qb = $this->getModulePackage($qb, 'c.channelModule'); $query = $qb->getQuery(); return $this->response( $query->getResult(\Doctrine\ORM\Query::HYDRATE_ARRAY) ); }
[ "public", "function", "getLocationsUrlsAction", "(", "$", "url", ")", "{", "$", "qb", "=", "$", "this", "->", "getQueryBuilder", "(", ")", ";", "$", "qb", "->", "select", "(", "'c.id, c.name AS displayName, l.url, c.trackingId, c.status, c.createdDate'", ")", ";", ...
Get a specific Channel Location by its URL. Example Request =============== GET /api/v1/channels/locations/urls/https%3A%2F%2Ftwitter.com%2FAmarikiTest1 Example Response ================ [ { "id": 2, "displayName": "Corporate Twitter Account", "url": "https://twitter.com/AmarikiTest1", "trackingId": "2f6d485e7789e7b6d70b546d221739cf", "status": "active", "createdDate": "2015-11-26T11:08:29+0000", "composerPackage": "campaignchain/channel-twitter", "moduleIdentifier": "campaignchain-twitter" } ] @ApiDoc( section="Core", requirements={ { "name"="url", "requirement"=".+" } } ) @REST\NoRoute() // We have specified a route manually. @param string $url URL of a Channel connected to CampaignChain, e.g. 'https://twitter.com/AmarikiTest1'. @return \Symfony\Component\HttpFoundation\Response
[ "Get", "a", "specific", "Channel", "Location", "by", "its", "URL", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Controller/REST/ChannelController.php#L123-L138
cornernote/yii-email-module
email/EmailModule.php
EmailModule.initYiiStrap
public function initYiiStrap() { // check that we are in a web application if (!(Yii::app() instanceof CWebApplication)) return; // and in this module $route = explode('/', Yii::app()->urlManager->parseUrl(Yii::app()->request)); if ($route[0] != $this->id) return; // and yiiStrap is not configured if (Yii::getPathOfAlias('bootstrap') && file_exists(Yii::getPathOfAlias('bootstrap.helpers') . '/TbHtml.php')) return; // try to guess yiiStrapPath if ($this->yiiStrapPath === null) $this->yiiStrapPath = Yii::getPathOfAlias('vendor.crisu83.yiistrap'); // check for valid path if (!realpath($this->yiiStrapPath)) return; // setup yiiStrap components Yii::setPathOfAlias('bootstrap', realpath($this->yiiStrapPath)); Yii::import('bootstrap.helpers.*'); Yii::import('bootstrap.widgets.*'); Yii::import('bootstrap.behaviors.*'); Yii::import('bootstrap.form.*'); Yii::app()->setComponents(array( 'bootstrap' => array( 'class' => 'bootstrap.components.TbApi', ), ), false); }
php
public function initYiiStrap() { // check that we are in a web application if (!(Yii::app() instanceof CWebApplication)) return; // and in this module $route = explode('/', Yii::app()->urlManager->parseUrl(Yii::app()->request)); if ($route[0] != $this->id) return; // and yiiStrap is not configured if (Yii::getPathOfAlias('bootstrap') && file_exists(Yii::getPathOfAlias('bootstrap.helpers') . '/TbHtml.php')) return; // try to guess yiiStrapPath if ($this->yiiStrapPath === null) $this->yiiStrapPath = Yii::getPathOfAlias('vendor.crisu83.yiistrap'); // check for valid path if (!realpath($this->yiiStrapPath)) return; // setup yiiStrap components Yii::setPathOfAlias('bootstrap', realpath($this->yiiStrapPath)); Yii::import('bootstrap.helpers.*'); Yii::import('bootstrap.widgets.*'); Yii::import('bootstrap.behaviors.*'); Yii::import('bootstrap.form.*'); Yii::app()->setComponents(array( 'bootstrap' => array( 'class' => 'bootstrap.components.TbApi', ), ), false); }
[ "public", "function", "initYiiStrap", "(", ")", "{", "// check that we are in a web application", "if", "(", "!", "(", "Yii", "::", "app", "(", ")", "instanceof", "CWebApplication", ")", ")", "return", ";", "// and in this module", "$", "route", "=", "explode", ...
Setup yiiStrap, works even if YiiBooster is used in main app.
[ "Setup", "yiiStrap", "works", "even", "if", "YiiBooster", "is", "used", "in", "main", "app", "." ]
train
https://github.com/cornernote/yii-email-module/blob/dcfb9e17dc0b4daff7052418d26402e05e1c8887/email/EmailModule.php#L207-L236
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Domain/Vocabulary/VocabularyService.php
VocabularyService.validateVocabularyUri
public function validateVocabularyUri($uri) { $uri = trim($uri); // If the vocabulary URI is invalid if (!strlen($uri) || !filter_var($uri, FILTER_VALIDATE_URL)) { throw new RuntimeException( sprintf(RuntimeException::INVALID_VOCABULARY_URI_STR, $uri), RuntimeException::INVALID_VOCABULARY_URI ); } return $uri; }
php
public function validateVocabularyUri($uri) { $uri = trim($uri); // If the vocabulary URI is invalid if (!strlen($uri) || !filter_var($uri, FILTER_VALIDATE_URL)) { throw new RuntimeException( sprintf(RuntimeException::INVALID_VOCABULARY_URI_STR, $uri), RuntimeException::INVALID_VOCABULARY_URI ); } return $uri; }
[ "public", "function", "validateVocabularyUri", "(", "$", "uri", ")", "{", "$", "uri", "=", "trim", "(", "$", "uri", ")", ";", "// If the vocabulary URI is invalid", "if", "(", "!", "strlen", "(", "$", "uri", ")", "||", "!", "filter_var", "(", "$", "uri",...
Validate a vocabulary URI @param string $uri URI @return string Valid vocabulary URI @throws RuntimeException If the vocabulary URI is invalid
[ "Validate", "a", "vocabulary", "URI" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Domain/Vocabulary/VocabularyService.php#L56-L69
Deathnerd/php-wtforms
src/Form.php
Form.validate
public function validate() { $this->_errors = []; $success = true; foreach ($this->fields as $name => $field) { /** @var $field Field */ if (!$field->validate($this, $this->getExtraValidatorFor($name))) { $success = false; } } return $success && count($this->_errors) === 0; }
php
public function validate() { $this->_errors = []; $success = true; foreach ($this->fields as $name => $field) { /** @var $field Field */ if (!$field->validate($this, $this->getExtraValidatorFor($name))) { $success = false; } } return $success && count($this->_errors) === 0; }
[ "public", "function", "validate", "(", ")", "{", "$", "this", "->", "_errors", "=", "[", "]", ";", "$", "success", "=", "true", ";", "foreach", "(", "$", "this", "->", "fields", "as", "$", "name", "=>", "$", "field", ")", "{", "/** @var $field Field ...
Validates the form by calling `validate` on each field, passing any extra `Form.validate_<fieldname>` validators to the field validator. @return bool
[ "Validates", "the", "form", "by", "calling", "validate", "on", "each", "field", "passing", "any", "extra", "Form", ".", "validate_<fieldname", ">", "validators", "to", "the", "field", "validator", "." ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/Form.php#L105-L117
Deathnerd/php-wtforms
src/Form.php
Form.populate
public function populate($data) { if (is_object($data)) { return $this->populateObj($data); } if (is_array($data)) { return $this->populateArray($data); } throw new \InvalidArgumentException( sprintf("Form::populate accepts only an array or an object as input; %s given.", gettype($data)) ); }
php
public function populate($data) { if (is_object($data)) { return $this->populateObj($data); } if (is_array($data)) { return $this->populateArray($data); } throw new \InvalidArgumentException( sprintf("Form::populate accepts only an array or an object as input; %s given.", gettype($data)) ); }
[ "public", "function", "populate", "(", "$", "data", ")", "{", "if", "(", "is_object", "(", "$", "data", ")", ")", "{", "return", "$", "this", "->", "populateObj", "(", "$", "data", ")", ";", "}", "if", "(", "is_array", "(", "$", "data", ")", ")",...
Convenience method for populating objects and arrays. Under the hood it calls {@link populateObj} or {@link populateArray} depending on what was passed into the function. @param array|object $data @throws \InvalidArgumentException If something besides an object or an array were passed @return array|object The result of populating the object or array passed
[ "Convenience", "method", "for", "populating", "objects", "and", "arrays", ".", "Under", "the", "hood", "it", "calls", "{", "@link", "populateObj", "}", "or", "{", "@link", "populateArray", "}", "depending", "on", "what", "was", "passed", "into", "the", "func...
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/Form.php#L228-L239
Deathnerd/php-wtforms
src/Form.php
Form.populateObj
public function populateObj(&$obj) { foreach ($this->fields as $field_name => $field) { /** * @var Field $field */ $field->populateObj($obj, $field_name); } return $obj; }
php
public function populateObj(&$obj) { foreach ($this->fields as $field_name => $field) { /** * @var Field $field */ $field->populateObj($obj, $field_name); } return $obj; }
[ "public", "function", "populateObj", "(", "&", "$", "obj", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field_name", "=>", "$", "field", ")", "{", "/**\n * @var Field $field\n */", "$", "field", "->", "populateObj", ...
This takes in an object with properties and assigns their values to the values of fields with the same name on this form. This is a destructive operation. If a field exists on this form that has the same name as a property on the object, it WILL BE OVERWRITTEN. @param object $obj The object to populate @return object The object with the data from the form replacing values for members of the object
[ "This", "takes", "in", "an", "object", "with", "properties", "and", "assigns", "their", "values", "to", "the", "values", "of", "fields", "with", "the", "same", "name", "on", "this", "form", "." ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/Form.php#L252-L262
Deathnerd/php-wtforms
src/Form.php
Form.populateArray
public function populateArray(array $array) { foreach ($this->fields as $field_name => $field) { if ($field->data) { $array[$field_name] = $field->data; } } return $array; }
php
public function populateArray(array $array) { foreach ($this->fields as $field_name => $field) { if ($field->data) { $array[$field_name] = $field->data; } } return $array; }
[ "public", "function", "populateArray", "(", "array", "$", "array", ")", "{", "foreach", "(", "$", "this", "->", "fields", "as", "$", "field_name", "=>", "$", "field", ")", "{", "if", "(", "$", "field", "->", "data", ")", "{", "$", "array", "[", "$"...
This takes in a keyed array and assigns their values to the values of fields with the same name as the key. !!!!!!!!!!!!! !!!WARNING!!! !!!!!!!!!!!!! This is a destructive operation. If a field exists on this form that has the same name as a key in the array, it WILL BE OVERWRITTEN. @param array $array The array to populate @return array The array with data from the form replacing values already existing in the array
[ "This", "takes", "in", "a", "keyed", "array", "and", "assigns", "their", "values", "to", "the", "values", "of", "fields", "with", "the", "same", "name", "as", "the", "key", "." ]
train
https://github.com/Deathnerd/php-wtforms/blob/2e1f9ad515f6241c9fac57edc472bf657267f4a1/src/Form.php#L278-L287
CampaignChain/core
Model/DhtmlxGantt.php
DhtmlxGantt.getTasks
public function getTasks($bundleName = null, $moduleIdentifier = null, $campaignId = null){ $qb = $this->em->createQueryBuilder(); $qb->select('c') ->from('CampaignChain\CoreBundle\Entity\Campaign', 'c'); if(isset($bundleName) && isset($moduleIdentifier)){ $qb->from('CampaignChain\CoreBundle\Entity\Module', 'm') ->from('CampaignChain\CoreBundle\Entity\Bundle', 'b') ->where('b.name = :bundleName') ->andWhere('m.identifier = :moduleIdentifier') ->andWhere('m.id = c.campaignModule') ->setParameter('bundleName', $bundleName) ->setParameter('moduleIdentifier', $moduleIdentifier); } if(isset($campaignId)){ $qb->andWhere('c.id = :campaignId') ->setParameter('campaignId', $campaignId); } $qb->andWhere('c.parent IS NULL'); $qb->orderBy('c.startDate', 'DESC'); $query = $qb->getQuery(); $campaigns = $query->getResult(); //$ganttTask = $campaigns; // Create GANTT data $ganttDataId = 1; $ganttLinkId = 1; foreach($campaigns as $campaign){ $campaign_data['text'] = $campaign->getName(); // Define the trigger hook's identifier. if($campaign->getTriggerHook()){ //$campaign_data['trigger_identifier'] = str_replace('-', '_', $campaign->getTriggerHook()->getIdentifier()); // Retrieve the start and end date from the trigger hook. $hookService = $this->container->get($campaign->getTriggerHook()->getServices()['entity']); $hook = $hookService->getHook($campaign); $campaign_data['start_date'] = $hook->getStartDate()->format(self::FORMAT_TIMELINE_DATE); if($hook->getEndDate()){ $campaign_data['end_date'] = $hook->getEndDate()->format(self::FORMAT_TIMELINE_DATE); } else { $campaign_data['end_date'] = $campaign_data['start_date']; } // Provide the hook's start and end date form field names. //$campaign_data['start_date_identifier'] = $hookService->getStartDateIdentifier(); //$campaign_data['end_date_identifier'] = $hookService->getEndDateIdentifier(); } $campaignId = $campaign->getId(); // $campaign_data['id'] = (string) $ganttDataId; $campaign_data['id'] = (string) $campaign->getId().'_campaign'; $campaign_data['campaignchain_id'] = (string) $campaign->getId(); $campaign_data['type'] = 'campaign'; $campaign_data['route_edit_api'] = $campaign->getCampaignModule()->getRoutes()['edit_api']; $campaign_data['route_plan_detail'] = $campaign->getCampaignModule()->getRoutes()['plan_detail']; $campaignService = $this->container->get('campaignchain.core.campaign'); $campaign_data['tpl_teaser'] = $campaignService->tplTeaser( $campaign->getCampaignModule(), array( 'only_icon' => true, 'size' => 24, ) ); $ganttDataId++; // $campaign['entity'] = array( // 'id' => $campaignId, // 'name' => 'Campaign', // ); $ganttCampaignData[] = $campaign_data; // Get activities of campaign $qb = $this->em->createQueryBuilder(); $qb->select('a') ->from('CampaignChain\CoreBundle\Entity\Activity', 'a') ->where('a.campaign = :campaignId') ->andWhere('a.parent IS NULL') ->setParameter('campaignId', $campaignId) ->orderBy('a.startDate', 'ASC'); $query = $qb->getQuery(); $activities = $query->getResult(); if(is_array($activities) && count($activities)){ foreach($activities as $activity){ $activity_data['text'] = $activity->getName(); // Define the trigger hook's identifier. //$activity_data['trigger_identifier'] = str_replace('-', '_', $activity->getTriggerHook()->getIdentifier()); // Retrieve the start and end date from the trigger hook. $hookService = $this->container->get($activity->getTriggerHook()->getServices()['entity']); $hook = $hookService->getHook($activity); $activity_data['start_date'] = $hook->getStartDate()->format(self::FORMAT_TIMELINE_DATE); if($hook->getEndDate()){ $activity_data['end_date'] = $hook->getEndDate()->format(self::FORMAT_TIMELINE_DATE); } else { $activity_data['end_date'] = $activity_data['start_date']; } // Provide the hook's start and end date form field names. //$activity_data['start_date_identifier'] = $hookService->getStartDateIdentifier(); //$activity_data['end_date_identifier'] = $hookService->getEndDateIdentifier(); // $activity_data['start_date'] = $activity_data['end_date'] = $activity->getDue()->format(self::FORMAT_TIMELINE_DATE); // $activity_data['id'] = $ganttDataId; $activity_data['id'] = (string) $activity->getId().'_activity'; $ganttDataId++; $activity_data['campaignchain_id'] = (string) $activity->getId(); $activity_data['parent'] = $campaign_data['id']; $activity_data['type'] = 'activity'; // $activity_data['form_root_name'] = $activity->getActivityModule()->getFormRootName(); $activity_data['route_edit_api'] = $activity->getActivityModule()->getRoutes()['edit_api']; $activity_data['route_read_modal'] = $activity->getActivityModule()->getRoutes()['read_modal']; // Get activity icons path $activityService = $this->container->get('campaignchain.core.activity'); $activity_data['tpl_teaser'] = $activityService->tplTeaser($activity, array('only_icon' => true)); $ganttActivityData[] = $activity_data; $ganttActivityLinks[] = array( 'id' => $ganttLinkId, 'source' => $campaign_data['id'], 'target' => $activity_data['id'], 'type' => '1', ); $ganttLinkId++; // TODO: Retrieve GANTT data for operations of an activity if the activity does not equal the operation. } } // Get milestones of campaign $qb = $this->em->createQueryBuilder(); $qb->select('m') ->from('CampaignChain\CoreBundle\Entity\Milestone', 'm') ->where('m.campaign = :campaignId') ->setParameter('campaignId', $campaignId) ->orderBy('m.startDate', 'ASC'); $query = $qb->getQuery(); $milestones = $query->getResult(); if(is_array($milestones) && count($milestones)){ foreach($milestones as $milestone){ $milestone_data['text'] = $milestone->getName(); // Define the trigger hook's identifier. //$milestone_data['trigger_identifier'] = str_replace('-', '_', $milestone->getTriggerHook()->getIdentifier()); // Retrieve the start and end date from the trigger hook. $hookService = $this->container->get($milestone->getTriggerHook()->getServices()['entity']); $hook = $hookService->getHook($milestone); $milestone_data['start_date'] = $hook->getStartDate()->format(self::FORMAT_TIMELINE_DATE); if($hook->getEndDate()){ $milestone_data['end_date'] = $hook->getEndDate()->format(self::FORMAT_TIMELINE_DATE); } else { $milestone_data['end_date'] = $milestone_data['start_date']; } // Provide the hook's start and end date form field names. //$milestone_data['start_date_identifier'] = $hookService->getStartDateIdentifier(); //$milestone_data['end_date_identifier'] = $hookService->getEndDateIdentifier(); // $milestone_data['id'] = $ganttDataId; $milestone_data['id'] = (string) $milestone->getId().'_milestone'; $ganttDataId++; $milestone_data['campaignchain_id'] = (string) $milestone->getId(); $milestone_data['parent'] = $campaign_data['id']; $milestone_data['type'] = 'milestone'; $milestone_data['route_edit_api'] = $milestone->getMilestoneModule()->getRoutes()['edit_api']; $milestone_data['route_read_modal'] = $milestone->getMilestoneModule()->getRoutes()['edit_api']; // Get icons path $milestoneService = $this->container->get('campaignchain.core.milestone'); $icons = $milestoneService->getIcons($milestone); $milestone_data['icon_path_16px'] = $icons['16px']; $milestone_data['icon_path_24px'] = $icons['24px']; $ganttMilestoneData[] = $milestone_data; $ganttMilestoneLinks[] = array( 'id' => $ganttLinkId, 'source' => $campaign_data['id'], 'target' => $milestone_data['id'], 'type' => '1', ); $ganttLinkId++; } } } $ganttTasks = array(); if(isset($ganttCampaignData) && is_array($ganttCampaignData)){ $hasMilestones = false; $hasActivities = false; $ganttTasks['data'] = $ganttCampaignData; if(isset($ganttMilestoneData) && is_array($ganttMilestoneData)){ $ganttTasks['data'] = array_merge($ganttTasks['data'], $ganttMilestoneData); $hasMilestones = true; } if(isset($ganttActivityData) && is_array($ganttActivityData)){ $ganttTasks['data'] = array_merge($ganttTasks['data'], $ganttActivityData); $hasActivities = true; } if($hasMilestones && $hasActivities){ $ganttTasks['links'] = array_merge($ganttActivityLinks, $ganttMilestoneLinks); } elseif($hasMilestones){ $ganttTasks['links'] = $ganttMilestoneLinks; } elseif($hasActivities){ $ganttTasks['links'] = $ganttActivityLinks; } } else { $this->container->get('session')->getFlashBag()->add( 'warning', 'No campaigns available yet. Please create one.' ); header('Location: '. $this->container->get('router')->generate('campaignchain_core_campaign_new') ); exit; } return $this->serializer->serialize($ganttTasks, 'json'); }
php
public function getTasks($bundleName = null, $moduleIdentifier = null, $campaignId = null){ $qb = $this->em->createQueryBuilder(); $qb->select('c') ->from('CampaignChain\CoreBundle\Entity\Campaign', 'c'); if(isset($bundleName) && isset($moduleIdentifier)){ $qb->from('CampaignChain\CoreBundle\Entity\Module', 'm') ->from('CampaignChain\CoreBundle\Entity\Bundle', 'b') ->where('b.name = :bundleName') ->andWhere('m.identifier = :moduleIdentifier') ->andWhere('m.id = c.campaignModule') ->setParameter('bundleName', $bundleName) ->setParameter('moduleIdentifier', $moduleIdentifier); } if(isset($campaignId)){ $qb->andWhere('c.id = :campaignId') ->setParameter('campaignId', $campaignId); } $qb->andWhere('c.parent IS NULL'); $qb->orderBy('c.startDate', 'DESC'); $query = $qb->getQuery(); $campaigns = $query->getResult(); //$ganttTask = $campaigns; // Create GANTT data $ganttDataId = 1; $ganttLinkId = 1; foreach($campaigns as $campaign){ $campaign_data['text'] = $campaign->getName(); // Define the trigger hook's identifier. if($campaign->getTriggerHook()){ //$campaign_data['trigger_identifier'] = str_replace('-', '_', $campaign->getTriggerHook()->getIdentifier()); // Retrieve the start and end date from the trigger hook. $hookService = $this->container->get($campaign->getTriggerHook()->getServices()['entity']); $hook = $hookService->getHook($campaign); $campaign_data['start_date'] = $hook->getStartDate()->format(self::FORMAT_TIMELINE_DATE); if($hook->getEndDate()){ $campaign_data['end_date'] = $hook->getEndDate()->format(self::FORMAT_TIMELINE_DATE); } else { $campaign_data['end_date'] = $campaign_data['start_date']; } // Provide the hook's start and end date form field names. //$campaign_data['start_date_identifier'] = $hookService->getStartDateIdentifier(); //$campaign_data['end_date_identifier'] = $hookService->getEndDateIdentifier(); } $campaignId = $campaign->getId(); // $campaign_data['id'] = (string) $ganttDataId; $campaign_data['id'] = (string) $campaign->getId().'_campaign'; $campaign_data['campaignchain_id'] = (string) $campaign->getId(); $campaign_data['type'] = 'campaign'; $campaign_data['route_edit_api'] = $campaign->getCampaignModule()->getRoutes()['edit_api']; $campaign_data['route_plan_detail'] = $campaign->getCampaignModule()->getRoutes()['plan_detail']; $campaignService = $this->container->get('campaignchain.core.campaign'); $campaign_data['tpl_teaser'] = $campaignService->tplTeaser( $campaign->getCampaignModule(), array( 'only_icon' => true, 'size' => 24, ) ); $ganttDataId++; // $campaign['entity'] = array( // 'id' => $campaignId, // 'name' => 'Campaign', // ); $ganttCampaignData[] = $campaign_data; // Get activities of campaign $qb = $this->em->createQueryBuilder(); $qb->select('a') ->from('CampaignChain\CoreBundle\Entity\Activity', 'a') ->where('a.campaign = :campaignId') ->andWhere('a.parent IS NULL') ->setParameter('campaignId', $campaignId) ->orderBy('a.startDate', 'ASC'); $query = $qb->getQuery(); $activities = $query->getResult(); if(is_array($activities) && count($activities)){ foreach($activities as $activity){ $activity_data['text'] = $activity->getName(); // Define the trigger hook's identifier. //$activity_data['trigger_identifier'] = str_replace('-', '_', $activity->getTriggerHook()->getIdentifier()); // Retrieve the start and end date from the trigger hook. $hookService = $this->container->get($activity->getTriggerHook()->getServices()['entity']); $hook = $hookService->getHook($activity); $activity_data['start_date'] = $hook->getStartDate()->format(self::FORMAT_TIMELINE_DATE); if($hook->getEndDate()){ $activity_data['end_date'] = $hook->getEndDate()->format(self::FORMAT_TIMELINE_DATE); } else { $activity_data['end_date'] = $activity_data['start_date']; } // Provide the hook's start and end date form field names. //$activity_data['start_date_identifier'] = $hookService->getStartDateIdentifier(); //$activity_data['end_date_identifier'] = $hookService->getEndDateIdentifier(); // $activity_data['start_date'] = $activity_data['end_date'] = $activity->getDue()->format(self::FORMAT_TIMELINE_DATE); // $activity_data['id'] = $ganttDataId; $activity_data['id'] = (string) $activity->getId().'_activity'; $ganttDataId++; $activity_data['campaignchain_id'] = (string) $activity->getId(); $activity_data['parent'] = $campaign_data['id']; $activity_data['type'] = 'activity'; // $activity_data['form_root_name'] = $activity->getActivityModule()->getFormRootName(); $activity_data['route_edit_api'] = $activity->getActivityModule()->getRoutes()['edit_api']; $activity_data['route_read_modal'] = $activity->getActivityModule()->getRoutes()['read_modal']; // Get activity icons path $activityService = $this->container->get('campaignchain.core.activity'); $activity_data['tpl_teaser'] = $activityService->tplTeaser($activity, array('only_icon' => true)); $ganttActivityData[] = $activity_data; $ganttActivityLinks[] = array( 'id' => $ganttLinkId, 'source' => $campaign_data['id'], 'target' => $activity_data['id'], 'type' => '1', ); $ganttLinkId++; // TODO: Retrieve GANTT data for operations of an activity if the activity does not equal the operation. } } // Get milestones of campaign $qb = $this->em->createQueryBuilder(); $qb->select('m') ->from('CampaignChain\CoreBundle\Entity\Milestone', 'm') ->where('m.campaign = :campaignId') ->setParameter('campaignId', $campaignId) ->orderBy('m.startDate', 'ASC'); $query = $qb->getQuery(); $milestones = $query->getResult(); if(is_array($milestones) && count($milestones)){ foreach($milestones as $milestone){ $milestone_data['text'] = $milestone->getName(); // Define the trigger hook's identifier. //$milestone_data['trigger_identifier'] = str_replace('-', '_', $milestone->getTriggerHook()->getIdentifier()); // Retrieve the start and end date from the trigger hook. $hookService = $this->container->get($milestone->getTriggerHook()->getServices()['entity']); $hook = $hookService->getHook($milestone); $milestone_data['start_date'] = $hook->getStartDate()->format(self::FORMAT_TIMELINE_DATE); if($hook->getEndDate()){ $milestone_data['end_date'] = $hook->getEndDate()->format(self::FORMAT_TIMELINE_DATE); } else { $milestone_data['end_date'] = $milestone_data['start_date']; } // Provide the hook's start and end date form field names. //$milestone_data['start_date_identifier'] = $hookService->getStartDateIdentifier(); //$milestone_data['end_date_identifier'] = $hookService->getEndDateIdentifier(); // $milestone_data['id'] = $ganttDataId; $milestone_data['id'] = (string) $milestone->getId().'_milestone'; $ganttDataId++; $milestone_data['campaignchain_id'] = (string) $milestone->getId(); $milestone_data['parent'] = $campaign_data['id']; $milestone_data['type'] = 'milestone'; $milestone_data['route_edit_api'] = $milestone->getMilestoneModule()->getRoutes()['edit_api']; $milestone_data['route_read_modal'] = $milestone->getMilestoneModule()->getRoutes()['edit_api']; // Get icons path $milestoneService = $this->container->get('campaignchain.core.milestone'); $icons = $milestoneService->getIcons($milestone); $milestone_data['icon_path_16px'] = $icons['16px']; $milestone_data['icon_path_24px'] = $icons['24px']; $ganttMilestoneData[] = $milestone_data; $ganttMilestoneLinks[] = array( 'id' => $ganttLinkId, 'source' => $campaign_data['id'], 'target' => $milestone_data['id'], 'type' => '1', ); $ganttLinkId++; } } } $ganttTasks = array(); if(isset($ganttCampaignData) && is_array($ganttCampaignData)){ $hasMilestones = false; $hasActivities = false; $ganttTasks['data'] = $ganttCampaignData; if(isset($ganttMilestoneData) && is_array($ganttMilestoneData)){ $ganttTasks['data'] = array_merge($ganttTasks['data'], $ganttMilestoneData); $hasMilestones = true; } if(isset($ganttActivityData) && is_array($ganttActivityData)){ $ganttTasks['data'] = array_merge($ganttTasks['data'], $ganttActivityData); $hasActivities = true; } if($hasMilestones && $hasActivities){ $ganttTasks['links'] = array_merge($ganttActivityLinks, $ganttMilestoneLinks); } elseif($hasMilestones){ $ganttTasks['links'] = $ganttMilestoneLinks; } elseif($hasActivities){ $ganttTasks['links'] = $ganttActivityLinks; } } else { $this->container->get('session')->getFlashBag()->add( 'warning', 'No campaigns available yet. Please create one.' ); header('Location: '. $this->container->get('router')->generate('campaignchain_core_campaign_new') ); exit; } return $this->serializer->serialize($ganttTasks, 'json'); }
[ "public", "function", "getTasks", "(", "$", "bundleName", "=", "null", ",", "$", "moduleIdentifier", "=", "null", ",", "$", "campaignId", "=", "null", ")", "{", "$", "qb", "=", "$", "this", "->", "em", "->", "createQueryBuilder", "(", ")", ";", "$", ...
Get JSON encoded data for DHTMLXGantt chart. @return string|\Symfony\Component\Serializer\Encoder\scalar
[ "Get", "JSON", "encoded", "data", "for", "DHTMLXGantt", "chart", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Model/DhtmlxGantt.php#L235-L453
CampaignChain/core
EntityService/CampaignService.php
CampaignService.isValidStartDate
public function isValidStartDate(Campaign $campaign, \DateTime $startDate) { if($startDate != $campaign->getStartDate()){ /* * While changing the campaign start date, has an earlier * Action been added by someone else? */ /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); if($firstAction && $startDate > $firstAction->getStartDate()){ return false; } } return true; }
php
public function isValidStartDate(Campaign $campaign, \DateTime $startDate) { if($startDate != $campaign->getStartDate()){ /* * While changing the campaign start date, has an earlier * Action been added by someone else? */ /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); if($firstAction && $startDate > $firstAction->getStartDate()){ return false; } } return true; }
[ "public", "function", "isValidStartDate", "(", "Campaign", "$", "campaign", ",", "\\", "DateTime", "$", "startDate", ")", "{", "if", "(", "$", "startDate", "!=", "$", "campaign", "->", "getStartDate", "(", ")", ")", "{", "/*\n * While changing the ca...
Find out if the start date was changed. If so, then make sure that while editing, no Actions have been added prior or after the respective date. @param Campaign $campaign @param \DateTime $startDate @throws \Exception
[ "Find", "out", "if", "the", "start", "date", "was", "changed", ".", "If", "so", "then", "make", "sure", "that", "while", "editing", "no", "Actions", "have", "been", "added", "prior", "or", "after", "the", "respective", "date", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CampaignService.php#L309-L326
CampaignChain/core
EntityService/CampaignService.php
CampaignService.isValidEndDate
public function isValidEndDate(Campaign $campaign, \DateTime $endDate) { if($endDate != $campaign->getEndDate()){ /* * While changing the campaign end date, has a later * Action been added by someone else? */ /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); if($lastAction && $endDate < $lastAction->getStartDate()){ return false; } } return true; }
php
public function isValidEndDate(Campaign $campaign, \DateTime $endDate) { if($endDate != $campaign->getEndDate()){ /* * While changing the campaign end date, has a later * Action been added by someone else? */ /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); if($lastAction && $endDate < $lastAction->getStartDate()){ return false; } } return true; }
[ "public", "function", "isValidEndDate", "(", "Campaign", "$", "campaign", ",", "\\", "DateTime", "$", "endDate", ")", "{", "if", "(", "$", "endDate", "!=", "$", "campaign", "->", "getEndDate", "(", ")", ")", "{", "/*\n * While changing the campaign e...
Find out if the end date was changed. If so, then make sure that while editing, no Actions have been added prior or after the respective date. @param Campaign $campaign @param \DateTime $endDate @throws \Exception
[ "Find", "out", "if", "the", "end", "date", "was", "changed", ".", "If", "so", "then", "make", "sure", "that", "while", "editing", "no", "Actions", "have", "been", "added", "prior", "or", "after", "the", "respective", "date", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CampaignService.php#L336-L353
CampaignChain/core
EntityService/CampaignService.php
CampaignService.isValidTimespan
public function isValidTimespan(Campaign $campaign, \DateInterval $campaignInterval) { /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); // If no first and last action, any timespan is fine. if(!$firstAction && !$lastAction){ return true; } /* * If first and last action exist, make sure the timespan stretches from * the start of the first to the start or end of the last action. */ if($firstAction && $lastAction){ if($lastAction->getEndDate()){ $endDate = $lastAction->getEndDate(); } else { $endDate = $lastAction->getStartDate(); } $actionsInterval = $firstAction->getStartDate()->diff($endDate); return $campaignInterval >= $actionsInterval; } /* * If only first action or last action, make sure the timespan covers * the duration of the action. */ if($firstAction && !$lastAction) { $action = $firstAction; } else { $action = $lastAction; } // If the action has no end date, then any timespan will do. if(!$action->getEndDate()){ return true; } $actionInterval = $action->getStartDate()->diff($action->getEndDate()); return $campaignInterval >= $actionInterval; }
php
public function isValidTimespan(Campaign $campaign, \DateInterval $campaignInterval) { /** @var Action $firstAction */ $firstAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getFirstAction($campaign); /** @var Action $lastAction */ $lastAction = $this->em->getRepository('CampaignChain\CoreBundle\Entity\Campaign') ->getLastAction($campaign); // If no first and last action, any timespan is fine. if(!$firstAction && !$lastAction){ return true; } /* * If first and last action exist, make sure the timespan stretches from * the start of the first to the start or end of the last action. */ if($firstAction && $lastAction){ if($lastAction->getEndDate()){ $endDate = $lastAction->getEndDate(); } else { $endDate = $lastAction->getStartDate(); } $actionsInterval = $firstAction->getStartDate()->diff($endDate); return $campaignInterval >= $actionsInterval; } /* * If only first action or last action, make sure the timespan covers * the duration of the action. */ if($firstAction && !$lastAction) { $action = $firstAction; } else { $action = $lastAction; } // If the action has no end date, then any timespan will do. if(!$action->getEndDate()){ return true; } $actionInterval = $action->getStartDate()->diff($action->getEndDate()); return $campaignInterval >= $actionInterval; }
[ "public", "function", "isValidTimespan", "(", "Campaign", "$", "campaign", ",", "\\", "DateInterval", "$", "campaignInterval", ")", "{", "/** @var Action $firstAction */", "$", "firstAction", "=", "$", "this", "->", "em", "->", "getRepository", "(", "'CampaignChain\...
Calculates whether the given timespan covers the first and last action in a campaign. @param Campaign $campaign @param \DateInterval $campaignInterval @return bool
[ "Calculates", "whether", "the", "given", "timespan", "covers", "the", "first", "and", "last", "action", "in", "a", "campaign", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/EntityService/CampaignService.php#L411-L460
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.processElement
public function processElement(\DOMElement $element, ContextInterface $context) { // Process default vocabulary registrations $context = $this->processVocab($element, $context); // Register vocabulary prefixes $context = $this->processPrefix($element, $context); // Create a property return $this->processProperty($element, $context); }
php
public function processElement(\DOMElement $element, ContextInterface $context) { // Process default vocabulary registrations $context = $this->processVocab($element, $context); // Register vocabulary prefixes $context = $this->processPrefix($element, $context); // Create a property return $this->processProperty($element, $context); }
[ "public", "function", "processElement", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "// Process default vocabulary registrations", "$", "context", "=", "$", "this", "->", "processVocab", "(", "$", "element", ",", "$"...
Process a DOM element @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "a", "DOM", "element" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L61-L71
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.processVocab
protected function processVocab(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('vocab') && ($context instanceof RdfaLiteContext)) { $defaultVocabulary = new Vocabulary($element->getAttribute('vocab')); $context = $context->setDefaultVocabulary($defaultVocabulary); } return $context; }
php
protected function processVocab(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('vocab') && ($context instanceof RdfaLiteContext)) { $defaultVocabulary = new Vocabulary($element->getAttribute('vocab')); $context = $context->setDefaultVocabulary($defaultVocabulary); } return $context; }
[ "protected", "function", "processVocab", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'vocab'", ")", "&&", "(", "$", "context", "instanceof", "RdfaLiteContext...
Process changes of the default vocabulary @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "changes", "of", "the", "default", "vocabulary" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L80-L88
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.processPrefix
protected function processPrefix(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) { $prefixes = preg_split('/\s+/', $element->getAttribute('prefix')); while (count($prefixes)) { $prefix = rtrim(array_shift($prefixes), ':'); $uri = array_shift($prefixes); $context = $context->registerVocabulary($prefix, $uri); } } return $context; }
php
protected function processPrefix(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('prefix') && ($context instanceof RdfaLiteContext)) { $prefixes = preg_split('/\s+/', $element->getAttribute('prefix')); while (count($prefixes)) { $prefix = rtrim(array_shift($prefixes), ':'); $uri = array_shift($prefixes); $context = $context->registerVocabulary($prefix, $uri); } } return $context; }
[ "protected", "function", "processPrefix", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'prefix'", ")", "&&", "(", "$", "context", "instanceof", "RdfaLiteConte...
Process vocabulary prefixes @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Process", "vocabulary", "prefixes" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L97-L109
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.processProperty
protected function processProperty(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('property') && !($context->getParentThing() instanceof RootThing)) { $properties = preg_split('/\s+/', $element->getAttribute('property')); foreach ($properties as $index => $property) { list($prefix, $name) = $this->getPrefixName($property); $context = $this->processPropertyPrefixName( $prefix, $name, $element, $context, $index == (count($properties) - 1) ); } } return $context; }
php
protected function processProperty(\DOMElement $element, ContextInterface $context) { if ($element->hasAttribute('property') && !($context->getParentThing() instanceof RootThing)) { $properties = preg_split('/\s+/', $element->getAttribute('property')); foreach ($properties as $index => $property) { list($prefix, $name) = $this->getPrefixName($property); $context = $this->processPropertyPrefixName( $prefix, $name, $element, $context, $index == (count($properties) - 1) ); } } return $context; }
[ "protected", "function", "processProperty", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "if", "(", "$", "element", "->", "hasAttribute", "(", "'property'", ")", "&&", "!", "(", "$", "context", "->", "getParentT...
Create a property @param \DOMElement $element DOM element @param ContextInterface $context Inherited Context @return ContextInterface Local context for this element
[ "Create", "a", "property" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L118-L135
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.getPrefixName
protected function getPrefixName($prefixName) { $prefixName = explode(':', $prefixName); $name = array_pop($prefixName); $prefix = array_pop($prefixName); return [$prefix, $name]; }
php
protected function getPrefixName($prefixName) { $prefixName = explode(':', $prefixName); $name = array_pop($prefixName); $prefix = array_pop($prefixName); return [$prefix, $name]; }
[ "protected", "function", "getPrefixName", "(", "$", "prefixName", ")", "{", "$", "prefixName", "=", "explode", "(", "':'", ",", "$", "prefixName", ")", ";", "$", "name", "=", "array_pop", "(", "$", "prefixName", ")", ";", "$", "prefix", "=", "array_pop",...
Split a value into a vocabulary prefix and a name @param string $prefixName Prefixed name @return array Prefix and name
[ "Split", "a", "value", "into", "a", "vocabulary", "prefix", "and", "a", "name" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L143-L149
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.getPropertyChildValue
protected function getPropertyChildValue(\DOMElement $element, ContextInterface $context) { // If the property creates a new thing if ($element->hasAttribute('typeof')) { return $this->getThing( $element->getAttribute('typeof'), trim($element->getAttribute('resource')) ?: null, $context ); } return null; }
php
protected function getPropertyChildValue(\DOMElement $element, ContextInterface $context) { // If the property creates a new thing if ($element->hasAttribute('typeof')) { return $this->getThing( $element->getAttribute('typeof'), trim($element->getAttribute('resource')) ?: null, $context ); } return null; }
[ "protected", "function", "getPropertyChildValue", "(", "\\", "DOMElement", "$", "element", ",", "ContextInterface", "$", "context", ")", "{", "// If the property creates a new thing", "if", "(", "$", "element", "->", "hasAttribute", "(", "'typeof'", ")", ")", "{", ...
Return a property child value @param \DOMElement $element DOM element @param ContextInterface $context Context @return ThingInterface|null Property child value
[ "Return", "a", "property", "child", "value" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L197-L209
jkphl/rdfa-lite-microdata
src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php
RdfaLiteElementProcessor.getVocabulary
protected function getVocabulary($prefix, ContextInterface $context) { return (empty($prefix) || !($context instanceof RdfaLiteContext)) ? $context->getDefaultVocabulary() : $context->getVocabulary($prefix); }
php
protected function getVocabulary($prefix, ContextInterface $context) { return (empty($prefix) || !($context instanceof RdfaLiteContext)) ? $context->getDefaultVocabulary() : $context->getVocabulary($prefix); }
[ "protected", "function", "getVocabulary", "(", "$", "prefix", ",", "ContextInterface", "$", "context", ")", "{", "return", "(", "empty", "(", "$", "prefix", ")", "||", "!", "(", "$", "context", "instanceof", "RdfaLiteContext", ")", ")", "?", "$", "context"...
Return a vocabulary by prefix with fallback to the default vocabulary @param string $prefix Vocabulary prefix @param ContextInterface $context Context @return VocabularyInterface Vocabulary
[ "Return", "a", "vocabulary", "by", "prefix", "with", "fallback", "to", "the", "default", "vocabulary" ]
train
https://github.com/jkphl/rdfa-lite-microdata/blob/12ea2dcc2bc9d3b78784530b08205c79b2dd7bd8/src/RdfaLiteMicrodata/Infrastructure/Parser/RdfaLiteElementProcessor.php#L229-L233
kgilden/php-digidoc
src/Tracker.php
Tracker.add
public function add($objects) { $objects = is_array($objects) ? $objects : array($objects); foreach ($objects as $object) { if ($this->has($object)) { continue; } $this->objects[] = $object; } }
php
public function add($objects) { $objects = is_array($objects) ? $objects : array($objects); foreach ($objects as $object) { if ($this->has($object)) { continue; } $this->objects[] = $object; } }
[ "public", "function", "add", "(", "$", "objects", ")", "{", "$", "objects", "=", "is_array", "(", "$", "objects", ")", "?", "$", "objects", ":", "array", "(", "$", "objects", ")", ";", "foreach", "(", "$", "objects", "as", "$", "object", ")", "{", ...
Adds the given objects to the tracker. You can pass either a single object or an array of objects. @param object|object[] $objects
[ "Adds", "the", "given", "objects", "to", "the", "tracker", ".", "You", "can", "pass", "either", "a", "single", "object", "or", "an", "array", "of", "objects", "." ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/Tracker.php#L27-L38
prooph/link-process-manager
src/Infrastructure/Factory/ScheduleFirstTasksForWorkflowHandlerFactory.php
ScheduleFirstTasksForWorkflowHandlerFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { return new ScheduleFirstTasksForWorkflowHandler( $serviceLocator->get('prooph.link.pm.workflow_collection'), $serviceLocator->get('prooph.link.pm.message_handler_collection'), $serviceLocator->get('prooph.link.pm.task_collection') ); }
php
public function createService(ServiceLocatorInterface $serviceLocator) { return new ScheduleFirstTasksForWorkflowHandler( $serviceLocator->get('prooph.link.pm.workflow_collection'), $serviceLocator->get('prooph.link.pm.message_handler_collection'), $serviceLocator->get('prooph.link.pm.task_collection') ); }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "return", "new", "ScheduleFirstTasksForWorkflowHandler", "(", "$", "serviceLocator", "->", "get", "(", "'prooph.link.pm.workflow_collection'", ")", ",", "$", "serviceLo...
Create service @param ServiceLocatorInterface $serviceLocator @return mixed
[ "Create", "service" ]
train
https://github.com/prooph/link-process-manager/blob/3d6c8bdc72e855786227747bf06bcf8221f7860a/src/Infrastructure/Factory/ScheduleFirstTasksForWorkflowHandlerFactory.php#L31-L38
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.getContent
public function getContent($type = self::URL_TYPE_SHORTENED_TRACKED) { if (self::URL_TYPE_ORIGINAL === $type) { return $this->content; } else { return ParserUtil::replaceURLsInText($this->content, $this->getReplacementUrls($type)); } }
php
public function getContent($type = self::URL_TYPE_SHORTENED_TRACKED) { if (self::URL_TYPE_ORIGINAL === $type) { return $this->content; } else { return ParserUtil::replaceURLsInText($this->content, $this->getReplacementUrls($type)); } }
[ "public", "function", "getContent", "(", "$", "type", "=", "self", "::", "URL_TYPE_SHORTENED_TRACKED", ")", "{", "if", "(", "self", "::", "URL_TYPE_ORIGINAL", "===", "$", "type", ")", "{", "return", "$", "this", "->", "content", ";", "}", "else", "{", "r...
Return the content with urls replaced. Various formats are available. @param mixed $type @return string
[ "Return", "the", "content", "with", "urls", "replaced", ".", "Various", "formats", "are", "available", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L67-L74
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.addTrackedCTA
public function addTrackedCTA(CTA $cta) { $this->trackedCTAs[] = $cta; $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $cta->getTrackingUrl(), $cta->getShortenedTrackingUrl() ); }
php
public function addTrackedCTA(CTA $cta) { $this->trackedCTAs[] = $cta; $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $cta->getTrackingUrl(), $cta->getShortenedTrackingUrl() ); }
[ "public", "function", "addTrackedCTA", "(", "CTA", "$", "cta", ")", "{", "$", "this", "->", "trackedCTAs", "[", "]", "=", "$", "cta", ";", "$", "this", "->", "queueForReplacement", "(", "$", "cta", "->", "getOriginalUrl", "(", ")", ",", "$", "cta", "...
Keep a record of a tracked CTA and queue it for replacement @param CTA $cta
[ "Keep", "a", "record", "of", "a", "tracked", "CTA", "and", "queue", "it", "for", "replacement" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L81-L91
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.addUntrackedCTA
public function addUntrackedCTA(CTA $cta) { $this->untrackedCTAs[] = $cta; if($cta->getShortenedExpandedUrl()) { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getShortenedExpandedUrl(); } elseif($cta->getShortenedUniqueExpandedUrl()){ $trackingUrl = $cta->getUniqueExpandedUrl(); $shortenedUrl = $cta->getShortenedUniqueExpandedUrl(); } else { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getOriginalUrl(); } $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $trackingUrl, $shortenedUrl ); }
php
public function addUntrackedCTA(CTA $cta) { $this->untrackedCTAs[] = $cta; if($cta->getShortenedExpandedUrl()) { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getShortenedExpandedUrl(); } elseif($cta->getShortenedUniqueExpandedUrl()){ $trackingUrl = $cta->getUniqueExpandedUrl(); $shortenedUrl = $cta->getShortenedUniqueExpandedUrl(); } else { $trackingUrl = $cta->getOriginalUrl(); $shortenedUrl = $cta->getOriginalUrl(); } $this->queueForReplacement( $cta->getOriginalUrl(), $cta->getExpandedUrl(), $trackingUrl, $shortenedUrl ); }
[ "public", "function", "addUntrackedCTA", "(", "CTA", "$", "cta", ")", "{", "$", "this", "->", "untrackedCTAs", "[", "]", "=", "$", "cta", ";", "if", "(", "$", "cta", "->", "getShortenedExpandedUrl", "(", ")", ")", "{", "$", "trackingUrl", "=", "$", "...
Keep a record of a untracked CTA and queue it for replacement @param CTA $cta
[ "Keep", "a", "record", "of", "a", "untracked", "CTA", "and", "queue", "it", "for", "replacement" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L98-L119
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.queueForReplacement
public function queueForReplacement($originalUrl, $expandedUrl, $trackingUrl, $shortenedTrackingUrl) { $this->replacementUrls[$originalUrl][] = array( self::URL_TYPE_EXPANDED => $expandedUrl, self::URL_TYPE_TRACKED => $trackingUrl, self::URL_TYPE_SHORTENED_TRACKED => $shortenedTrackingUrl ); }
php
public function queueForReplacement($originalUrl, $expandedUrl, $trackingUrl, $shortenedTrackingUrl) { $this->replacementUrls[$originalUrl][] = array( self::URL_TYPE_EXPANDED => $expandedUrl, self::URL_TYPE_TRACKED => $trackingUrl, self::URL_TYPE_SHORTENED_TRACKED => $shortenedTrackingUrl ); }
[ "public", "function", "queueForReplacement", "(", "$", "originalUrl", ",", "$", "expandedUrl", ",", "$", "trackingUrl", ",", "$", "shortenedTrackingUrl", ")", "{", "$", "this", "->", "replacementUrls", "[", "$", "originalUrl", "]", "[", "]", "=", "array", "(...
Queue urls for replacement @param string $originalUrl @param string $expandedUrl @param string $trackingUrl @param string $shortenedTrackingUrl
[ "Queue", "urls", "for", "replacement" ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L129-L136
CampaignChain/core
Entity/CTAParserData.php
CTAParserData.getReplacementUrls
public function getReplacementUrls($type) { $replacementUrls = array_map(function ($a1) use ($type) { return array_map(function ($a2) use ($type) { return $a2[$type]; }, $a1); }, $this->replacementUrls); return $replacementUrls; }
php
public function getReplacementUrls($type) { $replacementUrls = array_map(function ($a1) use ($type) { return array_map(function ($a2) use ($type) { return $a2[$type]; }, $a1); }, $this->replacementUrls); return $replacementUrls; }
[ "public", "function", "getReplacementUrls", "(", "$", "type", ")", "{", "$", "replacementUrls", "=", "array_map", "(", "function", "(", "$", "a1", ")", "use", "(", "$", "type", ")", "{", "return", "array_map", "(", "function", "(", "$", "a2", ")", "use...
Filter replacement urls so only one format is left. @param mixed $type @return array map of filtered replacement urls
[ "Filter", "replacement", "urls", "so", "only", "one", "format", "is", "left", "." ]
train
https://github.com/CampaignChain/core/blob/82526548a223ed49fcd65ed7c23638544499775f/Entity/CTAParserData.php#L144-L153
scaytrase/symfony-sms-interface
src/ScayTrase/SmsDeliveryBundle/Command/FlushCommand.php
FlushCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $sender = $this->getContainer()->get('sms_delivery.sender'); $sender->flush(); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $sender = $this->getContainer()->get('sms_delivery.sender'); $sender->flush(); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "sender", "=", "$", "this", "->", "getContainer", "(", ")", "->", "get", "(", "'sms_delivery.sender'", ")", ";", "$", "sender", "...
{@inheritdoc}
[ "{" ]
train
https://github.com/scaytrase/symfony-sms-interface/blob/5645a47652e6511b51f8fcdfba747a167dad0e2c/src/ScayTrase/SmsDeliveryBundle/Command/FlushCommand.php#L30-L35
moharrum/laravel-geoip-world-cities
src/migrations/2016_03_10_114715_create_cities_table.php
CreateCitiesTable.up
public function up() { Schema::create(Config::citiesTableName(), function (Blueprint $table) { $table->increments('id'); $table->char('country', 2) ->nullable(); $table->string('city') ->nullable() ->collation('utf8_unicode_ci'); $table->string('city_ascii') ->nullable(); $table->char('region', 2) ->nullable(); $table->integer('population') ->nullable() ->unsigned(); $table->decimal('latitude', 10, 6) ->nullable(); $table->decimal('longitude', 10, 6) ->nullable(); $table->index('country', 'idx_country'); $table->index('region', 'idx_region'); $table->index(['latitude', 'longitude'], 'idx_lat_long'); $table->timestamps = false; }); }
php
public function up() { Schema::create(Config::citiesTableName(), function (Blueprint $table) { $table->increments('id'); $table->char('country', 2) ->nullable(); $table->string('city') ->nullable() ->collation('utf8_unicode_ci'); $table->string('city_ascii') ->nullable(); $table->char('region', 2) ->nullable(); $table->integer('population') ->nullable() ->unsigned(); $table->decimal('latitude', 10, 6) ->nullable(); $table->decimal('longitude', 10, 6) ->nullable(); $table->index('country', 'idx_country'); $table->index('region', 'idx_region'); $table->index(['latitude', 'longitude'], 'idx_lat_long'); $table->timestamps = false; }); }
[ "public", "function", "up", "(", ")", "{", "Schema", "::", "create", "(", "Config", "::", "citiesTableName", "(", ")", ",", "function", "(", "Blueprint", "$", "table", ")", "{", "$", "table", "->", "increments", "(", "'id'", ")", ";", "$", "table", "...
Run the migrations. @return void
[ "Run", "the", "migrations", "." ]
train
https://github.com/moharrum/laravel-geoip-world-cities/blob/2a3e928d644da3348c3f203b4f41208209c5e97c/src/migrations/2016_03_10_114715_create_cities_table.php#L27-L63
kgilden/php-digidoc
src/File.php
File.createFromSoap
public static function createFromSoap(DataFileInfo $info) { $file = new static(); $file->id = $info->Id; $file->name = $info->Filename; $file->mimeType = $info->MimeType; $file->size = $info->Size; return $file; }
php
public static function createFromSoap(DataFileInfo $info) { $file = new static(); $file->id = $info->Id; $file->name = $info->Filename; $file->mimeType = $info->MimeType; $file->size = $info->Size; return $file; }
[ "public", "static", "function", "createFromSoap", "(", "DataFileInfo", "$", "info", ")", "{", "$", "file", "=", "new", "static", "(", ")", ";", "$", "file", "->", "id", "=", "$", "info", "->", "Id", ";", "$", "file", "->", "name", "=", "$", "info",...
@param DataFileInfo $info @return File
[ "@param", "DataFileInfo", "$info" ]
train
https://github.com/kgilden/php-digidoc/blob/88112ba05688fc1d32c0ff948cb8e1f4d2f264d3/src/File.php#L66-L75