repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_documentation_string
stringlengths
1
47.2k
func_code_url
stringlengths
85
339
valu-digital/valuso
src/ValuSo/Queue/Job/ServiceJob.php
ServiceJob.getCommand
public function getCommand() { $payload = $this->getContent(); $command = new Command( $payload['service'], $payload['operation'], $payload['params'], $payload['context']); $payloadIdentity = $payload['identity']; $identity = null; if (isset($payloadIdentity['username'])) { $identity = $this->resolveIdentity( $payloadIdentity['username'], $payloadIdentity['account']); } else if($payloadIdentity) { $identity = $this->prepareIdentity($payloadIdentity); } if ($identity) { $command->setIdentity($identity); } $command->setJob($this); return $command; }
php
public function getCommand() { $payload = $this->getContent(); $command = new Command( $payload['service'], $payload['operation'], $payload['params'], $payload['context']); $payloadIdentity = $payload['identity']; $identity = null; if (isset($payloadIdentity['username'])) { $identity = $this->resolveIdentity( $payloadIdentity['username'], $payloadIdentity['account']); } else if($payloadIdentity) { $identity = $this->prepareIdentity($payloadIdentity); } if ($identity) { $command->setIdentity($identity); } $command->setJob($this); return $command; }
Retrieve command @return CommandInterface
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L67-L95
valu-digital/valuso
src/ValuSo/Queue/Job/ServiceJob.php
ServiceJob.getServiceBroker
public function getServiceBroker() { if (!$this->serviceBroker && $this->serviceLocator) { $this->setServiceBroker($this->serviceLocator->get('ServiceBroker')); } if (!$this->serviceBroker instanceof ServiceBroker) { throw new RuntimeException( 'Unable to execute Job; Job is not correctly initialized (ServiceBroker is not available)'); } return $this->serviceBroker; }
php
public function getServiceBroker() { if (!$this->serviceBroker && $this->serviceLocator) { $this->setServiceBroker($this->serviceLocator->get('ServiceBroker')); } if (!$this->serviceBroker instanceof ServiceBroker) { throw new RuntimeException( 'Unable to execute Job; Job is not correctly initialized (ServiceBroker is not available)'); } return $this->serviceBroker; }
Retrieve service broker instance @throws RuntimeException @return ServiceBroker
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L113-L125
valu-digital/valuso
src/ValuSo/Queue/Job/ServiceJob.php
ServiceJob.resolveIdentity
protected function resolveIdentity($username, $accountId) { $identitySeed = $this->getServiceBroker() ->service('User') ->resolveIdentity($username); $accountIds = isset($identitySeed['accountIds']) ? $identitySeed['accountIds'] : []; if (in_array($accountId, $accountIds)) { $identitySeed['account'] = $accountId; $identitySeed['accountId'] = $accountId; } if ($identitySeed) { return $this->prepareIdentity($identitySeed); } else { return false; } }
php
protected function resolveIdentity($username, $accountId) { $identitySeed = $this->getServiceBroker() ->service('User') ->resolveIdentity($username); $accountIds = isset($identitySeed['accountIds']) ? $identitySeed['accountIds'] : []; if (in_array($accountId, $accountIds)) { $identitySeed['account'] = $accountId; $identitySeed['accountId'] = $accountId; } if ($identitySeed) { return $this->prepareIdentity($identitySeed); } else { return false; } }
Resolve identity based on username @param string $username @param string $accountId @return boolean
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L154-L172
valu-digital/valuso
src/ValuSo/Queue/Job/ServiceJob.php
ServiceJob.prepareIdentity
protected function prepareIdentity($identitySeed) { $this->getServiceBroker() ->service('Identity') ->setIdentity($identitySeed); $identity = $this->getServiceBroker() ->service('Identity') ->getIdentity(); $this->getServiceBroker() ->setDefaultIdentity($identity); return $identity; }
php
protected function prepareIdentity($identitySeed) { $this->getServiceBroker() ->service('Identity') ->setIdentity($identitySeed); $identity = $this->getServiceBroker() ->service('Identity') ->getIdentity(); $this->getServiceBroker() ->setDefaultIdentity($identity); return $identity; }
Build new identity from identity seed @param array $identitySeed
https://github.com/valu-digital/valuso/blob/c96bed0f6bd21551822334fe6cfe913a7436dd17/src/ValuSo/Queue/Job/ServiceJob.php#L179-L193
daijulong/sms
src/Supports/SmsResult.php
SmsResult.pack
private function pack() { return [ 'status' => $this->getStatusText(), 'message' => $this->getMessage(), 'agent' => $this->getAgent(), 'content' => $this->getContent(), 'params' => $this->getParams(), 'receipt_id' => $this->getReceiptId(), 'receipt_data' => $this->getReceiptData(), ]; }
php
private function pack() { return [ 'status' => $this->getStatusText(), 'message' => $this->getMessage(), 'agent' => $this->getAgent(), 'content' => $this->getContent(), 'params' => $this->getParams(), 'receipt_id' => $this->getReceiptId(), 'receipt_data' => $this->getReceiptData(), ]; }
打包数据 @return array
https://github.com/daijulong/sms/blob/3a632f332e3674de156cfc03ae334ee50248ba04/src/Supports/SmsResult.php#L209-L220
zbox/UnifiedPush
src/Zbox/UnifiedPush/NotificationService/NotificationServices.php
NotificationServices.validateServiceName
public static function validateServiceName($serviceName) { if (!in_array($serviceName, self::getAvailableServices())) { throw new DomainException(sprintf("Notification service '%s' is not supported.", $serviceName)); } return $serviceName; }
php
public static function validateServiceName($serviceName) { if (!in_array($serviceName, self::getAvailableServices())) { throw new DomainException(sprintf("Notification service '%s' is not supported.", $serviceName)); } return $serviceName; }
Checks if notification service is supported @param string $serviceName @return string @throws DomainException
https://github.com/zbox/UnifiedPush/blob/47da2d0577b18ac709cd947c68541014001e1866/src/Zbox/UnifiedPush/NotificationService/NotificationServices.php#L50-L56
bruno-barros/w.eloquent-framework
src/weloquent/Providers/EloquentBootstrapServiceProvider.php
EloquentBootstrapServiceProvider.register
public function register() { $params = array( 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'prefix' => $GLOBALS['table_prefix'] ); if(class_exists('Corcel\Database')) { Database::connect($params); } }
php
public function register() { $params = array( 'database' => DB_NAME, 'username' => DB_USER, 'password' => DB_PASSWORD, 'prefix' => $GLOBALS['table_prefix'] ); if(class_exists('Corcel\Database')) { Database::connect($params); } }
Register the service provider. @return void
https://github.com/bruno-barros/w.eloquent-framework/blob/d252dcb1ba1b6b1cecf67877d7d6d3ba57ebedbd/src/weloquent/Providers/EloquentBootstrapServiceProvider.php#L19-L33
denkfabrik-neueMedien/silverstripe-siteinfo
src/extension/SiteInfo.php
SiteInfo.updateCMSFields
public function updateCMSFields(FieldList $f) { // $mainTabTitle = "Root." . _t('SiteInfo.MODULETABTITLE', 'Siteinfo'); $miscTabTitle = $mainTabTitle . "." . _t('SiteInfo.MISCTABTITLE', 'Misc'); $privacyTabTitle = $mainTabTitle . "." . _t("SiteInfo.PRIVACY_TAB_TITLE", "Privacy"); $addressTabTitle = $mainTabTitle . "." . _t('SiteInfo.ADDRESSTABTITLE', 'Address'); $contactTabTitle = $mainTabTitle . "." . _t('SiteInfo.CONTACTTABTITLE', 'Contact'); $websiteTabTitle = $mainTabTitle . "." . _t('SiteInfo.WEBSITETABTITLE', 'Website'); $socialMediaTabTitle = $mainTabTitle . "." . _t('SiteInfo.SOCIALMEDIATABTITLE', 'Social Media'); $bankTabTitle = $mainTabTitle . "." . _t("BankAccount.PLURAL_NAME","Bank Accounts"); // $f->addFieldToTab($miscTabTitle, new Tab(_t('SiteInfo.MISCTABTITLE', 'Misc'))); $f->addFieldToTab($addressTabTitle, new Tab( _t('SiteInfo.ADDRESSTABTITLE', 'Address'))); $f->addFieldToTab($contactTabTitle, new Tab(_t('SiteInfo.CONTACTTABTITLE', 'Contact'))); $f->addFieldToTab($websiteTabTitle, new Tab(_t('SiteInfo.WEBSITETABTITLE', 'Website'))); $f->addFieldToTab($socialMediaTabTitle, new Tab(_t('SiteInfo.SOCIALMEDIATABTITLE', 'Social Media'))); $f->addFieldToTab($bankTabTitle, new Tab(_t("BankAccount.PLURAL_NAME","Bank Accounts"))); $f->addFieldToTab($privacyTabTitle, new Tab(_t("SiteInfo.PRIVACY_TAB_TITLE", "Privacy"))); // persons data grid $bankAccountsField = new GridField( "BankAccounts", _t("BankAccount.PLURAL_NAME","Bank Accounts"), $this->owner->BankAccounts(), GridFieldConfig_RecordEditor::create() ); $bankAccountsConfig = $bankAccountsField->getConfig(); $dataColumns = $bankAccountsConfig->getComponentByType(GridFieldDataColumns::class); // $dataColumns->setDisplayFields([ "BankName" => _t("SiteInfo.BANK_ACCOUNT_BANK_NAME","Bank Name"), "IBAN" => _t("SiteInfo.BANK_ACCOUNT_IBAN","IBAN"), "BIC" => _t("SiteInfo.BANK_ACCOUNT_BIC","BIC") ]); // $f->addFieldsToTab($miscTabTitle, [ new DropdownField("Type", _t("SiteInfo.TYPE", "Type"), $this->_typesNice()), new TextField("Company1", _t('SiteInfo.COMPANY1', 'Company 1' )), new TextField("Company2", _t('SiteInfo.COMPANY2', 'Company 2' )), new TextField("Firstname", _t('SiteInfo.FIRSTNAME', 'Firstname')), new TextField("Surname", _t('SiteInfo.SURNAME', 'Surname')), new TextField("Vatnumber", _t('SiteInfo.VATNUMBER', 'Vat Number')), new TextField("CommercialRegister", _t('SiteInfo.COMMERCIALREGISTER', 'Commercial Register')), new UploadField("Logo", _t('SiteInfo.LOGO', 'Logo')), new UploadField("LogoAlt", _t('SiteInfo.LOGO_ALT', 'Logo Alt')), new UploadField("GenericImage", _t('SiteInfo.GENERICIMAGE', 'Generic Image')), new HTMLEditorField("OpeningTimes", _t('SiteInfo.OPENINGTIMES', 'Opening Hours')), new HTMLEditorField("Description1", _t('SiteInfo.DESCRIPTION1', 'Description 1')), new HTMLEditorField("Description2", _t('SiteInfo.DESCRIPTION2', 'Description 2')) ]); $f->addFieldsToTab($addressTabTitle, [ new TextField("Street", _t('SiteInfo.STREET', 'Street')), new TextField("StreetNumber", _t('SiteInfo.STREETNUMBER', 'Steetnumber')), new TextField("POBox", _t('SiteInfo.POBOX', 'PO Box')), new TextField("Zip", _t('SiteInfo.ZIP', 'Zip')), new TextField("City", _t('SiteInfo.CITY', 'City')), new CountryDropdownField("Country", _t('SiteInfo.COUNTRY', 'Country'), ["Deutschland" => "Deutschland"]), new TextField("Latitude", _t('SiteInfo.LATITUDE', 'Latitude')), new TextField("Longitude", _t('SiteInfo.LONGITUDE', 'Longitude')) ]); $f->addFieldsToTab($contactTabTitle, [ new TextField("Phone", _t('SiteInfo.PHONE', 'Phone')), new TextField("Fax", _t('SiteInfo.FAX', 'Fax')), new TextField("Mobile", _t('SiteInfo.MOBILE', 'Mobile')), new TextField("Email", _t('SiteInfo.EMAIL', 'E-Mail')), new TextField("Website", _t('SiteInfo.WEBSITE', 'Website')) ]); $f->addFieldsToTab($websiteTabTitle, [ new TreeDropdownField("ContactPage", _t('SiteInfo.CONTACT_PAGE', 'Contact Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("ImprintPage", _t('SiteInfo.IMPRINT', 'Imprint Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("PrivacyPage", _t('SiteInfo.PRIVACY', 'Privacy Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("TermsPage", _t('SiteInfo.TERMS', 'Terms Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("SitemapPage", _t('SiteInfo.SITEMAP', 'Sitemap Page'), "SilverStripe\CMS\Model\SiteTree") ]); $f->addFieldsToTab($socialMediaTabTitle, [ new TextField("FacebookLink", _t('SiteInfo.FACEBOOKLINK', 'Facebook Link')), new TextField("TwitterLink", _t('SiteInfo.TWITTERLINK', 'Twitter Link')), new TextField("GooglePlusLink", _t('SiteInfo.GOOGLEPLUSLINK', 'Google+ Link')), new TextField("PinterestLink", _t('SiteInfo.PINTERESTLINK', 'Pinterest Link')), new TextField("YoutubeLink", _t('SiteInfo.YOUTUBELINK', 'Youtube Link')), new TextField("VimeoLink", _t('SiteInfo.VIMEOLINK', 'Vimeo Link')), new TextField("XINGLink", _t('SiteInfo.XINGLINK', 'XING Link')), new TextField("LinkedInLink", _t('SiteInfo.LINKEDINLINK', 'LinkedIn Link')), new TextField("TumblerLink", _t('SiteInfo.TUMBLERLINK', 'Tumbler Link')), new TextField("InstagramLink", _t('SiteInfo.INSTAGRAMLINK', 'Instagram Link')), new TextField("FivehundredPXLink", _t('SiteInfo.FIVEHUNDREDPXLINK', '500px Link')) ]); $f->addFieldsToTab($bankTabTitle, [ $bankAccountsField ]); $f->addFieldsToTab($privacyTabTitle, [ new HTMLEditorField("FormPrivacyHint", _t('SiteInfo.FORM_PRIVACY_HINT', 'Privacy Hint for your Forms')), new HTMLEditorField("CheckboxPrivacyLabel", _t('Siteinfo.CHECKBOX_PRIVACY_LABEL', 'Privacy Checkbox Label')) ]); }
php
public function updateCMSFields(FieldList $f) { // $mainTabTitle = "Root." . _t('SiteInfo.MODULETABTITLE', 'Siteinfo'); $miscTabTitle = $mainTabTitle . "." . _t('SiteInfo.MISCTABTITLE', 'Misc'); $privacyTabTitle = $mainTabTitle . "." . _t("SiteInfo.PRIVACY_TAB_TITLE", "Privacy"); $addressTabTitle = $mainTabTitle . "." . _t('SiteInfo.ADDRESSTABTITLE', 'Address'); $contactTabTitle = $mainTabTitle . "." . _t('SiteInfo.CONTACTTABTITLE', 'Contact'); $websiteTabTitle = $mainTabTitle . "." . _t('SiteInfo.WEBSITETABTITLE', 'Website'); $socialMediaTabTitle = $mainTabTitle . "." . _t('SiteInfo.SOCIALMEDIATABTITLE', 'Social Media'); $bankTabTitle = $mainTabTitle . "." . _t("BankAccount.PLURAL_NAME","Bank Accounts"); // $f->addFieldToTab($miscTabTitle, new Tab(_t('SiteInfo.MISCTABTITLE', 'Misc'))); $f->addFieldToTab($addressTabTitle, new Tab( _t('SiteInfo.ADDRESSTABTITLE', 'Address'))); $f->addFieldToTab($contactTabTitle, new Tab(_t('SiteInfo.CONTACTTABTITLE', 'Contact'))); $f->addFieldToTab($websiteTabTitle, new Tab(_t('SiteInfo.WEBSITETABTITLE', 'Website'))); $f->addFieldToTab($socialMediaTabTitle, new Tab(_t('SiteInfo.SOCIALMEDIATABTITLE', 'Social Media'))); $f->addFieldToTab($bankTabTitle, new Tab(_t("BankAccount.PLURAL_NAME","Bank Accounts"))); $f->addFieldToTab($privacyTabTitle, new Tab(_t("SiteInfo.PRIVACY_TAB_TITLE", "Privacy"))); // persons data grid $bankAccountsField = new GridField( "BankAccounts", _t("BankAccount.PLURAL_NAME","Bank Accounts"), $this->owner->BankAccounts(), GridFieldConfig_RecordEditor::create() ); $bankAccountsConfig = $bankAccountsField->getConfig(); $dataColumns = $bankAccountsConfig->getComponentByType(GridFieldDataColumns::class); // $dataColumns->setDisplayFields([ "BankName" => _t("SiteInfo.BANK_ACCOUNT_BANK_NAME","Bank Name"), "IBAN" => _t("SiteInfo.BANK_ACCOUNT_IBAN","IBAN"), "BIC" => _t("SiteInfo.BANK_ACCOUNT_BIC","BIC") ]); // $f->addFieldsToTab($miscTabTitle, [ new DropdownField("Type", _t("SiteInfo.TYPE", "Type"), $this->_typesNice()), new TextField("Company1", _t('SiteInfo.COMPANY1', 'Company 1' )), new TextField("Company2", _t('SiteInfo.COMPANY2', 'Company 2' )), new TextField("Firstname", _t('SiteInfo.FIRSTNAME', 'Firstname')), new TextField("Surname", _t('SiteInfo.SURNAME', 'Surname')), new TextField("Vatnumber", _t('SiteInfo.VATNUMBER', 'Vat Number')), new TextField("CommercialRegister", _t('SiteInfo.COMMERCIALREGISTER', 'Commercial Register')), new UploadField("Logo", _t('SiteInfo.LOGO', 'Logo')), new UploadField("LogoAlt", _t('SiteInfo.LOGO_ALT', 'Logo Alt')), new UploadField("GenericImage", _t('SiteInfo.GENERICIMAGE', 'Generic Image')), new HTMLEditorField("OpeningTimes", _t('SiteInfo.OPENINGTIMES', 'Opening Hours')), new HTMLEditorField("Description1", _t('SiteInfo.DESCRIPTION1', 'Description 1')), new HTMLEditorField("Description2", _t('SiteInfo.DESCRIPTION2', 'Description 2')) ]); $f->addFieldsToTab($addressTabTitle, [ new TextField("Street", _t('SiteInfo.STREET', 'Street')), new TextField("StreetNumber", _t('SiteInfo.STREETNUMBER', 'Steetnumber')), new TextField("POBox", _t('SiteInfo.POBOX', 'PO Box')), new TextField("Zip", _t('SiteInfo.ZIP', 'Zip')), new TextField("City", _t('SiteInfo.CITY', 'City')), new CountryDropdownField("Country", _t('SiteInfo.COUNTRY', 'Country'), ["Deutschland" => "Deutschland"]), new TextField("Latitude", _t('SiteInfo.LATITUDE', 'Latitude')), new TextField("Longitude", _t('SiteInfo.LONGITUDE', 'Longitude')) ]); $f->addFieldsToTab($contactTabTitle, [ new TextField("Phone", _t('SiteInfo.PHONE', 'Phone')), new TextField("Fax", _t('SiteInfo.FAX', 'Fax')), new TextField("Mobile", _t('SiteInfo.MOBILE', 'Mobile')), new TextField("Email", _t('SiteInfo.EMAIL', 'E-Mail')), new TextField("Website", _t('SiteInfo.WEBSITE', 'Website')) ]); $f->addFieldsToTab($websiteTabTitle, [ new TreeDropdownField("ContactPage", _t('SiteInfo.CONTACT_PAGE', 'Contact Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("ImprintPage", _t('SiteInfo.IMPRINT', 'Imprint Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("PrivacyPage", _t('SiteInfo.PRIVACY', 'Privacy Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("TermsPage", _t('SiteInfo.TERMS', 'Terms Page'), "SilverStripe\CMS\Model\SiteTree"), new TreeDropdownField("SitemapPage", _t('SiteInfo.SITEMAP', 'Sitemap Page'), "SilverStripe\CMS\Model\SiteTree") ]); $f->addFieldsToTab($socialMediaTabTitle, [ new TextField("FacebookLink", _t('SiteInfo.FACEBOOKLINK', 'Facebook Link')), new TextField("TwitterLink", _t('SiteInfo.TWITTERLINK', 'Twitter Link')), new TextField("GooglePlusLink", _t('SiteInfo.GOOGLEPLUSLINK', 'Google+ Link')), new TextField("PinterestLink", _t('SiteInfo.PINTERESTLINK', 'Pinterest Link')), new TextField("YoutubeLink", _t('SiteInfo.YOUTUBELINK', 'Youtube Link')), new TextField("VimeoLink", _t('SiteInfo.VIMEOLINK', 'Vimeo Link')), new TextField("XINGLink", _t('SiteInfo.XINGLINK', 'XING Link')), new TextField("LinkedInLink", _t('SiteInfo.LINKEDINLINK', 'LinkedIn Link')), new TextField("TumblerLink", _t('SiteInfo.TUMBLERLINK', 'Tumbler Link')), new TextField("InstagramLink", _t('SiteInfo.INSTAGRAMLINK', 'Instagram Link')), new TextField("FivehundredPXLink", _t('SiteInfo.FIVEHUNDREDPXLINK', '500px Link')) ]); $f->addFieldsToTab($bankTabTitle, [ $bankAccountsField ]); $f->addFieldsToTab($privacyTabTitle, [ new HTMLEditorField("FormPrivacyHint", _t('SiteInfo.FORM_PRIVACY_HINT', 'Privacy Hint for your Forms')), new HTMLEditorField("CheckboxPrivacyLabel", _t('Siteinfo.CHECKBOX_PRIVACY_LABEL', 'Privacy Checkbox Label')) ]); }
Update the base fields with our added ones @param $fields FieldList The list of existing fields
https://github.com/denkfabrik-neueMedien/silverstripe-siteinfo/blob/cd59ea0cf5c13678ff8efd93028d35c726670c25/src/extension/SiteInfo.php#L106-L203
denkfabrik-neueMedien/silverstripe-siteinfo
src/extension/SiteInfo.php
SiteInfo._typesNice
protected function _typesNice() { $enumValues = singleton("SilverStripe\SiteConfig\SiteConfig")->dbObject("Type")->enumValues(); $values = array(); foreach($enumValues as $enumValue) { $values[$enumValue] = _t("SiteInfo.TYPE" . strtoupper($enumValue), $enumValue); } return $values; }
php
protected function _typesNice() { $enumValues = singleton("SilverStripe\SiteConfig\SiteConfig")->dbObject("Type")->enumValues(); $values = array(); foreach($enumValues as $enumValue) { $values[$enumValue] = _t("SiteInfo.TYPE" . strtoupper($enumValue), $enumValue); } return $values; }
Add translated labels for the dropdown field @return array
https://github.com/denkfabrik-neueMedien/silverstripe-siteinfo/blob/cd59ea0cf5c13678ff8efd93028d35c726670c25/src/extension/SiteInfo.php#L214-L224
phPoirot/Stream
Streamable/SLimitSegment.php
SLimitSegment.read
function read($inByte = null) { if ($this->getSegmentLimit() == -1) return $this->_t__wrap_stream->read($inByte); $inByte = ($inByte === null) ? ( ($this->getBuffer() === null) ? $this->getSize() : $this->getBuffer() ) : $inByte; $remain = $this->getSegmentLimit() - $this->getCurrOffset(); if ($remain > 0) return $this->_t__wrap_stream->read(min($remain, $inByte)); return ''; }
php
function read($inByte = null) { if ($this->getSegmentLimit() == -1) return $this->_t__wrap_stream->read($inByte); $inByte = ($inByte === null) ? ( ($this->getBuffer() === null) ? $this->getSize() : $this->getBuffer() ) : $inByte; $remain = $this->getSegmentLimit() - $this->getCurrOffset(); if ($remain > 0) return $this->_t__wrap_stream->read(min($remain, $inByte)); return ''; }
Read Data From Stream - if $inByte argument not set, read entire stream @param int $inByte Read Data in byte @throws \Exception Error On Read Data @return string
https://github.com/phPoirot/Stream/blob/db448ee0528c2a5b07c594b8a30e2543fbc15f57/Streamable/SLimitSegment.php#L71-L88
phPoirot/Stream
Streamable/SLimitSegment.php
SLimitSegment.readLine
function readLine($ending = "\n", $inByte = null) { if ($this->getSegmentLimit() == -1) return $this->_t__wrap_stream->readLine($ending, $inByte); $inByte = ($inByte === null) ? ( ($this->getBuffer() === null) ? $this->getSize() : $this->getBuffer() ) : $inByte; $remain = $this->getSegmentLimit() - $this->getCurrOffset(); if ($remain > 0) return $this->_t__wrap_stream->readLine($ending, min($remain, $inByte)); return null; }
php
function readLine($ending = "\n", $inByte = null) { if ($this->getSegmentLimit() == -1) return $this->_t__wrap_stream->readLine($ending, $inByte); $inByte = ($inByte === null) ? ( ($this->getBuffer() === null) ? $this->getSize() : $this->getBuffer() ) : $inByte; $remain = $this->getSegmentLimit() - $this->getCurrOffset(); if ($remain > 0) return $this->_t__wrap_stream->readLine($ending, min($remain, $inByte)); return null; }
Gets line from stream resource up to a given delimiter Reading ends when length bytes have been read, when the string specified by ending is found (which is not included in the return value), or on EOF (whichever comes first) ! does not return the ending delimiter itself @param string $ending @param int $inByte @return string|null
https://github.com/phPoirot/Stream/blob/db448ee0528c2a5b07c594b8a30e2543fbc15f57/Streamable/SLimitSegment.php#L105-L122
phPoirot/Stream
Streamable/SLimitSegment.php
SLimitSegment.isEOF
function isEOF() { if ($this->_t__wrap_stream->isEOF()) ## wrap stream is on the end return true; if ($this->getSegmentLimit() == -1) return false; return ($this->_t__wrap_stream->getCurrOffset() >= $this->getSegmentOffset() + $this->getSegmentLimit()); }
php
function isEOF() { if ($this->_t__wrap_stream->isEOF()) ## wrap stream is on the end return true; if ($this->getSegmentLimit() == -1) return false; return ($this->_t__wrap_stream->getCurrOffset() >= $this->getSegmentOffset() + $this->getSegmentLimit()); }
Is Stream Positioned At The End? @return boolean
https://github.com/phPoirot/Stream/blob/db448ee0528c2a5b07c594b8a30e2543fbc15f57/Streamable/SLimitSegment.php#L209-L219
luoxiaojun1992/lb_framework
components/db/mysql/ActiveRecord.php
ActiveRecord.incrementByPk
public function incrementByPk($primary_key, $keys, $step = 1) { if ($this->is_single) { return $this->incrementOrDecrementByPk($primary_key, $keys, $step); } return false; }
php
public function incrementByPk($primary_key, $keys, $step = 1) { if ($this->is_single) { return $this->incrementOrDecrementByPk($primary_key, $keys, $step); } return false; }
Increase key or keys by primary key @param $primary_key @param $keys @param int $step @return bool
https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/db/mysql/ActiveRecord.php#L501-L507
luoxiaojun1992/lb_framework
components/db/mysql/ActiveRecord.php
ActiveRecord.decrementByPk
public function decrementByPk($primary_key, $keys, $step = 1) { if ($this->is_single) { return $this->incrementOrDecrementByPk($primary_key, $keys, $step, self::MINUS_NOTIFICATION); } return false; }
php
public function decrementByPk($primary_key, $keys, $step = 1) { if ($this->is_single) { return $this->incrementOrDecrementByPk($primary_key, $keys, $step, self::MINUS_NOTIFICATION); } return false; }
Decrease key or keys by primary key @param $primary_key @param $keys @param int $step @return bool
https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/db/mysql/ActiveRecord.php#L517-L523
luoxiaojun1992/lb_framework
components/db/mysql/ActiveRecord.php
ActiveRecord.incrementOrDecrementByPk
public function incrementOrDecrementByPk($primary_key, $keys, $steps = 1, $op = self::PLUS_NOTIFICATION) { if ($this->is_single) { $values = []; if (is_array($keys)) { foreach ($keys as $k => $key) { if (is_array($steps) && isset($steps[$k])) { $values[$key] = [$op => $steps[$k]]; } else { $values[$key] = [$op => $steps]; } } } else { $values[$keys] = [$op => $steps]; } return Dao::component() ->where( [ $this->_primary_key => $primary_key, ] ) ->update(static::TABLE_NAME, $values); } return false; }
php
public function incrementOrDecrementByPk($primary_key, $keys, $steps = 1, $op = self::PLUS_NOTIFICATION) { if ($this->is_single) { $values = []; if (is_array($keys)) { foreach ($keys as $k => $key) { if (is_array($steps) && isset($steps[$k])) { $values[$key] = [$op => $steps[$k]]; } else { $values[$key] = [$op => $steps]; } } } else { $values[$keys] = [$op => $steps]; } return Dao::component() ->where( [ $this->_primary_key => $primary_key, ] ) ->update(static::TABLE_NAME, $values); } return false; }
Increase or decrease key or keys by primary key @param $primary_key @param $keys @param int $steps @param string $op @return bool
https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/components/db/mysql/ActiveRecord.php#L534-L559
nasumilu/geometry
src/Operation/AbstractLinearReferenceOpSubscriber.php
AbstractLinearReferenceOpSubscriber.locateAlong
public function locateAlong(LinearReferenceOpEvent $evt) { $geometry = $evt->getGeometry(); $this->validGeometry($geometry); $mValue = $evt['mValue']; $offset = $evt['offset']; try { $results = $this->getLocateAlong($geometry, $mValue, $offset); $evt->setResults($results, true); } catch (OperationError $error) { $evt->addError($error); } }
php
public function locateAlong(LinearReferenceOpEvent $evt) { $geometry = $evt->getGeometry(); $this->validGeometry($geometry); $mValue = $evt['mValue']; $offset = $evt['offset']; try { $results = $this->getLocateAlong($geometry, $mValue, $offset); $evt->setResults($results, true); } catch (OperationError $error) { $evt->addError($error); } }
Gets the derived geometry collection with elements that match the specified measure. @param LinearReferenceOpEvent
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractLinearReferenceOpSubscriber.php#L86-L97
nasumilu/geometry
src/Operation/AbstractLinearReferenceOpSubscriber.php
AbstractLinearReferenceOpSubscriber.locateBetween
public function locateBetween(LinearReferenceOpEvent $evt) { $geometry = $evt->getGeometry(); $this->validGeometry($geometry); $mStart = $evt['mStart']; $mEnd = $evt['mEnd']; $offset = $evt['offset']; try { $results = $this->getLocateBetween($geometry, $mStart, $mEnd, $offset); $evt->setResults($results, true); } catch (OperationError $error) { $evt->addError($error); } }
php
public function locateBetween(LinearReferenceOpEvent $evt) { $geometry = $evt->getGeometry(); $this->validGeometry($geometry); $mStart = $evt['mStart']; $mEnd = $evt['mEnd']; $offset = $evt['offset']; try { $results = $this->getLocateBetween($geometry, $mStart, $mEnd, $offset); $evt->setResults($results, true); } catch (OperationError $error) { $evt->addError($error); } }
Gets the derived geometry collection with elements that match the specified range of measured inclusively. @param LinearReferenceOpEvent
https://github.com/nasumilu/geometry/blob/000fafe3e61f1d0682952ad236b7486dded65eae/src/Operation/AbstractLinearReferenceOpSubscriber.php#L105-L117
brainexe/core
src/DependencyInjection/CompilerPass/Log.php
Log.process
public function process(ContainerBuilder $container) { $definition = $container->getDefinition('logger'); $logLevels = [ 'error.log' => Logger::ERROR, 'info.log' => Logger::INFO, ]; if ($container->getParameter('debug')) { $logLevels['debug.log'] = Logger::DEBUG; } $baseDir = $container->getParameter('logger.dir'); foreach ($logLevels as $file => $level) { $definition->addMethodCall('pushHandler', [ new Definition(StreamHandler::class, [ $baseDir . $file, $level ]) ]); } }
php
public function process(ContainerBuilder $container) { $definition = $container->getDefinition('logger'); $logLevels = [ 'error.log' => Logger::ERROR, 'info.log' => Logger::INFO, ]; if ($container->getParameter('debug')) { $logLevels['debug.log'] = Logger::DEBUG; } $baseDir = $container->getParameter('logger.dir'); foreach ($logLevels as $file => $level) { $definition->addMethodCall('pushHandler', [ new Definition(StreamHandler::class, [ $baseDir . $file, $level ]) ]); } }
{@inheritdoc}
https://github.com/brainexe/core/blob/9ef69c6f045306abd20e271572386970db9b3e54/src/DependencyInjection/CompilerPass/Log.php#L20-L42
deweller/php-cliopts
src/CLIOpts/CLIOpts.php
CLIOpts.run
public static function run($arguments_spec_text, $do_validation=true, $do_help=true) { $cli_opts = self::createFromTextSpec($arguments_spec_text); return $cli_opts->runWithValidationAndHelp($do_validation, $do_help); }
php
public static function run($arguments_spec_text, $do_validation=true, $do_help=true) { $cli_opts = self::createFromTextSpec($arguments_spec_text); return $cli_opts->runWithValidationAndHelp($do_validation, $do_help); }
parse the argv data and build values This is an all-in-one method to check validation and show help if a help flag is specified @param string $arguments_spec_text a text specification of expected arguments and options @param bool $do_validation Include validation checking @param bool $do_help Include checking for --help flag @return ArgumentValues An array-like object that contains switches and data. This method will exit on validation failure or after showing help.
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/CLIOpts.php#L50-L53
deweller/php-cliopts
src/CLIOpts/CLIOpts.php
CLIOpts.runWithValidationAndHelp
public function runWithValidationAndHelp($do_validation=true, $do_help=true) { // get the values $values = $this->getOptsValues(); // check for the help switch before checking for valid values if ($do_help AND isset($values['help'])) { $this->showHelpTextAndExit(); // *** script exited *** // } // check validation. Then generate help and exit if not valid. if ($do_validation) { $validator = $values->getValidator(); if (!$validator->isValid()) { $indent_text = ' '; print ConsoleFormat::applyformatToText( 'bold','white','red_bg', 'The following errors were found:' )."\n". ConsoleFormat::applyformatToText( 'red','bold', $indent_text.implode("\n".$indent_text, $validator->getErrors()) )."\n\n"; $this->showHelpTextAndExit(); // *** script exited *** // } } return $values; }
php
public function runWithValidationAndHelp($do_validation=true, $do_help=true) { // get the values $values = $this->getOptsValues(); // check for the help switch before checking for valid values if ($do_help AND isset($values['help'])) { $this->showHelpTextAndExit(); // *** script exited *** // } // check validation. Then generate help and exit if not valid. if ($do_validation) { $validator = $values->getValidator(); if (!$validator->isValid()) { $indent_text = ' '; print ConsoleFormat::applyformatToText( 'bold','white','red_bg', 'The following errors were found:' )."\n". ConsoleFormat::applyformatToText( 'red','bold', $indent_text.implode("\n".$indent_text, $validator->getErrors()) )."\n\n"; $this->showHelpTextAndExit(); // *** script exited *** // } } return $values; }
parse the argv data and build values This is an all-in-one method to check validation and show help if a help flag is specified. @param bool $do_validation Include validation checking @param bool $do_help Include checking for --help flag @return ArgumentValues An array-like object that contains switches and data. This method will exit on validation failure or after showing help.
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/CLIOpts.php#L94-L129
deweller/php-cliopts
src/CLIOpts/CLIOpts.php
CLIOpts.getOptsValues
public function getOptsValues($argv=null) { $parsed_args = ArgumentsParser::parseArgvWithSpec($this->resolveArgv($argv), $this->arguments_spec); return new ArgumentValues($this->arguments_spec, $parsed_args); }
php
public function getOptsValues($argv=null) { $parsed_args = ArgumentsParser::parseArgvWithSpec($this->resolveArgv($argv), $this->arguments_spec); return new ArgumentValues($this->arguments_spec, $parsed_args); }
parse the argv data and build values @param array $argv An optional array of argv values used for testing. Leave blank to use the default $_SERVER['argv'] @return ArgumentValues An array-like object that contains switches and data
https://github.com/deweller/php-cliopts/blob/1923f3a7ad24062c6279c725579ff3af15141dec/src/CLIOpts/CLIOpts.php#L139-L142
UnionOfRAD/li3_quality
qa/rules/syntax/WeakComparisonOperators.php
WeakComparisonOperators.apply
public function apply($testable, array $config = array()) { $tokens = $testable->tokens(); $message = 'Weak comparison operator {:key} used, try {:value} instead'; $filtered = $testable->findAll(array_keys($this->inspectableTokens)); foreach ($filtered as $id) { $token = $tokens[$id]; $this->addWarning(array( 'message' => String::insert($message, array( 'key' => token_name($token['id']), 'value' => $this->inspectableTokens[$token['id']], )), 'line' => $token['line'], )); } }
php
public function apply($testable, array $config = array()) { $tokens = $testable->tokens(); $message = 'Weak comparison operator {:key} used, try {:value} instead'; $filtered = $testable->findAll(array_keys($this->inspectableTokens)); foreach ($filtered as $id) { $token = $tokens[$id]; $this->addWarning(array( 'message' => String::insert($message, array( 'key' => token_name($token['id']), 'value' => $this->inspectableTokens[$token['id']], )), 'line' => $token['line'], )); } }
Will iterate over each line checking if any weak comparison operators are used within the code. @param Testable $testable The testable object @return void
https://github.com/UnionOfRAD/li3_quality/blob/acb72a43ae835e6d200bc0eba1a61aee610e36bf/qa/rules/syntax/WeakComparisonOperators.php#L32-L47
4devs/serializer
PropertyFactory.php
PropertyFactory.createNormalizeProperty
public function createNormalizeProperty(PropertyMetadataInterface $metadata, array $context = [], NormalizerInterface $normalizer = null) { $property = new NormalizeProperty($metadata, $context, $this->optionManager); $property->setNormalizer($normalizer); return $property; }
php
public function createNormalizeProperty(PropertyMetadataInterface $metadata, array $context = [], NormalizerInterface $normalizer = null) { $property = new NormalizeProperty($metadata, $context, $this->optionManager); $property->setNormalizer($normalizer); return $property; }
{@inheritdoc}
https://github.com/4devs/serializer/blob/c2a9bf81ed59dd123c9877ef3f75c1a9673b236e/PropertyFactory.php#L36-L42
4devs/serializer
PropertyFactory.php
PropertyFactory.createDenormalizeProperty
public function createDenormalizeProperty(PropertyMetadataInterface $metadata, array $context = [], DenormalizerInterface $denormalizer = null) { $property = new DenormalizeProperty($metadata, $context, $this->optionManager); $property->setDenormalizer($denormalizer); return $property; }
php
public function createDenormalizeProperty(PropertyMetadataInterface $metadata, array $context = [], DenormalizerInterface $denormalizer = null) { $property = new DenormalizeProperty($metadata, $context, $this->optionManager); $property->setDenormalizer($denormalizer); return $property; }
{@inheritdoc}
https://github.com/4devs/serializer/blob/c2a9bf81ed59dd123c9877ef3f75c1a9673b236e/PropertyFactory.php#L47-L53
4devs/serializer
DataType/CollectionType.php
CollectionType.denormalize
public function denormalize($data, array $options, array $context = []) { $result = []; if (!$options['data_class'] && !isset($context[$options['key']])) { throw new MappingException(sprintf('set "data_class" or set context with key "%s"', $options['key'])); } $dataClass = $options['data_class'] ?: $context[$options['key']]; foreach ($data as $key => $item) { $result[$key] = $this->denormalizer->denormalize($item, $dataClass, $options['format'], $context); } return $result; }
php
public function denormalize($data, array $options, array $context = []) { $result = []; if (!$options['data_class'] && !isset($context[$options['key']])) { throw new MappingException(sprintf('set "data_class" or set context with key "%s"', $options['key'])); } $dataClass = $options['data_class'] ?: $context[$options['key']]; foreach ($data as $key => $item) { $result[$key] = $this->denormalizer->denormalize($item, $dataClass, $options['format'], $context); } return $result; }
{@inheritdoc}
https://github.com/4devs/serializer/blob/c2a9bf81ed59dd123c9877ef3f75c1a9673b236e/DataType/CollectionType.php#L27-L40
4devs/serializer
DataType/CollectionType.php
CollectionType.normalize
public function normalize($data, array $options, array $context = []) { $result = []; foreach ($data as $key => $item) { $result[$key] = $this->normalizer->normalize($item, $options['format'], $context); } return $result; }
php
public function normalize($data, array $options, array $context = []) { $result = []; foreach ($data as $key => $item) { $result[$key] = $this->normalizer->normalize($item, $options['format'], $context); } return $result; }
{@inheritdoc}
https://github.com/4devs/serializer/blob/c2a9bf81ed59dd123c9877ef3f75c1a9673b236e/DataType/CollectionType.php#L45-L53
apishka/easy-extend
source/Builder.php
Builder.buildFromEvent
public function buildFromEvent(Event $event) { $this->setEvent($event); $configs = $this->getConfigFilesByComposer(); $this->addFindersByConfigs($configs); // We have to initialize composer autoload require_once 'vendor/autoload.php'; $this->build(); }
php
public function buildFromEvent(Event $event) { $this->setEvent($event); $configs = $this->getConfigFilesByComposer(); $this->addFindersByConfigs($configs); // We have to initialize composer autoload require_once 'vendor/autoload.php'; $this->build(); }
Build @param Event $event
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L48-L59
apishka/easy-extend
source/Builder.php
Builder.addFindersByConfigs
protected function addFindersByConfigs(array $configs): self { foreach ($configs as $package => $path) { $data = @include $path; if ($data && isset($data['easy-extend'])) { $config = $data['easy-extend']; if ($config) { if (isset($config['finder'])) { $finder_callbacks = $config['finder']; if (!is_array($finder_callbacks)) $finder_callbacks = array($finder_callbacks); foreach ($finder_callbacks as $callback) { $finder = new Finder(); $finder = $callback($finder); $this->addFinder($finder); } } if (isset($config['bootstrap'])) { $config['bootstrap'](); } } } } return $this; }
php
protected function addFindersByConfigs(array $configs): self { foreach ($configs as $package => $path) { $data = @include $path; if ($data && isset($data['easy-extend'])) { $config = $data['easy-extend']; if ($config) { if (isset($config['finder'])) { $finder_callbacks = $config['finder']; if (!is_array($finder_callbacks)) $finder_callbacks = array($finder_callbacks); foreach ($finder_callbacks as $callback) { $finder = new Finder(); $finder = $callback($finder); $this->addFinder($finder); } } if (isset($config['bootstrap'])) { $config['bootstrap'](); } } } } return $this; }
Add finders by configs @param array $configs @return Builder this
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L90-L127
apishka/easy-extend
source/Builder.php
Builder.build
public function build(): void { $this->requireFiles(); Broker::getInstance()->cache(); foreach (Broker::getInstance()->getData() as $info) { $class = $info['class']; $router = new $class(); $router->cache(); } }
php
public function build(): void { $this->requireFiles(); Broker::getInstance()->cache(); foreach (Broker::getInstance()->getData() as $info) { $class = $info['class']; $router = new $class(); $router->cache(); } }
Build
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L132-L145
apishka/easy-extend
source/Builder.php
Builder.requireFiles
protected function requireFiles(): self { foreach ($this->_finders as $finder) { foreach ($finder as $file) { require_once $file->getRealpath(); } } return $this; }
php
protected function requireFiles(): self { foreach ($this->_finders as $finder) { foreach ($finder as $file) { require_once $file->getRealpath(); } } return $this; }
Require files @return Builder this
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L166-L177
apishka/easy-extend
source/Builder.php
Builder.getConfigFilesByComposer
protected function getConfigFilesByComposer(): array { $this->getLogger()->write('<info>Searching for ".apishka" files</info>'); if ($this->getEvent() === null) throw new \LogicException('Event not exists'); $configs = array(); if ($this->isDependantPackage($this->getEvent()->getComposer()->getPackage())) { $path = $this->getConfigPackagePath( rtrim($this->getRootPackagePath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $this->getEvent()->getComposer()->getPackage() ); if ($path) $configs[$this->getEvent()->getComposer()->getPackage()->getName()] = $path; } $packages = $this->getEvent()->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages(); foreach ($packages as $package) { if ($this->isDependantPackage($package, false)) { $path = $this->getConfigPackagePath( $this->getEvent()->getComposer()->getInstallationManager()->getInstallPath($package), $package ); if ($path) $configs[$package->getName()] = $path; } } ksort($configs); Cacher::getInstance()->set( $this->getConfigsCacheName(), $configs ); return $configs; }
php
protected function getConfigFilesByComposer(): array { $this->getLogger()->write('<info>Searching for ".apishka" files</info>'); if ($this->getEvent() === null) throw new \LogicException('Event not exists'); $configs = array(); if ($this->isDependantPackage($this->getEvent()->getComposer()->getPackage())) { $path = $this->getConfigPackagePath( rtrim($this->getRootPackagePath(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR, $this->getEvent()->getComposer()->getPackage() ); if ($path) $configs[$this->getEvent()->getComposer()->getPackage()->getName()] = $path; } $packages = $this->getEvent()->getComposer()->getRepositoryManager()->getLocalRepository()->getPackages(); foreach ($packages as $package) { if ($this->isDependantPackage($package, false)) { $path = $this->getConfigPackagePath( $this->getEvent()->getComposer()->getInstallationManager()->getInstallPath($package), $package ); if ($path) $configs[$package->getName()] = $path; } } ksort($configs); Cacher::getInstance()->set( $this->getConfigsCacheName(), $configs ); return $configs; }
Get config files by composer @return array
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L184-L226
apishka/easy-extend
source/Builder.php
Builder.getConfigPackagePath
protected function getConfigPackagePath(string $dir, PackageInterface $package): ?string { $dir = preg_replace( '#^(' . preg_quote(getcwd() . DIRECTORY_SEPARATOR, '#') . ')#', '.' . DIRECTORY_SEPARATOR, $dir ); $path = $this->getConfigPath($dir); if (file_exists($path)) { $this->getLogger()->write( sprintf( ' - Found in <info>%s</info>', $package->getPrettyName() ) ); return $path; } return null; }
php
protected function getConfigPackagePath(string $dir, PackageInterface $package): ?string { $dir = preg_replace( '#^(' . preg_quote(getcwd() . DIRECTORY_SEPARATOR, '#') . ')#', '.' . DIRECTORY_SEPARATOR, $dir ); $path = $this->getConfigPath($dir); if (file_exists($path)) { $this->getLogger()->write( sprintf( ' - Found in <info>%s</info>', $package->getPrettyName() ) ); return $path; } return null; }
Get config package file path @param string $dir @param PackageInterface $package @return null|string
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L236-L258
apishka/easy-extend
source/Builder.php
Builder.isDependantPackage
public function isDependantPackage(PackageInterface $package, bool $dev_mode = null) { if ($package->getName() === 'apishka/easy-extend') return true; foreach ($package->getRequires() as $link) { if ($link->getTarget() === 'apishka/easy-extend') return true; } if ($dev_mode) { foreach ($package->getDevRequires() as $link) { if ($link->getTarget() === 'apishka/easy-extend') return true; } } return false; }
php
public function isDependantPackage(PackageInterface $package, bool $dev_mode = null) { if ($package->getName() === 'apishka/easy-extend') return true; foreach ($package->getRequires() as $link) { if ($link->getTarget() === 'apishka/easy-extend') return true; } if ($dev_mode) { foreach ($package->getDevRequires() as $link) { if ($link->getTarget() === 'apishka/easy-extend') return true; } } return false; }
Returns true if the supplied package requires the Composer NPM bridge. @param PackageInterface $package the package to inspect @param bool|null $dev_mode true if the dev dependencies should also be inspected @return bool true if the package requires the bridge
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L290-L311
apishka/easy-extend
source/Builder.php
Builder.getLogger
public function getLogger(): IOInterface { if ($this->_logger === null) { if ($this->getEvent() !== null) { $this->_logger = $this->getEvent()->getIO(); } else { $this->_logger = new \Composer\IO\NullIO(); } } return $this->_logger; }
php
public function getLogger(): IOInterface { if ($this->_logger === null) { if ($this->getEvent() !== null) { $this->_logger = $this->getEvent()->getIO(); } else { $this->_logger = new \Composer\IO\NullIO(); } } return $this->_logger; }
Get logger @return IOInterface
https://github.com/apishka/easy-extend/blob/5e5c63c2509377abc3db6956e353623683703e09/source/Builder.php#L356-L371
bitrank-verified/php-client
src/BitRank/Score.php
Score.boundsCheck
protected function boundsCheck() { $scores = $this->bitrank->getScores(); if ($this->score > $scores->max) { $this->score = $scores->max; } if ($this->score < $scores->min) { $this->score = $scores->min; } }
php
protected function boundsCheck() { $scores = $this->bitrank->getScores(); if ($this->score > $scores->max) { $this->score = $scores->max; } if ($this->score < $scores->min) { $this->score = $scores->min; } }
Ensure score is within bounds @return void
https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L111-L120
bitrank-verified/php-client
src/BitRank/Score.php
Score.getFlagsOfType
public function getFlagsOfType($type) { if ($this->flags === null) { return []; } $matches = []; foreach ($this->flags as $flag) { if ($flag->type == $type) { $matches []= $flag; } } return $matches; }
php
public function getFlagsOfType($type) { if ($this->flags === null) { return []; } $matches = []; foreach ($this->flags as $flag) { if ($flag->type == $type) { $matches []= $flag; } } return $matches; }
Returns flags of the specified type associated with this address, if any. @param $type The flag type you're looking for. Will be one of the Flag::TYPE_* constants. @return array of Flag, or an empty array if none found.
https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L127-L142
bitrank-verified/php-client
src/BitRank/Score.php
Score.hasFlagsOfType
public function hasFlagsOfType($type) { if ($this->flags === null) { return false; } foreach ($this->flags as $flag) { if ($flag->type == $type) { return true; } } return false; }
php
public function hasFlagsOfType($type) { if ($this->flags === null) { return false; } foreach ($this->flags as $flag) { if ($flag->type == $type) { return true; } } return false; }
Returns whether or not this address has any flags of type. @param string $type The flag type you're looking for. Will be one of the Flag::TYPE_* constants. @return boolean
https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L149-L162
bitrank-verified/php-client
src/BitRank/Score.php
Score.toArray
public function toArray() { $array = [ 'address' => $this->address, 'score' => $this->score, 'seen' => $this->seen ]; $flags = []; if ($this->flags) { foreach ($this->flags as $flag) { $flags[$flag->slug] = 1; } } if (count($flags)) { $array['flags'] = array_keys($flags); } else { $array['flags'] = []; } return $array; }
php
public function toArray() { $array = [ 'address' => $this->address, 'score' => $this->score, 'seen' => $this->seen ]; $flags = []; if ($this->flags) { foreach ($this->flags as $flag) { $flags[$flag->slug] = 1; } } if (count($flags)) { $array['flags'] = array_keys($flags); } else { $array['flags'] = []; } return $array; }
Generates an assoc-array version of this Score. (Identical in shape to the JSON format of the API) @return array
https://github.com/bitrank-verified/php-client/blob/8c1a2eb3b82e317852f70af9bb9ea75af34b715c/src/BitRank/Score.php#L169-L192
digipolisgent/robo-digipolis-deploy
src/Traits/SymlinkFolderFileContentsTrait.php
SymlinkFolderFileContentsTrait.taskSymlinkFolderFileContents
protected function taskSymlinkFolderFileContents($source, $destination, Finder $finder = null) { return $this->task(SymlinkFolderFileContents::class, $source, $destination, $finder); }
php
protected function taskSymlinkFolderFileContents($source, $destination, Finder $finder = null) { return $this->task(SymlinkFolderFileContents::class, $source, $destination, $finder); }
Creates a SymlinkFolderFileContents task. @param string $source The directory containing the files to symlink. @param string $destination The directory where the symlinks should be placed. @param null|\Symfony\Component\Finder\Finder $finder The finder used to get the files from the source folder. @return \DigipolisGent\Robo\Task\Package\Deploy\SymlinkFolderFileContents The package project task.
https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/Traits/SymlinkFolderFileContentsTrait.php#L24-L27
fxpio/fxp-gluon
Form/Extension/CollectionExtension.php
CollectionExtension.finishView
public function finishView(FormView $view, FormInterface $form, array $options) { if (!isset($view->vars['selector'])) { return; } /* @var FormView $selectorView */ $selectorView = $view->vars['selector']; $selectorView->vars = array_replace($selectorView->vars, [ 'row_attr' => $view->vars['row_attr'], 'display_label' => $view->vars['display_label'], 'size' => $view->vars['size'], 'layout' => $view->vars['layout'], 'layout_col_size' => $view->vars['layout_col_size'], 'layout_col_label' => $view->vars['layout_col_label'], 'layout_col_control' => $view->vars['layout_col_control'], 'validation_state' => $view->vars['validation_state'], 'static_control' => $view->vars['static_control'], 'static_control_empty' => $view->vars['static_control_empty'], 'help_text' => $view->vars['help_text'], 'help_attr' => $view->vars['help_attr'], ]); }
php
public function finishView(FormView $view, FormInterface $form, array $options) { if (!isset($view->vars['selector'])) { return; } /* @var FormView $selectorView */ $selectorView = $view->vars['selector']; $selectorView->vars = array_replace($selectorView->vars, [ 'row_attr' => $view->vars['row_attr'], 'display_label' => $view->vars['display_label'], 'size' => $view->vars['size'], 'layout' => $view->vars['layout'], 'layout_col_size' => $view->vars['layout_col_size'], 'layout_col_label' => $view->vars['layout_col_label'], 'layout_col_control' => $view->vars['layout_col_control'], 'validation_state' => $view->vars['validation_state'], 'static_control' => $view->vars['static_control'], 'static_control_empty' => $view->vars['static_control_empty'], 'help_text' => $view->vars['help_text'], 'help_attr' => $view->vars['help_attr'], ]); }
{@inheritdoc}
https://github.com/fxpio/fxp-gluon/blob/0548b7d598ef4b0785b5df3b849a10f439b2dc65/Form/Extension/CollectionExtension.php#L29-L52
atelierspierrot/templatengine
src/Assets/Package/Preset.php
Preset.load
public function load() { if (empty($this->_statements)) { parent::load(); } /* @var $template_engine \TemplateEngine\TemplateEngine */ $template_engine = TemplateEngine::getInstance(); foreach ($this->getOrganizedStatements() as $type=>$statements) { foreach ($statements as $statement) { if ('css'===$type) { $template_object = $template_engine->getTemplateObject('CssFile'); $css = $statement->getData(); if (isset($css['minified']) && true===$css['minified']) { $template_object->addMinified($css['src'], $css['media']); } else { $template_object->add($css['src'], $css['media']); } } elseif ('jsfiles_header'===$type) { $template_object = $template_engine->getTemplateObject('JavascriptFile', 'jsfiles_header'); $js = $statement->getData(); if ( (isset($js['minified']) && true===$js['minified']) || (isset($js['packed']) && true===$js['packed']) ) { $template_object->addMinified($js['src']); } else { $template_object->add($js['src']); } } elseif (in_array($type, array('js', 'jsfiles_footer'))) { $template_object = $template_engine->getTemplateObject('JavascriptFile', 'jsfiles_footer'); $js = $statement->getData(); if ( (isset($js['minified']) && true===$js['minified']) || (isset($js['packed']) && true===$js['packed']) ) { $template_object->addMinified($js['src']); } else { $template_object->add($js['src']); } } } } }
php
public function load() { if (empty($this->_statements)) { parent::load(); } /* @var $template_engine \TemplateEngine\TemplateEngine */ $template_engine = TemplateEngine::getInstance(); foreach ($this->getOrganizedStatements() as $type=>$statements) { foreach ($statements as $statement) { if ('css'===$type) { $template_object = $template_engine->getTemplateObject('CssFile'); $css = $statement->getData(); if (isset($css['minified']) && true===$css['minified']) { $template_object->addMinified($css['src'], $css['media']); } else { $template_object->add($css['src'], $css['media']); } } elseif ('jsfiles_header'===$type) { $template_object = $template_engine->getTemplateObject('JavascriptFile', 'jsfiles_header'); $js = $statement->getData(); if ( (isset($js['minified']) && true===$js['minified']) || (isset($js['packed']) && true===$js['packed']) ) { $template_object->addMinified($js['src']); } else { $template_object->add($js['src']); } } elseif (in_array($type, array('js', 'jsfiles_footer'))) { $template_object = $template_engine->getTemplateObject('JavascriptFile', 'jsfiles_footer'); $js = $statement->getData(); if ( (isset($js['minified']) && true===$js['minified']) || (isset($js['packed']) && true===$js['packed']) ) { $template_object->addMinified($js['src']); } else { $template_object->add($js['src']); } } } } }
Automatic assets loading from an Assets package declare in a `composer.json` @return void
https://github.com/atelierspierrot/templatengine/blob/de01b117f882670bed7b322e2d3b8b30fa9ae45f/src/Assets/Package/Preset.php#L56-L100
ekyna/AdminBundle
DependencyInjection/Compiler/ResourceRegistryPass.php
ResourceRegistryPass.process
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('ekyna_admin.pool_registry')) { return; } $definition = $container->getDefinition('ekyna_admin.pool_registry'); $configurations = []; foreach ($container->findTaggedServiceIds('ekyna_admin.configuration') as $serviceId => $tag) { $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; $configurations[$alias] = new Reference($serviceId); } $definition->replaceArgument(0, $configurations); }
php
public function process(ContainerBuilder $container) { if (!$container->hasDefinition('ekyna_admin.pool_registry')) { return; } $definition = $container->getDefinition('ekyna_admin.pool_registry'); $configurations = []; foreach ($container->findTaggedServiceIds('ekyna_admin.configuration') as $serviceId => $tag) { $alias = isset($tag[0]['alias']) ? $tag[0]['alias'] : $serviceId; $configurations[$alias] = new Reference($serviceId); } $definition->replaceArgument(0, $configurations); }
{@inheritdoc}
https://github.com/ekyna/AdminBundle/blob/3f58e253ae9cf651add7f3d587caec80eaea459a/DependencyInjection/Compiler/ResourceRegistryPass.php#L19-L33
drakonli/php-imap
src/PhpImap/Mail/Body/Part/Structure/Extractor/Basic/BasicImapMailBodyPartStructureExtractor.php
BasicImapMailBodyPartStructureExtractor.extractPartsRecursive
private function extractPartsRecursive(stdClass $partStructure, $partNum) { $partStructure->number = $partNum; $parts = []; $parts[] = $partStructure; if (false === isset($partStructure->parts) || [] === $partStructure->parts) { return $parts; } foreach ($partStructure->parts as $subPartNum => $subPartStructure) { $nextPartNumber = $partNum.'.'.($subPartNum + 1); $type = $partStructure->type; $subType = $partStructure->subtype; if ($type == TYPEMESSAGE && $subType == ImapMailBodyPartStructureInterface::SUBTYPE_RFC822) { $nextPartNumber = $partNum; } $parts = array_merge($parts, $this->extractPartsRecursive($subPartStructure, $nextPartNumber)); } return $parts; }
php
private function extractPartsRecursive(stdClass $partStructure, $partNum) { $partStructure->number = $partNum; $parts = []; $parts[] = $partStructure; if (false === isset($partStructure->parts) || [] === $partStructure->parts) { return $parts; } foreach ($partStructure->parts as $subPartNum => $subPartStructure) { $nextPartNumber = $partNum.'.'.($subPartNum + 1); $type = $partStructure->type; $subType = $partStructure->subtype; if ($type == TYPEMESSAGE && $subType == ImapMailBodyPartStructureInterface::SUBTYPE_RFC822) { $nextPartNumber = $partNum; } $parts = array_merge($parts, $this->extractPartsRecursive($subPartStructure, $nextPartNumber)); } return $parts; }
@param stdClass $partStructure @param string $partNum @return array
https://github.com/drakonli/php-imap/blob/966dbb5d639897712d1570d62d3ce9bde3376089/src/PhpImap/Mail/Body/Part/Structure/Extractor/Basic/BasicImapMailBodyPartStructureExtractor.php#L43-L68
digipolisgent/robo-digipolis-deploy
src/BackupManager/Adapter/BackupProcedureAdapter.php
BackupProcedureAdapter.run
public function run($database, array $destinations, $compression) { return $this->procedure->run($database, $destinations, $compression); }
php
public function run($database, array $destinations, $compression) { return $this->procedure->run($database, $destinations, $compression); }
{@inheritdoc}
https://github.com/digipolisgent/robo-digipolis-deploy/blob/fafa8967d98ed4d3f2265b17f4b1abe53bf0b5ab/src/BackupManager/Adapter/BackupProcedureAdapter.php#L19-L22
mlocati/concrete5-translation-library
src/Parser/ThemePresets.php
ThemePresets.parseDirectoryDo
protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty) { $themesPresets = array(); $prefix = ($relativePath === '') ? '' : "$relativePath/"; $matches = null; foreach (array_merge(array(''), $this->getDirectoryStructure($rootDirectory, $exclude3rdParty)) as $child) { $presetsAbsDirectory = ($child === '') ? $rootDirectory : "$rootDirectory/$child"; if (preg_match('%(?:^|/)themes/\w+/css/presets$%', $presetsAbsDirectory, $matches)) { $dirList = @scandir($presetsAbsDirectory); if ($dirList === false) { throw new \Exception("Unable to parse directory $presetsAbsDirectory"); } $shownChild = ($child === '') ? rtrim($prefix, '/') : ($prefix.$child); foreach ($dirList as $file) { if (($file[0] !== '.') && preg_match('/[^.].*\.less$/i', $file)) { $fileAbs = "$presetsAbsDirectory/$file"; if (is_file($fileAbs)) { $content = @file_get_contents($fileAbs); if ($content === false) { throw new \Exception("Error reading file '$fileAbs'"); } $content = str_replace("\r", "\n", str_replace("\r\n", "\n", $content)); // Strip multiline comments $content = preg_replace_callback( '|/\*.*?\*/|s', function ($matches) { return str_repeat("\n", substr_count($matches[0], "\n")); }, $content ); foreach (array("'", '"') as $quote) { if (preg_match('%(?:^|\\n|;)[ \\t]*@preset-name:\\s*'.$quote.'([^'.$quote.']*)'.$quote.'\\s*(?:;|$)%s', $content, $matches)) { $presetName = $matches[1]; $presetLine = null; $p = strpos($content, $matches[0]); if ($p !== false) { $presetLine = substr_count(substr($content, 0, $p), "\n") + 1; } if (!isset($themesPresets[$presetName])) { $themesPresets[$presetName] = array(); } $themesPresets[$presetName][] = array($shownChild."/$file", $presetLine); break; } } } } } } } foreach ($themesPresets as $themesPreset => $references) { $translation = $translations->insert('PresetName', ucwords(str_replace(array('_', '-', '/'), ' ', $themesPreset))); foreach ($references as $reference) { $translation->addReference($reference[0], $reference[1]); } } }
php
protected function parseDirectoryDo(\Gettext\Translations $translations, $rootDirectory, $relativePath, $subParsersFilter, $exclude3rdParty) { $themesPresets = array(); $prefix = ($relativePath === '') ? '' : "$relativePath/"; $matches = null; foreach (array_merge(array(''), $this->getDirectoryStructure($rootDirectory, $exclude3rdParty)) as $child) { $presetsAbsDirectory = ($child === '') ? $rootDirectory : "$rootDirectory/$child"; if (preg_match('%(?:^|/)themes/\w+/css/presets$%', $presetsAbsDirectory, $matches)) { $dirList = @scandir($presetsAbsDirectory); if ($dirList === false) { throw new \Exception("Unable to parse directory $presetsAbsDirectory"); } $shownChild = ($child === '') ? rtrim($prefix, '/') : ($prefix.$child); foreach ($dirList as $file) { if (($file[0] !== '.') && preg_match('/[^.].*\.less$/i', $file)) { $fileAbs = "$presetsAbsDirectory/$file"; if (is_file($fileAbs)) { $content = @file_get_contents($fileAbs); if ($content === false) { throw new \Exception("Error reading file '$fileAbs'"); } $content = str_replace("\r", "\n", str_replace("\r\n", "\n", $content)); // Strip multiline comments $content = preg_replace_callback( '|/\*.*?\*/|s', function ($matches) { return str_repeat("\n", substr_count($matches[0], "\n")); }, $content ); foreach (array("'", '"') as $quote) { if (preg_match('%(?:^|\\n|;)[ \\t]*@preset-name:\\s*'.$quote.'([^'.$quote.']*)'.$quote.'\\s*(?:;|$)%s', $content, $matches)) { $presetName = $matches[1]; $presetLine = null; $p = strpos($content, $matches[0]); if ($p !== false) { $presetLine = substr_count(substr($content, 0, $p), "\n") + 1; } if (!isset($themesPresets[$presetName])) { $themesPresets[$presetName] = array(); } $themesPresets[$presetName][] = array($shownChild."/$file", $presetLine); break; } } } } } } } foreach ($themesPresets as $themesPreset => $references) { $translation = $translations->insert('PresetName', ucwords(str_replace(array('_', '-', '/'), ' ', $themesPreset))); foreach ($references as $reference) { $translation->addReference($reference[0], $reference[1]); } } }
{@inheritdoc} @see \C5TL\Parser::parseDirectoryDo()
https://github.com/mlocati/concrete5-translation-library/blob/26f806c8c1ecb6ce63115a4058ab396303622e00/src/Parser/ThemePresets.php#L35-L91
PHPColibri/framework
Cache/Storage/AbstractStorage.php
AbstractStorage.remember
public function remember(string $key, \Closure $getValueCallback, int $expire = null) { if (($fromCache = $this->get($key)) !== false) { return $fromCache; } $this->set($key, $value = $getValueCallback(), $expire); return $value; }
php
public function remember(string $key, \Closure $getValueCallback, int $expire = null) { if (($fromCache = $this->get($key)) !== false) { return $fromCache; } $this->set($key, $value = $getValueCallback(), $expire); return $value; }
@param string $key @param \Closure $getValueCallback @param int|null $expire @return mixed @throws \Psr\SimpleCache\InvalidArgumentException
https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Cache/Storage/AbstractStorage.php#L31-L40
ghousseyn/phiber
library/oosql/oosql.php
oosql.getInstance
public static function getInstance($oosql_table = null, $oosql_class = null, $config = null) { if (null !== self::$instance) { self::$instance->reset(); self::$instance->setClass($oosql_class); self::$instance->setTable($oosql_table); return self::$instance; } return self::$instance = new self($oosql_table, $oosql_class, $config); }
php
public static function getInstance($oosql_table = null, $oosql_class = null, $config = null) { if (null !== self::$instance) { self::$instance->reset(); self::$instance->setClass($oosql_class); self::$instance->setTable($oosql_table); return self::$instance; } return self::$instance = new self($oosql_table, $oosql_class, $config); }
Get an instance of this class @param string $oosql_table @param string $oosql_class @param \Phiber\config $config @return oosql An oosql\oosql object @static
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L234-L244
ghousseyn/phiber
library/oosql/oosql.php
oosql.reset
public function reset() { $this->oosql_limit = null; $this->oosql_order = null; $this->oosql_where = null; $this->oosql_join = null; $this->oosql_stmt = null; $this->oosql_conValues = array(); $this->oosql_numargs = null; $this->oosql_fromFlag = false; $this->oosql_multiFlag = false; $this->oosql_del_multiFlag = false; $this->oosql_multi = array(); $this->oosql_del_numargs = null; $this->oosql_sql = null; $this->oosql_select = null; $this->oosql_distinct = false; $this->oosql_insert = false; $this->oosql_sub = false; $this->oosql_table_alias = null; $this->oosql_fields = array(); $this->oosql_entity_obj = null; $this->oosql_in = null; $this->oosql_between = null; $this->oosql_fetchChanged = null; $this->oosql_group = null; $this->oosql_prepParams = null; return $this; }
php
public function reset() { $this->oosql_limit = null; $this->oosql_order = null; $this->oosql_where = null; $this->oosql_join = null; $this->oosql_stmt = null; $this->oosql_conValues = array(); $this->oosql_numargs = null; $this->oosql_fromFlag = false; $this->oosql_multiFlag = false; $this->oosql_del_multiFlag = false; $this->oosql_multi = array(); $this->oosql_del_numargs = null; $this->oosql_sql = null; $this->oosql_select = null; $this->oosql_distinct = false; $this->oosql_insert = false; $this->oosql_sub = false; $this->oosql_table_alias = null; $this->oosql_fields = array(); $this->oosql_entity_obj = null; $this->oosql_in = null; $this->oosql_between = null; $this->oosql_fetchChanged = null; $this->oosql_group = null; $this->oosql_prepParams = null; return $this; }
Resets the class vars to their initial values for a new query @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L250-L304
ghousseyn/phiber
library/oosql/oosql.php
oosql.sql
protected function sql($sql = null, $replace = false) { if (null !== $sql) { if (!isset($this->oosql_sql[$this->oosql_table]) || $replace) { $this->oosql_sql[$this->oosql_table] = $sql; } else { $this->oosql_sql[$this->oosql_table] .= $sql; } return; } return $this->oosql_sql[$this->oosql_table]; }
php
protected function sql($sql = null, $replace = false) { if (null !== $sql) { if (!isset($this->oosql_sql[$this->oosql_table]) || $replace) { $this->oosql_sql[$this->oosql_table] = $sql; } else { $this->oosql_sql[$this->oosql_table] .= $sql; } return; } return $this->oosql_sql[$this->oosql_table]; }
Append to the query string or return the current one @param mixed $sql SQL @param boolean $replace Replace current query or not
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L347-L359
ghousseyn/phiber
library/oosql/oosql.php
oosql.select
public function select() { self::$instance->reset(); $this->sql('SELECT '); if ($this->oosql_distinct) { $this->sql('DISTINCT '); } $numargs = func_num_args(); if ($numargs > 0) { $arg_list = func_get_args(); $this->oosql_fields = $arg_list; for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > 1) { $this->sql(','); } $this->sql($arg_list[$i]); } } else { $this->oosql_fields[] = '*'; $this->sql($this->oosql_table . '.* '); } $this->oosql_fromFlag = true; $this->oosql_select = $this; $this->oosql_where = null; return $this; }
php
public function select() { self::$instance->reset(); $this->sql('SELECT '); if ($this->oosql_distinct) { $this->sql('DISTINCT '); } $numargs = func_num_args(); if ($numargs > 0) { $arg_list = func_get_args(); $this->oosql_fields = $arg_list; for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > 1) { $this->sql(','); } $this->sql($arg_list[$i]); } } else { $this->oosql_fields[] = '*'; $this->sql($this->oosql_table . '.* '); } $this->oosql_fromFlag = true; $this->oosql_select = $this; $this->oosql_where = null; return $this; }
Create a select statement @variadic @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L366-L397
ghousseyn/phiber
library/oosql/oosql.php
oosql.getFields
public function getFields($table = null) { if (null == $table) { $table = $this->oosql_table; } $newFields = array(); foreach ($this->oosql_fields as $field) { $newFields[] = $table . '.' . $field; } return $newFields; }
php
public function getFields($table = null) { if (null == $table) { $table = $this->oosql_table; } $newFields = array(); foreach ($this->oosql_fields as $field) { $newFields[] = $table . '.' . $field; } return $newFields; }
Get an array of fields of the current or given table @param mixed $table table name @return array Table fields
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L404-L414
ghousseyn/phiber
library/oosql/oosql.php
oosql.insert
public function insert() { self::$instance->reset(); $this->sql('INSERT INTO ' . $this->oosql_table); $arg_list = func_get_args(); $numargs = func_num_args(); if ($numargs > 0) { $this->oosql_numargs = $numargs; $this->sql(' ('); $this->sql(implode(',', $arg_list)); $this->sql(')'); } $this->oosql_insert = true; return $this; }
php
public function insert() { self::$instance->reset(); $this->sql('INSERT INTO ' . $this->oosql_table); $arg_list = func_get_args(); $numargs = func_num_args(); if ($numargs > 0) { $this->oosql_numargs = $numargs; $this->sql(' ('); $this->sql(implode(',', $arg_list)); $this->sql(')'); } $this->oosql_insert = true; return $this; }
Creates an INSERT query @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L429-L447
ghousseyn/phiber
library/oosql/oosql.php
oosql.update
public function update() { self::$instance->reset(); $this->sql('UPDATE'); $numargs = func_num_args(); if ($numargs > 0) { $arg_list = func_get_args(); $this->oosql_multiFlag = true; $this->oosql_multi = $arg_list; for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > $i) { $this->sql(','); } $this->sql(' ' . $arg_list[$i]); } } else { $this->sql(" $this->oosql_table"); } $this->sql(' SET '); $this->oosql_where = null; return $this; }
php
public function update() { self::$instance->reset(); $this->sql('UPDATE'); $numargs = func_num_args(); if ($numargs > 0) { $arg_list = func_get_args(); $this->oosql_multiFlag = true; $this->oosql_multi = $arg_list; for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > $i) { $this->sql(','); } $this->sql(' ' . $arg_list[$i]); } } else { $this->sql(" $this->oosql_table"); } $this->sql(' SET '); $this->oosql_where = null; return $this; }
Creates an UPDATE query @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L453-L480
ghousseyn/phiber
library/oosql/oosql.php
oosql.delete
public function delete() { self::$instance->reset(); $this->sql('DELETE'); $this->oosql_where = null; $numargs = func_num_args(); if ($numargs > 0) { if ($numargs > 1) { $this->oosql_del_multiFlag = true; $this->oosql_del_numargs = $numargs; } $arg_list = func_get_args(); if (is_array($arg_list[0])) { $this->sql(' FROM ' . $this->oosql_table); $this->where($arg_list[0][0] . ' = ?', $arg_list[0][1]); return $this; } $this->oosql_sql .= ' FROM'; for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > 1) { $this->sql(','); } $this->sql(' ' . $arg_list[$i]); } } else { $this->oosql_fromFlag = true; } return $this; }
php
public function delete() { self::$instance->reset(); $this->sql('DELETE'); $this->oosql_where = null; $numargs = func_num_args(); if ($numargs > 0) { if ($numargs > 1) { $this->oosql_del_multiFlag = true; $this->oosql_del_numargs = $numargs; } $arg_list = func_get_args(); if (is_array($arg_list[0])) { $this->sql(' FROM ' . $this->oosql_table); $this->where($arg_list[0][0] . ' = ?', $arg_list[0][1]); return $this; } $this->oosql_sql .= ' FROM'; for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > 1) { $this->sql(','); } $this->sql(' ' . $arg_list[$i]); } } else { $this->oosql_fromFlag = true; } return $this; }
Creates a DELETE query @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L486-L518
ghousseyn/phiber
library/oosql/oosql.php
oosql.deleteRecord
public function deleteRecord($oosql = null, array $criteria) { if (null == $oosql) { $oosql = $this; } $oosql->delete()->createWhere($criteria)->exe(); return $this; }
php
public function deleteRecord($oosql = null, array $criteria) { if (null == $oosql) { $oosql = $this; } $oosql->delete()->createWhere($criteria)->exe(); return $this; }
Delete a record or more from a table @param mixed $oosql Optional oosql\oosql instance to run query on @param array $criteria Criteria of current opperation @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L526-L533
ghousseyn/phiber
library/oosql/oosql.php
oosql.set
public function set(array $data) { $sql = ''; foreach ($data as $field => $value) { $sql .= $field . ' = ?,'; $this->oosql_conValues[] = $value; } $this->sql(rtrim($sql, ',')); return $this; }
php
public function set(array $data) { $sql = ''; foreach ($data as $field => $value) { $sql .= $field . ' = ?,'; $this->oosql_conValues[] = $value; } $this->sql(rtrim($sql, ',')); return $this; }
Sets the column, value pairs in update queries @param array $data An array of the fields with their corresponding values in a key => value format @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L540-L552
ghousseyn/phiber
library/oosql/oosql.php
oosql.save
public function save(entity $object = null) { $data = null; $primaryValue = array(); if (null !== $object) { $primaryValue = array_filter(array_values($object->getPrimaryValue()), 'strlen'); } if (null === $object || empty($primaryValue)) { $entity = $object; if (null === $object) { if ( null === $this->oosql_entity_obj) { $msg = 'Nothing to save! ' . $this->sql(); throw new \Exception($msg, 9806, null); } // This is a brand new record let's insert; $entity = $this->getEntityObject(); } $fields = (array)$entity; if ($identity = $entity->identity()) { unset($fields[$identity]); } $populated = array_filter($fields, 'strlen'); $fieldnames = array_keys($populated); $fvalues = array_values($populated); call_user_func_array(array($this, 'insert'), $fieldnames); $lastID = call_user_func_array(array($this, 'values'), $fvalues)->exe(); $entity->{$identity} = $lastID; return $entity; } if (isset(self::$oosql_result)) { // Updating after a select $primaryField = $object->getPrimary(); $old = self::$oosql_result->objectWhere($primaryField[0], $object->{$primaryField[0]}); // Is it really a modification of a selected row? if ($old) { $identity = $this->getEntityObject()->identity(); foreach (array_diff_assoc((array)$object, (array)$old) as $key => $value) { if ($key == $identity) { continue; } $data[$key] = $value; } if (null === $data) { $msg = 'Nothing to save! ' . $this->sql(); throw new \Exception($msg, 9807, null); } $this->update()->set($data)->createWhere($object->getPrimaryValue())->exe(); return $object; } } // update a row just after inserting it // Or // update a related table (no select on it) $identity = $object->identity(); foreach ((array)$object as $k => $v) { if ($v === null || $k == $identity) { continue; } $data[$k] = $v; } if (count($data) !== 0) { $this->update()->set($data)->createWhere($object->getPrimaryValue())->exe(); return $object; } $msg = 'Nothing to save! ' . $this->sql(); throw new \Exception($msg, 9808, null); }
php
public function save(entity $object = null) { $data = null; $primaryValue = array(); if (null !== $object) { $primaryValue = array_filter(array_values($object->getPrimaryValue()), 'strlen'); } if (null === $object || empty($primaryValue)) { $entity = $object; if (null === $object) { if ( null === $this->oosql_entity_obj) { $msg = 'Nothing to save! ' . $this->sql(); throw new \Exception($msg, 9806, null); } // This is a brand new record let's insert; $entity = $this->getEntityObject(); } $fields = (array)$entity; if ($identity = $entity->identity()) { unset($fields[$identity]); } $populated = array_filter($fields, 'strlen'); $fieldnames = array_keys($populated); $fvalues = array_values($populated); call_user_func_array(array($this, 'insert'), $fieldnames); $lastID = call_user_func_array(array($this, 'values'), $fvalues)->exe(); $entity->{$identity} = $lastID; return $entity; } if (isset(self::$oosql_result)) { // Updating after a select $primaryField = $object->getPrimary(); $old = self::$oosql_result->objectWhere($primaryField[0], $object->{$primaryField[0]}); // Is it really a modification of a selected row? if ($old) { $identity = $this->getEntityObject()->identity(); foreach (array_diff_assoc((array)$object, (array)$old) as $key => $value) { if ($key == $identity) { continue; } $data[$key] = $value; } if (null === $data) { $msg = 'Nothing to save! ' . $this->sql(); throw new \Exception($msg, 9807, null); } $this->update()->set($data)->createWhere($object->getPrimaryValue())->exe(); return $object; } } // update a row just after inserting it // Or // update a related table (no select on it) $identity = $object->identity(); foreach ((array)$object as $k => $v) { if ($v === null || $k == $identity) { continue; } $data[$k] = $v; } if (count($data) !== 0) { $this->update()->set($data)->createWhere($object->getPrimaryValue())->exe(); return $object; } $msg = 'Nothing to save! ' . $this->sql(); throw new \Exception($msg, 9808, null); }
Decides if this is an insert or an update and what fields have changed if appropriate @param mixed $object If null this is an insert if not than it's an update @throws \Exception @return object An entity Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L560-L648
ghousseyn/phiber
library/oosql/oosql.php
oosql.createWhere
public function createWhere(array $conditions, $operator = '=', $condition = 'and') { foreach ($conditions as $col => $value) { if (null === $this->oosql_where) { $this->where($col . ' ' . $operator . '?', $value); continue; } $method = $condition . 'Where'; $this->{$method}($col . ' ' . $operator . '?', $value); } return $this; }
php
public function createWhere(array $conditions, $operator = '=', $condition = 'and') { foreach ($conditions as $col => $value) { if (null === $this->oosql_where) { $this->where($col . ' ' . $operator . '?', $value); continue; } $method = $condition . 'Where'; $this->{$method}($col . ' ' . $operator . '?', $value); } return $this; }
Creates where clause(s) from an array of conditions @param array $conditions An array of conditions in the format: <code>array("column" => $value)</code> @param string $operator @param string $condition @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L658-L675
ghousseyn/phiber
library/oosql/oosql.php
oosql.values
public function values() { $arg_list = func_get_args(); $numargs = func_num_args(); if (($this->oosql_numargs !== 0 && $numargs !== $this->oosql_numargs) || $numargs === 0) { $msg = 'Insert numargs: ' . $this->oosql_numargs . ' | values numargs = ' . $numargs . ', Columns and passed data do not match! ' . $this->sql(); throw new \Exception($msg, 9809, null); } $this->sql(' VALUES ('); for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > 1) { $this->sql(','); } if (is_array($arg_list[$i])) { $this->sql(rtrim(str_repeat('?,', count($arg_list[$i])), ',')); $this->oosql_conValues += $arg_list[$i]; } else { $this->oosql_conValues[] = $arg_list[$i]; $this->sql(' ?'); } } $this->sql(')'); $this->oosql_fromFlag = false; return $this; }
php
public function values() { $arg_list = func_get_args(); $numargs = func_num_args(); if (($this->oosql_numargs !== 0 && $numargs !== $this->oosql_numargs) || $numargs === 0) { $msg = 'Insert numargs: ' . $this->oosql_numargs . ' | values numargs = ' . $numargs . ', Columns and passed data do not match! ' . $this->sql(); throw new \Exception($msg, 9809, null); } $this->sql(' VALUES ('); for ($i = 0; $i < $numargs; $i++) { if ($i != 0 && $numargs > 1) { $this->sql(','); } if (is_array($arg_list[$i])) { $this->sql(rtrim(str_repeat('?,', count($arg_list[$i])), ',')); $this->oosql_conValues += $arg_list[$i]; } else { $this->oosql_conValues[] = $arg_list[$i]; $this->sql(' ?'); } } $this->sql(')'); $this->oosql_fromFlag = false; return $this; }
Assembles values part of an insert @throws \Exception @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L682-L715
ghousseyn/phiber
library/oosql/oosql.php
oosql.from
public function from() { $from = ''; $numargs = func_num_args(); if ($this->oosql_del_multiFlag) { if ($numargs < $this->oosql_del_numargs) { $msg = 'Columns and passed data do not match! ' . $this->sql(); throw new \Exception($msg, 9810, null); } } $from .= ' FROM '; $from .= $this->oosql_table; if ($numargs > 0) { $from .= ', '; $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { if ($i !== 0 && $numargs > $i) { $from .= ', '; } if ($arg_list[$i] instanceof oosql) { $arg_list[$i]->alias(); $fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias()); $this->sql(',' . implode(', ', $fields)); $from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias(); } else { $from .= $arg_list[$i]; } } } $this->sql($from); $this->oosql_fromFlag = false; return $this; }
php
public function from() { $from = ''; $numargs = func_num_args(); if ($this->oosql_del_multiFlag) { if ($numargs < $this->oosql_del_numargs) { $msg = 'Columns and passed data do not match! ' . $this->sql(); throw new \Exception($msg, 9810, null); } } $from .= ' FROM '; $from .= $this->oosql_table; if ($numargs > 0) { $from .= ', '; $arg_list = func_get_args(); for ($i = 0; $i < $numargs; $i++) { if ($i !== 0 && $numargs > $i) { $from .= ', '; } if ($arg_list[$i] instanceof oosql) { $arg_list[$i]->alias(); $fields = $arg_list[$i]->getFields($arg_list[$i]->getTableAlias()); $this->sql(',' . implode(', ', $fields)); $from .= $arg_list[$i]->getSql() . ' AS ' . $arg_list[$i]->getTableAlias(); } else { $from .= $arg_list[$i]; } } } $this->sql($from); $this->oosql_fromFlag = false; return $this; }
Assembles the FROM part of the query @throws \Exception @return \Phiber\oosql\oosql Instance
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L722-L771
ghousseyn/phiber
library/oosql/oosql.php
oosql.where
public function where($condition, $value = null, $type = null) { switch ($type) { case null: $clause = 'WHERE'; break; case 'or': $clause = 'OR'; break; case 'and': $clause = 'AND'; break; default: $clause = 'WHERE'; } $this->oosql_where .= " $clause $condition"; if ($value instanceof oosql) { $this->oosql_where .= $value->getSql(); } elseif (null !== $value) { $this->oosql_conValues[] = $value; } return $this; }
php
public function where($condition, $value = null, $type = null) { switch ($type) { case null: $clause = 'WHERE'; break; case 'or': $clause = 'OR'; break; case 'and': $clause = 'AND'; break; default: $clause = 'WHERE'; } $this->oosql_where .= " $clause $condition"; if ($value instanceof oosql) { $this->oosql_where .= $value->getSql(); } elseif (null !== $value) { $this->oosql_conValues[] = $value; } return $this; }
Assembles a WHERE clause @param string $condition @param string $value @param string $type @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L829-L857
ghousseyn/phiber
library/oosql/oosql.php
oosql.sub
public function sub() { $this->oosql_sub = true; $this->exe(); $this->sql('(' . $this->getSql() . ')', true); return $this; }
php
public function sub() { $this->oosql_sub = true; $this->exe(); $this->sql('(' . $this->getSql() . ')', true); return $this; }
Declares current query as a sub-query @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L863-L870
ghousseyn/phiber
library/oosql/oosql.php
oosql.prep
public function prep($values = null) { $hash = $this->queryHash(); $prepOnly = true; if (is_array($values)) { $prepOnly = false; } if ($this->oosql_prepParams) { $this->oosql_stmt = $this->prepare(trim($this->sql()), $this->oosql_prepParams); } else { $this->oosql_stmt = $this->prepare(trim($this->sql())); } if ($prepOnly) { return $this->oosql_stmt; } return $this->execBound($this->oosql_stmt, $values); }
php
public function prep($values = null) { $hash = $this->queryHash(); $prepOnly = true; if (is_array($values)) { $prepOnly = false; } if ($this->oosql_prepParams) { $this->oosql_stmt = $this->prepare(trim($this->sql()), $this->oosql_prepParams); } else { $this->oosql_stmt = $this->prepare(trim($this->sql())); } if ($prepOnly) { return $this->oosql_stmt; } return $this->execBound($this->oosql_stmt, $values); }
Prepare a query statement @param array $values Bound values if any @return mixed A \PDOStatement object or the boolean return of PDOStatement::execute
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L901-L928
ghousseyn/phiber
library/oosql/oosql.php
oosql.execBound
public function execBound(\PDOStatement $stmt, array $values) { $ord = 1; foreach ($values as $val) { if (is_bool($val)) { $stmt->bindValue($ord, $val, \PDO::PARAM_BOOL); } elseif (is_resource($val)) { $stmt->bindValue($ord, $val, \PDO::PARAM_LOB); } elseif ((string)$val === ((string)(int)$val)) { $stmt->bindValue($ord, $val, \PDO::PARAM_INT); } else { $stmt->bindValue($ord, $val, \PDO::PARAM_STR); } $ord++; } return $stmt->execute(); }
php
public function execBound(\PDOStatement $stmt, array $values) { $ord = 1; foreach ($values as $val) { if (is_bool($val)) { $stmt->bindValue($ord, $val, \PDO::PARAM_BOOL); } elseif (is_resource($val)) { $stmt->bindValue($ord, $val, \PDO::PARAM_LOB); } elseif ((string)$val === ((string)(int)$val)) { $stmt->bindValue($ord, $val, \PDO::PARAM_INT); } else { $stmt->bindValue($ord, $val, \PDO::PARAM_STR); } $ord++; } return $stmt->execute(); }
Executes a prepared statement with parameterized values @param \PDOStatement $stmt @param array $values @return boolean True on success
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L936-L961
ghousseyn/phiber
library/oosql/oosql.php
oosql.exe
public function exe() { if ($this->oosql_fromFlag) { $this->from(); } if (null != $this->oosql_join) { $this->sql($this->oosql_join); } if (null != $this->oosql_where) { $this->sql($this->oosql_where); } if (null != $this->oosql_in) { $this->sql($this->oosql_in); } if (null != $this->oosql_between) { $this->sql($this->oosql_between); } if (null != $this->oosql_limit) { $this->sql(' ' . $this->oosql_limit); } if (null != $this->oosql_group) { $this->sql(' ' . $this->oosql_group); } if (null != $this->oosql_order) { $this->sql(' ' . $this->oosql_order); } if (count($this->oosql_conValues) !== 0) { $return = $this->prep($this->oosql_conValues); $this->oosql_conValues = array(); if ($return === false) { $msg = 'Execution failed! ' . $this->sql(); throw new \Exception($msg, 9811, null); } } else { $this->oosql_stmt = $this->query($this->sql()); } if ($this->oosql_insert) { $identity = $this->getEntityObject()->identity(); if ($identity !== false) { if ($this->oosql_driver == 'pgsql') { $identity = $this->oosql_table . '_' . $identity . '_seq'; } $lastID = $this->lastInsertId($identity); return $lastID; } } return $this->oosql_stmt; }
php
public function exe() { if ($this->oosql_fromFlag) { $this->from(); } if (null != $this->oosql_join) { $this->sql($this->oosql_join); } if (null != $this->oosql_where) { $this->sql($this->oosql_where); } if (null != $this->oosql_in) { $this->sql($this->oosql_in); } if (null != $this->oosql_between) { $this->sql($this->oosql_between); } if (null != $this->oosql_limit) { $this->sql(' ' . $this->oosql_limit); } if (null != $this->oosql_group) { $this->sql(' ' . $this->oosql_group); } if (null != $this->oosql_order) { $this->sql(' ' . $this->oosql_order); } if (count($this->oosql_conValues) !== 0) { $return = $this->prep($this->oosql_conValues); $this->oosql_conValues = array(); if ($return === false) { $msg = 'Execution failed! ' . $this->sql(); throw new \Exception($msg, 9811, null); } } else { $this->oosql_stmt = $this->query($this->sql()); } if ($this->oosql_insert) { $identity = $this->getEntityObject()->identity(); if ($identity !== false) { if ($this->oosql_driver == 'pgsql') { $identity = $this->oosql_table . '_' . $identity . '_seq'; } $lastID = $this->lastInsertId($identity); return $lastID; } } return $this->oosql_stmt; }
Checks flags and clauses then assembles and executes the query @throws \Exception @return string|object @throws \Exception
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L969-L1029
ghousseyn/phiber
library/oosql/oosql.php
oosql.prepFetch
protected function prepFetch() { if ($this->oosql_sub) { return $this; } if (!$this->oosql_select instanceof oosql) { $this->select(); } $this->oosql_select->exe(); if (!$this->oosql_stmt) { $msg = 'Query returned no results! ' . $this->sql(); throw new \Exception($msg, 9814, null); } if (!is_array($this->oosql_fetchChanged)) { $this->oosql_stmt->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->oosql_class); } else { call_user_func_array(array($this->oosql_stmt, 'setFetchMode'), $this->oosql_fetchChanged); } }
php
protected function prepFetch() { if ($this->oosql_sub) { return $this; } if (!$this->oosql_select instanceof oosql) { $this->select(); } $this->oosql_select->exe(); if (!$this->oosql_stmt) { $msg = 'Query returned no results! ' . $this->sql(); throw new \Exception($msg, 9814, null); } if (!is_array($this->oosql_fetchChanged)) { $this->oosql_stmt->setFetchMode(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $this->oosql_class); } else { call_user_func_array(array($this->oosql_stmt, 'setFetchMode'), $this->oosql_fetchChanged); } }
Returns the results of a SELECT if any @throws \InvalidArgumentException @throws \Exception @return \Phiber\oosql\oosql|\Phiber\oosql\collection
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1037-L1058
ghousseyn/phiber
library/oosql/oosql.php
oosql.all
public function all() { $this->prepFetch(); $result = $this->oosql_stmt->fetchAll(); $collection = new collection(); $collection->addBulk($result); $collection->obj_name = $this->oosql_class; self::$oosql_result = clone $collection; return $collection; }
php
public function all() { $this->prepFetch(); $result = $this->oosql_stmt->fetchAll(); $collection = new collection(); $collection->addBulk($result); $collection->obj_name = $this->oosql_class; self::$oosql_result = clone $collection; return $collection; }
Acts as a fetchAll() but returns a collection @author Housseyn Guettaf <[email protected]> @link http://phiber.myjetbrains.com/youtrack/issue/core-35 @return collection @throws \Exception
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1085-L1100
ghousseyn/phiber
library/oosql/oosql.php
oosql.cursor
public function cursor() { static $stmt; if (!$stmt) { $this->setPrepareParams(array(\PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL)); $this->prepFetch(); $stmt = $this->oosql_stmt; } return $stmt; }
php
public function cursor() { static $stmt; if (!$stmt) { $this->setPrepareParams(array(\PDO::ATTR_CURSOR => \PDO::CURSOR_SCROLL)); $this->prepFetch(); $stmt = $this->oosql_stmt; } return $stmt; }
Enable the cursor and returns a statement object to allow using fetch() on it @author Housseyn Guettaf <[email protected]> @link http://phiber.myjetbrains.com/youtrack/issue/core-35 @return \PDOStatement @throws \Exception
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1112-L1122
ghousseyn/phiber
library/oosql/oosql.php
oosql.with
public function with(array $related) { $relations = $this->getEntityObject()->getRelations(); foreach ($relations as $fk => $target) { $table = strstr($target, '.', true); if (in_array($table, $related)) { $this->sql(" ,$table.*"); $this->join($table, "$this->oosql_table.$fk = $target"); } elseif (isset($related[$table])) { foreach ($related[$table] as $field) { $this->sql(" ,$table.$field"); } $this->join($table, "$this->oosql_table.$fk = $target"); } } return $this; }
php
public function with(array $related) { $relations = $this->getEntityObject()->getRelations(); foreach ($relations as $fk => $target) { $table = strstr($target, '.', true); if (in_array($table, $related)) { $this->sql(" ,$table.*"); $this->join($table, "$this->oosql_table.$fk = $target"); } elseif (isset($related[$table])) { foreach ($related[$table] as $field) { $this->sql(" ,$table.$field"); } $this->join($table, "$this->oosql_table.$fk = $target"); } } return $this; }
Creates a join automatically based on the relationships of current entity @param array $related @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1144-L1164
ghousseyn/phiber
library/oosql/oosql.php
oosql.limit
public function limit($from, $size) { if (!$this->oosql_multiFlag) { $this->oosql_limit = ' LIMIT ' . $from . ', ' . $size; } return $this; }
php
public function limit($from, $size) { if (!$this->oosql_multiFlag) { $this->oosql_limit = ' LIMIT ' . $from . ', ' . $size; } return $this; }
Creates a limit clause for MySQL @param integer $from Offset tostart from @param integer $size Chunk size @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1172-L1178
ghousseyn/phiber
library/oosql/oosql.php
oosql.orderBy
public function orderBy($field, $dir = 'ASC') { if (!$this->oosql_multiFlag) { $this->oosql_order = ' ORDER BY ' . $field . ' ' . $dir; } return $this; }
php
public function orderBy($field, $dir = 'ASC') { if (!$this->oosql_multiFlag) { $this->oosql_order = ' ORDER BY ' . $field . ' ' . $dir; } return $this; }
Creates an ORDER BY clause @param string $field Field name @param string DESC|ASC @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1186-L1192
ghousseyn/phiber
library/oosql/oosql.php
oosql.findOne
public function findOne($arg = null, $operator = '=', $fields = array('*')) { return $this->find($arg, $operator, $fields)->limit(0, 1); }
php
public function findOne($arg = null, $operator = '=', $fields = array('*')) { return $this->find($arg, $operator, $fields)->limit(0, 1); }
Find first random value returned by the query @param string $arg @param string $operator @param array $fields @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1201-L1204
ghousseyn/phiber
library/oosql/oosql.php
oosql.findLimited
public function findLimited($from, $to, $arg = null, $operator = '=', $fields = array('*')) { return $this->find($arg, $operator, $fields)->limit($from, $to); }
php
public function findLimited($from, $to, $arg = null, $operator = '=', $fields = array('*')) { return $this->find($arg, $operator, $fields)->limit($from, $to); }
Find with limit @param string $arg @param integer $from @param integer $to @param string $operator @param array $fields @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1215-L1218
ghousseyn/phiber
library/oosql/oosql.php
oosql.find
public function find($arg = null, $operator = '=', $fields = array('*')) { if ($fields[0] == '*') { $this->select(); } else { $select_args = ''; foreach ($fields as $key => $field) { if (is_array($field) && is_string($key)) { foreach ($field as $part) { $select_args .= $key . '.' . $part . ', '; } } else { $select_args .= $this->oosql_table . '.' . $field . ', '; } } $this->select(rtrim($select_args, ',')); } if (!is_array($arg)) { $obj = $this->getEntityObject(); $pri = $obj->getPrimary(); if (null !== $arg) { $arg = array($pri[0] => $arg); } } $i = 0; $flag = ''; if (is_array($arg)) { foreach ($arg as $col => $val) { if ($i > 0) { $flag = 'and'; } $this->where("$this->oosql_table.$col $operator ?", $val, $flag); $i++; } } return $this; }
php
public function find($arg = null, $operator = '=', $fields = array('*')) { if ($fields[0] == '*') { $this->select(); } else { $select_args = ''; foreach ($fields as $key => $field) { if (is_array($field) && is_string($key)) { foreach ($field as $part) { $select_args .= $key . '.' . $part . ', '; } } else { $select_args .= $this->oosql_table . '.' . $field . ', '; } } $this->select(rtrim($select_args, ',')); } if (!is_array($arg)) { $obj = $this->getEntityObject(); $pri = $obj->getPrimary(); if (null !== $arg) { $arg = array($pri[0] => $arg); } } $i = 0; $flag = ''; if (is_array($arg)) { foreach ($arg as $col => $val) { if ($i > 0) { $flag = 'and'; } $this->where("$this->oosql_table.$col $operator ?", $val, $flag); $i++; } } return $this; }
Find records with a filtering condition @param string $arg @param string $operator @param array $fields @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1227-L1267
ghousseyn/phiber
library/oosql/oosql.php
oosql.alias
public function alias($alias = null) { if (null === $alias) { $alias = $this->getTableAlias(); } $this->oosql_table_alias = $alias; return $this; }
php
public function alias($alias = null) { if (null === $alias) { $alias = $this->getTableAlias(); } $this->oosql_table_alias = $alias; return $this; }
Creates or bind provided alias with the current loaded table class @param string $alias @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1274-L1281
ghousseyn/phiber
library/oosql/oosql.php
oosql.getTableAlias
public function getTableAlias() { if (null !== $this->oosql_table_alias) { return $this->oosql_table_alias; } $hash = $this->queryHash(); $this->oosql_table_alias = $hash; return $hash; }
php
public function getTableAlias() { if (null !== $this->oosql_table_alias) { return $this->oosql_table_alias; } $hash = $this->queryHash(); $this->oosql_table_alias = $hash; return $hash; }
Returns the alias for the current table (creates one if none was found) @return string
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1287-L1295
ghousseyn/phiber
library/oosql/oosql.php
oosql.notIn
public function notIn($item, array $list, $cond = null, $not = true) { return $this->in($item, $list, $cond, $not); }
php
public function notIn($item, array $list, $cond = null, $not = true) { return $this->in($item, $list, $cond, $not); }
Creates a NOT IN clause @param mixed $item Subject of comparison @param array $list A list of values @param string $cond OR|AND @param boolean $not
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1332-L1335
ghousseyn/phiber
library/oosql/oosql.php
oosql.orIn
public function orIn($item, array $list, $cond = 'or', $not = false) { return $this->in($item, $list, $cond, $not); }
php
public function orIn($item, array $list, $cond = 'or', $not = false) { return $this->in($item, $list, $cond, $not); }
Creates a OR IN clause @param mixed $item Subject of comparison @param array $list A list of values @param string $cond OR|AND @param boolean $not
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1344-L1347
ghousseyn/phiber
library/oosql/oosql.php
oosql.orNotIn
public function orNotIn($item, array $list, $cond = 'or', $not = true) { return $this->in($item, $list, $cond, $not); }
php
public function orNotIn($item, array $list, $cond = 'or', $not = true) { return $this->in($item, $list, $cond, $not); }
Creates an OR NOT IN clause @param mixed $item Subject of comparison @param array $list A list of values @param string $cond OR|AND @param boolean $not
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1356-L1359
ghousseyn/phiber
library/oosql/oosql.php
oosql.in
public function in($item, array $list, $cond = null, $not = false) { $inClause = ''; if (null == $this->oosql_where && null == $this->oosql_in && null == $this->oosql_between) { $inClause .= ' WHERE '; } else { $cnd = ' AND '; if (null != $cond) { if (strtolower($cond) == 'or') { $cnd = ' OR '; } } $inClause .= $cnd; } if ($not) { $item = $item . ' NOT '; } $inClause .= $item . ' IN '; $obj = $this; $list = array_map(function ($data) use ($obj) { return (!$obj->validInt($data)) ? $obj->quote($data) : $data; }, $list); $inClause .= '(' . implode(',', $list) . ')'; $this->oosql_in = $inClause; return $this; }
php
public function in($item, array $list, $cond = null, $not = false) { $inClause = ''; if (null == $this->oosql_where && null == $this->oosql_in && null == $this->oosql_between) { $inClause .= ' WHERE '; } else { $cnd = ' AND '; if (null != $cond) { if (strtolower($cond) == 'or') { $cnd = ' OR '; } } $inClause .= $cnd; } if ($not) { $item = $item . ' NOT '; } $inClause .= $item . ' IN '; $obj = $this; $list = array_map(function ($data) use ($obj) { return (!$obj->validInt($data)) ? $obj->quote($data) : $data; }, $list); $inClause .= '(' . implode(',', $list) . ')'; $this->oosql_in = $inClause; return $this; }
Creates an IN clause @param mixed $item Subject of comparison @param array $list A list of values @param string $cond OR|AND @param boolean $not
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1368-L1402
ghousseyn/phiber
library/oosql/oosql.php
oosql.between
public function between($item, $low, $up, $cond = null, $not = false) { $bClause = ''; if (null == $this->oosql_where && null == $this->oosql_between && null == $this->oosql_in) { $bClause .= ' WHERE '; } else { $cnd = ' AND '; if (null != $cond) { if (strtolower($cond) == 'or') { $cnd = ' OR '; } } $bClause .= $cnd; } if ($not) { $item = $item . ' NOT '; } $bClause .= $item . ' BETWEEN ' . $low . ' AND ' . $up; $this->oosql_between = $bClause; return $this; }
php
public function between($item, $low, $up, $cond = null, $not = false) { $bClause = ''; if (null == $this->oosql_where && null == $this->oosql_between && null == $this->oosql_in) { $bClause .= ' WHERE '; } else { $cnd = ' AND '; if (null != $cond) { if (strtolower($cond) == 'or') { $cnd = ' OR '; } } $bClause .= $cnd; } if ($not) { $item = $item . ' NOT '; } $bClause .= $item . ' BETWEEN ' . $low . ' AND ' . $up; $this->oosql_between = $bClause; return $this; }
Creates a BETWEEN clause @param mixed $item @param mixed $low @param mixed $up @param string $cond OR|AND @param boolean $not @return \Phiber\oosql\oosql
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1413-L1440
ghousseyn/phiber
library/oosql/oosql.php
oosql.transactional
public static function transactional($fn) { $oosql = self::getInstance('oosql', 'void'); if (!$oosql->beginTransaction()) { $msg = 'Could not start this transaction. BeginTransaction failed!'; throw new \Exception($msg, 9815, null); } if (is_callable($fn)) { $ret = $fn($oosql); return $ret; } $msg = 'Please pass a Lamda function as a parameter to this method!'; throw new \Exception($msg, 9816, null); }
php
public static function transactional($fn) { $oosql = self::getInstance('oosql', 'void'); if (!$oosql->beginTransaction()) { $msg = 'Could not start this transaction. BeginTransaction failed!'; throw new \Exception($msg, 9815, null); } if (is_callable($fn)) { $ret = $fn($oosql); return $ret; } $msg = 'Please pass a Lamda function as a parameter to this method!'; throw new \Exception($msg, 9816, null); }
Starts a transaction if current driver supports it @param callable $fn A Closure @throws \Exception @return mixed Whatever the Closure returns is passed to the higher scope variable if any
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1474-L1487
ghousseyn/phiber
library/oosql/oosql.php
oosql.getNamedLock
public function getNamedLock($name, $timeout = 15) { $stmt = $this->query('SELECT GET_LOCK("' . $name . '", '.$timeout .')'); return $stmt->fetch(self::FETCH_COLUMN); }
php
public function getNamedLock($name, $timeout = 15) { $stmt = $this->query('SELECT GET_LOCK("' . $name . '", '.$timeout .')'); return $stmt->fetch(self::FETCH_COLUMN); }
Try to obtain a named lock @author Housseyn Guettaf @param string $name - Lock name @param int $timeout - Timeout @return mixed
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1499-L1504
ghousseyn/phiber
library/oosql/oosql.php
oosql.releaseNamedLock
public function releaseNamedLock($name) { $stmt = $this->query('SELECT RELEASE_LOCK("' . $name . '")'); return $stmt->fetch(self::FETCH_COLUMN); }
php
public function releaseNamedLock($name) { $stmt = $this->query('SELECT RELEASE_LOCK("' . $name . '")'); return $stmt->fetch(self::FETCH_COLUMN); }
releases a named lock @author Housseyn Guettaf @param string $name - Lock name @return mixed
https://github.com/ghousseyn/phiber/blob/2574249d49b6930a0123a310a32073a105cdd486/library/oosql/oosql.php#L1514-L1519
zbox/UnifiedPush
src/Zbox/UnifiedPush/Notification/PayloadHandler/APNS.php
APNS.packPayload
public function packPayload($payload) { $payload = JsonEncoder::jsonEncode($payload); /** @var APNSMessage $message */ $message = $this->message; $recipientId = $message->getRecipientDeviceCollection()->current()->getIdentifier(); $messageRecipientId = $this->notificationId . '_' . $recipientId; $packedPayload = pack('C', 1). // Command push pack('N', $messageRecipientId). pack('N', $message->getExpirationTime()->format('U')). pack('n', 32). // Token binary length pack('H*', $recipientId); pack('n', strlen($payload)); $packedPayload .= $payload; return $packedPayload; }
php
public function packPayload($payload) { $payload = JsonEncoder::jsonEncode($payload); /** @var APNSMessage $message */ $message = $this->message; $recipientId = $message->getRecipientDeviceCollection()->current()->getIdentifier(); $messageRecipientId = $this->notificationId . '_' . $recipientId; $packedPayload = pack('C', 1). // Command push pack('N', $messageRecipientId). pack('N', $message->getExpirationTime()->format('U')). pack('n', 32). // Token binary length pack('H*', $recipientId); pack('n', strlen($payload)); $packedPayload .= $payload; return $packedPayload; }
Pack message body into binary string @param array $payload @return string
https://github.com/zbox/UnifiedPush/blob/47da2d0577b18ac709cd947c68541014001e1866/src/Zbox/UnifiedPush/Notification/PayloadHandler/APNS.php#L77-L99
newestindustry/ginger-rest
src/Ginger/Routes.php
Routes.set
public static function set($uri, $path = false) { $route = new \Ginger\Route($uri, $path); self::$routes[$route->route] = $route; }
php
public static function set($uri, $path = false) { $route = new \Ginger\Route($uri, $path); self::$routes[$route->route] = $route; }
set function. @access public @static @param mixed $uri @param bool $path (default: false) @return void
https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/Routes.php#L48-L52
newestindustry/ginger-rest
src/Ginger/Routes.php
Routes.detect
public static function detect($uri) { $routes = self::get(); $found = false; foreach($routes as $key => $route) { $currentLength = strlen($route->route); if(substr($uri, 0, $currentLength) == $route->route) { $found = $route; break; } } return $found; }
php
public static function detect($uri) { $routes = self::get(); $found = false; foreach($routes as $key => $route) { $currentLength = strlen($route->route); if(substr($uri, 0, $currentLength) == $route->route) { $found = $route; break; } } return $found; }
detect function. @access public @static @param string $uri @return false|\Ginger\Route
https://github.com/newestindustry/ginger-rest/blob/482b77dc122a60ab0bf143a3c4a1e67168985c83/src/Ginger/Routes.php#L74-L87
schpill/thin
src/Html/Qwerly.php
Qwerly._lookUpBy
private function _lookUpBy($service, $data) { $batch = false; $urlFormat = self::$URLS[$service]; if (is_array($data)) { $data = implode(',', $data); $batch = true; } $url = self::BASE_URL . sprintf($urlFormat, urlencode($data)) . sprintf(self::API_KEY, $this->_apiKey); $this->_client->setUri($url); $request = $this->_client->request(); $data = json_decode($request->getBody(), true); if ($request->getStatus() == self::TRY_AGAIN_LATER_CODE || $request->getStatus() == self::NOT_FOUND_CODE) { throw new \Thin\Exception( $data['message'], $data['status'] ); } else if ($request->getStatus() == 400) { throw new \Thin\Exception( $data['message'], $data['status'] ); } else if (!$request->isSuccessful()) { throw new \Thin\Exception($request->getBody()); } if ($batch) { return new \Thin\Html\Qwerly\Batch($data); } else { return new \Thin\Html\Qwerly\User($data); } }
php
private function _lookUpBy($service, $data) { $batch = false; $urlFormat = self::$URLS[$service]; if (is_array($data)) { $data = implode(',', $data); $batch = true; } $url = self::BASE_URL . sprintf($urlFormat, urlencode($data)) . sprintf(self::API_KEY, $this->_apiKey); $this->_client->setUri($url); $request = $this->_client->request(); $data = json_decode($request->getBody(), true); if ($request->getStatus() == self::TRY_AGAIN_LATER_CODE || $request->getStatus() == self::NOT_FOUND_CODE) { throw new \Thin\Exception( $data['message'], $data['status'] ); } else if ($request->getStatus() == 400) { throw new \Thin\Exception( $data['message'], $data['status'] ); } else if (!$request->isSuccessful()) { throw new \Thin\Exception($request->getBody()); } if ($batch) { return new \Thin\Html\Qwerly\Batch($data); } else { return new \Thin\Html\Qwerly\User($data); } }
Looks up an user using the given service data. @param string $service Service to look up with. @param mixed $data Data relevant to the service. @return Qwerly_API_Response|null @throws Qwerly_API_ErrorException @throws Qwerly_API_NotFoundException
https://github.com/schpill/thin/blob/a9102d9d6f70e8b0f6be93153f70849f46489ee1/src/Html/Qwerly.php#L120-L154
harmony-project/modular-bundle
source/HarmonyModularBundle.php
HarmonyModularBundle.build
public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new Compiler\MetadataResourceResolverPass); }
php
public function build(ContainerBuilder $container) { parent::build($container); $container->addCompilerPass(new Compiler\MetadataResourceResolverPass); }
{@inheritdoc}
https://github.com/harmony-project/modular-bundle/blob/2813f7285eb5ae18d2ebe7dd1623fd0e032cfab7/source/HarmonyModularBundle.php#L25-L30
chilimatic/chilimatic-framework
lib/database/sql/mysql/Collection.php
Collection.getInstance
public static function getInstance($database = null) { if (self::$instance instanceof Pool) { self::$instance->add($database); return self::$instance; } self::$instance = new Pool($database); return self::$instance; }
php
public static function getInstance($database = null) { if (self::$instance instanceof Pool) { self::$instance->add($database); return self::$instance; } self::$instance = new Pool($database); return self::$instance; }
singelton constructor @param mixed $database @return Pool
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Collection.php#L53-L65
chilimatic/chilimatic-framework
lib/database/sql/mysql/Collection.php
Collection._checkdatabase
private function _checkdatabase($database) { if (count($this->_collection) == 0) { $this->_collection[$database] = new $database(); return $this->_collection[$database]; } $new = false; foreach ($this->_collection as $db) { if ($db === $database) continue; $new = true; } if ($new === true) { $this->_collection[$database] = new $database(); } return false; }
php
private function _checkdatabase($database) { if (count($this->_collection) == 0) { $this->_collection[$database] = new $database(); return $this->_collection[$database]; } $new = false; foreach ($this->_collection as $db) { if ($db === $database) continue; $new = true; } if ($new === true) { $this->_collection[$database] = new $database(); } return false; }
checks if a database already exists @param $database @return $this
https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/database/sql/mysql/Collection.php#L79-L99
aboutcoders/resource-lock-bundle
DependencyInjection/AbcResourceLockExtension.php
AbcResourceLockExtension.load
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/services')); if ('custom' !== $config['db_driver']) { $loader->load(sprintf('%s.xml', $config['db_driver'])); } $this->remapParametersNamespaces($config, $container, array( '' => array( 'model_manager_name' => 'abc.resource_lock.model_manager_name' ) )); if (!empty($config['resource_lock'])) { $this->loadResourceLock($config['resource_lock'], $container, $loader, $config['db_driver']); } if (!empty($config['managers'])) { $this->loadCustomManagers($config['managers'], $container, $loader, $config['db_driver']); } }
php
public function load(array $configs, ContainerBuilder $container) { $configuration = new Configuration(); $config = $this->processConfiguration($configuration, $configs); $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config/services')); if ('custom' !== $config['db_driver']) { $loader->load(sprintf('%s.xml', $config['db_driver'])); } $this->remapParametersNamespaces($config, $container, array( '' => array( 'model_manager_name' => 'abc.resource_lock.model_manager_name' ) )); if (!empty($config['resource_lock'])) { $this->loadResourceLock($config['resource_lock'], $container, $loader, $config['db_driver']); } if (!empty($config['managers'])) { $this->loadCustomManagers($config['managers'], $container, $loader, $config['db_driver']); } }
{@inheritDoc}
https://github.com/aboutcoders/resource-lock-bundle/blob/7e24113d605876144532cf76fb242bb34aacf288/DependencyInjection/AbcResourceLockExtension.php#L30-L53
acacha/forge-publish
src/Console/Commands/Traits/PossibleEmails.php
PossibleEmails.getPossibleEmails
protected function getPossibleEmails() { $this->checkGit(); $github_email = null; $github_email = str_replace(array("\r", "\n"), '', shell_exec('git config user.email')); if (filter_var($github_email, FILTER_VALIDATE_EMAIL)) { return [ $github_email ]; } else { return []; } }
php
protected function getPossibleEmails() { $this->checkGit(); $github_email = null; $github_email = str_replace(array("\r", "\n"), '', shell_exec('git config user.email')); if (filter_var($github_email, FILTER_VALIDATE_EMAIL)) { return [ $github_email ]; } else { return []; } }
Get possible emails @return array
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/PossibleEmails.php#L20-L31
Napp/aclcore
src/Middleware/Authorize.php
Authorize.handle
public function handle($request, Closure $next, ...$ability) { $user = auth(config('acl.guard'))->user(); if (null === $user) { throw new AuthenticationException; } if (false === acl($ability)) { throw new AuthorizationException; } return $next($request); }
php
public function handle($request, Closure $next, ...$ability) { $user = auth(config('acl.guard'))->user(); if (null === $user) { throw new AuthenticationException; } if (false === acl($ability)) { throw new AuthorizationException; } return $next($request); }
Handle an incoming request. @param \Illuminate\Http\Request $request @param \Closure $next @param string|array $ability @return mixed @throws \Illuminate\Auth\AuthenticationException @throws \Napp\Core\Api\Exceptions\Exceptions\AuthorizationException
https://github.com/Napp/aclcore/blob/9f2f48fe0af4c50ed7cbbafe653761da42e39596/src/Middleware/Authorize.php#L26-L39
acacha/forge-publish
src/Console/Commands/PublishMySQLUsers.php
PublishMySQLUsers.createMySQLUser
protected function createMySQLUser() { $this->checkParameters(); $this->url = $this->obtainAPIURLEndpoint(); $this->http->post($this->url, [ 'form_params' => $this->getData(), 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest', 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') ] ] ); }
php
protected function createMySQLUser() { $this->checkParameters(); $this->url = $this->obtainAPIURLEndpoint(); $this->http->post($this->url, [ 'form_params' => $this->getData(), 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest', 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') ] ] ); }
Create MySQL user.
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishMySQLUsers.php#L75-L87
acacha/forge-publish
src/Console/Commands/PublishMySQLUsers.php
PublishMySQLUsers.listMySQLUsers
protected function listMySQLUsers() { $this->url = $this->obtainAPIURLEndpointForList(); $response = $this->http->get($this->url, [ 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest', 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') ] ] ); $users = json_decode($response->getBody(), true) ; if ($this->option('dump')) { dump($users); } if (empty($users)) { $this->error('No users found.'); die(); } $headers = ['Id', 'Server Id','Name','Status','Created at']; $rows = []; foreach ($users as $user) { $rows[] = [ $user['id'], $user['serverId'], $user['name'], $user['status'], $user['createdAt'] ]; } $this->table($headers, $rows); }
php
protected function listMySQLUsers() { $this->url = $this->obtainAPIURLEndpointForList(); $response = $this->http->get($this->url, [ 'headers' => [ 'X-Requested-With' => 'XMLHttpRequest', 'Authorization' => 'Bearer ' . fp_env('ACACHA_FORGE_ACCESS_TOKEN') ] ] ); $users = json_decode($response->getBody(), true) ; if ($this->option('dump')) { dump($users); } if (empty($users)) { $this->error('No users found.'); die(); } $headers = ['Id', 'Server Id','Name','Status','Created at']; $rows = []; foreach ($users as $user) { $rows[] = [ $user['id'], $user['serverId'], $user['name'], $user['status'], $user['createdAt'] ]; } $this->table($headers, $rows); }
List MySQL users.
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishMySQLUsers.php#L92-L129
acacha/forge-publish
src/Console/Commands/PublishMySQLUsers.php
PublishMySQLUsers.getData
protected function getData() { if ($this->argument('user')) { return [ 'name' => $this->argument('name'), 'user' => $this->argument('user'), 'password' => $this->argument('password') ]; } else { return [ 'name' => $this->argument('name') ]; } }
php
protected function getData() { if ($this->argument('user')) { return [ 'name' => $this->argument('name'), 'user' => $this->argument('user'), 'password' => $this->argument('password') ]; } else { return [ 'name' => $this->argument('name') ]; } }
Get data. @return array
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishMySQLUsers.php#L149-L162
Tuna-CMS/tuna-bundle
Twig/TunaConfigExtension.php
TunaConfigExtension.getConfig
public function getConfig($key) { $keyParts = explode('.', $key); $config = $this->config; foreach ($keyParts as $keyPart) { if (!array_key_exists($keyPart, $config)) { throw new \InvalidArgumentException(sprintf('Invalid config key (%s). Available keys: %s', $key, implode(', ', $this->getAvailableKeys()) )); } $config = $config[$keyPart]; } return $config; }
php
public function getConfig($key) { $keyParts = explode('.', $key); $config = $this->config; foreach ($keyParts as $keyPart) { if (!array_key_exists($keyPart, $config)) { throw new \InvalidArgumentException(sprintf('Invalid config key (%s). Available keys: %s', $key, implode(', ', $this->getAvailableKeys()) )); } $config = $config[$keyPart]; } return $config; }
@param string $key Compatible with PropertyAccessor format (ie. `[components][menu][default_template]`) @return mixed
https://github.com/Tuna-CMS/tuna-bundle/blob/1f999de44e14cbe9f992d46f2e5e74ddc117b04c/Twig/TunaConfigExtension.php#L26-L43
acacha/forge-publish
src/Console/Commands/Traits/InteractsWithEnvironment.php
InteractsWithEnvironment.addValueToEnv
protected function addValueToEnv($key, $value) { $env_path = base_path('.env'); $sed_command = "/bin/sed -i '/^$key=/d' " . $env_path; passthru($sed_command); File::append($env_path, "\n$key=$value\n"); }
php
protected function addValueToEnv($key, $value) { $env_path = base_path('.env'); $sed_command = "/bin/sed -i '/^$key=/d' " . $env_path; passthru($sed_command); File::append($env_path, "\n$key=$value\n"); }
Add value to env. @param $key @param $value
https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/Traits/InteractsWithEnvironment.php#L20-L26
PHPColibri/framework
Application/Application/API.php
API.getModuleView
public static function getModuleView($division, $module, $method, ...$params) { return self::$application->getModuleView($division, $module, $method, $params); }
php
public static function getModuleView($division, $module, $method, ...$params) { return self::$application->getModuleView($division, $module, $method, $params); }
@param string $division @param string $module @param string $method @param array $params @return string @throws \Colibri\Routing\Exception\NotFoundException
https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Application/Application/API.php#L40-L43