repo stringlengths 6 63 | path stringlengths 5 140 | func_name stringlengths 3 151 | original_string stringlengths 84 13k | language stringclasses 1 value | code stringlengths 84 13k | code_tokens list | docstring stringlengths 3 47.2k | docstring_tokens list | sha stringlengths 40 40 | url stringlengths 91 247 | partition stringclasses 1 value |
|---|---|---|---|---|---|---|---|---|---|---|---|
byrokrat/autogiro | src/Writer/TreeBuilder.php | TreeBuilder.addDeletePaymentRequest | public function addDeletePaymentRequest(string $payerNr): void
{
$this->amendments[] = new Record(
'AmendmentRequest',
$this->payeeBgNode,
new Number(0, $payerNr, 'PayerNumber'),
new Text(0, str_repeat(' ', 52))
);
} | php | public function addDeletePaymentRequest(string $payerNr): void
{
$this->amendments[] = new Record(
'AmendmentRequest',
$this->payeeBgNode,
new Number(0, $payerNr, 'PayerNumber'),
new Text(0, str_repeat(' ', 52))
);
} | [
"public",
"function",
"addDeletePaymentRequest",
"(",
"string",
"$",
"payerNr",
")",
":",
"void",
"{",
"$",
"this",
"->",
"amendments",
"[",
"]",
"=",
"new",
"Record",
"(",
"'AmendmentRequest'",
",",
"$",
"this",
"->",
"payeeBgNode",
",",
"new",
"Number",
... | Add a delete payment request to tree | [
"Add",
"a",
"delete",
"payment",
"request",
"to",
"tree"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Writer/TreeBuilder.php#L253-L261 | train |
byrokrat/autogiro | src/Writer/TreeBuilder.php | TreeBuilder.buildTree | public function buildTree(): Node
{
$sections = [];
foreach (self::SECTION_TO_RECORD_STORE_MAP as $sectionName => $recordStore) {
if (!empty($this->$recordStore)) {
$sections[] = new Section($sectionName, $this->opening, ...$this->$recordStore);
}
}
return new AutogiroFile('AutogiroRequestFile', ...$sections);
} | php | public function buildTree(): Node
{
$sections = [];
foreach (self::SECTION_TO_RECORD_STORE_MAP as $sectionName => $recordStore) {
if (!empty($this->$recordStore)) {
$sections[] = new Section($sectionName, $this->opening, ...$this->$recordStore);
}
}
return new AutogiroFile('AutogiroRequestFile', ...$sections);
} | [
"public",
"function",
"buildTree",
"(",
")",
":",
"Node",
"{",
"$",
"sections",
"=",
"[",
"]",
";",
"foreach",
"(",
"self",
"::",
"SECTION_TO_RECORD_STORE_MAP",
"as",
"$",
"sectionName",
"=>",
"$",
"recordStore",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
... | Get the created request tree | [
"Get",
"the",
"created",
"request",
"tree"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Writer/TreeBuilder.php#L266-L277 | train |
anklimsk/cakephp-theme | Controller/FilterController.php | FilterController.autocomplete | public function autocomplete() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = [];
$query = $this->request->data('query');
if (empty($query)) {
$this->set(compact('data'));
$this->set('_serialize', 'data');
return;
}
$type = $this->request->data('type');
$plugin = $this->request->data('plugin');
$limit = $this->ConfigTheme->getAutocompleteLimitConfig();
$data = $this->Filter->getAutocomplete($query, $type, $plugin, $limit);
if (empty($data)) {
$data = [];
}
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | php | public function autocomplete() {
Configure::write('debug', 0);
if (!$this->request->is('ajax') || !$this->request->is('post') ||
!$this->RequestHandler->prefers('json')) {
throw new BadRequestException();
}
$data = [];
$query = $this->request->data('query');
if (empty($query)) {
$this->set(compact('data'));
$this->set('_serialize', 'data');
return;
}
$type = $this->request->data('type');
$plugin = $this->request->data('plugin');
$limit = $this->ConfigTheme->getAutocompleteLimitConfig();
$data = $this->Filter->getAutocomplete($query, $type, $plugin, $limit);
if (empty($data)) {
$data = [];
}
$this->set(compact('data'));
$this->set('_serialize', 'data');
} | [
"public",
"function",
"autocomplete",
"(",
")",
"{",
"Configure",
"::",
"write",
"(",
"'debug'",
",",
"0",
")",
";",
"if",
"(",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
"(",
"'ajax'",
")",
"||",
"!",
"$",
"this",
"->",
"request",
"->",
"is",
... | Action `autocomplete`. Is used to autocomplte input fields.
POST Data:
- `query`: query string for autocomple.
- `type`: type for autocomplete suggestions, e.g. Model.Field.
- `plugin`: plugin name for autocomplete field.
@throws BadRequestException if request is not `AJAX`, or not `POST`
or not `JSON`
@return void | [
"Action",
"autocomplete",
".",
"Is",
"used",
"to",
"autocomplte",
"input",
"fields",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Controller/FilterController.php#L58-L84 | train |
williamdes/mariadb-mysql-kbs | src/KBEntry.php | KBEntry.addDocumentation | public function addDocumentation(string $url, ?string $anchor = null ): KBDocumentation
{
$this->url = $url;
if ($this->docs === null) {
$this->docs = array();
}
$kbd = new KBDocumentation($url, $anchor);
$this->docs[] = $kbd;
return $kbd;
} | php | public function addDocumentation(string $url, ?string $anchor = null ): KBDocumentation
{
$this->url = $url;
if ($this->docs === null) {
$this->docs = array();
}
$kbd = new KBDocumentation($url, $anchor);
$this->docs[] = $kbd;
return $kbd;
} | [
"public",
"function",
"addDocumentation",
"(",
"string",
"$",
"url",
",",
"?",
"string",
"$",
"anchor",
"=",
"null",
")",
":",
"KBDocumentation",
"{",
"$",
"this",
"->",
"url",
"=",
"$",
"url",
";",
"if",
"(",
"$",
"this",
"->",
"docs",
"===",
"null"... | Add documentation link
@param string $url The URL
@param string|null $anchor The anchor
@return KBDocumentation | [
"Add",
"documentation",
"link"
] | c5cafc66b59aee56e0db8ca42a0ddb8e0fc14f7e | https://github.com/williamdes/mariadb-mysql-kbs/blob/c5cafc66b59aee56e0db8ca42a0ddb8e0fc14f7e/src/KBEntry.php#L118-L127 | train |
fastdlabs/migration | src/Table.php | Table.getColumn | public function getColumn($name)
{
return isset($this->columns[$name]) ? $this->columns[$name] : false;
} | php | public function getColumn($name)
{
return isset($this->columns[$name]) ? $this->columns[$name] : false;
} | [
"public",
"function",
"getColumn",
"(",
"$",
"name",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"columns",
"[",
"$",
"name",
"]",
")",
"?",
"$",
"this",
"->",
"columns",
"[",
"$",
"name",
"]",
":",
"false",
";",
"}"
] | Get one table column object.
@param $name
@return Column|bool | [
"Get",
"one",
"table",
"column",
"object",
"."
] | aeb1b86cbe6fe129765729f4f2fd6e9a4fa7808c | https://github.com/fastdlabs/migration/blob/aeb1b86cbe6fe129765729f4f2fd6e9a4fa7808c/src/Table.php#L149-L152 | train |
stanislav-web/PhalconSonar | src/Sonar/Services/StorageService.php | StorageService.add | public function add(array $data) {
try {
// add user data
$lastInsertId = $this->visitorMapper->add($data);
return $lastInsertId;
}
catch(MongoMapperException $e) {
throw new StorageServiceException($e->getMessage());
}
} | php | public function add(array $data) {
try {
// add user data
$lastInsertId = $this->visitorMapper->add($data);
return $lastInsertId;
}
catch(MongoMapperException $e) {
throw new StorageServiceException($e->getMessage());
}
} | [
"public",
"function",
"add",
"(",
"array",
"$",
"data",
")",
"{",
"try",
"{",
"// add user data",
"$",
"lastInsertId",
"=",
"$",
"this",
"->",
"visitorMapper",
"->",
"add",
"(",
"$",
"data",
")",
";",
"return",
"$",
"lastInsertId",
";",
"}",
"catch",
"... | Add record to collection
@param array $data
@throws \Sonar\Exceptions\StorageServiceException
@return \MongoId | [
"Add",
"record",
"to",
"collection"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/Services/StorageService.php#L51-L62 | train |
k-gun/oppa | src/Util.php | Util.arrayPick | public static function arrayPick(array &$array, $key, $value = null)
{
if (array_key_exists($key, $array)) {
$value = $array[$key] ?? $value;
unset($array[$key]);
}
return $value;
} | php | public static function arrayPick(array &$array, $key, $value = null)
{
if (array_key_exists($key, $array)) {
$value = $array[$key] ?? $value;
unset($array[$key]);
}
return $value;
} | [
"public",
"static",
"function",
"arrayPick",
"(",
"array",
"&",
"$",
"array",
",",
"$",
"key",
",",
"$",
"value",
"=",
"null",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"key",
",",
"$",
"array",
")",
")",
"{",
"$",
"value",
"=",
"$",
"ar... | Array pick.
@param array &$array
@param int|string $key
@param any $value
@return any | [
"Array",
"pick",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Util.php#L56-L64 | train |
k-gun/oppa | src/Util.php | Util.getIp | public static function getIp(): string
{
$ip = 'unknown';
if ('' != ($ip = ($_SERVER['HTTP_X_FORWARDED_FOR'] ?? ''))) {
if (false !== strpos($ip, ',')) {
$ip = trim((string) end(explode(',', $ip)));
}
}
// all ok
elseif ('' != ($ip = ($_SERVER['HTTP_CLIENT_IP'] ?? ''))) {}
elseif ('' != ($ip = ($_SERVER['HTTP_X_REAL_IP'] ?? ''))) {}
elseif ('' != ($ip = ($_SERVER['REMOTE_ADDR_REAL'] ?? ''))) {}
elseif ('' != ($ip = ($_SERVER['REMOTE_ADDR'] ?? ''))) {}
return $ip;
} | php | public static function getIp(): string
{
$ip = 'unknown';
if ('' != ($ip = ($_SERVER['HTTP_X_FORWARDED_FOR'] ?? ''))) {
if (false !== strpos($ip, ',')) {
$ip = trim((string) end(explode(',', $ip)));
}
}
// all ok
elseif ('' != ($ip = ($_SERVER['HTTP_CLIENT_IP'] ?? ''))) {}
elseif ('' != ($ip = ($_SERVER['HTTP_X_REAL_IP'] ?? ''))) {}
elseif ('' != ($ip = ($_SERVER['REMOTE_ADDR_REAL'] ?? ''))) {}
elseif ('' != ($ip = ($_SERVER['REMOTE_ADDR'] ?? ''))) {}
return $ip;
} | [
"public",
"static",
"function",
"getIp",
"(",
")",
":",
"string",
"{",
"$",
"ip",
"=",
"'unknown'",
";",
"if",
"(",
"''",
"!=",
"(",
"$",
"ip",
"=",
"(",
"$",
"_SERVER",
"[",
"'HTTP_X_FORWARDED_FOR'",
"]",
"??",
"''",
")",
")",
")",
"{",
"if",
"(... | Get IP.
@return string | [
"Get",
"IP",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Util.php#L82-L97 | train |
k-gun/oppa | src/Util.php | Util.generateDeprecatedMessage | public static function generateDeprecatedMessage($class, string $oldStuff, string $newStuff): void
{
if (is_object($class)) {
$class = get_class($class);
}
user_error(sprintf('%1$s::%2$s is deprecated, use %1$s::%3$s instead!',
$class, $oldStuff, $newStuff), E_USER_DEPRECATED);
} | php | public static function generateDeprecatedMessage($class, string $oldStuff, string $newStuff): void
{
if (is_object($class)) {
$class = get_class($class);
}
user_error(sprintf('%1$s::%2$s is deprecated, use %1$s::%3$s instead!',
$class, $oldStuff, $newStuff), E_USER_DEPRECATED);
} | [
"public",
"static",
"function",
"generateDeprecatedMessage",
"(",
"$",
"class",
",",
"string",
"$",
"oldStuff",
",",
"string",
"$",
"newStuff",
")",
":",
"void",
"{",
"if",
"(",
"is_object",
"(",
"$",
"class",
")",
")",
"{",
"$",
"class",
"=",
"get_class... | Generate deprecated message.
@param string|object $class
@param string $oldStuff
@param string $newStuff
@return void | [
"Generate",
"deprecated",
"message",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Util.php#L130-L138 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/PlayerQueryBuilder.php | PlayerQueryBuilder.save | public function save(Player $player)
{
// First clear references. Player has no references that needs saving.
$player->clearAllReferences(false);
// Save and free memory.
$player->save();
PlayerTableMap::clearInstancePool();
} | php | public function save(Player $player)
{
// First clear references. Player has no references that needs saving.
$player->clearAllReferences(false);
// Save and free memory.
$player->save();
PlayerTableMap::clearInstancePool();
} | [
"public",
"function",
"save",
"(",
"Player",
"$",
"player",
")",
"{",
"// First clear references. Player has no references that needs saving.",
"$",
"player",
"->",
"clearAllReferences",
"(",
"false",
")",
";",
"// Save and free memory.",
"$",
"player",
"->",
"save",
"(... | Save individual player.
@param Player $player
@throws PropelException | [
"Save",
"individual",
"player",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/PlayerQueryBuilder.php#L61-L69 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/PlayerQueryBuilder.php | PlayerQueryBuilder.saveAll | public function saveAll($players)
{
$connection = Propel::getWriteConnection(PlayerTableMap::DATABASE_NAME);
$connection->beginTransaction();
foreach ($players as $record) {
$this->save($record);
}
$connection->commit();
PlayerTableMap::clearInstancePool();
} | php | public function saveAll($players)
{
$connection = Propel::getWriteConnection(PlayerTableMap::DATABASE_NAME);
$connection->beginTransaction();
foreach ($players as $record) {
$this->save($record);
}
$connection->commit();
PlayerTableMap::clearInstancePool();
} | [
"public",
"function",
"saveAll",
"(",
"$",
"players",
")",
"{",
"$",
"connection",
"=",
"Propel",
"::",
"getWriteConnection",
"(",
"PlayerTableMap",
"::",
"DATABASE_NAME",
")",
";",
"$",
"connection",
"->",
"beginTransaction",
"(",
")",
";",
"foreach",
"(",
... | Save multiple player models at the tume
@param Player[] $players
@throws PropelException | [
"Save",
"multiple",
"player",
"models",
"at",
"the",
"tume"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/PlayerQueryBuilder.php#L78-L89 | train |
stanislav-web/PhalconSonar | src/Sonar/Aware/AbstractMongoMapper.php | AbstractMongoMapper.getConnectUri | private function getConnectUri(\Phalcon\Config $config) {
if($config->offsetExists('user') && $config->offsetExists('password')) {
return "mongodb://".$config['user'].":".$config['password']."@".$config['host'].":".$config['port']."/".$config['dbname'];
}
else {
return "mongodb://".$config['host'].":".$config['port']."/".$config['dbname'];
}
} | php | private function getConnectUri(\Phalcon\Config $config) {
if($config->offsetExists('user') && $config->offsetExists('password')) {
return "mongodb://".$config['user'].":".$config['password']."@".$config['host'].":".$config['port']."/".$config['dbname'];
}
else {
return "mongodb://".$config['host'].":".$config['port']."/".$config['dbname'];
}
} | [
"private",
"function",
"getConnectUri",
"(",
"\\",
"Phalcon",
"\\",
"Config",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"offsetExists",
"(",
"'user'",
")",
"&&",
"$",
"config",
"->",
"offsetExists",
"(",
"'password'",
")",
")",
"{",
"retur... | Get mongo connection URI
@param \Phalcon\Config $config
@return string | [
"Get",
"mongo",
"connection",
"URI"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/Aware/AbstractMongoMapper.php#L78-L86 | train |
stanislav-web/PhalconSonar | src/Sonar/Aware/AbstractMongoMapper.php | AbstractMongoMapper.setProfiler | public function setProfiler($level = self::PROFILE_ALL, $slowms = 100) {
return $this->db->command([
'profile' => (int)$level,
'slowms' => (int)$slowms
]);
} | php | public function setProfiler($level = self::PROFILE_ALL, $slowms = 100) {
return $this->db->command([
'profile' => (int)$level,
'slowms' => (int)$slowms
]);
} | [
"public",
"function",
"setProfiler",
"(",
"$",
"level",
"=",
"self",
"::",
"PROFILE_ALL",
",",
"$",
"slowms",
"=",
"100",
")",
"{",
"return",
"$",
"this",
"->",
"db",
"->",
"command",
"(",
"[",
"'profile'",
"=>",
"(",
"int",
")",
"$",
"level",
",",
... | Set MongoDb profiler
@param int $level 0, 1, 2
@param int $slowms slow queries in ms.
@return array | [
"Set",
"MongoDb",
"profiler"
] | 4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa | https://github.com/stanislav-web/PhalconSonar/blob/4ebf59428fccfd7c7dfb100e0de00e5dd0efe1fa/src/Sonar/Aware/AbstractMongoMapper.php#L107-L113 | train |
Due/php-ecom-sdk | lib/Customers.php | Customers.get | public static function get(array $arg_params)
{
//validate params
$data = self::getParams($arg_params);
$url = '/ecommerce/customers';
if(!empty($data['id'])){
$url .= '/'.$data['id'];
}else{
return null;
}
//submit to api
$customer_data = APIRequests::request(
$url,
APIRequests::METHOD_GET
);
//return response
return self::toObj($customer_data['body']);
} | php | public static function get(array $arg_params)
{
//validate params
$data = self::getParams($arg_params);
$url = '/ecommerce/customers';
if(!empty($data['id'])){
$url .= '/'.$data['id'];
}else{
return null;
}
//submit to api
$customer_data = APIRequests::request(
$url,
APIRequests::METHOD_GET
);
//return response
return self::toObj($customer_data['body']);
} | [
"public",
"static",
"function",
"get",
"(",
"array",
"$",
"arg_params",
")",
"{",
"//validate params",
"$",
"data",
"=",
"self",
"::",
"getParams",
"(",
"$",
"arg_params",
")",
";",
"$",
"url",
"=",
"'/ecommerce/customers'",
";",
"if",
"(",
"!",
"empty",
... | Get Customer Data
@param array $arg_params
@return null|object
@throws \Exception | [
"Get",
"Customer",
"Data"
] | 4c2e4040469bb159e62461363ec133b6faf0a7ae | https://github.com/Due/php-ecom-sdk/blob/4c2e4040469bb159e62461363ec133b6faf0a7ae/lib/Customers.php#L50-L69 | train |
Due/php-ecom-sdk | lib/Customers.php | Customers.create | public static function create(array $arg_params)
{
//validate params
$data = self::getParams($arg_params);
if(!empty($data['metadata'])){
$data['metadata'] = json_encode($data['metadata']);
}
//submit to api
$customer_data = APIRequests::request(
'/ecommerce/customers',
APIRequests::METHOD_POST,
$data
);
//return response
return self::toObj($customer_data['body']);
} | php | public static function create(array $arg_params)
{
//validate params
$data = self::getParams($arg_params);
if(!empty($data['metadata'])){
$data['metadata'] = json_encode($data['metadata']);
}
//submit to api
$customer_data = APIRequests::request(
'/ecommerce/customers',
APIRequests::METHOD_POST,
$data
);
//return response
return self::toObj($customer_data['body']);
} | [
"public",
"static",
"function",
"create",
"(",
"array",
"$",
"arg_params",
")",
"{",
"//validate params",
"$",
"data",
"=",
"self",
"::",
"getParams",
"(",
"$",
"arg_params",
")",
";",
"if",
"(",
"!",
"empty",
"(",
"$",
"data",
"[",
"'metadata'",
"]",
... | Create A Customer
@param array $arg_params
@return null|object
@throws \Exception | [
"Create",
"A",
"Customer"
] | 4c2e4040469bb159e62461363ec133b6faf0a7ae | https://github.com/Due/php-ecom-sdk/blob/4c2e4040469bb159e62461363ec133b6faf0a7ae/lib/Customers.php#L106-L123 | train |
Due/php-ecom-sdk | lib/Customers.php | Customers.update | public static function update($arg_params)
{
//validate params
if(is_array($arg_params)){
$data = self::getParams($arg_params);
}else{
$data = self::getParams(json_decode(json_encode($arg_params), true));
}
$url = '/ecommerce/customers';
if(!empty($data['id'])){
$url .= '/'.$data['id'];
}else{
return null;
}
unset($data['id']);
//submit to api
$customer_data = APIRequests::request(
$url,
APIRequests::METHOD_PUT,
$data
);
//return response
return self::toObj($customer_data['body']);
} | php | public static function update($arg_params)
{
//validate params
if(is_array($arg_params)){
$data = self::getParams($arg_params);
}else{
$data = self::getParams(json_decode(json_encode($arg_params), true));
}
$url = '/ecommerce/customers';
if(!empty($data['id'])){
$url .= '/'.$data['id'];
}else{
return null;
}
unset($data['id']);
//submit to api
$customer_data = APIRequests::request(
$url,
APIRequests::METHOD_PUT,
$data
);
//return response
return self::toObj($customer_data['body']);
} | [
"public",
"static",
"function",
"update",
"(",
"$",
"arg_params",
")",
"{",
"//validate params",
"if",
"(",
"is_array",
"(",
"$",
"arg_params",
")",
")",
"{",
"$",
"data",
"=",
"self",
"::",
"getParams",
"(",
"$",
"arg_params",
")",
";",
"}",
"else",
"... | Update A Customer
@param array|object $arg_params
@return null|object
@throws \Exception | [
"Update",
"A",
"Customer"
] | 4c2e4040469bb159e62461363ec133b6faf0a7ae | https://github.com/Due/php-ecom-sdk/blob/4c2e4040469bb159e62461363ec133b6faf0a7ae/lib/Customers.php#L132-L157 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Listener/BaseStorageUpdateListener.php | BaseStorageUpdateListener.onManiaplanetGameBeginMap | public function onManiaplanetGameBeginMap(DedicatedEvent $event)
{
$serverOptions = $this->factory->getConnection()->getServerOptions();
$this->gameDataStorage->setScriptOptions($this->factory->getConnection()->getModeScriptSettings());
$this->gameDataStorage->setServerOptions($serverOptions);
$this->gameDataStorage->setSystemInfo($this->factory->getConnection()->getSystemInfo());
$newGameInfos = $this->factory->getConnection()->getCurrentGameInfo();
$prevousGameInfos = $this->gameDataStorage->getGameInfos();
// TODO move this logic somewhere else.
$this->dispatcher->reset($this->mapStorage->getMap($event->getParameters()[0]['UId']));
if ($prevousGameInfos->gameMode != $newGameInfos->gameMode || $prevousGameInfos->scriptName != $newGameInfos->scriptName) {
$this->gameDataStorage->setGameInfos(clone $newGameInfos);
// TODO dispatch custom event to let it know?
}
} | php | public function onManiaplanetGameBeginMap(DedicatedEvent $event)
{
$serverOptions = $this->factory->getConnection()->getServerOptions();
$this->gameDataStorage->setScriptOptions($this->factory->getConnection()->getModeScriptSettings());
$this->gameDataStorage->setServerOptions($serverOptions);
$this->gameDataStorage->setSystemInfo($this->factory->getConnection()->getSystemInfo());
$newGameInfos = $this->factory->getConnection()->getCurrentGameInfo();
$prevousGameInfos = $this->gameDataStorage->getGameInfos();
// TODO move this logic somewhere else.
$this->dispatcher->reset($this->mapStorage->getMap($event->getParameters()[0]['UId']));
if ($prevousGameInfos->gameMode != $newGameInfos->gameMode || $prevousGameInfos->scriptName != $newGameInfos->scriptName) {
$this->gameDataStorage->setGameInfos(clone $newGameInfos);
// TODO dispatch custom event to let it know?
}
} | [
"public",
"function",
"onManiaplanetGameBeginMap",
"(",
"DedicatedEvent",
"$",
"event",
")",
"{",
"$",
"serverOptions",
"=",
"$",
"this",
"->",
"factory",
"->",
"getConnection",
"(",
")",
"->",
"getServerOptions",
"(",
")",
";",
"$",
"this",
"->",
"gameDataSto... | Called on the begining of a new map.
@param DedicatedEvent $event | [
"Called",
"on",
"the",
"begining",
"of",
"a",
"new",
"map",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Listener/BaseStorageUpdateListener.php#L89-L106 | train |
honeybee/trellis | src/CodeGen/Parser/Schema/Xpath.php | Xpath.initNamespace | protected function initNamespace(DOMDocument $document, $namespace_prefix = null)
{
// @todo: check for conflicting namespace prefixes
$this->document_namespace = trim($document->documentElement->namespaceURI);
$namespace_prefix = trim($namespace_prefix);
if ($this->hasNamespace()) {
$this->namespace_prefix = empty($namespace_prefix) ? $this->getDefaultNamespacePrefix() : $namespace_prefix;
$this->registerNamespace(
$this->namespace_prefix,
$this->document_namespace
);
}
} | php | protected function initNamespace(DOMDocument $document, $namespace_prefix = null)
{
// @todo: check for conflicting namespace prefixes
$this->document_namespace = trim($document->documentElement->namespaceURI);
$namespace_prefix = trim($namespace_prefix);
if ($this->hasNamespace()) {
$this->namespace_prefix = empty($namespace_prefix) ? $this->getDefaultNamespacePrefix() : $namespace_prefix;
$this->registerNamespace(
$this->namespace_prefix,
$this->document_namespace
);
}
} | [
"protected",
"function",
"initNamespace",
"(",
"DOMDocument",
"$",
"document",
",",
"$",
"namespace_prefix",
"=",
"null",
")",
"{",
"// @todo: check for conflicting namespace prefixes",
"$",
"this",
"->",
"document_namespace",
"=",
"trim",
"(",
"$",
"document",
"->",
... | Get the namespace of the document, if defined.
@param DOMDocument $document Document to query on
@return string | [
"Get",
"the",
"namespace",
"of",
"the",
"document",
"if",
"defined",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/CodeGen/Parser/Schema/Xpath.php#L88-L102 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.getBetterButtonsActions | public function getBetterButtonsActions()
{
/** @var FieldList $fields */
$fields = parent::getBetterButtonsActions();
$fields->push(BetterButtonCustomAction::create('send', _t('Reservation.RESEND', 'Resend the reservation')));
return $fields;
} | php | public function getBetterButtonsActions()
{
/** @var FieldList $fields */
$fields = parent::getBetterButtonsActions();
$fields->push(BetterButtonCustomAction::create('send', _t('Reservation.RESEND', 'Resend the reservation')));
return $fields;
} | [
"public",
"function",
"getBetterButtonsActions",
"(",
")",
"{",
"/** @var FieldList $fields */",
"$",
"fields",
"=",
"parent",
"::",
"getBetterButtonsActions",
"(",
")",
";",
"$",
"fields",
"->",
"push",
"(",
"BetterButtonCustomAction",
"::",
"create",
"(",
"'send'"... | Add utility actions to the reservation details view
@return FieldList | [
"Add",
"utility",
"actions",
"to",
"the",
"reservation",
"details",
"view"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L167-L174 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.onBeforeWrite | public function onBeforeWrite()
{
// Set the title to the name of the reservation holder
$this->Title = $this->getName();
// Create a validation code to be used for confirmation and in the barcode
if ($this->exists() && empty($this->ReservationCode)) {
$this->ReservationCode = $this->createReservationCode();
}
parent::onBeforeWrite();
} | php | public function onBeforeWrite()
{
// Set the title to the name of the reservation holder
$this->Title = $this->getName();
// Create a validation code to be used for confirmation and in the barcode
if ($this->exists() && empty($this->ReservationCode)) {
$this->ReservationCode = $this->createReservationCode();
}
parent::onBeforeWrite();
} | [
"public",
"function",
"onBeforeWrite",
"(",
")",
"{",
"// Set the title to the name of the reservation holder",
"$",
"this",
"->",
"Title",
"=",
"$",
"this",
"->",
"getName",
"(",
")",
";",
"// Create a validation code to be used for confirmation and in the barcode",
"if",
... | Generate a reservation code if it does not yet exists | [
"Generate",
"a",
"reservation",
"code",
"if",
"it",
"does",
"not",
"yet",
"exists"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L179-L190 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.onBeforeDelete | public function onBeforeDelete()
{
// If a reservation is deleted remove the names from the guest list
foreach ($this->Attendees() as $attendee) {
/** @var Attendee $attendee */
if ($attendee->exists()) {
$attendee->delete();
}
}
// Remove the folder
if (($folder = Folder::get()->find('Name', $this->ReservationCode)) && $folder->exists() && $folder->isEmpty()) {
$folder->delete();
}
parent::onBeforeDelete();
} | php | public function onBeforeDelete()
{
// If a reservation is deleted remove the names from the guest list
foreach ($this->Attendees() as $attendee) {
/** @var Attendee $attendee */
if ($attendee->exists()) {
$attendee->delete();
}
}
// Remove the folder
if (($folder = Folder::get()->find('Name', $this->ReservationCode)) && $folder->exists() && $folder->isEmpty()) {
$folder->delete();
}
parent::onBeforeDelete();
} | [
"public",
"function",
"onBeforeDelete",
"(",
")",
"{",
"// If a reservation is deleted remove the names from the guest list",
"foreach",
"(",
"$",
"this",
"->",
"Attendees",
"(",
")",
"as",
"$",
"attendee",
")",
"{",
"/** @var Attendee $attendee */",
"if",
"(",
"$",
"... | After deleting a reservation, delete the attendees and files | [
"After",
"deleting",
"a",
"reservation",
"delete",
"the",
"attendees",
"and",
"files"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L195-L211 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.isDiscarded | public function isDiscarded()
{
$deleteAfter = strtotime(self::config()->get('delete_after'), strtotime($this->Created));
return ($this->Status === 'CART') && (time() > $deleteAfter);
} | php | public function isDiscarded()
{
$deleteAfter = strtotime(self::config()->get('delete_after'), strtotime($this->Created));
return ($this->Status === 'CART') && (time() > $deleteAfter);
} | [
"public",
"function",
"isDiscarded",
"(",
")",
"{",
"$",
"deleteAfter",
"=",
"strtotime",
"(",
"self",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'delete_after'",
")",
",",
"strtotime",
"(",
"$",
"this",
"->",
"Created",
")",
")",
";",
"return",
"(",... | Check if the cart is still in cart state and the delete_after time period has been exceeded
@return bool | [
"Check",
"if",
"the",
"cart",
"is",
"still",
"in",
"cart",
"state",
"and",
"the",
"delete_after",
"time",
"period",
"has",
"been",
"exceeded"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L239-L243 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.getName | public function getName()
{
/** @var Attendee $attendee */
if (($mainContact = $this->MainContact()) && $mainContact->exists() && $name = $mainContact->getName()) {
return $name;
} else {
return 'new reservation';
}
} | php | public function getName()
{
/** @var Attendee $attendee */
if (($mainContact = $this->MainContact()) && $mainContact->exists() && $name = $mainContact->getName()) {
return $name;
} else {
return 'new reservation';
}
} | [
"public",
"function",
"getName",
"(",
")",
"{",
"/** @var Attendee $attendee */",
"if",
"(",
"(",
"$",
"mainContact",
"=",
"$",
"this",
"->",
"MainContact",
"(",
")",
")",
"&&",
"$",
"mainContact",
"->",
"exists",
"(",
")",
"&&",
"$",
"name",
"=",
"$",
... | Get the full name
@return string | [
"Get",
"the",
"full",
"name"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L250-L258 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.calculateTotal | public function calculateTotal()
{
$total = $this->Subtotal = $this->Attendees()->leftJoin(
'Broarm\EventTickets\Ticket',
'`Broarm\EventTickets\Attendee`.`TicketID` = `Broarm\EventTickets\Ticket`.`ID`'
)->sum('Price');
// Calculate any price modifications if added
if ($this->PriceModifiers()->exists()) {
foreach ($this->PriceModifiers() as $priceModifier) {
$priceModifier->updateTotal($total);
}
}
return $this->Total = $total;
} | php | public function calculateTotal()
{
$total = $this->Subtotal = $this->Attendees()->leftJoin(
'Broarm\EventTickets\Ticket',
'`Broarm\EventTickets\Attendee`.`TicketID` = `Broarm\EventTickets\Ticket`.`ID`'
)->sum('Price');
// Calculate any price modifications if added
if ($this->PriceModifiers()->exists()) {
foreach ($this->PriceModifiers() as $priceModifier) {
$priceModifier->updateTotal($total);
}
}
return $this->Total = $total;
} | [
"public",
"function",
"calculateTotal",
"(",
")",
"{",
"$",
"total",
"=",
"$",
"this",
"->",
"Subtotal",
"=",
"$",
"this",
"->",
"Attendees",
"(",
")",
"->",
"leftJoin",
"(",
"'Broarm\\EventTickets\\Ticket'",
",",
"'`Broarm\\EventTickets\\Attendee`.`TicketID` = `Bro... | Get the total by querying the sum of attendee ticket prices
@return float | [
"Get",
"the",
"total",
"by",
"querying",
"the",
"sum",
"of",
"attendee",
"ticket",
"prices"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L287-L302 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.changeState | public function changeState($state)
{
$availableStates = $this->dbObject('Status')->enumValues();
if (in_array($state, $availableStates)) {
$this->Status = $state;
return true;
} else {
user_error(_t('Reservation.STATE_CHANGE_ERROR', 'Selected state is not available'));
return false;
}
} | php | public function changeState($state)
{
$availableStates = $this->dbObject('Status')->enumValues();
if (in_array($state, $availableStates)) {
$this->Status = $state;
return true;
} else {
user_error(_t('Reservation.STATE_CHANGE_ERROR', 'Selected state is not available'));
return false;
}
} | [
"public",
"function",
"changeState",
"(",
"$",
"state",
")",
"{",
"$",
"availableStates",
"=",
"$",
"this",
"->",
"dbObject",
"(",
"'Status'",
")",
"->",
"enumValues",
"(",
")",
";",
"if",
"(",
"in_array",
"(",
"$",
"state",
",",
"$",
"availableStates",
... | Safely change to a state
todo check if state direction matches
@param $state
@return boolean | [
"Safely",
"change",
"to",
"a",
"state",
"todo",
"check",
"if",
"state",
"direction",
"matches"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L312-L322 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.sendReservation | public function sendReservation()
{
// Get the mail sender or fallback to the admin email
if (($from = self::config()->get('mail_sender')) && empty($from)) {
$from = Config::inst()->get('Email', 'admin_email');
}
// Create the email with given template and reservation data
$email = new Email();
$email->setSubject(_t(
'ReservationMail.TITLE',
'Your order at {sitename}',
null,
array(
'sitename' => SiteConfig::current_site_config()->Title
)
));
$email->setFrom($from);
$email->setTo($this->MainContact()->Email);
$email->setTemplate('ReservationMail');
$email->populateTemplate($this);
$this->extend('updateReservationMail', $email);
return $email->send();
} | php | public function sendReservation()
{
// Get the mail sender or fallback to the admin email
if (($from = self::config()->get('mail_sender')) && empty($from)) {
$from = Config::inst()->get('Email', 'admin_email');
}
// Create the email with given template and reservation data
$email = new Email();
$email->setSubject(_t(
'ReservationMail.TITLE',
'Your order at {sitename}',
null,
array(
'sitename' => SiteConfig::current_site_config()->Title
)
));
$email->setFrom($from);
$email->setTo($this->MainContact()->Email);
$email->setTemplate('ReservationMail');
$email->populateTemplate($this);
$this->extend('updateReservationMail', $email);
return $email->send();
} | [
"public",
"function",
"sendReservation",
"(",
")",
"{",
"// Get the mail sender or fallback to the admin email",
"if",
"(",
"(",
"$",
"from",
"=",
"self",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'mail_sender'",
")",
")",
"&&",
"empty",
"(",
"$",
"from",
... | Send the reservation mail
@return mixed | [
"Send",
"the",
"reservation",
"mail"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L376-L399 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.sendTickets | public function sendTickets()
{
// Get the mail sender or fallback to the admin email
if (($from = self::config()->get('mail_sender')) && empty($from)) {
$from = Config::inst()->get('Email', 'admin_email');
}
// Send the tickets to the main contact
$email = new Email();
$email->setSubject(_t(
'MainContactMail.TITLE',
'Uw tickets voor {event}',
null,
array(
'event' => $this->Event()->Title
)
));
$email->setFrom($from);
$email->setTo($this->MainContact()->Email);
$email->setTemplate('MainContactMail');
$email->populateTemplate($this);
$this->extend('updateMainContactMail', $email);
$sent = $email->send();
// Get the attendees for this event that are checked as receiver
$ticketReceivers = $this->Attendees()->filter('TicketReceiver', 1)->exclude('ID', $this->MainContactID);
if ($ticketReceivers->exists()) {
/** @var Attendee $ticketReceiver */
foreach ($ticketReceivers as $ticketReceiver) {
$sentAttendee = $ticketReceiver->sendTicket();
if ($sent && !$sentAttendee) {
$sent = $sentAttendee;
}
}
}
return $sent;
} | php | public function sendTickets()
{
// Get the mail sender or fallback to the admin email
if (($from = self::config()->get('mail_sender')) && empty($from)) {
$from = Config::inst()->get('Email', 'admin_email');
}
// Send the tickets to the main contact
$email = new Email();
$email->setSubject(_t(
'MainContactMail.TITLE',
'Uw tickets voor {event}',
null,
array(
'event' => $this->Event()->Title
)
));
$email->setFrom($from);
$email->setTo($this->MainContact()->Email);
$email->setTemplate('MainContactMail');
$email->populateTemplate($this);
$this->extend('updateMainContactMail', $email);
$sent = $email->send();
// Get the attendees for this event that are checked as receiver
$ticketReceivers = $this->Attendees()->filter('TicketReceiver', 1)->exclude('ID', $this->MainContactID);
if ($ticketReceivers->exists()) {
/** @var Attendee $ticketReceiver */
foreach ($ticketReceivers as $ticketReceiver) {
$sentAttendee = $ticketReceiver->sendTicket();
if ($sent && !$sentAttendee) {
$sent = $sentAttendee;
}
}
}
return $sent;
} | [
"public",
"function",
"sendTickets",
"(",
")",
"{",
"// Get the mail sender or fallback to the admin email",
"if",
"(",
"(",
"$",
"from",
"=",
"self",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'mail_sender'",
")",
")",
"&&",
"empty",
"(",
"$",
"from",
")"... | Send the reserved tickets
@return mixed | [
"Send",
"the",
"reserved",
"tickets"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L406-L444 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.sendNotification | public function sendNotification()
{
if (($from = self::config()->get('mail_sender')) && empty($from)) {
$from = Config::inst()->get('Email', 'admin_email');
}
if (($to = self::config()->get('mail_receiver')) && empty($to)) {
$to = Config::inst()->get('Email', 'admin_email');
}
$email = new Email();
$email->setSubject(_t(
'NotificationMail.TITLE',
'Nieuwe reservering voor {event}',
null, array('event' => $this->Event()->Title)
));
$email->setFrom($from);
$email->setTo($to);
$email->setTemplate('NotificationMail');
$email->populateTemplate($this);
$this->extend('updateNotificationMail', $email);
return $email->send();
} | php | public function sendNotification()
{
if (($from = self::config()->get('mail_sender')) && empty($from)) {
$from = Config::inst()->get('Email', 'admin_email');
}
if (($to = self::config()->get('mail_receiver')) && empty($to)) {
$to = Config::inst()->get('Email', 'admin_email');
}
$email = new Email();
$email->setSubject(_t(
'NotificationMail.TITLE',
'Nieuwe reservering voor {event}',
null, array('event' => $this->Event()->Title)
));
$email->setFrom($from);
$email->setTo($to);
$email->setTemplate('NotificationMail');
$email->populateTemplate($this);
$this->extend('updateNotificationMail', $email);
return $email->send();
} | [
"public",
"function",
"sendNotification",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"from",
"=",
"self",
"::",
"config",
"(",
")",
"->",
"get",
"(",
"'mail_sender'",
")",
")",
"&&",
"empty",
"(",
"$",
"from",
")",
")",
"{",
"$",
"from",
"=",
"Config",
... | Send a booking notification to the ticket mail sender or the site admin
@return mixed | [
"Send",
"a",
"booking",
"notification",
"to",
"the",
"ticket",
"mail",
"sender",
"or",
"the",
"site",
"admin"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L451-L474 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.send | public function send()
{
$this->createFiles();
$this->SentReservation = (boolean)$this->sendReservation();
$this->SentNotification = (boolean)$this->sendNotification();
$this->SentTickets = (boolean)$this->sendTickets();
} | php | public function send()
{
$this->createFiles();
$this->SentReservation = (boolean)$this->sendReservation();
$this->SentNotification = (boolean)$this->sendNotification();
$this->SentTickets = (boolean)$this->sendTickets();
} | [
"public",
"function",
"send",
"(",
")",
"{",
"$",
"this",
"->",
"createFiles",
"(",
")",
";",
"$",
"this",
"->",
"SentReservation",
"=",
"(",
"boolean",
")",
"$",
"this",
"->",
"sendReservation",
"(",
")",
";",
"$",
"this",
"->",
"SentNotification",
"=... | Create the files and send the reservation, notification and tickets | [
"Create",
"the",
"files",
"and",
"send",
"the",
"reservation",
"notification",
"and",
"tickets"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L479-L485 | train |
TheBnl/event-tickets | code/model/Reservation.php | Reservation.getDownloadLink | public function getDownloadLink()
{
/** @var Attendee $attendee */
if (
($attendee = $this->Attendees()->first())
&& ($file = $attendee->TicketFile())
&& $file->exists()
) {
return $file->Link();
}
return null;
} | php | public function getDownloadLink()
{
/** @var Attendee $attendee */
if (
($attendee = $this->Attendees()->first())
&& ($file = $attendee->TicketFile())
&& $file->exists()
) {
return $file->Link();
}
return null;
} | [
"public",
"function",
"getDownloadLink",
"(",
")",
"{",
"/** @var Attendee $attendee */",
"if",
"(",
"(",
"$",
"attendee",
"=",
"$",
"this",
"->",
"Attendees",
"(",
")",
"->",
"first",
"(",
")",
")",
"&&",
"(",
"$",
"file",
"=",
"$",
"attendee",
"->",
... | Get the download link
@return string|null | [
"Get",
"the",
"download",
"link"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Reservation.php#L492-L504 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.deleteCounter | protected function deleteCounter()
{
if ( is_null( \Input::get('dlstatsid',true) ) )
{
return ;
}
\Database::getInstance()->prepare("DELETE FROM tl_dlstatdets WHERE pid=?")
->execute(\Input::get('dlstatsid',true));
\Database::getInstance()->prepare("DELETE FROM tl_dlstats WHERE id=?")
->execute(\Input::get('dlstatsid',true));
return ;
} | php | protected function deleteCounter()
{
if ( is_null( \Input::get('dlstatsid',true) ) )
{
return ;
}
\Database::getInstance()->prepare("DELETE FROM tl_dlstatdets WHERE pid=?")
->execute(\Input::get('dlstatsid',true));
\Database::getInstance()->prepare("DELETE FROM tl_dlstats WHERE id=?")
->execute(\Input::get('dlstatsid',true));
return ;
} | [
"protected",
"function",
"deleteCounter",
"(",
")",
"{",
"if",
"(",
"is_null",
"(",
"\\",
"Input",
"::",
"get",
"(",
"'dlstatsid'",
",",
"true",
")",
")",
")",
"{",
"return",
";",
"}",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
... | Delete a counter | [
"Delete",
"a",
"counter"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L124-L135 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.getStatusDetailed | protected function getStatusDetailed()
{
if ( isset($GLOBALS['TL_CONFIG']['dlstats'])
&& (bool) $GLOBALS['TL_CONFIG']['dlstats'] === true
&& isset($GLOBALS['TL_CONFIG']['dlstatdets'])
&& (bool) $GLOBALS['TL_CONFIG']['dlstatdets'] === true
)
{
return '<span class="tl_green">'.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_activated'].'</span>';
}
$this->boolDetails = false;
return '<span class="">'.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_deactivated'].'</span>';
} | php | protected function getStatusDetailed()
{
if ( isset($GLOBALS['TL_CONFIG']['dlstats'])
&& (bool) $GLOBALS['TL_CONFIG']['dlstats'] === true
&& isset($GLOBALS['TL_CONFIG']['dlstatdets'])
&& (bool) $GLOBALS['TL_CONFIG']['dlstatdets'] === true
)
{
return '<span class="tl_green">'.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_activated'].'</span>';
}
$this->boolDetails = false;
return '<span class="">'.$GLOBALS['TL_LANG']['tl_dlstatstatistics_stat']['status_deactivated'].'</span>';
} | [
"protected",
"function",
"getStatusDetailed",
"(",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'dlstats'",
"]",
")",
"&&",
"(",
"bool",
")",
"$",
"GLOBALS",
"[",
"'TL_CONFIG'",
"]",
"[",
"'dlstats'",
"]",
"===",
"t... | Get Detailed Logging Status
@return string | [
"Get",
"Detailed",
"Logging",
"Status"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L156-L168 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.getMonth | protected function getMonth()
{
$arrMonth = array();
$objMonth = \Database::getInstance()->prepare("SELECT
FROM_UNIXTIME(`tstamp`,'%Y-%m') AS YM
, COUNT(`id`) AS SUMDL
FROM `tl_dlstatdets`
WHERE 1
GROUP BY YM
ORDER BY YM DESC")
->limit(12)
->execute();
$intRows = $objMonth->numRows;
if ($intRows>0)
{
while ($objMonth->next())
{
$Y = substr($objMonth->YM, 0,4);
$M = (int)substr($objMonth->YM, -2);
$arrMonth[] = array($Y.' '.$GLOBALS['TL_LANG']['MONTHS'][($M - 1)], $this->getFormattedNumber($objMonth->SUMDL,0) );
}
}
return $arrMonth;
} | php | protected function getMonth()
{
$arrMonth = array();
$objMonth = \Database::getInstance()->prepare("SELECT
FROM_UNIXTIME(`tstamp`,'%Y-%m') AS YM
, COUNT(`id`) AS SUMDL
FROM `tl_dlstatdets`
WHERE 1
GROUP BY YM
ORDER BY YM DESC")
->limit(12)
->execute();
$intRows = $objMonth->numRows;
if ($intRows>0)
{
while ($objMonth->next())
{
$Y = substr($objMonth->YM, 0,4);
$M = (int)substr($objMonth->YM, -2);
$arrMonth[] = array($Y.' '.$GLOBALS['TL_LANG']['MONTHS'][($M - 1)], $this->getFormattedNumber($objMonth->SUMDL,0) );
}
}
return $arrMonth;
} | [
"protected",
"function",
"getMonth",
"(",
")",
"{",
"$",
"arrMonth",
"=",
"array",
"(",
")",
";",
"$",
"objMonth",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT\n FROM_UN... | Monthly Statistics, last 12 Months
@return array | [
"Monthly",
"Statistics",
"last",
"12",
"Months"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L189-L213 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.getYear | protected function getYear()
{
$arrYear = array();
$objYear = \Database::getInstance()->prepare("SELECT
FROM_UNIXTIME(`tstamp`,'%Y') AS Y
, COUNT(`id`) AS SUMDL
FROM `tl_dlstatdets`
WHERE 1
GROUP BY Y
ORDER BY Y DESC")
->limit(12)
->execute();
$intRows = $objYear->numRows;
if ($intRows>0)
{
while ($objYear->next())
{
// Y, formatierte Zahl, unformatierte Zahl
$arrYear[] = array($objYear->Y, $this->getFormattedNumber($objYear->SUMDL,0),$objYear->SUMDL );
}
}
return $arrYear;
} | php | protected function getYear()
{
$arrYear = array();
$objYear = \Database::getInstance()->prepare("SELECT
FROM_UNIXTIME(`tstamp`,'%Y') AS Y
, COUNT(`id`) AS SUMDL
FROM `tl_dlstatdets`
WHERE 1
GROUP BY Y
ORDER BY Y DESC")
->limit(12)
->execute();
$intRows = $objYear->numRows;
if ($intRows>0)
{
while ($objYear->next())
{
// Y, formatierte Zahl, unformatierte Zahl
$arrYear[] = array($objYear->Y, $this->getFormattedNumber($objYear->SUMDL,0),$objYear->SUMDL );
}
}
return $arrYear;
} | [
"protected",
"function",
"getYear",
"(",
")",
"{",
"$",
"arrYear",
"=",
"array",
"(",
")",
";",
"$",
"objYear",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT\n FROM_UNIXTI... | Years Statistic, last 12 years
@return array | [
"Years",
"Statistic",
"last",
"12",
"years"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L219-L242 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.getStartDate | protected function getStartDate()
{
$StartDate = false;
$objStartDate = \Database::getInstance()->prepare("SELECT
MIN(`tstamp`) AS YMD
FROM `tl_dlstatdets`
WHERE 1")
->execute();
if ($objStartDate->YMD !== null)
{
$StartDate = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objStartDate->YMD);
}
return $StartDate;
} | php | protected function getStartDate()
{
$StartDate = false;
$objStartDate = \Database::getInstance()->prepare("SELECT
MIN(`tstamp`) AS YMD
FROM `tl_dlstatdets`
WHERE 1")
->execute();
if ($objStartDate->YMD !== null)
{
$StartDate = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objStartDate->YMD);
}
return $StartDate;
} | [
"protected",
"function",
"getStartDate",
"(",
")",
"{",
"$",
"StartDate",
"=",
"false",
";",
"$",
"objStartDate",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT\n MIN(`tstam... | Get Startdate of detailed logging
@return string Date | [
"Get",
"Startdate",
"of",
"detailed",
"logging"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L269-L284 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.getLastDownloads | protected function getLastDownloads($limit=20)
{
$newDate = '02.02.1971';
$oldDate = '01.01.1970';
$viewDate = false;
$arrLastDownloads = array();
$objLastDownloads = \Database::getInstance()->prepare("SELECT `tstamp`, `filename`, `downloads`, `id`
FROM `tl_dlstats`
ORDER BY `tstamp` DESC, `filename`")
->limit($limit)
->execute();
$intRows = $objLastDownloads->numRows;
if ($intRows>0)
{
while ($objLastDownloads->next())
{
$viewDate = false;
if ($oldDate != \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objLastDownloads->tstamp))
{
$newDate = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objLastDownloads->tstamp);
$viewDate = $newDate;
}
$c4d = $this->check4details($objLastDownloads->id);
$arrLastDownloads[] = array( \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $objLastDownloads->tstamp)
, $objLastDownloads->filename
, $this->getFormattedNumber($objLastDownloads->downloads,0)
, $viewDate
, $objLastDownloads->id
, $c4d
, $objLastDownloads->downloads // for sorting
, $objLastDownloads->tstamp // for sorting
);
$oldDate = $newDate;
}
}
return $arrLastDownloads;
} | php | protected function getLastDownloads($limit=20)
{
$newDate = '02.02.1971';
$oldDate = '01.01.1970';
$viewDate = false;
$arrLastDownloads = array();
$objLastDownloads = \Database::getInstance()->prepare("SELECT `tstamp`, `filename`, `downloads`, `id`
FROM `tl_dlstats`
ORDER BY `tstamp` DESC, `filename`")
->limit($limit)
->execute();
$intRows = $objLastDownloads->numRows;
if ($intRows>0)
{
while ($objLastDownloads->next())
{
$viewDate = false;
if ($oldDate != \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objLastDownloads->tstamp))
{
$newDate = \Date::parse($GLOBALS['TL_CONFIG']['dateFormat'], $objLastDownloads->tstamp);
$viewDate = $newDate;
}
$c4d = $this->check4details($objLastDownloads->id);
$arrLastDownloads[] = array( \Date::parse($GLOBALS['TL_CONFIG']['datimFormat'], $objLastDownloads->tstamp)
, $objLastDownloads->filename
, $this->getFormattedNumber($objLastDownloads->downloads,0)
, $viewDate
, $objLastDownloads->id
, $c4d
, $objLastDownloads->downloads // for sorting
, $objLastDownloads->tstamp // for sorting
);
$oldDate = $newDate;
}
}
return $arrLastDownloads;
} | [
"protected",
"function",
"getLastDownloads",
"(",
"$",
"limit",
"=",
"20",
")",
"{",
"$",
"newDate",
"=",
"'02.02.1971'",
";",
"$",
"oldDate",
"=",
"'01.01.1970'",
";",
"$",
"viewDate",
"=",
"false",
";",
"$",
"arrLastDownloads",
"=",
"array",
"(",
")",
... | Get Last Downloadslist
@param numbner $limit optional
@return array $arrLastDownloads | [
"Get",
"Last",
"Downloadslist"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L324-L361 | train |
BugBuster1701/contao-dlstats-bundle | src/Resources/contao/modules/ModuleDlstatsStatistics.php | ModuleDlstatsStatistics.check4details | protected function check4details($id)
{
$objC4D = \Database::getInstance()->prepare("SELECT count(`id`) AS num
FROM `tl_dlstatdets`
WHERE `pid`=?")
->execute($id);
return $objC4D->num;
} | php | protected function check4details($id)
{
$objC4D = \Database::getInstance()->prepare("SELECT count(`id`) AS num
FROM `tl_dlstatdets`
WHERE `pid`=?")
->execute($id);
return $objC4D->num;
} | [
"protected",
"function",
"check4details",
"(",
"$",
"id",
")",
"{",
"$",
"objC4D",
"=",
"\\",
"Database",
"::",
"getInstance",
"(",
")",
"->",
"prepare",
"(",
"\"SELECT count(`id`) AS num\n FROM `tl_dlstatdets`\n ... | Get Number of Logged Details
@param number $id pid of file
@return number | [
"Get",
"Number",
"of",
"Logged",
"Details"
] | d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3 | https://github.com/BugBuster1701/contao-dlstats-bundle/blob/d0d6f8cbbd6a6694bb0564d9865e24bd95e1f6e3/src/Resources/contao/modules/ModuleDlstatsStatistics.php#L368-L375 | train |
pauci/cqrs | src/Domain/Model/EventContainer.php | EventContainer.addEvent | public function addEvent($payload, $metadata = null)
{
$domainEventMessage = new GenericDomainEventMessage(
$this->aggregateType,
$this->aggregateId,
$this->newSequenceNumber(),
$payload,
$metadata
);
$this->addEventMessage($domainEventMessage);
return $domainEventMessage;
} | php | public function addEvent($payload, $metadata = null)
{
$domainEventMessage = new GenericDomainEventMessage(
$this->aggregateType,
$this->aggregateId,
$this->newSequenceNumber(),
$payload,
$metadata
);
$this->addEventMessage($domainEventMessage);
return $domainEventMessage;
} | [
"public",
"function",
"addEvent",
"(",
"$",
"payload",
",",
"$",
"metadata",
"=",
"null",
")",
"{",
"$",
"domainEventMessage",
"=",
"new",
"GenericDomainEventMessage",
"(",
"$",
"this",
"->",
"aggregateType",
",",
"$",
"this",
"->",
"aggregateId",
",",
"$",
... | Add an event to this container.
@param mixed $payload
@param Metadata|array $metadata
@return GenericDomainEventMessage | [
"Add",
"an",
"event",
"to",
"this",
"container",
"."
] | 951f2a3118b5f7d93b1e173952490f4a15b8f3fb | https://github.com/pauci/cqrs/blob/951f2a3118b5f7d93b1e173952490f4a15b8f3fb/src/Domain/Model/EventContainer.php#L63-L75 | train |
pauci/cqrs | src/Domain/Model/EventContainer.php | EventContainer.getLastSequenceNumber | public function getLastSequenceNumber()
{
if (count($this->events) === 0) {
return $this->lastCommittedSequenceNumber;
}
if ($this->lastSequenceNumber === null) {
$event = end($this->events);
$this->lastSequenceNumber = $event->getSequenceNumber();
}
return $this->lastSequenceNumber;
} | php | public function getLastSequenceNumber()
{
if (count($this->events) === 0) {
return $this->lastCommittedSequenceNumber;
}
if ($this->lastSequenceNumber === null) {
$event = end($this->events);
$this->lastSequenceNumber = $event->getSequenceNumber();
}
return $this->lastSequenceNumber;
} | [
"public",
"function",
"getLastSequenceNumber",
"(",
")",
"{",
"if",
"(",
"count",
"(",
"$",
"this",
"->",
"events",
")",
"===",
"0",
")",
"{",
"return",
"$",
"this",
"->",
"lastCommittedSequenceNumber",
";",
"}",
"if",
"(",
"$",
"this",
"->",
"lastSequen... | Returns the sequence number of the last committed event, or null if no events have been committed.
@return int | [
"Returns",
"the",
"sequence",
"number",
"of",
"the",
"last",
"committed",
"event",
"or",
"null",
"if",
"no",
"events",
"have",
"been",
"committed",
"."
] | 951f2a3118b5f7d93b1e173952490f4a15b8f3fb | https://github.com/pauci/cqrs/blob/951f2a3118b5f7d93b1e173952490f4a15b8f3fb/src/Domain/Model/EventContainer.php#L155-L165 | train |
spekulatius/silverstripe-timezones | code/models/TimeZoneData.php | TimeZoneData.prepareTitle | public function prepareTitle()
{
$title = $this->format;
// replace the placeholders with actual data
foreach (array_keys(self::$db) as $key) {
$title = str_ireplace('%' . $key, $this->$key, $title);
}
return $title;
} | php | public function prepareTitle()
{
$title = $this->format;
// replace the placeholders with actual data
foreach (array_keys(self::$db) as $key) {
$title = str_ireplace('%' . $key, $this->$key, $title);
}
return $title;
} | [
"public",
"function",
"prepareTitle",
"(",
")",
"{",
"$",
"title",
"=",
"$",
"this",
"->",
"format",
";",
"// replace the placeholders with actual data",
"foreach",
"(",
"array_keys",
"(",
"self",
"::",
"$",
"db",
")",
"as",
"$",
"key",
")",
"{",
"$",
"tit... | Returns the title according to the configuration
@return string | [
"Returns",
"the",
"title",
"according",
"to",
"the",
"configuration"
] | 61702bafd2288589f8b87c0c55cdb972c17e05e9 | https://github.com/spekulatius/silverstripe-timezones/blob/61702bafd2288589f8b87c0c55cdb972c17e05e9/code/models/TimeZoneData.php#L43-L53 | train |
dontdrinkandroot/gitki-bundle.php | Controller/FileController.php | FileController.cancelAction | public function cancelAction($path)
{
$this->securityService->assertCommitter();
$filePath = FilePath::parse($path);
$user = $this->securityService->getGitUser();
$this->wikiService->removeLock($user, $filePath);
return $this->redirect($this->generateUrl('ddr_gitki_file', ['path' => $filePath]));
} | php | public function cancelAction($path)
{
$this->securityService->assertCommitter();
$filePath = FilePath::parse($path);
$user = $this->securityService->getGitUser();
$this->wikiService->removeLock($user, $filePath);
return $this->redirect($this->generateUrl('ddr_gitki_file', ['path' => $filePath]));
} | [
"public",
"function",
"cancelAction",
"(",
"$",
"path",
")",
"{",
"$",
"this",
"->",
"securityService",
"->",
"assertCommitter",
"(",
")",
";",
"$",
"filePath",
"=",
"FilePath",
"::",
"parse",
"(",
"$",
"path",
")",
";",
"$",
"user",
"=",
"$",
"this",
... | Cancels editing.
@param string $path
@return Response | [
"Cancels",
"editing",
"."
] | ab4399419be89b75f3d76180636c5ad020eb8b34 | https://github.com/dontdrinkandroot/gitki-bundle.php/blob/ab4399419be89b75f3d76180636c5ad020eb8b34/Controller/FileController.php#L190-L198 | train |
honeybee/trellis | src/Runtime/Entity/EntityList.php | EntityList.containsMultipleTypes | public function containsMultipleTypes()
{
$mixed = false;
$types = [];
foreach ($this->items as $item) {
$class = get_class($item->getType());
if (!in_array($class, $types, true)) {
$types[] = $class;
}
}
if (count($types) > 1) {
$mixed = true;
}
return $mixed;
} | php | public function containsMultipleTypes()
{
$mixed = false;
$types = [];
foreach ($this->items as $item) {
$class = get_class($item->getType());
if (!in_array($class, $types, true)) {
$types[] = $class;
}
}
if (count($types) > 1) {
$mixed = true;
}
return $mixed;
} | [
"public",
"function",
"containsMultipleTypes",
"(",
")",
"{",
"$",
"mixed",
"=",
"false",
";",
"$",
"types",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"items",
"as",
"$",
"item",
")",
"{",
"$",
"class",
"=",
"get_class",
"(",
"$",
"ite... | Returns whether the entities in the list have the same entity type
@return boolean | [
"Returns",
"whether",
"the",
"entities",
"in",
"the",
"list",
"have",
"the",
"same",
"entity",
"type"
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Entity/EntityList.php#L88-L105 | train |
honeybee/trellis | src/Runtime/Entity/EntityList.php | EntityList.getEntityByIdentifier | public function getEntityByIdentifier($identifier)
{
$found_entities = $this->filter(
function (EntityInterface $entity) use ($identifier) {
return $entity->getIdentifier() === $identifier;
}
);
return $found_entities->getFirst();
} | php | public function getEntityByIdentifier($identifier)
{
$found_entities = $this->filter(
function (EntityInterface $entity) use ($identifier) {
return $entity->getIdentifier() === $identifier;
}
);
return $found_entities->getFirst();
} | [
"public",
"function",
"getEntityByIdentifier",
"(",
"$",
"identifier",
")",
"{",
"$",
"found_entities",
"=",
"$",
"this",
"->",
"filter",
"(",
"function",
"(",
"EntityInterface",
"$",
"entity",
")",
"use",
"(",
"$",
"identifier",
")",
"{",
"return",
"$",
"... | Returns the entity in the list with the specified identifier.
@return EntityInterface | [
"Returns",
"the",
"entity",
"in",
"the",
"list",
"with",
"the",
"specified",
"identifier",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Entity/EntityList.php#L112-L121 | train |
honeybee/trellis | src/Runtime/Entity/EntityList.php | EntityList.propagateEntityChangedEvent | protected function propagateEntityChangedEvent(EntityChangedEvent $event)
{
foreach ($this->listeners as $listener) {
$listener->onEntityChanged($event);
}
} | php | protected function propagateEntityChangedEvent(EntityChangedEvent $event)
{
foreach ($this->listeners as $listener) {
$listener->onEntityChanged($event);
}
} | [
"protected",
"function",
"propagateEntityChangedEvent",
"(",
"EntityChangedEvent",
"$",
"event",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"listeners",
"as",
"$",
"listener",
")",
"{",
"$",
"listener",
"->",
"onEntityChanged",
"(",
"$",
"event",
")",
";",
... | Propagates a given entity-changed event to all attached entity-changed listeners.
@param EntityChangedEvent $event | [
"Propagates",
"a",
"given",
"entity",
"-",
"changed",
"event",
"to",
"all",
"attached",
"entity",
"-",
"changed",
"listeners",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Entity/EntityList.php#L128-L133 | train |
honeybee/trellis | src/Runtime/Entity/EntityList.php | EntityList.propagateCollectionChangedEvent | protected function propagateCollectionChangedEvent(CollectionChangedEvent $event)
{
if ($event->getType() === CollectionChangedEvent::ITEM_REMOVED) {
$event->getItem()->removeEntityChangedListener($this);
} else {
$event->getItem()->addEntityChangedListener($this);
}
parent::propagateCollectionChangedEvent($event);
} | php | protected function propagateCollectionChangedEvent(CollectionChangedEvent $event)
{
if ($event->getType() === CollectionChangedEvent::ITEM_REMOVED) {
$event->getItem()->removeEntityChangedListener($this);
} else {
$event->getItem()->addEntityChangedListener($this);
}
parent::propagateCollectionChangedEvent($event);
} | [
"protected",
"function",
"propagateCollectionChangedEvent",
"(",
"CollectionChangedEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"getType",
"(",
")",
"===",
"CollectionChangedEvent",
"::",
"ITEM_REMOVED",
")",
"{",
"$",
"event",
"->",
"getItem",
... | Propagates a given collection-changed event to all attached collection-changed listeners.
@param CollectionChangedEvent $event | [
"Propagates",
"a",
"given",
"collection",
"-",
"changed",
"event",
"to",
"all",
"attached",
"collection",
"-",
"changed",
"listeners",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Entity/EntityList.php#L140-L149 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.getResourceStats | public final function getResourceStats(): ?array
{
$return = null;
$resourceType = $this->resource->getType();
$resourceObject = $this->resource->getObject();
if ($resourceType == Resource::TYPE_MYSQL_LINK) {
$result = $resourceObject->query('SHOW SESSION STATUS');
while ($row = $result->fetch_assoc()) {
$return[strtolower($row['Variable_name'])] = $row['Value'];
}
$result->free();
} elseif ($resourceType == Resource::TYPE_PGSQL_LINK) {
$result = pg_query($resourceObject, sprintf(
"SELECT * FROM pg_stat_activity WHERE usename = '%s'",
pg_escape_string($resourceObject, $this->config['username'])
));
$resultArray = pg_fetch_all($result);
if (isset($resultArray[0])) {
$return = $resultArray[0];
}
pg_free_result($result);
}
return $return;
} | php | public final function getResourceStats(): ?array
{
$return = null;
$resourceType = $this->resource->getType();
$resourceObject = $this->resource->getObject();
if ($resourceType == Resource::TYPE_MYSQL_LINK) {
$result = $resourceObject->query('SHOW SESSION STATUS');
while ($row = $result->fetch_assoc()) {
$return[strtolower($row['Variable_name'])] = $row['Value'];
}
$result->free();
} elseif ($resourceType == Resource::TYPE_PGSQL_LINK) {
$result = pg_query($resourceObject, sprintf(
"SELECT * FROM pg_stat_activity WHERE usename = '%s'",
pg_escape_string($resourceObject, $this->config['username'])
));
$resultArray = pg_fetch_all($result);
if (isset($resultArray[0])) {
$return = $resultArray[0];
}
pg_free_result($result);
}
return $return;
} | [
"public",
"final",
"function",
"getResourceStats",
"(",
")",
":",
"?",
"array",
"{",
"$",
"return",
"=",
"null",
";",
"$",
"resourceType",
"=",
"$",
"this",
"->",
"resource",
"->",
"getType",
"(",
")",
";",
"$",
"resourceObject",
"=",
"$",
"this",
"->"... | Get resource stats.
@return ?array | [
"Get",
"resource",
"stats",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L139-L164 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.quoteField | public function quoteField(string $input): string
{
$input = $this->unquoteField($input);
// nope.. quote all
// if (ctype_lower($input)) {
// return $input;
// }
if ($this->isMysql()) {
return '`'. str_replace('`', '``', $input) .'`';
} elseif ($this->isPgsql()) {
return '"'. str_replace('"', '""', $input) .'"';
}
} | php | public function quoteField(string $input): string
{
$input = $this->unquoteField($input);
// nope.. quote all
// if (ctype_lower($input)) {
// return $input;
// }
if ($this->isMysql()) {
return '`'. str_replace('`', '``', $input) .'`';
} elseif ($this->isPgsql()) {
return '"'. str_replace('"', '""', $input) .'"';
}
} | [
"public",
"function",
"quoteField",
"(",
"string",
"$",
"input",
")",
":",
"string",
"{",
"$",
"input",
"=",
"$",
"this",
"->",
"unquoteField",
"(",
"$",
"input",
")",
";",
"// nope.. quote all",
"// if (ctype_lower($input)) {",
"// return $input;",
"// }",
... | Quote field.
@param string $input
@return string
@throws Oppa\Agent\AgentException | [
"Quote",
"field",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L354-L368 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.escapeLikeString | public function escapeLikeString(string $input, bool $quote = true, bool $escape = true): string
{
if ($escape) {
$input = $this->escapeString($input, $quote);
}
return addcslashes($input, '%_');
} | php | public function escapeLikeString(string $input, bool $quote = true, bool $escape = true): string
{
if ($escape) {
$input = $this->escapeString($input, $quote);
}
return addcslashes($input, '%_');
} | [
"public",
"function",
"escapeLikeString",
"(",
"string",
"$",
"input",
",",
"bool",
"$",
"quote",
"=",
"true",
",",
"bool",
"$",
"escape",
"=",
"true",
")",
":",
"string",
"{",
"if",
"(",
"$",
"escape",
")",
"{",
"$",
"input",
"=",
"$",
"this",
"->... | Escape like string.
@param string $input
@param bool $quote
@param bool $escape
@return string | [
"Escape",
"like",
"string",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L471-L478 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.escapeIdentifier | public function escapeIdentifier($input, bool $join = true)
{
if (is_array($input)) {
$input = array_map([$this, 'escapeIdentifier'], array_filter($input));
return $join ? join(', ', $input) : $input;
} elseif ($input instanceof Sql) {
return $input->toString();
} elseif ($input instanceof Identifier) {
$input = $input->toString();
}
if (!is_string($input)) {
throw new AgentException(sprintf('String, array and Query\Sql,Identifier type identifiers'.
' accepted only, %s given!', gettype($input)));
}
$input = trim($input);
if ($input == '' || $input == '*') {
return $input;
}
// functions, parentheses etc are not allowed
if (strpos($input, '(') !== false) {
throw new AgentException('Found parentheses in input, complex identifiers not allowed!');
}
// trim all non-word characters
$input = preg_replace('~^[^\w]|[^\w]$~', '', $input);
if ($input == '') {
return $input;
}
// multiple fields
if (strpos($input, ',')) {
return $this->escapeIdentifier(Util::split(',', $input), $join);
}
// aliases
if (strpos($input, ' ')) {
return preg_replace_callback('~([^\s]+)\s+(AS\s+)?(\w+)~i', function ($match) {
return $this->escapeIdentifier($match[1]) . (
($as = trim($match[2])) ? ' '. strtoupper($as) .' ' : ' '
) . $this->escapeIdentifier($match[3]);
}, $input);
}
// dots
if (strpos($input, '.')) {
return implode('.', array_map([$this, 'escapeIdentifier'], explode('.', $input)));
}
return $this->quoteField($input);
} | php | public function escapeIdentifier($input, bool $join = true)
{
if (is_array($input)) {
$input = array_map([$this, 'escapeIdentifier'], array_filter($input));
return $join ? join(', ', $input) : $input;
} elseif ($input instanceof Sql) {
return $input->toString();
} elseif ($input instanceof Identifier) {
$input = $input->toString();
}
if (!is_string($input)) {
throw new AgentException(sprintf('String, array and Query\Sql,Identifier type identifiers'.
' accepted only, %s given!', gettype($input)));
}
$input = trim($input);
if ($input == '' || $input == '*') {
return $input;
}
// functions, parentheses etc are not allowed
if (strpos($input, '(') !== false) {
throw new AgentException('Found parentheses in input, complex identifiers not allowed!');
}
// trim all non-word characters
$input = preg_replace('~^[^\w]|[^\w]$~', '', $input);
if ($input == '') {
return $input;
}
// multiple fields
if (strpos($input, ',')) {
return $this->escapeIdentifier(Util::split(',', $input), $join);
}
// aliases
if (strpos($input, ' ')) {
return preg_replace_callback('~([^\s]+)\s+(AS\s+)?(\w+)~i', function ($match) {
return $this->escapeIdentifier($match[1]) . (
($as = trim($match[2])) ? ' '. strtoupper($as) .' ' : ' '
) . $this->escapeIdentifier($match[3]);
}, $input);
}
// dots
if (strpos($input, '.')) {
return implode('.', array_map([$this, 'escapeIdentifier'], explode('.', $input)));
}
return $this->quoteField($input);
} | [
"public",
"function",
"escapeIdentifier",
"(",
"$",
"input",
",",
"bool",
"$",
"join",
"=",
"true",
")",
"{",
"if",
"(",
"is_array",
"(",
"$",
"input",
")",
")",
"{",
"$",
"input",
"=",
"array_map",
"(",
"[",
"$",
"this",
",",
"'escapeIdentifier'",
"... | Escape identifier.
@param string|array|Oppa\Query\Identifier $input
@param bool $join
@return string|array
@throws Oppa\Agent\AgentException | [
"Escape",
"identifier",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L487-L539 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.escapeBytea | public function escapeBytea(string $input): string
{
if ($this->resource->getType() != Resource::TYPE_PGSQL_LINK) {
throw new AgentException('escapeBytea() available for only Pgsql!');
}
return pg_escape_bytea($this->resource->getObject(), $input);
} | php | public function escapeBytea(string $input): string
{
if ($this->resource->getType() != Resource::TYPE_PGSQL_LINK) {
throw new AgentException('escapeBytea() available for only Pgsql!');
}
return pg_escape_bytea($this->resource->getObject(), $input);
} | [
"public",
"function",
"escapeBytea",
"(",
"string",
"$",
"input",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"resource",
"->",
"getType",
"(",
")",
"!=",
"Resource",
"::",
"TYPE_PGSQL_LINK",
")",
"{",
"throw",
"new",
"AgentException",
"(",
"'... | Escape bytea.
@param string $input
@return string
@throws Oppa\Agent\AgentException | [
"Escape",
"bytea",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L547-L554 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.unescapeBytea | public function unescapeBytea(string $input): string
{
if ($this->resource->getType() != Resource::TYPE_PGSQL_LINK) {
throw new AgentException('unescapeBytea() available for only Pgsql!');
}
return pg_unescape_bytea($input);
} | php | public function unescapeBytea(string $input): string
{
if ($this->resource->getType() != Resource::TYPE_PGSQL_LINK) {
throw new AgentException('unescapeBytea() available for only Pgsql!');
}
return pg_unescape_bytea($input);
} | [
"public",
"function",
"unescapeBytea",
"(",
"string",
"$",
"input",
")",
":",
"string",
"{",
"if",
"(",
"$",
"this",
"->",
"resource",
"->",
"getType",
"(",
")",
"!=",
"Resource",
"::",
"TYPE_PGSQL_LINK",
")",
"{",
"throw",
"new",
"AgentException",
"(",
... | Unescape bytea.
@param string $input
@return string
@throws Oppa\Agent\AgentException | [
"Unescape",
"bytea",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L562-L569 | train |
k-gun/oppa | src/Agent/Agent.php | Agent.prepareIdentifier | public final function prepareIdentifier(string $input, $inputParam): string
{
if (empty($inputParam)) {
if (strpos($input, '%n') !== false) {
throw new AgentException('Found %n operator but no replacement parameter given!');
} elseif (strpos($input, '??') !== false) {
throw new AgentException('Found ?? operator but no replacement parameter given!');
}
} else {
$input = $this->prepare($input, (array) $inputParam);
// eg: ('@a.id=?', 1), ('@a.id=@b.id')
// eg: ('??=?', ['a.id',1]), ('??=??', ['a.id','b.id'])
// eg: ('a.id=?, a.b=?', [1,2]), ('a.id=??, a.b=?', ['b.id',2])
if (strpos($input, '=')) {
$input = implode(', ', array_map(function ($input) {
$input = trim($input);
if ($input != '') {
$input = array_map('trim', explode('=', $input));
$input = $this->escapeIdentifier($input[0]) .' = '. (
($input[1] && $input[1][0] == '@' )
? $this->escapeIdentifier($input[1]) : $input[1]
);
return $input;
}
}, explode(',', $input)));
}
return $input;
}
// eg: (a.id = 1), (a.id = @b.id)
if (strpos($input, '=')) {
$input = implode(', ', array_map(function ($input) {
$input = trim($input);
if ($input != '') {
$input = array_map('trim', explode('=', $input));
$input = $this->escapeIdentifier($input[0]) .' = '. (
($input[1] && $input[1][0] == '@' )
? $this->escapeIdentifier($input[1]) : $this->escape($input[1])
);
return $input;
}
}, explode(',', $input)));
} else {
// eg: a.id
$input = $this->escapeIdentifier($input);
}
return $input;
} | php | public final function prepareIdentifier(string $input, $inputParam): string
{
if (empty($inputParam)) {
if (strpos($input, '%n') !== false) {
throw new AgentException('Found %n operator but no replacement parameter given!');
} elseif (strpos($input, '??') !== false) {
throw new AgentException('Found ?? operator but no replacement parameter given!');
}
} else {
$input = $this->prepare($input, (array) $inputParam);
// eg: ('@a.id=?', 1), ('@a.id=@b.id')
// eg: ('??=?', ['a.id',1]), ('??=??', ['a.id','b.id'])
// eg: ('a.id=?, a.b=?', [1,2]), ('a.id=??, a.b=?', ['b.id',2])
if (strpos($input, '=')) {
$input = implode(', ', array_map(function ($input) {
$input = trim($input);
if ($input != '') {
$input = array_map('trim', explode('=', $input));
$input = $this->escapeIdentifier($input[0]) .' = '. (
($input[1] && $input[1][0] == '@' )
? $this->escapeIdentifier($input[1]) : $input[1]
);
return $input;
}
}, explode(',', $input)));
}
return $input;
}
// eg: (a.id = 1), (a.id = @b.id)
if (strpos($input, '=')) {
$input = implode(', ', array_map(function ($input) {
$input = trim($input);
if ($input != '') {
$input = array_map('trim', explode('=', $input));
$input = $this->escapeIdentifier($input[0]) .' = '. (
($input[1] && $input[1][0] == '@' )
? $this->escapeIdentifier($input[1]) : $this->escape($input[1])
);
return $input;
}
}, explode(',', $input)));
} else {
// eg: a.id
$input = $this->escapeIdentifier($input);
}
return $input;
} | [
"public",
"final",
"function",
"prepareIdentifier",
"(",
"string",
"$",
"input",
",",
"$",
"inputParam",
")",
":",
"string",
"{",
"if",
"(",
"empty",
"(",
"$",
"inputParam",
")",
")",
"{",
"if",
"(",
"strpos",
"(",
"$",
"input",
",",
"'%n'",
")",
"!=... | Prepare identifier.
@param string $input
@param string|array $inputParam
@return string | [
"Prepare",
"identifier",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Agent/Agent.php#L751-L801 | train |
anklimsk/cakephp-theme | Model/FlashMessage.php | FlashMessage.getMessage | public function getMessage($key = null) {
$result = [];
if (empty($key)) {
return $result;
}
$sessionKey = $this->_sessionKey . '.' . $key;
if (!CakeSession::check($sessionKey)) {
return $result;
}
$data = CakeSession::read($sessionKey);
if (empty($data)) {
return $result;
}
$result = (array)$data;
if (isAssoc($result)) {
$result = [$result];
}
return $result;
} | php | public function getMessage($key = null) {
$result = [];
if (empty($key)) {
return $result;
}
$sessionKey = $this->_sessionKey . '.' . $key;
if (!CakeSession::check($sessionKey)) {
return $result;
}
$data = CakeSession::read($sessionKey);
if (empty($data)) {
return $result;
}
$result = (array)$data;
if (isAssoc($result)) {
$result = [$result];
}
return $result;
} | [
"public",
"function",
"getMessage",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"[",
"]",
";",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"$",
"result",
";",
"}",
"$",
"sessionKey",
"=",
"$",
"this",
"->",
"_s... | Get list of Flash messages.
@param string $key Key of Flash messages
to obtain list of messages
@return array List of Flash messages. | [
"Get",
"list",
"of",
"Flash",
"messages",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/FlashMessage.php#L44-L66 | train |
anklimsk/cakephp-theme | Model/FlashMessage.php | FlashMessage.deleteMessage | public function deleteMessage($key = null) {
if (empty($key)) {
return false;
}
$sessionKey = $this->_sessionKey . '.' . $key;
if (!CakeSession::check($sessionKey)) {
return false;
}
return CakeSession::delete($sessionKey);
} | php | public function deleteMessage($key = null) {
if (empty($key)) {
return false;
}
$sessionKey = $this->_sessionKey . '.' . $key;
if (!CakeSession::check($sessionKey)) {
return false;
}
return CakeSession::delete($sessionKey);
} | [
"public",
"function",
"deleteMessage",
"(",
"$",
"key",
"=",
"null",
")",
"{",
"if",
"(",
"empty",
"(",
"$",
"key",
")",
")",
"{",
"return",
"false",
";",
"}",
"$",
"sessionKey",
"=",
"$",
"this",
"->",
"_sessionKey",
".",
"'.'",
".",
"$",
"key",
... | Delete Flash messages.
@param string $key Key of Flash messages
to delete
@return bool Success. | [
"Delete",
"Flash",
"messages",
"."
] | b815a4aaabaaf03ef1df3d547200f73f332f38a7 | https://github.com/anklimsk/cakephp-theme/blob/b815a4aaabaaf03ef1df3d547200f73f332f38a7/Model/FlashMessage.php#L75-L86 | train |
Corviz/framework | src/Application.php | Application.registerProviders | private function registerProviders()
{
$providers = $this->config('app')['providers'];
foreach ($providers as $provider) {
$obj = new $provider($this);
if (!$obj instanceof Provider) {
throw new \Exception("Invalid provider: $provider");
}
$this->container->invoke($obj, 'register');
}
} | php | private function registerProviders()
{
$providers = $this->config('app')['providers'];
foreach ($providers as $provider) {
$obj = new $provider($this);
if (!$obj instanceof Provider) {
throw new \Exception("Invalid provider: $provider");
}
$this->container->invoke($obj, 'register');
}
} | [
"private",
"function",
"registerProviders",
"(",
")",
"{",
"$",
"providers",
"=",
"$",
"this",
"->",
"config",
"(",
"'app'",
")",
"[",
"'providers'",
"]",
";",
"foreach",
"(",
"$",
"providers",
"as",
"$",
"provider",
")",
"{",
"$",
"obj",
"=",
"new",
... | Register application providers. | [
"Register",
"application",
"providers",
"."
] | e297f890aa1c5aad28aae383b2df5c913bf6c780 | https://github.com/Corviz/framework/blob/e297f890aa1c5aad28aae383b2df5c913bf6c780/src/Application.php#L213-L225 | train |
dfeyer/Ttree.Oembed | Classes/Validation/Validator/UriValidator.php | UriValidator.isValid | protected function isValid($value)
{
$consumer = new Consumer();
$embedObject = $consumer->consume($value);
if ($embedObject === null) {
$this->addError('This URI has no oEmbed support.', 1403004582, [$value]);
}
} | php | protected function isValid($value)
{
$consumer = new Consumer();
$embedObject = $consumer->consume($value);
if ($embedObject === null) {
$this->addError('This URI has no oEmbed support.', 1403004582, [$value]);
}
} | [
"protected",
"function",
"isValid",
"(",
"$",
"value",
")",
"{",
"$",
"consumer",
"=",
"new",
"Consumer",
"(",
")",
";",
"$",
"embedObject",
"=",
"$",
"consumer",
"->",
"consume",
"(",
"$",
"value",
")",
";",
"if",
"(",
"$",
"embedObject",
"===",
"nu... | Checks if the given value is a specific boolean value.
@param mixed $value The value that should be validated
@return void
@api | [
"Checks",
"if",
"the",
"given",
"value",
"is",
"a",
"specific",
"boolean",
"value",
"."
] | 1f38d18f51c1abe96c19fe4760acc9ef907194df | https://github.com/dfeyer/Ttree.Oembed/blob/1f38d18f51c1abe96c19fe4760acc9ef907194df/Classes/Validation/Validator/UriValidator.php#L31-L38 | train |
Due/php-ecom-sdk | lib/Refund.php | Refund.getParams | protected static function getParams(array $arg_params)
{
$return = array();
//validate params
$data = array(
'amount',
'transaction_id',
'customer_id',
'security_token',
'customer_ip'
);
foreach ($data as $key) {
if(!empty($arg_params[$key])){
$return[$key] = $arg_params[$key];
}
}
return $return;
} | php | protected static function getParams(array $arg_params)
{
$return = array();
//validate params
$data = array(
'amount',
'transaction_id',
'customer_id',
'security_token',
'customer_ip'
);
foreach ($data as $key) {
if(!empty($arg_params[$key])){
$return[$key] = $arg_params[$key];
}
}
return $return;
} | [
"protected",
"static",
"function",
"getParams",
"(",
"array",
"$",
"arg_params",
")",
"{",
"$",
"return",
"=",
"array",
"(",
")",
";",
"//validate params",
"$",
"data",
"=",
"array",
"(",
"'amount'",
",",
"'transaction_id'",
",",
"'customer_id'",
",",
"'secu... | Get Class params
@param array $arg_params
@return array | [
"Get",
"Class",
"params"
] | 4c2e4040469bb159e62461363ec133b6faf0a7ae | https://github.com/Due/php-ecom-sdk/blob/4c2e4040469bb159e62461363ec133b6faf0a7ae/lib/Refund.php#L20-L38 | train |
Due/php-ecom-sdk | lib/Refund.php | Refund.doCardRefund | public static function doCardRefund($arg_params)
{
//validate params
$data = array();
if(is_array($arg_params)){
$data = self::getParams($arg_params);
}else{
$transaction = json_decode(json_encode($arg_params), true);
if(!empty($transaction['id'])){
$data = array('transaction_id'=>$transaction['id']);
}
}
//submit to api
$refund_data = APIRequests::request(
'/ecommerce/refund/card',
APIRequests::METHOD_POST,
array('payload'=>$data)
);
//return response
return self::toObj($refund_data['body']);
} | php | public static function doCardRefund($arg_params)
{
//validate params
$data = array();
if(is_array($arg_params)){
$data = self::getParams($arg_params);
}else{
$transaction = json_decode(json_encode($arg_params), true);
if(!empty($transaction['id'])){
$data = array('transaction_id'=>$transaction['id']);
}
}
//submit to api
$refund_data = APIRequests::request(
'/ecommerce/refund/card',
APIRequests::METHOD_POST,
array('payload'=>$data)
);
//return response
return self::toObj($refund_data['body']);
} | [
"public",
"static",
"function",
"doCardRefund",
"(",
"$",
"arg_params",
")",
"{",
"//validate params",
"$",
"data",
"=",
"array",
"(",
")",
";",
"if",
"(",
"is_array",
"(",
"$",
"arg_params",
")",
")",
"{",
"$",
"data",
"=",
"self",
"::",
"getParams",
... | Refund A Card Payment
@param array $arg_params
@return null|object
@throws \Exception | [
"Refund",
"A",
"Card",
"Payment"
] | 4c2e4040469bb159e62461363ec133b6faf0a7ae | https://github.com/Due/php-ecom-sdk/blob/4c2e4040469bb159e62461363ec133b6faf0a7ae/lib/Refund.php#L47-L68 | train |
TheBnl/event-tickets | code/model/Ticket.php | Ticket.getAvailableFrom | public function getAvailableFrom()
{
if ($this->AvailableFromDate) {
return $this->dbObject('AvailableFromDate');
} elseif ($startDate = $this->getEventStartDate()) {
$lastWeek = new Date();
$lastWeek->setValue(strtotime(self::config()->get('sale_start_threshold'), strtotime($startDate->value)));
return $lastWeek;
}
return null;
} | php | public function getAvailableFrom()
{
if ($this->AvailableFromDate) {
return $this->dbObject('AvailableFromDate');
} elseif ($startDate = $this->getEventStartDate()) {
$lastWeek = new Date();
$lastWeek->setValue(strtotime(self::config()->get('sale_start_threshold'), strtotime($startDate->value)));
return $lastWeek;
}
return null;
} | [
"public",
"function",
"getAvailableFrom",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"AvailableFromDate",
")",
"{",
"return",
"$",
"this",
"->",
"dbObject",
"(",
"'AvailableFromDate'",
")",
";",
"}",
"elseif",
"(",
"$",
"startDate",
"=",
"$",
"this",
"... | Get the available form date if it is set,
otherwise get it from the parent
@return \SS_DateTime|Date|\DBField|null | [
"Get",
"the",
"available",
"form",
"date",
"if",
"it",
"is",
"set",
"otherwise",
"get",
"it",
"from",
"the",
"parent"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Ticket.php#L141-L152 | train |
TheBnl/event-tickets | code/model/Ticket.php | Ticket.getAvailableTill | public function getAvailableTill()
{
if ($this->AvailableTillDate) {
return $this->dbObject('AvailableTillDate');
} elseif ($startDate = $this->getEventStartDate()) {
$till = strtotime(self::config()->get('sale_end_threshold'), strtotime($startDate->Nice()));
$date = SS_Datetime::create();
$date->setValue(date('Y-m-d H:i:s', $till));
return $date;
}
return null;
} | php | public function getAvailableTill()
{
if ($this->AvailableTillDate) {
return $this->dbObject('AvailableTillDate');
} elseif ($startDate = $this->getEventStartDate()) {
$till = strtotime(self::config()->get('sale_end_threshold'), strtotime($startDate->Nice()));
$date = SS_Datetime::create();
$date->setValue(date('Y-m-d H:i:s', $till));
return $date;
}
return null;
} | [
"public",
"function",
"getAvailableTill",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"AvailableTillDate",
")",
"{",
"return",
"$",
"this",
"->",
"dbObject",
"(",
"'AvailableTillDate'",
")",
";",
"}",
"elseif",
"(",
"$",
"startDate",
"=",
"$",
"this",
"... | Get the available till date if it is set,
otherwise get it from the parent
Use the event start date as last sale possibility
@return \SS_DateTime|Date|\DBField|null | [
"Get",
"the",
"available",
"till",
"date",
"if",
"it",
"is",
"set",
"otherwise",
"get",
"it",
"from",
"the",
"parent",
"Use",
"the",
"event",
"start",
"date",
"as",
"last",
"sale",
"possibility"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Ticket.php#L161-L173 | train |
TheBnl/event-tickets | code/model/Ticket.php | Ticket.validateDate | public function validateDate()
{
if (
($from = $this->getAvailableFrom()) &&
($till = $this->getAvailableTill()) &&
$from->InPast() &&
$till->InFuture()
) {
return true;
}
return false;
} | php | public function validateDate()
{
if (
($from = $this->getAvailableFrom()) &&
($till = $this->getAvailableTill()) &&
$from->InPast() &&
$till->InFuture()
) {
return true;
}
return false;
} | [
"public",
"function",
"validateDate",
"(",
")",
"{",
"if",
"(",
"(",
"$",
"from",
"=",
"$",
"this",
"->",
"getAvailableFrom",
"(",
")",
")",
"&&",
"(",
"$",
"till",
"=",
"$",
"this",
"->",
"getAvailableTill",
"(",
")",
")",
"&&",
"$",
"from",
"->",... | Validate if the start and end date are in the past and the future
todo check start time and treshhold
@return bool | [
"Validate",
"if",
"the",
"start",
"and",
"end",
"date",
"are",
"in",
"the",
"past",
"and",
"the",
"future",
"todo",
"check",
"start",
"time",
"and",
"treshhold"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Ticket.php#L181-L193 | train |
TheBnl/event-tickets | code/model/Ticket.php | Ticket.getAvailable | public function getAvailable()
{
if (!$this->getAvailableFrom() && !$this->getAvailableTill()) {
return false;
} elseif ($this->validateDate() && $this->validateAvailability()) {
return true;
}
return false;
} | php | public function getAvailable()
{
if (!$this->getAvailableFrom() && !$this->getAvailableTill()) {
return false;
} elseif ($this->validateDate() && $this->validateAvailability()) {
return true;
}
return false;
} | [
"public",
"function",
"getAvailable",
"(",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"getAvailableFrom",
"(",
")",
"&&",
"!",
"$",
"this",
"->",
"getAvailableTill",
"(",
")",
")",
"{",
"return",
"false",
";",
"}",
"elseif",
"(",
"$",
"this",
"->",... | Return if the ticket is available or not
@return bool | [
"Return",
"if",
"the",
"ticket",
"is",
"available",
"or",
"not"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Ticket.php#L210-L219 | train |
TheBnl/event-tickets | code/model/Ticket.php | Ticket.getEventStartDate | private function getEventStartDate()
{
$currentDate = $this->Event()->getController()->CurrentDate();
if ($currentDate && $currentDate->exists()) {
$date = $currentDate->obj('StartDate')->Format('Y-m-d');
$time = $currentDate->obj('StartTime')->Format('H:i:s');
$dateTime = SS_Datetime::create();
$dateTime->setValue("$date $time");
return $dateTime;
} else {
return null;
}
} | php | private function getEventStartDate()
{
$currentDate = $this->Event()->getController()->CurrentDate();
if ($currentDate && $currentDate->exists()) {
$date = $currentDate->obj('StartDate')->Format('Y-m-d');
$time = $currentDate->obj('StartTime')->Format('H:i:s');
$dateTime = SS_Datetime::create();
$dateTime->setValue("$date $time");
return $dateTime;
} else {
return null;
}
} | [
"private",
"function",
"getEventStartDate",
"(",
")",
"{",
"$",
"currentDate",
"=",
"$",
"this",
"->",
"Event",
"(",
")",
"->",
"getController",
"(",
")",
"->",
"CurrentDate",
"(",
")",
";",
"if",
"(",
"$",
"currentDate",
"&&",
"$",
"currentDate",
"->",
... | Get the event start date
@return Date | [
"Get",
"the",
"event",
"start",
"date"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/model/Ticket.php#L240-L252 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/LocalRecords/Model/Map/RecordTableMap.php | RecordTableMap.doDelete | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(RecordTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Bundle\LocalRecords\Model\Record) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(RecordTableMap::DATABASE_NAME);
$criteria->add(RecordTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = RecordQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
RecordTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
RecordTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | php | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(RecordTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Bundle\LocalRecords\Model\Record) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(RecordTableMap::DATABASE_NAME);
$criteria->add(RecordTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = RecordQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
RecordTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
RecordTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getW... | Performs a DELETE on the database, given a Record or Criteria object OR a primary key value.
@param mixed $values Criteria or Record object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"Record",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/LocalRecords/Model/Map/RecordTableMap.php#L412-L440 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php | Factory.createForPlayer | public function createForPlayer($login)
{
if (!isset($this->groups[$login])) {
$class = $this->class;
/** @var Group $group */
$group = new $class(null, $this->dispatcher);
$this->groups[$login] = $group;
$group->addLogin($login);
}
return $this->groups[$login];
} | php | public function createForPlayer($login)
{
if (!isset($this->groups[$login])) {
$class = $this->class;
/** @var Group $group */
$group = new $class(null, $this->dispatcher);
$this->groups[$login] = $group;
$group->addLogin($login);
}
return $this->groups[$login];
} | [
"public",
"function",
"createForPlayer",
"(",
"$",
"login",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"groups",
"[",
"$",
"login",
"]",
")",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"/** @var Group $group */",
"$... | Get the individual group of a single player.
@param string $login
@return Group | [
"Get",
"the",
"individual",
"group",
"of",
"a",
"single",
"player",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php#L47-L59 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php | Factory.createForPlayers | public function createForPlayers($logins)
{
$class = $this->class;
/** @var Group $group */
$group = new $class(null, $this->dispatcher);
$this->groups[$group->getName()] = $group;
foreach ($logins as $login) {
$group->addLogin($login);
}
return $group;
} | php | public function createForPlayers($logins)
{
$class = $this->class;
/** @var Group $group */
$group = new $class(null, $this->dispatcher);
$this->groups[$group->getName()] = $group;
foreach ($logins as $login) {
$group->addLogin($login);
}
return $group;
} | [
"public",
"function",
"createForPlayers",
"(",
"$",
"logins",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"/** @var Group $group */",
"$",
"group",
"=",
"new",
"$",
"class",
"(",
"null",
",",
"$",
"this",
"->",
"dispatcher",
")",
";",
... | Create a group for array of logins.
@param string[] $logins
@return Group | [
"Create",
"a",
"group",
"for",
"array",
"of",
"logins",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php#L68-L80 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php | Factory.create | public function create($name)
{
$class = $this->class;
/** @var Group $group */
$group = new $class($name, $this->dispatcher);
$this->groups[$group->getName()] = $group;
return $group;
} | php | public function create($name)
{
$class = $this->class;
/** @var Group $group */
$group = new $class($name, $this->dispatcher);
$this->groups[$group->getName()] = $group;
return $group;
} | [
"public",
"function",
"create",
"(",
"$",
"name",
")",
"{",
"$",
"class",
"=",
"$",
"this",
"->",
"class",
";",
"/** @var Group $group */",
"$",
"group",
"=",
"new",
"$",
"class",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"dispatcher",
")",
";",
"$",... | Create a persistent group.
@param $name
@return Group | [
"Create",
"a",
"persistent",
"group",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php#L88-L96 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php | Factory.getGroup | public function getGroup($groupName)
{
return isset($this->groups[$groupName]) ? $this->groups[$groupName] : null;
} | php | public function getGroup($groupName)
{
return isset($this->groups[$groupName]) ? $this->groups[$groupName] : null;
} | [
"public",
"function",
"getGroup",
"(",
"$",
"groupName",
")",
"{",
"return",
"isset",
"(",
"$",
"this",
"->",
"groups",
"[",
"$",
"groupName",
"]",
")",
"?",
"$",
"this",
"->",
"groups",
"[",
"$",
"groupName",
"]",
":",
"null",
";",
"}"
] | Get a group from it's name if it exist.
@param $groupName
@return Group|null | [
"Get",
"a",
"group",
"from",
"it",
"s",
"name",
"if",
"it",
"exist",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php#L105-L108 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php | Factory.onExpansionGroupDestroy | public function onExpansionGroupDestroy(Group $group, $lastLogin)
{
if (isset($this->groups[$group->getName()])) {
unset($this->groups[$group->getName()]);
}
} | php | public function onExpansionGroupDestroy(Group $group, $lastLogin)
{
if (isset($this->groups[$group->getName()])) {
unset($this->groups[$group->getName()]);
}
} | [
"public",
"function",
"onExpansionGroupDestroy",
"(",
"Group",
"$",
"group",
",",
"$",
"lastLogin",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"this",
"->",
"groups",
"[",
"$",
"group",
"->",
"getName",
"(",
")",
"]",
")",
")",
"{",
"unset",
"(",
"$",
... | When a group is destyoed delete object.
@param Group $group
@param $lastLogin | [
"When",
"a",
"group",
"is",
"destyoed",
"delete",
"object",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/UserGroups/Factory.php#L116-L121 | train |
GoIntegro/hateoas-bundle | Util/HttpClientUtil.php | HttpClientUtil.buildHttpClient | public static function buildHttpClient(
$url = NULL,
$username = NULL,
$password = NULL,
$contentType = self::CONTENT_JSON_API,
$language = self::HEADER_LOCALE
)
{
$client = new Client($url);
$client->setHead([
'Accept: ' . $contentType,
'Accept-Language: ' . $language,
'Content-Type: application/vnd.api+json'
]);
if (is_scalar($username) && is_scalar($password)) {
$client->setOptions([CURLOPT_HTTPAUTH, CURLAUTH_ANY]);
$client->setOption(CURLOPT_USERPWD, $username . ':' . $password);
}
return $client;
} | php | public static function buildHttpClient(
$url = NULL,
$username = NULL,
$password = NULL,
$contentType = self::CONTENT_JSON_API,
$language = self::HEADER_LOCALE
)
{
$client = new Client($url);
$client->setHead([
'Accept: ' . $contentType,
'Accept-Language: ' . $language,
'Content-Type: application/vnd.api+json'
]);
if (is_scalar($username) && is_scalar($password)) {
$client->setOptions([CURLOPT_HTTPAUTH, CURLAUTH_ANY]);
$client->setOption(CURLOPT_USERPWD, $username . ':' . $password);
}
return $client;
} | [
"public",
"static",
"function",
"buildHttpClient",
"(",
"$",
"url",
"=",
"NULL",
",",
"$",
"username",
"=",
"NULL",
",",
"$",
"password",
"=",
"NULL",
",",
"$",
"contentType",
"=",
"self",
"::",
"CONTENT_JSON_API",
",",
"$",
"language",
"=",
"self",
"::"... | Obtiene un cliente de HTTP.
@param string $url
@param string $username
@param string $password
@return Client | [
"Obtiene",
"un",
"cliente",
"de",
"HTTP",
"."
] | 0dbd009466e6a09b0d53ec3ec74193d699b16e6f | https://github.com/GoIntegro/hateoas-bundle/blob/0dbd009466e6a09b0d53ec3ec74193d699b16e6f/Util/HttpClientUtil.php#L24-L45 | train |
k-gun/oppa | src/Mapper.php | Mapper.normalizeType | public static function normalizeType(string $type): string
{
switch ($type) {
case self::DATA_TYPE_INT:
case self::DATA_TYPE_BIGINT:
case self::DATA_TYPE_TINYINT:
case self::DATA_TYPE_SMALLINT:
case self::DATA_TYPE_MEDIUMINT:
case self::DATA_TYPE_INTEGER:
case self::DATA_TYPE_SERIAL:
case self::DATA_TYPE_BIGSERIAL:
return 'int';
case self::DATA_TYPE_FLOAT:
case self::DATA_TYPE_DECIMAL:
case self::DATA_TYPE_DOUBLE:
case self::DATA_TYPE_DOUBLEP:
case self::DATA_TYPE_REAL:
case self::DATA_TYPE_NUMERIC:
return 'float';
case self::DATA_TYPE_BOOLEAN:
return 'bool';
case self::DATA_TYPE_BIT:
return 'bit';
}
// all others
return 'string';
} | php | public static function normalizeType(string $type): string
{
switch ($type) {
case self::DATA_TYPE_INT:
case self::DATA_TYPE_BIGINT:
case self::DATA_TYPE_TINYINT:
case self::DATA_TYPE_SMALLINT:
case self::DATA_TYPE_MEDIUMINT:
case self::DATA_TYPE_INTEGER:
case self::DATA_TYPE_SERIAL:
case self::DATA_TYPE_BIGSERIAL:
return 'int';
case self::DATA_TYPE_FLOAT:
case self::DATA_TYPE_DECIMAL:
case self::DATA_TYPE_DOUBLE:
case self::DATA_TYPE_DOUBLEP:
case self::DATA_TYPE_REAL:
case self::DATA_TYPE_NUMERIC:
return 'float';
case self::DATA_TYPE_BOOLEAN:
return 'bool';
case self::DATA_TYPE_BIT:
return 'bit';
}
// all others
return 'string';
} | [
"public",
"static",
"function",
"normalizeType",
"(",
"string",
"$",
"type",
")",
":",
"string",
"{",
"switch",
"(",
"$",
"type",
")",
"{",
"case",
"self",
"::",
"DATA_TYPE_INT",
":",
"case",
"self",
"::",
"DATA_TYPE_BIGINT",
":",
"case",
"self",
"::",
"... | Normalize type.
@param string $type
@return string | [
"Normalize",
"type",
"."
] | 3a20b5cc85cb3899c41737678798ec3de73a3836 | https://github.com/k-gun/oppa/blob/3a20b5cc85cb3899c41737678798ec3de73a3836/src/Mapper.php#L192-L219 | train |
video-games-records/CoreBundle | Service/Game.php | Game.addFromCsv | public function addFromCsv()
{
$files = array_diff(scandir($this->directory . '/in', SCANDIR_SORT_NONE), ['..', '.']);
foreach ($files as $file) {
if (0 !== strpos($file, 'game-add')) {
continue;
}
$fileIn = $this->directory . '/in/' . $file;
$fileOut = $this->directory . '/out/' . $file;
$handle = fopen($fileIn, 'rb');
$idGame = substr($file, 8, -4);
if (!is_numeric($idGame)) {
continue;
}
/** @var \VideoGamesRecords\CoreBundle\Entity\Game $game */
$game = $this->em->getReference(GameEntity::class, $idGame);
if ($game === null) {
continue;
}
$group = null;
$types = null;
while (($row = fgetcsv($handle, null, ';')) !== false) {
list($type, $libEn, $libFr) = $row;
if (isset($row[3]) && null !== $row[3] && in_array($type, ['group', 'chart'])) {
$types = explode('|', $row[3]);
}
switch ($row[0]) {
case 'object':
// DO nohting
break;
case 'group':
$group = new Group();
$group->translate('en', false)->setName($libEn);
$group->translate('fr', false)->setName($libFr);
$group->setGame($game);
$group->mergeNewTranslations();
$this->em->persist($group);
break;
case 'chart':
$chart = new Chart();
$chart->translate('en', false)->setName($libEn);
$chart->translate('fr', false)->setName($libFr);
$chart->setGroup($group);
$chart->mergeNewTranslations();
if ($types !== null) {
foreach ($types as $idType) {
$chartLib = new ChartLib();
$chartLib
->setChart($chart)
->setType($this->em->getReference(ChartType::class, $idType));
$chart->addLib($chartLib);
}
}
$this->em->persist($chart);
break;
}
}
$this->em->flush();
rename($fileIn, $fileOut);
}
} | php | public function addFromCsv()
{
$files = array_diff(scandir($this->directory . '/in', SCANDIR_SORT_NONE), ['..', '.']);
foreach ($files as $file) {
if (0 !== strpos($file, 'game-add')) {
continue;
}
$fileIn = $this->directory . '/in/' . $file;
$fileOut = $this->directory . '/out/' . $file;
$handle = fopen($fileIn, 'rb');
$idGame = substr($file, 8, -4);
if (!is_numeric($idGame)) {
continue;
}
/** @var \VideoGamesRecords\CoreBundle\Entity\Game $game */
$game = $this->em->getReference(GameEntity::class, $idGame);
if ($game === null) {
continue;
}
$group = null;
$types = null;
while (($row = fgetcsv($handle, null, ';')) !== false) {
list($type, $libEn, $libFr) = $row;
if (isset($row[3]) && null !== $row[3] && in_array($type, ['group', 'chart'])) {
$types = explode('|', $row[3]);
}
switch ($row[0]) {
case 'object':
// DO nohting
break;
case 'group':
$group = new Group();
$group->translate('en', false)->setName($libEn);
$group->translate('fr', false)->setName($libFr);
$group->setGame($game);
$group->mergeNewTranslations();
$this->em->persist($group);
break;
case 'chart':
$chart = new Chart();
$chart->translate('en', false)->setName($libEn);
$chart->translate('fr', false)->setName($libFr);
$chart->setGroup($group);
$chart->mergeNewTranslations();
if ($types !== null) {
foreach ($types as $idType) {
$chartLib = new ChartLib();
$chartLib
->setChart($chart)
->setType($this->em->getReference(ChartType::class, $idType));
$chart->addLib($chartLib);
}
}
$this->em->persist($chart);
break;
}
}
$this->em->flush();
rename($fileIn, $fileOut);
}
} | [
"public",
"function",
"addFromCsv",
"(",
")",
"{",
"$",
"files",
"=",
"array_diff",
"(",
"scandir",
"(",
"$",
"this",
"->",
"directory",
".",
"'/in'",
",",
"SCANDIR_SORT_NONE",
")",
",",
"[",
"'..'",
",",
"'.'",
"]",
")",
";",
"foreach",
"(",
"$",
"f... | Add groups and charts from a csv file | [
"Add",
"groups",
"and",
"charts",
"from",
"a",
"csv",
"file"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Service/Game.php#L25-L92 | train |
video-games-records/CoreBundle | Service/Game.php | Game.updateFromCsv | public function updateFromCsv()
{
$files = array_diff(scandir($this->directory . '/in', SCANDIR_SORT_NONE), ['..', '.']);
foreach ($files as $file) {
if (0 !== strpos($file, 'game-update')) {
continue;
}
$fileIn = $this->directory . '/in/' . $file;
$fileOut = $this->directory . '/out/' . $file;
$handle = fopen($fileIn, 'rb');
$idGame = substr($file, 11, -4);
if (!is_numeric($idGame)) {
continue;
}
$group = null;
$types = null;
while (($row = fgetcsv($handle, null, ';')) !== false) {
list($type, $id, $libEn, $libFr) = $row;
switch ($type) {
case 'object':
// DO nothing
break;
case 'group':
$group = $this->em->getRepository('VideoGamesRecordsCoreBundle:Group')->find($id);
$group->translate('en', false)->setName($libEn);
$group->translate('fr', false)->setName($libFr);
$group->mergeNewTranslations();
$this->em->persist($group);
break;
case 'chart':
$chart = $this->em->getRepository('VideoGamesRecordsCoreBundle:Chart')->find($id);
$chart->translate('en', false)->setName($libEn);
$chart->translate('fr', false)->setName($libFr);
$chart->mergeNewTranslations();
$this->em->persist($chart);
break;
}
}
$this->em->flush();
rename($fileIn, $fileOut);
}
} | php | public function updateFromCsv()
{
$files = array_diff(scandir($this->directory . '/in', SCANDIR_SORT_NONE), ['..', '.']);
foreach ($files as $file) {
if (0 !== strpos($file, 'game-update')) {
continue;
}
$fileIn = $this->directory . '/in/' . $file;
$fileOut = $this->directory . '/out/' . $file;
$handle = fopen($fileIn, 'rb');
$idGame = substr($file, 11, -4);
if (!is_numeric($idGame)) {
continue;
}
$group = null;
$types = null;
while (($row = fgetcsv($handle, null, ';')) !== false) {
list($type, $id, $libEn, $libFr) = $row;
switch ($type) {
case 'object':
// DO nothing
break;
case 'group':
$group = $this->em->getRepository('VideoGamesRecordsCoreBundle:Group')->find($id);
$group->translate('en', false)->setName($libEn);
$group->translate('fr', false)->setName($libFr);
$group->mergeNewTranslations();
$this->em->persist($group);
break;
case 'chart':
$chart = $this->em->getRepository('VideoGamesRecordsCoreBundle:Chart')->find($id);
$chart->translate('en', false)->setName($libEn);
$chart->translate('fr', false)->setName($libFr);
$chart->mergeNewTranslations();
$this->em->persist($chart);
break;
}
}
$this->em->flush();
rename($fileIn, $fileOut);
}
} | [
"public",
"function",
"updateFromCsv",
"(",
")",
"{",
"$",
"files",
"=",
"array_diff",
"(",
"scandir",
"(",
"$",
"this",
"->",
"directory",
".",
"'/in'",
",",
"SCANDIR_SORT_NONE",
")",
",",
"[",
"'..'",
",",
"'.'",
"]",
")",
";",
"foreach",
"(",
"$",
... | Update groups and charts from a csv file | [
"Update",
"groups",
"and",
"charts",
"from",
"a",
"csv",
"file"
] | 64fc8fbc8217f4593b26223168463bfbe8f3fd61 | https://github.com/video-games-records/CoreBundle/blob/64fc8fbc8217f4593b26223168463bfbe8f3fd61/Service/Game.php#L97-L141 | train |
Due/php-ecom-sdk | lib/Due.php | Due.setEnvName | public static function setEnvName($arg_env_name)
{
if($arg_env_name == 'stage'){
self::$envName = 'stage';
self::$domain = self::$domainStage;
}elseif($arg_env_name == 'prod'){
self::$envName = 'prod';
self::$domain = self::$domainProd;
}else{
throw new \Exception('Invalid Environment Given',4046969);
}
} | php | public static function setEnvName($arg_env_name)
{
if($arg_env_name == 'stage'){
self::$envName = 'stage';
self::$domain = self::$domainStage;
}elseif($arg_env_name == 'prod'){
self::$envName = 'prod';
self::$domain = self::$domainProd;
}else{
throw new \Exception('Invalid Environment Given',4046969);
}
} | [
"public",
"static",
"function",
"setEnvName",
"(",
"$",
"arg_env_name",
")",
"{",
"if",
"(",
"$",
"arg_env_name",
"==",
"'stage'",
")",
"{",
"self",
"::",
"$",
"envName",
"=",
"'stage'",
";",
"self",
"::",
"$",
"domain",
"=",
"self",
"::",
"$",
"domain... | Set Environment Name
@param string $arg_env_name
@return null
@throws \Exception | [
"Set",
"Environment",
"Name"
] | 4c2e4040469bb159e62461363ec133b6faf0a7ae | https://github.com/Due/php-ecom-sdk/blob/4c2e4040469bb159e62461363ec133b6faf0a7ae/lib/Due.php#L106-L117 | train |
BR0kEN-/behat-debug-extension | src/Debugger.php | Debugger.debug | public static function debug(array $strings, array $placeholders = [])
{
// Initialize messages storage.
if (!isset($_SESSION[__TRAIT__])) {
$_SESSION[__TRAIT__] = [];
}
// Mark debug message.
array_unshift($strings, '<question>DEBUG:</question>');
$_SESSION[__TRAIT__][] = new Message('comment', 4, $strings, $placeholders, (bool) getenv('BEHAT_DEBUG'));
} | php | public static function debug(array $strings, array $placeholders = [])
{
// Initialize messages storage.
if (!isset($_SESSION[__TRAIT__])) {
$_SESSION[__TRAIT__] = [];
}
// Mark debug message.
array_unshift($strings, '<question>DEBUG:</question>');
$_SESSION[__TRAIT__][] = new Message('comment', 4, $strings, $placeholders, (bool) getenv('BEHAT_DEBUG'));
} | [
"public",
"static",
"function",
"debug",
"(",
"array",
"$",
"strings",
",",
"array",
"$",
"placeholders",
"=",
"[",
"]",
")",
"{",
"// Initialize messages storage.",
"if",
"(",
"!",
"isset",
"(",
"$",
"_SESSION",
"[",
"__TRAIT__",
"]",
")",
")",
"{",
"$"... | Store message for debugging.
@param string[] $strings
The lines to print. One item per line. Every item will be processed by sprintf().
@param string[] $placeholders
Placeholder values for sprintf(). | [
"Store",
"message",
"for",
"debugging",
"."
] | 5dcb1e01bdbb19246009eaa805c53b33a76ddfe1 | https://github.com/BR0kEN-/behat-debug-extension/blob/5dcb1e01bdbb19246009eaa805c53b33a76ddfe1/src/Debugger.php#L22-L33 | train |
BR0kEN-/behat-debug-extension | src/Debugger.php | Debugger.printMessages | public static function printMessages($clearQueue = true)
{
if (!empty($_SESSION[__TRAIT__])) {
/** @var Message $message */
foreach ($_SESSION[__TRAIT__] as $message) {
$message->output();
}
}
if ($clearQueue) {
static::clearQueue();
}
} | php | public static function printMessages($clearQueue = true)
{
if (!empty($_SESSION[__TRAIT__])) {
/** @var Message $message */
foreach ($_SESSION[__TRAIT__] as $message) {
$message->output();
}
}
if ($clearQueue) {
static::clearQueue();
}
} | [
"public",
"static",
"function",
"printMessages",
"(",
"$",
"clearQueue",
"=",
"true",
")",
"{",
"if",
"(",
"!",
"empty",
"(",
"$",
"_SESSION",
"[",
"__TRAIT__",
"]",
")",
")",
"{",
"/** @var Message $message */",
"foreach",
"(",
"$",
"_SESSION",
"[",
"__TR... | Output messages to a command line.
@param bool $clearQueue
Is message queue should be cleared after output? | [
"Output",
"messages",
"to",
"a",
"command",
"line",
"."
] | 5dcb1e01bdbb19246009eaa805c53b33a76ddfe1 | https://github.com/BR0kEN-/behat-debug-extension/blob/5dcb1e01bdbb19246009eaa805c53b33a76ddfe1/src/Debugger.php#L41-L53 | train |
karwana/php-mime | Mime/Mime.php | Mime.getTypeForExtension | public static function getTypeForExtension($extension) {
static::ensureDataLoaded();
$extension = strtolower($extension);
foreach (static::$mime_types as $mime_type => $extensions) {
if (is_array($extensions)) {
if (in_array($extension, $extensions, true)) {
return $mime_type;
}
} else if ($extension === $extensions) {
return $mime_type;
}
}
} | php | public static function getTypeForExtension($extension) {
static::ensureDataLoaded();
$extension = strtolower($extension);
foreach (static::$mime_types as $mime_type => $extensions) {
if (is_array($extensions)) {
if (in_array($extension, $extensions, true)) {
return $mime_type;
}
} else if ($extension === $extensions) {
return $mime_type;
}
}
} | [
"public",
"static",
"function",
"getTypeForExtension",
"(",
"$",
"extension",
")",
"{",
"static",
"::",
"ensureDataLoaded",
"(",
")",
";",
"$",
"extension",
"=",
"strtolower",
"(",
"$",
"extension",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"mime_types"... | Get the MIME type associated with a given extension.
@param string $extension A file extension e.g. pdf.
@return string|null The associated MIME type or null if none found. | [
"Get",
"the",
"MIME",
"type",
"associated",
"with",
"a",
"given",
"extension",
"."
] | ae55390cf88262d75d4122f245999d91d5b1cd66 | https://github.com/karwana/php-mime/blob/ae55390cf88262d75d4122f245999d91d5b1cd66/Mime/Mime.php#L34-L47 | train |
karwana/php-mime | Mime/Mime.php | Mime.getExtensionForType | public static function getExtensionForType($mime_type) {
static::ensureDataLoaded();
if (!static::hasType($mime_type)) {
return;
}
$extensions = static::$mime_types[$mime_type];
if (is_array($extensions)) {
return $extensions[0];
}
return $extensions;
} | php | public static function getExtensionForType($mime_type) {
static::ensureDataLoaded();
if (!static::hasType($mime_type)) {
return;
}
$extensions = static::$mime_types[$mime_type];
if (is_array($extensions)) {
return $extensions[0];
}
return $extensions;
} | [
"public",
"static",
"function",
"getExtensionForType",
"(",
"$",
"mime_type",
")",
"{",
"static",
"::",
"ensureDataLoaded",
"(",
")",
";",
"if",
"(",
"!",
"static",
"::",
"hasType",
"(",
"$",
"mime_type",
")",
")",
"{",
"return",
";",
"}",
"$",
"extensio... | Get the extension associated with a given MIME type.
@param string $mime_type A MIME type e.g. application/pdf.
@return string|null The first available associated extension or null if none found. | [
"Get",
"the",
"extension",
"associated",
"with",
"a",
"given",
"MIME",
"type",
"."
] | ae55390cf88262d75d4122f245999d91d5b1cd66 | https://github.com/karwana/php-mime/blob/ae55390cf88262d75d4122f245999d91d5b1cd66/Mime/Mime.php#L57-L70 | train |
karwana/php-mime | Mime/Mime.php | Mime.hasExtension | public static function hasExtension($extension) {
static::ensureDataLoaded();
$extension = strtolower($extension);
foreach (static::$mime_types as $extensions) {
if (is_array($extensions)) {
if (in_array($extension, $extensions, true)) {
return true;
}
} else if ($extension === $extensions) {
return true;
}
}
return false;
} | php | public static function hasExtension($extension) {
static::ensureDataLoaded();
$extension = strtolower($extension);
foreach (static::$mime_types as $extensions) {
if (is_array($extensions)) {
if (in_array($extension, $extensions, true)) {
return true;
}
} else if ($extension === $extensions) {
return true;
}
}
return false;
} | [
"public",
"static",
"function",
"hasExtension",
"(",
"$",
"extension",
")",
"{",
"static",
"::",
"ensureDataLoaded",
"(",
")",
";",
"$",
"extension",
"=",
"strtolower",
"(",
"$",
"extension",
")",
";",
"foreach",
"(",
"static",
"::",
"$",
"mime_types",
"as... | Check if an extension is known.
@param string $extension An extension e.g. pdf.
@return boolean | [
"Check",
"if",
"an",
"extension",
"is",
"known",
"."
] | ae55390cf88262d75d4122f245999d91d5b1cd66 | https://github.com/karwana/php-mime/blob/ae55390cf88262d75d4122f245999d91d5b1cd66/Mime/Mime.php#L96-L111 | train |
karwana/php-mime | Mime/Mime.php | Mime.guessType | public static function guessType($file_path, $reference_name = null, $default = 'application/octet-stream') {
if (!$reference_name) {
$reference_name = basename($file_path);
}
$extension = pathinfo($reference_name, PATHINFO_EXTENSION);
if ($extension and $mime_type = static::getTypeForExtension($extension)) {
return $mime_type;
}
// While it's true that the extension doesn't determine the type,
// only use finfo as a fallback because it's bad at detecting text
// types like CSS and JavaScript.
if ($mime_type = static::getMagicType($file_path)) {
return $mime_type;
}
return $default;
} | php | public static function guessType($file_path, $reference_name = null, $default = 'application/octet-stream') {
if (!$reference_name) {
$reference_name = basename($file_path);
}
$extension = pathinfo($reference_name, PATHINFO_EXTENSION);
if ($extension and $mime_type = static::getTypeForExtension($extension)) {
return $mime_type;
}
// While it's true that the extension doesn't determine the type,
// only use finfo as a fallback because it's bad at detecting text
// types like CSS and JavaScript.
if ($mime_type = static::getMagicType($file_path)) {
return $mime_type;
}
return $default;
} | [
"public",
"static",
"function",
"guessType",
"(",
"$",
"file_path",
",",
"$",
"reference_name",
"=",
"null",
",",
"$",
"default",
"=",
"'application/octet-stream'",
")",
"{",
"if",
"(",
"!",
"$",
"reference_name",
")",
"{",
"$",
"reference_name",
"=",
"basen... | Guess the MIME type of a given file, first by checking the extension then by falling back to magic.
@param string $file_path Relative or absolute path to an existing file.
@param string $reference_name Use this name for detection based on the extension.
@param string $default Default MIME type.
@return string|null The associated MIME type or the default if none found. | [
"Guess",
"the",
"MIME",
"type",
"of",
"a",
"given",
"file",
"first",
"by",
"checking",
"the",
"extension",
"then",
"by",
"falling",
"back",
"to",
"magic",
"."
] | ae55390cf88262d75d4122f245999d91d5b1cd66 | https://github.com/karwana/php-mime/blob/ae55390cf88262d75d4122f245999d91d5b1cd66/Mime/Mime.php#L136-L154 | train |
karwana/php-mime | Mime/Mime.php | Mime.guessExtension | public static function guessExtension($file_path, $reference_name = null, $default = 'bin') {
if (!$reference_name) {
$reference_name = basename($file_path);
}
if ($extension = pathinfo($reference_name, PATHINFO_EXTENSION) and static::hasExtension($extension)) {
return strtolower($extension);
}
$mime_type = static::getMagicType($file_path);
if ($mime_type and $extension = static::getExtensionForType($mime_type)) {
return $extension;
}
return $default;
} | php | public static function guessExtension($file_path, $reference_name = null, $default = 'bin') {
if (!$reference_name) {
$reference_name = basename($file_path);
}
if ($extension = pathinfo($reference_name, PATHINFO_EXTENSION) and static::hasExtension($extension)) {
return strtolower($extension);
}
$mime_type = static::getMagicType($file_path);
if ($mime_type and $extension = static::getExtensionForType($mime_type)) {
return $extension;
}
return $default;
} | [
"public",
"static",
"function",
"guessExtension",
"(",
"$",
"file_path",
",",
"$",
"reference_name",
"=",
"null",
",",
"$",
"default",
"=",
"'bin'",
")",
"{",
"if",
"(",
"!",
"$",
"reference_name",
")",
"{",
"$",
"reference_name",
"=",
"basename",
"(",
"... | Guess the extension of a given file, first by checking the path then by falling back to magic.
@param string $file_path Relative or absolute path to an existing file.
@param string $reference_name Use this name for detection based on the extension.
@param string $default Default extension.
@return string|null The associated extension or the default if none found. | [
"Guess",
"the",
"extension",
"of",
"a",
"given",
"file",
"first",
"by",
"checking",
"the",
"path",
"then",
"by",
"falling",
"back",
"to",
"magic",
"."
] | ae55390cf88262d75d4122f245999d91d5b1cd66 | https://github.com/karwana/php-mime/blob/ae55390cf88262d75d4122f245999d91d5b1cd66/Mime/Mime.php#L166-L181 | train |
karwana/php-mime | Mime/Mime.php | Mime.getMagicType | public static function getMagicType($file_path) {
$file_info = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($file_info, $file_path);
finfo_close($file_info);
// Only return valid types, in order to maintain circular compatibility between methods.
if (static::hasType($mime_type)) {
return $mime_type;
}
} | php | public static function getMagicType($file_path) {
$file_info = finfo_open(FILEINFO_MIME_TYPE);
$mime_type = finfo_file($file_info, $file_path);
finfo_close($file_info);
// Only return valid types, in order to maintain circular compatibility between methods.
if (static::hasType($mime_type)) {
return $mime_type;
}
} | [
"public",
"static",
"function",
"getMagicType",
"(",
"$",
"file_path",
")",
"{",
"$",
"file_info",
"=",
"finfo_open",
"(",
"FILEINFO_MIME_TYPE",
")",
";",
"$",
"mime_type",
"=",
"finfo_file",
"(",
"$",
"file_info",
",",
"$",
"file_path",
")",
";",
"finfo_clo... | Get the MIME type of a file using magic.
@param string $file_path Relative or absolute path to an existing file.
@return string|null The associated MIME type or null if no known type was detected. | [
"Get",
"the",
"MIME",
"type",
"of",
"a",
"file",
"using",
"magic",
"."
] | ae55390cf88262d75d4122f245999d91d5b1cd66 | https://github.com/karwana/php-mime/blob/ae55390cf88262d75d4122f245999d91d5b1cd66/Mime/Mime.php#L191-L200 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Core/Plugins/ScriptAdapter.php | ScriptAdapter.parseParameters | protected function parseParameters($parameters)
{
if (isset($parameters[0])) {
$params = json_decode($parameters[0], true);
if ($params) {
return $params;
}
}
// If json couldn't be encoded return string as it was
return $parameters;
} | php | protected function parseParameters($parameters)
{
if (isset($parameters[0])) {
$params = json_decode($parameters[0], true);
if ($params) {
return $params;
}
}
// If json couldn't be encoded return string as it was
return $parameters;
} | [
"protected",
"function",
"parseParameters",
"(",
"$",
"parameters",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"parameters",
"[",
"0",
"]",
")",
")",
"{",
"$",
"params",
"=",
"json_decode",
"(",
"$",
"parameters",
"[",
"0",
"]",
",",
"true",
")",
";",
... | Parse parameters that are usually in json.
@param $parameters
@return string|array | [
"Parse",
"parameters",
"that",
"are",
"usually",
"in",
"json",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Core/Plugins/ScriptAdapter.php#L48-L59 | train |
honeybee/trellis | src/Runtime/Attribute/Uuid/UuidValueHolder.php | UuidValueHolder.isDefault | public function isDefault()
{
if ($this->getAttribute()->hasOption(UuidAttribute::OPTION_DEFAULT_VALUE)
&& $this->getAttribute()->getOption(UuidAttribute::OPTION_DEFAULT_VALUE) !== 'auto_gen'
) {
return $this->sameValueAs($this->getAttribute()->getDefaultValue());
}
throw new RuntimeException(
'Operation not supported. A new UUIDv4 is generated for every getNullValue call. No default value set.'
);
} | php | public function isDefault()
{
if ($this->getAttribute()->hasOption(UuidAttribute::OPTION_DEFAULT_VALUE)
&& $this->getAttribute()->getOption(UuidAttribute::OPTION_DEFAULT_VALUE) !== 'auto_gen'
) {
return $this->sameValueAs($this->getAttribute()->getDefaultValue());
}
throw new RuntimeException(
'Operation not supported. A new UUIDv4 is generated for every getNullValue call. No default value set.'
);
} | [
"public",
"function",
"isDefault",
"(",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"getAttribute",
"(",
")",
"->",
"hasOption",
"(",
"UuidAttribute",
"::",
"OPTION_DEFAULT_VALUE",
")",
"&&",
"$",
"this",
"->",
"getAttribute",
"(",
")",
"->",
"getOption",
"(",... | Tells whether the valueholder's value is considered to be the same as
the default value defined on the attribute.
@return boolean | [
"Tells",
"whether",
"the",
"valueholder",
"s",
"value",
"is",
"considered",
"to",
"be",
"the",
"same",
"as",
"the",
"default",
"value",
"defined",
"on",
"the",
"attribute",
"."
] | 511300e193b22adc48a22e8ea8294ad40d53f681 | https://github.com/honeybee/trellis/blob/511300e193b22adc48a22e8ea8294ad40d53f681/src/Runtime/Attribute/Uuid/UuidValueHolder.php#L19-L30 | train |
vube/php-filesystem | src/Vube/FileSystem/TempDirectory.php | TempDirectory.rmdir | private function rmdir($dir, $recursive)
{
$is_link = is_link($dir);
if($is_link)
{
if(! unlink($dir))
throw new Exception("Error unlinking $dir");
}
else if(! $recursive)
{
if(! rmdir($dir))
throw new Exception("Error removing temp dir: $dir");
}
else
{
$dh = opendir($dir);
if(! $dh)
throw new Exception("Cannot read temp dir contents for removal: $dir");
do
{
$file = readdir($dh);
if($file === false)
break;
// Don't delete current dir or parent dir (yet)
if($file === '.' || $file === '..')
continue;
$path = $dir .DIRECTORY_SEPARATOR. $file;
$is_link = is_link($path);
$is_dir = is_dir($path);
if($is_dir && ! $is_link)
{
$this->rmdir($path, true);
}
else // anything else, should be able to unlink
{
if(! unlink($path))
throw new Exception("Cannot remove nested temp file: $path");
}
}
while($file !== false);
closedir($dh);
// Now remove the dir itself (non-recursive, it should now be empty)
$this->rmdir($dir, false);
}
} | php | private function rmdir($dir, $recursive)
{
$is_link = is_link($dir);
if($is_link)
{
if(! unlink($dir))
throw new Exception("Error unlinking $dir");
}
else if(! $recursive)
{
if(! rmdir($dir))
throw new Exception("Error removing temp dir: $dir");
}
else
{
$dh = opendir($dir);
if(! $dh)
throw new Exception("Cannot read temp dir contents for removal: $dir");
do
{
$file = readdir($dh);
if($file === false)
break;
// Don't delete current dir or parent dir (yet)
if($file === '.' || $file === '..')
continue;
$path = $dir .DIRECTORY_SEPARATOR. $file;
$is_link = is_link($path);
$is_dir = is_dir($path);
if($is_dir && ! $is_link)
{
$this->rmdir($path, true);
}
else // anything else, should be able to unlink
{
if(! unlink($path))
throw new Exception("Cannot remove nested temp file: $path");
}
}
while($file !== false);
closedir($dh);
// Now remove the dir itself (non-recursive, it should now be empty)
$this->rmdir($dir, false);
}
} | [
"private",
"function",
"rmdir",
"(",
"$",
"dir",
",",
"$",
"recursive",
")",
"{",
"$",
"is_link",
"=",
"is_link",
"(",
"$",
"dir",
")",
";",
"if",
"(",
"$",
"is_link",
")",
"{",
"if",
"(",
"!",
"unlink",
"(",
"$",
"dir",
")",
")",
"throw",
"new... | Remove the directory
@param string $dir
@param bool $recursive
@throws Exception | [
"Remove",
"the",
"directory"
] | 147513e8c3809a1d9d947d2753780c0671cc3194 | https://github.com/vube/php-filesystem/blob/147513e8c3809a1d9d947d2753780c0671cc3194/src/Vube/FileSystem/TempDirectory.php#L52-L103 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Modules/HandleException.php | HandleException.Setup | public function Setup($xmlModuleName, $customArgs)
{
parent::Setup($xmlModuleName, $customArgs);
$this->_ErrorMessage = $customArgs;
} | php | public function Setup($xmlModuleName, $customArgs)
{
parent::Setup($xmlModuleName, $customArgs);
$this->_ErrorMessage = $customArgs;
} | [
"public",
"function",
"Setup",
"(",
"$",
"xmlModuleName",
",",
"$",
"customArgs",
")",
"{",
"parent",
"::",
"Setup",
"(",
"$",
"xmlModuleName",
",",
"$",
"customArgs",
")",
";",
"$",
"this",
"->",
"_ErrorMessage",
"=",
"$",
"customArgs",
";",
"}"
] | This method receive a external error message and show it.
@param Object $customArg | [
"This",
"method",
"receive",
"a",
"external",
"error",
"message",
"and",
"show",
"it",
"."
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Modules/HandleException.php#L60-L64 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Bundle/Maps/Plugins/ManiaExchange.php | ManiaExchange.addMapToQueue | public function addMapToQueue($login, $id, $mxsite)
{
if (!$this->adminGroups->hasPermission($login, "maps.add")) {
$this->chatNotification->sendMessage('expansion_mx.chat.nopermission', $login);
return;
}
if ($this->downloadProgressing || count($this->addQueue) > 1) {
$this->addQueue[] = ['mxid' => $id, 'mxsite' => $mxsite];
$this->chatNotification->sendMessage("|info| Adding map to download queue...", $login);
return;
} else {
$this->addMap($login, $id, $mxsite);
}
} | php | public function addMapToQueue($login, $id, $mxsite)
{
if (!$this->adminGroups->hasPermission($login, "maps.add")) {
$this->chatNotification->sendMessage('expansion_mx.chat.nopermission', $login);
return;
}
if ($this->downloadProgressing || count($this->addQueue) > 1) {
$this->addQueue[] = ['mxid' => $id, 'mxsite' => $mxsite];
$this->chatNotification->sendMessage("|info| Adding map to download queue...", $login);
return;
} else {
$this->addMap($login, $id, $mxsite);
}
} | [
"public",
"function",
"addMapToQueue",
"(",
"$",
"login",
",",
"$",
"id",
",",
"$",
"mxsite",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"adminGroups",
"->",
"hasPermission",
"(",
"$",
"login",
",",
"\"maps.add\"",
")",
")",
"{",
"$",
"this",
"->",... | add map to queue
@param string $login
@param integer $id
@param string $mxsite "TM" or "SM" | [
"add",
"map",
"to",
"queue"
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Bundle/Maps/Plugins/ManiaExchange.php#L135-L154 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/Config/Services/ConfigUiManager.php | ConfigUiManager.getUiHandler | public function getUiHandler(ConfigInterface $config)
{
if ($config->isHidden()) {
return null;
}
foreach ($this->uiHandlers as $ui) {
if ($ui->isCompatible($config)) {
return $ui;
}
}
return null;
} | php | public function getUiHandler(ConfigInterface $config)
{
if ($config->isHidden()) {
return null;
}
foreach ($this->uiHandlers as $ui) {
if ($ui->isCompatible($config)) {
return $ui;
}
}
return null;
} | [
"public",
"function",
"getUiHandler",
"(",
"ConfigInterface",
"$",
"config",
")",
"{",
"if",
"(",
"$",
"config",
"->",
"isHidden",
"(",
")",
")",
"{",
"return",
"null",
";",
"}",
"foreach",
"(",
"$",
"this",
"->",
"uiHandlers",
"as",
"$",
"ui",
")",
... | Get proper handler to generate ui for a config element.
@param ConfigInterface $config
@return UiInterface|null | [
"Get",
"proper",
"handler",
"to",
"generate",
"ui",
"for",
"a",
"config",
"element",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/Config/Services/ConfigUiManager.php#L37-L50 | train |
orkestra/OrkestraPdfBundle | Pdf/WkPdf/WkPdfBuilder.php | WkPdfBuilder.render | public function render()
{
$process = $this->getProcess();
$process->run();
if (0 === $process->getExitCode()) {
return file_get_contents($this->getOutput());
}
throw new \RuntimeException(
sprintf('Unable to render PDF. Command "%s" exited with "%s" (code: %s): %s',
$process->getCommandLine(),
$process->getExitCodeText(),
$process->getExitCode(),
$process->getErrorOutput()
)
);
} | php | public function render()
{
$process = $this->getProcess();
$process->run();
if (0 === $process->getExitCode()) {
return file_get_contents($this->getOutput());
}
throw new \RuntimeException(
sprintf('Unable to render PDF. Command "%s" exited with "%s" (code: %s): %s',
$process->getCommandLine(),
$process->getExitCodeText(),
$process->getExitCode(),
$process->getErrorOutput()
)
);
} | [
"public",
"function",
"render",
"(",
")",
"{",
"$",
"process",
"=",
"$",
"this",
"->",
"getProcess",
"(",
")",
";",
"$",
"process",
"->",
"run",
"(",
")",
";",
"if",
"(",
"0",
"===",
"$",
"process",
"->",
"getExitCode",
"(",
")",
")",
"{",
"retur... | Render a PDF with this builder's configuration
@return WkPdf
@throws \RuntimeException | [
"Render",
"a",
"PDF",
"with",
"this",
"builder",
"s",
"configuration"
] | 45979a93b662e81787116f26b53362911878c685 | https://github.com/orkestra/OrkestraPdfBundle/blob/45979a93b662e81787116f26b53362911878c685/Pdf/WkPdf/WkPdfBuilder.php#L72-L88 | train |
orkestra/OrkestraPdfBundle | Pdf/WkPdf/WkPdfBuilder.php | WkPdfBuilder.getProcess | public function getProcess()
{
$this->processBuilder->setArguments(array());
foreach ($this->options as $option => $value) {
if (!$value) {
continue;
}
if (!in_array($option, static::$nonPrefixedOptions)) {
$option = sprintf('--%s', $option);
}
$this->processBuilder->add($option);
if (true !== $value) {
$this->processBuilder->add($value);
}
}
$this->processBuilder->add('-')->add($this->getOutput());
$process = $this->processBuilder->getProcess();
$process->setCommandLine(sprintf('echo "%s" | %s', addslashes($this->getInput()), $process->getCommandLine()));
return $process;
} | php | public function getProcess()
{
$this->processBuilder->setArguments(array());
foreach ($this->options as $option => $value) {
if (!$value) {
continue;
}
if (!in_array($option, static::$nonPrefixedOptions)) {
$option = sprintf('--%s', $option);
}
$this->processBuilder->add($option);
if (true !== $value) {
$this->processBuilder->add($value);
}
}
$this->processBuilder->add('-')->add($this->getOutput());
$process = $this->processBuilder->getProcess();
$process->setCommandLine(sprintf('echo "%s" | %s', addslashes($this->getInput()), $process->getCommandLine()));
return $process;
} | [
"public",
"function",
"getProcess",
"(",
")",
"{",
"$",
"this",
"->",
"processBuilder",
"->",
"setArguments",
"(",
"array",
"(",
")",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"options",
"as",
"$",
"option",
"=>",
"$",
"value",
")",
"{",
"if",
"("... | Builds command line arguments based on the current configuration
Command line format for wkhtmltopdf:
wkhtmltopdf [GLOBAL OPTION]... [OBJECT]... <output file>
@return Process | [
"Builds",
"command",
"line",
"arguments",
"based",
"on",
"the",
"current",
"configuration"
] | 45979a93b662e81787116f26b53362911878c685 | https://github.com/orkestra/OrkestraPdfBundle/blob/45979a93b662e81787116f26b53362911878c685/Pdf/WkPdf/WkPdfBuilder.php#L98-L124 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeDocument.php | XmlnukeDocument.addJavaScriptMethod | public function addJavaScriptMethod($jsObject, $jsMethod, $jsSource, $jsParameters = "")
{
$jsEventSource =
"$(function() { \n" .
" $('$jsObject').$jsMethod(function($jsParameters) { \n" .
" $jsSource \n" .
" }); \n" .
"});\n\n";
$this->addJavaScriptSource($jsEventSource, false);
} | php | public function addJavaScriptMethod($jsObject, $jsMethod, $jsSource, $jsParameters = "")
{
$jsEventSource =
"$(function() { \n" .
" $('$jsObject').$jsMethod(function($jsParameters) { \n" .
" $jsSource \n" .
" }); \n" .
"});\n\n";
$this->addJavaScriptSource($jsEventSource, false);
} | [
"public",
"function",
"addJavaScriptMethod",
"(",
"$",
"jsObject",
",",
"$",
"jsMethod",
",",
"$",
"jsSource",
",",
"$",
"jsParameters",
"=",
"\"\"",
")",
"{",
"$",
"jsEventSource",
"=",
"\"$(function() { \\n\"",
".",
"\"\t$('$jsObject').$jsMethod(function($jsParamete... | Add a JavaScript method to a JavaScript object.
Some examples:
addJavaScriptMethod("a", "click", "alert('clicked on a hiperlink');");
addJavaScriptMethod("#myID", "blur", "alert('blur a ID object in JavaScript');");
@param string $jsObject
@param string $jsMethod
@param string $jsSource
@param string $jsParameters
@return void | [
"Add",
"a",
"JavaScript",
"method",
"to",
"a",
"JavaScript",
"object",
"."
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeDocument.php#L204-L213 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeDocument.php | XmlnukeDocument.addJavaScriptAttribute | public function addJavaScriptAttribute($jsObject, $jsAttrName, $attrParam)
{
if (!is_array($attrParam))
{
$attrParam = array($attrParam);
}
$jsEventSource =
"$(function() { \n" .
" $('$jsObject').$jsAttrName({ \n";
$first = true;
foreach ($attrParam as $key=>$value)
{
$jsEventSource .= (!$first ? ",\n" : "") . " " . (!is_numeric($key) ? "$key: " : "" ) . $value;
$first = false;
}
$jsEventSource .=
"\n }); \n" .
"});\n\n";
$this->addJavaScriptSource($jsEventSource, false);
} | php | public function addJavaScriptAttribute($jsObject, $jsAttrName, $attrParam)
{
if (!is_array($attrParam))
{
$attrParam = array($attrParam);
}
$jsEventSource =
"$(function() { \n" .
" $('$jsObject').$jsAttrName({ \n";
$first = true;
foreach ($attrParam as $key=>$value)
{
$jsEventSource .= (!$first ? ",\n" : "") . " " . (!is_numeric($key) ? "$key: " : "" ) . $value;
$first = false;
}
$jsEventSource .=
"\n }); \n" .
"});\n\n";
$this->addJavaScriptSource($jsEventSource, false);
} | [
"public",
"function",
"addJavaScriptAttribute",
"(",
"$",
"jsObject",
",",
"$",
"jsAttrName",
",",
"$",
"attrParam",
")",
"{",
"if",
"(",
"!",
"is_array",
"(",
"$",
"attrParam",
")",
")",
"{",
"$",
"attrParam",
"=",
"array",
"(",
"$",
"attrParam",
")",
... | Add a JavaScript attribute to a JavaScript object.
Some examples:
addJavaScriptMethod("#myID", "someAttr", array("param"=>"'teste'"));
@param string $jsObject
@param string $jsAttribute
@param array $attrParam
@return void | [
"Add",
"a",
"JavaScript",
"attribute",
"to",
"a",
"JavaScript",
"object",
"."
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeDocument.php#L227-L250 | train |
byjg/xmlnuke | xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeDocument.php | XmlnukeDocument.CompactJs | protected function CompactJs( $sText )
{
$sBuffer = "";
$i = 0;
$iStop = strlen($sText);
// Compact and Copy PHP Source Code.
$sChar = '';
$sLast = '';
$sWanted = '';
$fEscape = false;
for( $i = $i; $i < $iStop; $i++ )
{
$sLast = $sChar;
$sChar = substr( $sText, $i, 1 );
// \ in a string marks possible an escape sequence
if ( $sChar == '\\' )
// are we in a string?
if ( $sWanted == '"' || $sWanted == "'" )
// if we are not in an escape sequence, turn it on
// if we are in an escape sequence, turn it off
$fEscape = !$fEscape;
// " marks start or end of a string
if ( $sChar == '"' && !$fEscape )
if ( $sWanted == '' )
$sWanted = '"';
else
if ( $sWanted == '"' )
$sWanted = '';
// ' marks start or end of a string
if ( $sChar == "'" && !$fEscape )
if ( $sWanted == '' )
$sWanted = "'";
else
if ( $sWanted == "'" )
$sWanted = '';
// // marks start of a comment
if ( $sChar == '/' && $sWanted == '' )
if ( substr( $sText, $i + 1, 1 ) == '/' )
{
$sWanted = "\n";
$i++;
continue;
}
// \n marks possible end of comment
if ( $sChar == "\n" && $sWanted == "\n" )
{
$sWanted = '';
continue;
}
// /* marks start of a comment
if ( $sChar == '/' && $sWanted == '' )
if ( substr( $sText, $i + 1, 1 ) == '*' )
{
$sWanted = "*/";
$i++;
continue;
}
// */ marks possible end of comment
if ( $sChar == '*' && $sWanted == '*/' )
if ( substr( $sText, $i + 1, 1 ) == '/' )
{
$sWanted = '';
$i++;
continue;
}
// if we have a tab or a crlf replace it with a blank and continue if we had one recently
if ( ( $sChar == "\t" || $sChar == "\n" || $sChar == "\r" ) && $sWanted == '' )
{
$sChar = ' ';
if ( $sLast == ' ' )
continue;
}
// skip blanks only if previous char was a blank or nothing
if ( $sChar == ' ' && ( $sLast == ' ' || $sLast == '' ) && $sWanted == '' )
continue;
// add char to buffer if we are not inside a comment
if ( $sWanted == '' || $sWanted == '"' || $sWanted == "'" )
$sBuffer .= $sChar;
// if we had an escape sequence and the actual char isn't the escape char, cancel escape sequence...
// since we are only interested in escape sequences of \' and \".
if ( $fEscape && $sChar != '\\' )
$fEscape = false;
}
// Copy Rest
$sBuffer .= substr( $sText, $iStop );
return( $sBuffer );
} | php | protected function CompactJs( $sText )
{
$sBuffer = "";
$i = 0;
$iStop = strlen($sText);
// Compact and Copy PHP Source Code.
$sChar = '';
$sLast = '';
$sWanted = '';
$fEscape = false;
for( $i = $i; $i < $iStop; $i++ )
{
$sLast = $sChar;
$sChar = substr( $sText, $i, 1 );
// \ in a string marks possible an escape sequence
if ( $sChar == '\\' )
// are we in a string?
if ( $sWanted == '"' || $sWanted == "'" )
// if we are not in an escape sequence, turn it on
// if we are in an escape sequence, turn it off
$fEscape = !$fEscape;
// " marks start or end of a string
if ( $sChar == '"' && !$fEscape )
if ( $sWanted == '' )
$sWanted = '"';
else
if ( $sWanted == '"' )
$sWanted = '';
// ' marks start or end of a string
if ( $sChar == "'" && !$fEscape )
if ( $sWanted == '' )
$sWanted = "'";
else
if ( $sWanted == "'" )
$sWanted = '';
// // marks start of a comment
if ( $sChar == '/' && $sWanted == '' )
if ( substr( $sText, $i + 1, 1 ) == '/' )
{
$sWanted = "\n";
$i++;
continue;
}
// \n marks possible end of comment
if ( $sChar == "\n" && $sWanted == "\n" )
{
$sWanted = '';
continue;
}
// /* marks start of a comment
if ( $sChar == '/' && $sWanted == '' )
if ( substr( $sText, $i + 1, 1 ) == '*' )
{
$sWanted = "*/";
$i++;
continue;
}
// */ marks possible end of comment
if ( $sChar == '*' && $sWanted == '*/' )
if ( substr( $sText, $i + 1, 1 ) == '/' )
{
$sWanted = '';
$i++;
continue;
}
// if we have a tab or a crlf replace it with a blank and continue if we had one recently
if ( ( $sChar == "\t" || $sChar == "\n" || $sChar == "\r" ) && $sWanted == '' )
{
$sChar = ' ';
if ( $sLast == ' ' )
continue;
}
// skip blanks only if previous char was a blank or nothing
if ( $sChar == ' ' && ( $sLast == ' ' || $sLast == '' ) && $sWanted == '' )
continue;
// add char to buffer if we are not inside a comment
if ( $sWanted == '' || $sWanted == '"' || $sWanted == "'" )
$sBuffer .= $sChar;
// if we had an escape sequence and the actual char isn't the escape char, cancel escape sequence...
// since we are only interested in escape sequences of \' and \".
if ( $fEscape && $sChar != '\\' )
$fEscape = false;
}
// Copy Rest
$sBuffer .= substr( $sText, $iStop );
return( $sBuffer );
} | [
"protected",
"function",
"CompactJs",
"(",
"$",
"sText",
")",
"{",
"$",
"sBuffer",
"=",
"\"\"",
";",
"$",
"i",
"=",
"0",
";",
"$",
"iStop",
"=",
"strlen",
"(",
"$",
"sText",
")",
";",
"// Compact and Copy PHP Source Code.",
"$",
"sChar",
"=",
"''",
";"... | A 3rd party implementation for compact a javascript.
@Author: Hannes Dorn
@Company: IBIT.at
@Homepage: http://www.ibit.at
@Email: hannes.dorn@ibit.at
@Comment: Original compact PHP code. Changes by João Gilberto Magalhães (ByJG) to Work on JavaScript.
@param string $sText
@return unknown | [
"A",
"3rd",
"party",
"implementation",
"for",
"compact",
"a",
"javascript",
"."
] | aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7 | https://github.com/byjg/xmlnuke/blob/aeb458e4b7e0f6df1d900202f3c1c2a7ad7384f7/xmlnuke-php5/src/Xmlnuke/Core/Classes/XmlnukeDocument.php#L492-L592 | train |
rokka-io/rokka-client-php-cli | src/Command/OperationListCommand.php | OperationListCommand.getPropertySettings | private function getPropertySettings($property)
{
$data = [];
$settings = [
'minimum' => 'min',
'maximum' => 'max',
];
foreach ($settings as $setting => $name) {
if (isset($property[$setting])) {
$data[] = $name.':'.$property[$setting];
}
}
return implode(' | ', $data);
} | php | private function getPropertySettings($property)
{
$data = [];
$settings = [
'minimum' => 'min',
'maximum' => 'max',
];
foreach ($settings as $setting => $name) {
if (isset($property[$setting])) {
$data[] = $name.':'.$property[$setting];
}
}
return implode(' | ', $data);
} | [
"private",
"function",
"getPropertySettings",
"(",
"$",
"property",
")",
"{",
"$",
"data",
"=",
"[",
"]",
";",
"$",
"settings",
"=",
"[",
"'minimum'",
"=>",
"'min'",
",",
"'maximum'",
"=>",
"'max'",
",",
"]",
";",
"foreach",
"(",
"$",
"settings",
"as",... | Build a string for the "Other" column for the given property.
@param $property
@return string | [
"Build",
"a",
"string",
"for",
"the",
"Other",
"column",
"for",
"the",
"given",
"property",
"."
] | ef22af122af65579a8607a0df976a9ce5248dbbb | https://github.com/rokka-io/rokka-client-php-cli/blob/ef22af122af65579a8607a0df976a9ce5248dbbb/src/Command/OperationListCommand.php#L68-L82 | train |
eXpansionPluginPack/eXpansion2 | src/eXpansion/Framework/PlayersBundle/Model/Map/PlayerTableMap.php | PlayerTableMap.doDelete | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(PlayerTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Framework\PlayersBundle\Model\Player) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(PlayerTableMap::DATABASE_NAME);
$criteria->add(PlayerTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = PlayerQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
PlayerTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
PlayerTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | php | public static function doDelete($values, ConnectionInterface $con = null)
{
if (null === $con) {
$con = Propel::getServiceContainer()->getWriteConnection(PlayerTableMap::DATABASE_NAME);
}
if ($values instanceof Criteria) {
// rename for clarity
$criteria = $values;
} elseif ($values instanceof \eXpansion\Framework\PlayersBundle\Model\Player) { // it's a model object
// create criteria based on pk values
$criteria = $values->buildPkeyCriteria();
} else { // it's a primary key, or an array of pks
$criteria = new Criteria(PlayerTableMap::DATABASE_NAME);
$criteria->add(PlayerTableMap::COL_ID, (array) $values, Criteria::IN);
}
$query = PlayerQuery::create()->mergeWith($criteria);
if ($values instanceof Criteria) {
PlayerTableMap::clearInstancePool();
} elseif (!is_object($values)) { // it's a primary key, or an array of pks
foreach ((array) $values as $singleval) {
PlayerTableMap::removeInstanceFromPool($singleval);
}
}
return $query->delete($con);
} | [
"public",
"static",
"function",
"doDelete",
"(",
"$",
"values",
",",
"ConnectionInterface",
"$",
"con",
"=",
"null",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"con",
")",
"{",
"$",
"con",
"=",
"Propel",
"::",
"getServiceContainer",
"(",
")",
"->",
"getW... | Performs a DELETE on the database, given a Player or Criteria object OR a primary key value.
@param mixed $values Criteria or Player object or primary key or array of primary keys
which is used to create the DELETE statement
@param ConnectionInterface $con the connection to use
@return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
if supported by native driver or if emulated using Propel.
@throws PropelException Any exceptions caught during processing will be
rethrown wrapped into a PropelException. | [
"Performs",
"a",
"DELETE",
"on",
"the",
"database",
"given",
"a",
"Player",
"or",
"Criteria",
"object",
"OR",
"a",
"primary",
"key",
"value",
"."
] | e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31 | https://github.com/eXpansionPluginPack/eXpansion2/blob/e82ffcfa7bcbcb8e354d2fde0eb64bb5695b4a31/src/eXpansion/Framework/PlayersBundle/Model/Map/PlayerTableMap.php#L384-L412 | train |
TheBnl/event-tickets | code/tasks/MigrateAttendeeFieldsTask.php | MigrateAttendeeFieldsTask.publishEvents | private function publishEvents() {
/** @var CalendarEvent|TicketExtension $event */
foreach (CalendarEvent::get() as $event) {
if ($event->Tickets()->exists()) {
if ($event->doPublish()) {
echo "[$event->ID] Published event \n";
$this->moveFieldData($event);
} else {
echo "[$event->ID] Failed to publish event \n\n";
}
}
}
} | php | private function publishEvents() {
/** @var CalendarEvent|TicketExtension $event */
foreach (CalendarEvent::get() as $event) {
if ($event->Tickets()->exists()) {
if ($event->doPublish()) {
echo "[$event->ID] Published event \n";
$this->moveFieldData($event);
} else {
echo "[$event->ID] Failed to publish event \n\n";
}
}
}
} | [
"private",
"function",
"publishEvents",
"(",
")",
"{",
"/** @var CalendarEvent|TicketExtension $event */",
"foreach",
"(",
"CalendarEvent",
"::",
"get",
"(",
")",
"as",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"Tickets",
"(",
")",
"->",
"exists",... | Publishes the events so the default fields are created | [
"Publishes",
"the",
"events",
"so",
"the",
"default",
"fields",
"are",
"created"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/tasks/MigrateAttendeeFieldsTask.php#L49-L61 | train |
TheBnl/event-tickets | code/tasks/MigrateAttendeeFieldsTask.php | MigrateAttendeeFieldsTask.moveFieldData | private function moveFieldData(CalendarEvent $event) {
if ($event->Attendees()->exists()) {
/** @var Attendee $attendee */
foreach ($event->Attendees() as $attendee) {
/** @var UserField $field */
foreach ($event->Fields() as $field) {
$q = SQLSelect::create(
$field->FieldName,
"`{$attendee->getClassName()}`",
array('ID' => $attendee->ID)
);
try {
$value = $q->execute()->value();
$attendee->Fields()->add($field, array(
'Value' => $value
));
echo "[$event->ID][$attendee->ID] Set '$field->FieldName' with '{$value}' \n";
} catch (\Exception $e) {
// fails silent
echo "[$event->ID][$attendee->ID] Failed, '$field->FieldName' does not exist \n";
}
}
}
echo "[$event->ID] Finished migrating event \n\n";
} else {
echo "[$event->ID] No attendees to migrate \n\n";
}
} | php | private function moveFieldData(CalendarEvent $event) {
if ($event->Attendees()->exists()) {
/** @var Attendee $attendee */
foreach ($event->Attendees() as $attendee) {
/** @var UserField $field */
foreach ($event->Fields() as $field) {
$q = SQLSelect::create(
$field->FieldName,
"`{$attendee->getClassName()}`",
array('ID' => $attendee->ID)
);
try {
$value = $q->execute()->value();
$attendee->Fields()->add($field, array(
'Value' => $value
));
echo "[$event->ID][$attendee->ID] Set '$field->FieldName' with '{$value}' \n";
} catch (\Exception $e) {
// fails silent
echo "[$event->ID][$attendee->ID] Failed, '$field->FieldName' does not exist \n";
}
}
}
echo "[$event->ID] Finished migrating event \n\n";
} else {
echo "[$event->ID] No attendees to migrate \n\n";
}
} | [
"private",
"function",
"moveFieldData",
"(",
"CalendarEvent",
"$",
"event",
")",
"{",
"if",
"(",
"$",
"event",
"->",
"Attendees",
"(",
")",
"->",
"exists",
"(",
")",
")",
"{",
"/** @var Attendee $attendee */",
"foreach",
"(",
"$",
"event",
"->",
"Attendees",... | Migrate the field data from the attendee model to relations
Use an SQLSelect to access the data directly from the database
@param CalendarEvent|TicketExtension $event | [
"Migrate",
"the",
"field",
"data",
"from",
"the",
"attendee",
"model",
"to",
"relations",
"Use",
"an",
"SQLSelect",
"to",
"access",
"the",
"data",
"directly",
"from",
"the",
"database"
] | d18db4146a141795fd50689057130a6fd41ac397 | https://github.com/TheBnl/event-tickets/blob/d18db4146a141795fd50689057130a6fd41ac397/code/tasks/MigrateAttendeeFieldsTask.php#L69-L97 | train |
byrokrat/autogiro | src/Visitor/VisitorContainer.php | VisitorContainer.visitBefore | public function visitBefore(Node $node): void
{
parent::visitBefore($node);
foreach ($this->visitors as $visitor) {
$visitor->visitBefore($node);
}
} | php | public function visitBefore(Node $node): void
{
parent::visitBefore($node);
foreach ($this->visitors as $visitor) {
$visitor->visitBefore($node);
}
} | [
"public",
"function",
"visitBefore",
"(",
"Node",
"$",
"node",
")",
":",
"void",
"{",
"parent",
"::",
"visitBefore",
"(",
"$",
"node",
")",
";",
"foreach",
"(",
"$",
"this",
"->",
"visitors",
"as",
"$",
"visitor",
")",
"{",
"$",
"visitor",
"->",
"vis... | Delegate visit before to registered visitors | [
"Delegate",
"visit",
"before",
"to",
"registered",
"visitors"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Visitor/VisitorContainer.php#L61-L68 | train |
byrokrat/autogiro | src/Visitor/VisitorContainer.php | VisitorContainer.visitAfter | public function visitAfter(Node $node): void
{
foreach ($this->visitors as $visitor) {
$visitor->visitAfter($node);
}
parent::visitAfter($node);
} | php | public function visitAfter(Node $node): void
{
foreach ($this->visitors as $visitor) {
$visitor->visitAfter($node);
}
parent::visitAfter($node);
} | [
"public",
"function",
"visitAfter",
"(",
"Node",
"$",
"node",
")",
":",
"void",
"{",
"foreach",
"(",
"$",
"this",
"->",
"visitors",
"as",
"$",
"visitor",
")",
"{",
"$",
"visitor",
"->",
"visitAfter",
"(",
"$",
"node",
")",
";",
"}",
"parent",
"::",
... | Delegate visit after to registered visitors | [
"Delegate",
"visit",
"after",
"to",
"registered",
"visitors"
] | 7035467af18e991c0c130d83294b0779aa3e1583 | https://github.com/byrokrat/autogiro/blob/7035467af18e991c0c130d83294b0779aa3e1583/src/Visitor/VisitorContainer.php#L73-L80 | train |
BenGorUser/UserBundle | src/BenGorUser/UserBundle/BenGorUserBundle.php | BenGorUserBundle.buildLoadableBundles | protected function buildLoadableBundles(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
foreach ($bundles as $bundle) {
$reflectionClass = new \ReflectionClass($bundle);
if ($reflectionClass->implementsInterface(LoadableBundle::class)) {
(new $bundle())->load($container);
}
}
} | php | protected function buildLoadableBundles(ContainerBuilder $container)
{
$bundles = $container->getParameter('kernel.bundles');
foreach ($bundles as $bundle) {
$reflectionClass = new \ReflectionClass($bundle);
if ($reflectionClass->implementsInterface(LoadableBundle::class)) {
(new $bundle())->load($container);
}
}
} | [
"protected",
"function",
"buildLoadableBundles",
"(",
"ContainerBuilder",
"$",
"container",
")",
"{",
"$",
"bundles",
"=",
"$",
"container",
"->",
"getParameter",
"(",
"'kernel.bundles'",
")",
";",
"foreach",
"(",
"$",
"bundles",
"as",
"$",
"bundle",
")",
"{",... | Executes the load method of LoadableBundle instances.
@param ContainerBuilder $container The container builder | [
"Executes",
"the",
"load",
"method",
"of",
"LoadableBundle",
"instances",
"."
] | a6d0173496c269a6c80e1319d42eaed4b3bbbd4a | https://github.com/BenGorUser/UserBundle/blob/a6d0173496c269a6c80e1319d42eaed4b3bbbd4a/src/BenGorUser/UserBundle/BenGorUserBundle.php#L59-L68 | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.