idx
int64 0
60.3k
| question
stringlengths 101
6.21k
| target
stringlengths 7
803
|
|---|---|---|
56,400
|
public function setAvailableDate ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ availableDate ) { $ this -> availableDate = $ availableDate ; }
|
Set the date that this content becomes available for playback .
|
56,401
|
public function getExpirationDate ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> expirationDate ) { return new NullDateTime ( ) ; } return $ this -> expirationDate ; }
|
Returns the date that this content expires and is no longer available for playback .
|
56,402
|
public function setExpirationDate ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ expirationDate ) { $ this -> expirationDate = $ expirationDate ; }
|
Set the date that this content expires and is no longer available for playback .
|
56,403
|
public function getFileSourceMediaId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> fileSourceMediaId ) { return new Uri ( ) ; } return $ this -> fileSourceMediaId ; }
|
Returns reserved for future use .
|
56,404
|
public function getProgramId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> programId ) { return new Uri ( ) ; } return $ this -> programId ; }
|
Returns the ID of the Program that represents this media . The GUID URI is recommended .
|
56,405
|
public function getProviderId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> providerId ) { return new Uri ( ) ; } return $ this -> providerId ; }
|
Returns the id of the Provider that represents the account that shared this Media .
|
56,406
|
public function getPubDate ( ) : \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface { if ( ! $ this -> pubDate ) { return new NullDateTime ( ) ; } return $ this -> pubDate ; }
|
Returns the original release date or airdate of this Media object s content .
|
56,407
|
public function setPubDate ( \ Lullabot \ Mpx \ DataService \ DateTime \ DateTimeFormatInterface $ pubDate ) { $ this -> pubDate = $ pubDate ; }
|
Set the original release date or airdate of this Media object s content .
|
56,408
|
public function getSeriesId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> seriesId ) { return new Uri ( ) ; } return $ this -> seriesId ; }
|
Returns the ID of the Program that represents the series to which this media belongs . The GUID URI is recommended .
|
56,409
|
public function getTransliterationMap ( $ path , $ alphabet ) { if ( ! in_array ( $ alphabet , array ( Settings :: ALPHABET_CYR , Settings :: ALPHABET_LAT ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Alphabet "%s" is not recognized.' , $ alphabet ) ) ; } $ map = $ this -> loadFromCache ( $ path , $ alphabet ) ; if ( null !== $ map ) { return $ map ; } $ map = $ this -> loadFromFile ( $ path ) ; $ this -> storeToCache ( $ path , $ map ) ; return $ this -> loadFromCache ( $ path , $ alphabet ) ; }
|
Get transliteration map .
|
56,410
|
protected function loadFromFile ( $ path ) { if ( ! file_exists ( $ path ) ) { throw new \ Exception ( sprintf ( 'Map file "%s" does not exist.' , $ path ) ) ; } $ map = require ( $ path ) ; if ( ! is_array ( $ map ) || ! is_array ( $ map [ Settings :: ALPHABET_CYR ] ) || ! is_array ( $ map [ Settings :: ALPHABET_LAT ] ) ) { throw new \ Exception ( sprintf ( 'Map file "%s" is not valid, should return an array with %s and %s subarrays.' , $ path , Settings :: ALPHABET_CYR , Settings :: ALPHABET_LAT ) ) ; } return $ map ; }
|
Load map from file .
|
56,411
|
protected function loadFromCache ( $ id , $ alphabet ) { if ( isset ( $ this -> mappingCache [ $ id ] ) && isset ( $ this -> mappingCache [ $ id ] [ $ alphabet ] ) ) { return $ this -> mappingCache [ $ id ] [ $ alphabet ] ; } return null ; }
|
Load map from cache .
|
56,412
|
public function setAmount ( $ amount ) { if ( ! is_int ( $ amount ) ) { throw new InvalidArgumentException ( "Integer expected. Amount is always in cents" ) ; } if ( $ amount <= 0 ) { throw new InvalidArgumentException ( "Amount must be a positive number" ) ; } $ this -> parameters [ 'amount' ] = $ amount ; }
|
Set amount in cents eg EUR 12 . 34 is written as 1234
|
56,413
|
public function copyDirectory ( $ directory , $ destination ) { $ files = $ this -> fileSystem -> allFiles ( $ directory ) ; $ fileDeployed = false ; $ this -> fileSystem -> copyDirectory ( $ directory , $ destination ) ; foreach ( $ files as $ file ) { $ fileContents = $ this -> fileSystem -> get ( $ file ) ; $ fileDeployed = $ this -> fileSystem -> put ( $ destination . '/' . $ file -> getRelativePathname ( ) , $ fileContents ) ; } return $ fileDeployed ; }
|
Copy a directory and its content .
|
56,414
|
private function publishConfig ( ) { if ( ! file_exists ( getcwd ( ) . '/config/crudmaker.php' ) ) { $ this -> copyDirectory ( __DIR__ . '/../../config' , getcwd ( ) . '/config' ) ; $ this -> info ( "\n\nLumen config file have been published" ) ; } else { $ this -> error ( 'Lumen config files has already been published' ) ; } }
|
Publish config files for Lumen .
|
56,415
|
private function publishTemplates ( ) { if ( ! $ this -> fileSystem -> isDirectory ( getcwd ( ) . '/resources/crudmaker' ) ) { $ this -> copyDirectory ( __DIR__ . '/../Templates/Lumen' , getcwd ( ) . '/resources/crudmaker' ) ; $ this -> info ( "\n\nLumen templates files have been published" ) ; } else { $ this -> error ( 'Lumen templates files has already been published' ) ; } }
|
Publish templates files for Lumen .
|
56,416
|
public function basicConfig ( $ framework , $ appPath , $ basePath , $ appNamespace , $ table , $ options ) { $ config = [ 'framework' => $ framework , 'bootstrap' => false , 'semantic' => false , 'template_source' => '' , '_sectionPrefix_' => '' , '_sectionTablePrefix_' => '' , '_sectionRoutePrefix_' => '' , '_sectionNamespace_' => '' , '_path_facade_' => $ appPath . '/Facades' , '_path_service_' => $ appPath . '/Services' , '_path_model_' => $ appPath . '/Models' , '_path_controller_' => $ appPath . '/Http/Controllers/' , '_path_api_controller_' => $ appPath . '/Http/Controllers/Api' , '_path_views_' => $ basePath . '/resources/views' , '_path_tests_' => $ basePath . '/tests' , '_path_request_' => $ appPath . '/Http/Requests/' , '_path_routes_' => $ basePath . '/routes/web.php' , '_path_api_routes_' => $ basePath . '/routes/api.php' , '_path_migrations_' => $ basePath . '/database/migrations' , '_path_factory_' => $ basePath . '/database/factories/' . snake_case ( $ table ) . 'Factory.php' , 'routes_prefix' => '' , 'routes_suffix' => '' , '_app_namespace_' => 'App\\' , '_namespace_services_' => $ appNamespace . 'Services' , '_namespace_facade_' => $ appNamespace . 'Facades' , '_namespace_model_' => $ appNamespace . 'Models' , '_namespace_controller_' => $ appNamespace . 'Http\Controllers' , '_namespace_api_controller_' => $ appNamespace . 'Http\Controllers\Api' , '_namespace_request_' => $ appNamespace . 'Http\Requests' , '_table_name_' => str_plural ( strtolower ( snake_case ( $ table ) ) ) , '_lower_case_' => strtolower ( snake_case ( $ table ) ) , '_lower_casePlural_' => str_plural ( strtolower ( snake_case ( $ table ) ) ) , '_camel_case_' => ucfirst ( camel_case ( $ table ) ) , '_camel_casePlural_' => str_plural ( camel_case ( $ table ) ) , '_ucCamel_casePlural_' => ucfirst ( str_plural ( camel_case ( $ table ) ) ) , '_plain_space_textLower_' => strtolower ( str_replace ( '_' , ' ' , snake_case ( $ table ) ) ) , '_plain_space_textFirst_' => ucfirst ( strtolower ( str_replace ( '_' , ' ' , snake_case ( $ table ) ) ) ) , '_snake_case_' => snake_case ( $ table ) , '_snake_casePlural_' => str_plural ( snake_case ( $ table ) ) , 'options-api' => $ options [ 'api' ] , 'options-apiOnly' => $ options [ 'apiOnly' ] , 'options-ui' => $ options [ 'ui' ] , 'options-serviceOnly' => $ options [ 'serviceOnly' ] , 'options-withFacade' => $ options [ 'withFacade' ] , 'options-withBaseService' => $ options [ 'withBaseService' ] , 'options-migration' => $ options [ 'migration' ] , 'options-schema' => $ options [ 'schema' ] , 'options-relationships' => $ options [ 'relationships' ] , ] ; return $ config ; }
|
Generate the basic config
|
56,417
|
public function getTemplateConfig ( $ framework ) { $ templates = __DIR__ . '/../Templates/' . $ framework ; $ templates = app ( 'config' ) -> get ( 'crudmaker.template_source' , $ templates ) ; return $ templates ; }
|
Get the templates directory .
|
56,418
|
public function addField ( string $ field , string $ value ) : self { $ this -> fields [ $ field ] = $ value ; return $ this ; }
|
Add a field to this filter such as title .
|
56,419
|
public function toQueryParts ( ) : array { $ fields = [ ] ; foreach ( $ this -> fields as $ field => $ value ) { $ fields [ 'by' . ucfirst ( $ field ) ] = $ value ; } return $ fields ; }
|
Return all of the fields being filtered .
|
56,420
|
private function skipToNextStringOrNamespaceSeparator ( \ ArrayIterator $ tokens ) { while ( $ tokens -> valid ( ) && ( T_STRING !== $ tokens -> current ( ) [ 0 ] ) && ( T_NS_SEPARATOR !== $ tokens -> current ( ) [ 0 ] ) ) { $ tokens -> next ( ) ; } }
|
Fast - forwards the iterator as longs as we don t encounter a T_STRING or T_NS_SEPARATOR token .
|
56,421
|
private function extractUseStatement ( \ ArrayIterator $ tokens ) { $ result = [ '' ] ; while ( $ tokens -> valid ( ) && ( self :: T_LITERAL_USE_SEPARATOR !== $ tokens -> current ( ) [ 0 ] ) && ( self :: T_LITERAL_END_OF_USE !== $ tokens -> current ( ) [ 0 ] ) ) { if ( T_AS === $ tokens -> current ( ) [ 0 ] ) { $ result [ ] = '' ; } if ( T_STRING === $ tokens -> current ( ) [ 0 ] || T_NS_SEPARATOR === $ tokens -> current ( ) [ 0 ] ) { $ result [ \ count ( $ result ) - 1 ] .= $ tokens -> current ( ) [ 1 ] ; } $ tokens -> next ( ) ; } if ( 1 == \ count ( $ result ) ) { $ backslashPos = strrpos ( $ result [ 0 ] , '\\' ) ; if ( false !== $ backslashPos ) { $ result [ ] = substr ( $ result [ 0 ] , $ backslashPos + 1 ) ; } else { $ result [ ] = $ result [ 0 ] ; } } return array_reverse ( $ result ) ; }
|
Deduce the namespace name and alias of an import when we are at the T_USE token or have not reached the end of a USE statement yet .
|
56,422
|
public static function validateData ( $ data ) { $ required = [ 'responseCode' , 'isException' , 'title' , ] ; if ( isset ( $ data [ 'responseCode' ] ) && $ data [ 'responseCode' ] >= 400 && $ data [ 'responseCode' ] < 500 ) { $ required [ ] = 'description' ; } foreach ( $ required as $ key ) { if ( empty ( $ data [ $ key ] ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Required key %s is missing.' , $ key ) ) ; } } }
|
Validate required data in the MPX error .
|
56,423
|
protected function parseResponse ( ResponseInterface $ response ) : string { $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) , true ) ; isset ( $ data [ 0 ] ) ? $ this -> setNotificationData ( $ data ) : $ this -> setData ( $ data ) ; $ message = sprintf ( 'HTTP %s Error %s' , $ response -> getStatusCode ( ) , $ this -> data [ 'title' ] ) ; if ( isset ( $ this -> data [ 'description' ] ) ) { $ message .= sprintf ( ': %s' , $ this -> getDescription ( ) ) ; } return $ message ; }
|
Parse a response into the exception .
|
56,424
|
protected function cacheKey ( $ type , $ params ) { return sprintf ( '%s:%s:%s' , $ this -> cachePrefix , $ type , md5 ( http_build_query ( $ params ) ) ) ; }
|
get a cache key for the given type and params .
|
56,425
|
protected function loadConfig ( ) { parent :: loadConfig ( ) ; $ this -> iTunesConfig = array_merge ( $ this -> iTunesConfig , $ this -> config -> get ( 'itunes' ) ) ; }
|
Load the configuration parameters .
|
56,426
|
public static function mpxErrors ( ) : \ Closure { return function ( callable $ handler ) { return function ( RequestInterface $ request , array $ options ) use ( $ handler ) { return $ handler ( $ request , $ options ) -> then ( function ( ResponseInterface $ response ) use ( $ request , $ handler ) { $ contentType = $ response -> getHeaderLine ( 'Content-Type' ) ; if ( 0 === preg_match ( '!^(application|text)\/json!' , $ contentType ) ) { return $ response ; } $ data = \ GuzzleHttp \ json_decode ( $ response -> getBody ( ) , true ) ; if ( isset ( $ data [ 0 ] ) && isset ( $ data [ 0 ] [ 'type' ] ) && 'Exception' == $ data [ 0 ] [ 'type' ] ) { throw MpxExceptionFactory :: createFromNotificationException ( $ request , $ response ) ; } if ( empty ( $ data [ 'responseCode' ] ) && empty ( $ data [ 'isException' ] ) ) { return $ response ; } throw MpxExceptionFactory :: create ( $ request , $ response ) ; } ) ; } ; } ; }
|
A middleware to check for MPX errors in the body of the response .
|
56,427
|
public function hasNext ( ) : bool { return ! empty ( $ this -> entries ) && ( $ this -> getStartIndex ( ) + $ this -> getItemsPerPage ( ) - 1 < $ this -> getTotalResults ( ) ) ; }
|
Return if this object list has a next list to load .
|
56,428
|
public function nextList ( ) { if ( ! $ this -> hasNext ( ) ) { return false ; } if ( ! isset ( $ this -> dataObjectFactory ) ) { throw new \ LogicException ( 'setDataObjectFactory must be called before calling nextList.' ) ; } if ( ! isset ( $ this -> objectListQuery ) ) { throw new \ LogicException ( 'setByFields must be called before calling nextList.' ) ; } $ byFields = clone $ this -> objectListQuery ; $ range = Range :: nextRange ( $ this ) ; $ byFields -> setRange ( $ range ) ; return $ this -> dataObjectFactory -> selectRequest ( $ byFields ) ; }
|
Return the next object list request if one exists .
|
56,429
|
public function yieldLists ( ) : \ Generator { if ( ! isset ( $ this -> dataObjectFactory ) ) { throw new \ LogicException ( 'setDataObjectFactory must be called before calling nextList.' ) ; } if ( ! isset ( $ this -> objectListQuery ) ) { throw new \ LogicException ( 'setByFields must be called before calling nextList.' ) ; } $ thisList = new Promise ( ) ; $ thisList -> resolve ( $ this ) ; yield $ thisList ; $ ranges = Range :: nextRanges ( $ this ) ; foreach ( $ ranges as $ range ) { $ byFields = clone $ this -> objectListQuery ; $ byFields -> setRange ( $ range ) ; yield $ this -> dataObjectFactory -> selectRequest ( $ byFields ) ; } }
|
Yield select requests for all pages of this object list .
|
56,430
|
public function getClient ( ) : SellsyClient { if ( ! $ this -> client instanceof SellsyClient ) { $ this -> client = new SellsyClient ( $ this -> getTransport ( ) , $ this -> apiUrl , $ this -> oauthAccessToken , $ this -> oauthAccessTokenSecret , $ this -> oauthConsumerKey , $ this -> oauthConsumerSecret ) ; } return $ this -> client ; }
|
Return and configure a sellsy client on the flow .
|
56,431
|
protected function headerSettings ( ) { $ this -> setPrintHeader ( Config :: get ( 'laravel-tcpdf::header_on' ) ) ; $ this -> setHeaderFont ( array ( Config :: get ( 'laravel-tcpdf::header_font' ) , '' , Config :: get ( 'laravel-tcpdf::header_font_size' ) ) ) ; $ this -> setHeaderMargin ( Config :: get ( 'laravel-tcpdf::header_margin' ) ) ; $ this -> SetHeaderData ( Config :: get ( 'laravel-tcpdf::header_logo' ) , Config :: get ( 'laravel-tcpdf::header_logo_width' ) , Config :: get ( 'laravel-tcpdf::header_title' ) , Config :: get ( 'laravel-tcpdf::header_string' ) ) ; }
|
Set all the necessary header settings
|
56,432
|
protected function footerSettings ( ) { $ this -> setPrintFooter ( Config :: get ( 'laravel-tcpdf::footer_on' ) ) ; $ this -> setFooterFont ( array ( Config :: get ( 'laravel-tcpdf::footer_font' ) , '' , Config :: get ( 'laravel-tcpdf::footer_font_size' ) ) ) ; $ this -> setFooterMargin ( Config :: get ( 'laravel-tcpdf::footer_margin' ) ) ; }
|
Set all the necessary footer settings
|
56,433
|
private function collectRequest ( GuzzleRequestInterface $ request ) { $ body = null ; if ( $ request instanceof EntityEnclosingRequestInterface ) { $ body = ( string ) $ request -> getBody ( ) ; } return array ( 'headers' => $ request -> getHeaders ( ) , 'method' => $ request -> getMethod ( ) , 'scheme' => $ request -> getScheme ( ) , 'host' => $ request -> getHost ( ) , 'port' => $ request -> getPort ( ) , 'path' => $ request -> getPath ( ) , 'query' => $ request -> getQuery ( ) , 'body' => $ body ) ; }
|
Collect & sanitize data about a Guzzle request
|
56,434
|
private function collectResponse ( GuzzleRequestInterface $ request ) { $ response = $ request -> getResponse ( ) ; $ body = $ response -> getBody ( true ) ; return array ( 'statusCode' => $ response -> getStatusCode ( ) , 'reasonPhrase' => $ response -> getReasonPhrase ( ) , 'headers' => $ response -> getHeaders ( ) , 'body' => $ body ) ; }
|
Collect & sanitize data about a Guzzle response
|
56,435
|
private function collectTime ( GuzzleRequestInterface $ request ) { $ response = $ request -> getResponse ( ) ; return array ( 'total' => $ response -> getInfo ( 'total_time' ) , 'connection' => $ response -> getInfo ( 'connect_time' ) ) ; }
|
Collect time for a Guzzle request
|
56,436
|
public function getColorSchemeId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> colorSchemeId ) { return new Uri ( ) ; } return $ this -> colorSchemeId ; }
|
Returns identifier for the color scheme assigned to this player .
|
56,437
|
public function getEmbedAdPolicyId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> embedAdPolicyId ) { return new Uri ( ) ; } return $ this -> embedAdPolicyId ; }
|
Returns the identifier for the advertising policy to use when the player is embedded in another site .
|
56,438
|
public function getEmbedRestrictionId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> embedRestrictionId ) { return new Uri ( ) ; } return $ this -> embedRestrictionId ; }
|
Returns the identifier for the restriction to apply to this player when embedded in another site .
|
56,439
|
public function getLayoutId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> layoutId ) { return new Uri ( ) ; } return $ this -> layoutId ; }
|
Returns the identifier for the layout assigned to this player .
|
56,440
|
public function getSkinId ( ) : \ Psr \ Http \ Message \ UriInterface { if ( ! $ this -> skinId ) { return new Uri ( ) ; } return $ this -> skinId ; }
|
Returns identifier for the skin object to apply this player .
|
56,441
|
public function getFieldDataService ( ) : DiscoveredDataService { $ service = clone $ this ; $ service -> objectType .= '/Field' ; $ service -> schemaVersion = '1.2' ; return new DiscoveredDataService ( Field :: class , $ service ) ; }
|
Return a discovered data service for custom fields .
|
56,442
|
public function createMigration ( $ config , $ section , $ table , $ splitTable , $ command ) { try { if ( ! empty ( $ section ) ) { $ migrationName = 'create_' . str_plural ( strtolower ( implode ( '_' , $ splitTable ) ) ) . '_table' ; $ tableName = str_plural ( strtolower ( implode ( '_' , $ splitTable ) ) ) ; } else { $ migrationName = 'create_' . str_plural ( strtolower ( snake_case ( $ table ) ) ) . '_table' ; $ tableName = str_plural ( strtolower ( snake_case ( $ table ) ) ) ; } $ command -> callSilent ( 'make:migration' , [ 'name' => $ migrationName , '--table' => $ tableName , '--create' => true , '--path' => $ this -> getMigrationsPath ( $ config , true ) , ] ) ; return true ; } catch ( Exception $ e ) { throw new Exception ( 'Could not create the migration: ' . $ e -> getMessage ( ) , 1 ) ; } }
|
Create the migrations .
|
56,443
|
public function createSchema ( $ config , $ section , $ table , $ splitTable , $ schema ) { $ migrationFiles = $ this -> filesystem -> allFiles ( $ this -> getMigrationsPath ( $ config ) ) ; if ( ! empty ( $ section ) ) { $ migrationName = 'create_' . str_plural ( strtolower ( implode ( '_' , $ splitTable ) ) ) . '_table' ; } else { $ migrationName = 'create_' . str_plural ( strtolower ( snake_case ( $ table ) ) ) . '_table' ; } $ parsedTable = '' ; $ definitions = $ this -> calibrateDefinitions ( $ schema ) ; foreach ( $ definitions as $ key => $ column ) { $ columnDefinition = explode ( ':' , $ column ) ; $ columnDetails = explode ( '|' , $ columnDefinition [ 1 ] ) ; $ columnDetailString = $ this -> createColumnDetailString ( $ columnDetails ) ; if ( $ key === 0 ) { $ parsedTable .= $ this -> getSchemaString ( $ columnDetails , $ columnDefinition , $ columnDetailString ) ; } else { $ parsedTable .= "\t\t\t" . $ this -> getSchemaString ( $ columnDetails , $ columnDefinition , $ columnDetailString ) ; } } if ( isset ( $ config [ 'relationships' ] ) && ! is_null ( $ config [ 'relationships' ] ) ) { $ relationships = explode ( ',' , $ config [ 'relationships' ] ) ; foreach ( $ relationships as $ relationship ) { $ relation = explode ( '|' , $ relationship ) ; if ( isset ( $ relation [ 2 ] ) ) { if ( ! stristr ( $ parsedTable , "integer('$relation[2]')" ) ) { $ parsedTable .= "\t\t\t\$table->integer('$relation[2]');\n" ; } } } } foreach ( $ migrationFiles as $ file ) { if ( stristr ( $ file -> getBasename ( ) , $ migrationName ) ) { $ migrationData = $ this -> filesystem -> get ( $ file -> getPathname ( ) ) ; $ migrationData = str_replace ( "\$table->increments('id');" , $ parsedTable , $ migrationData ) ; $ this -> filesystem -> put ( $ file -> getPathname ( ) , $ migrationData ) ; } } return $ parsedTable ; }
|
Create the Schema .
|
56,444
|
public function createColumnDetailString ( $ columnDetails ) { $ columnDetailString = '' ; if ( count ( $ columnDetails ) > 1 ) { array_shift ( $ columnDetails ) ; foreach ( $ columnDetails as $ key => $ detail ) { if ( $ key === 0 ) { $ columnDetailString .= '->' ; } $ columnDetailString .= $ this -> columnDetail ( $ detail ) ; if ( $ key != count ( $ columnDetails ) - 1 ) { $ columnDetailString .= '->' ; } } return $ columnDetailString ; } }
|
Create a column detail string .
|
56,445
|
public function columnDetail ( $ detail ) { $ columnDetailString = '' ; if ( stristr ( $ detail , '(' ) ) { $ columnDetailString .= $ detail ; } else { $ columnDetailString .= $ detail . '()' ; } return $ columnDetailString ; }
|
Determine column detail string .
|
56,446
|
private function getMigrationsPath ( $ config , $ relative = false ) { $ this -> fileService -> mkdir ( $ config [ '_path_migrations_' ] , 0777 , true ) ; if ( $ relative ) { return str_replace ( base_path ( ) , '' , $ config [ '_path_migrations_' ] ) ; } return $ config [ '_path_migrations_' ] ; }
|
Get the migration path .
|
56,447
|
public function actionView ( $ id ) { $ photos = GalleryPhoto :: find ( ) -> where ( [ 'gallery_id' => $ id ] ) -> orderBy ( 'name' ) -> all ( ) ; return $ this -> render ( 'view' , [ 'model' => $ this -> findModel ( $ id ) , 'photos' => $ photos , ] ) ; }
|
Displays a single Gallery model .
|
56,448
|
public function actionDelete ( $ id ) { $ request = Yii :: $ app -> request ; $ model = $ this -> findModel ( $ id ) ; $ galleryId = $ model -> gallery_id ; $ dir = Yii :: getAlias ( '@app/web/img/gallery/' . Translator :: rus2translit ( $ model -> name ) ) ; try { File :: removeDirectory ( $ dir ) ; } catch ( \ Exception $ e ) { echo ( 'Something went wrong... Error: ' . $ dir . ' - ' . $ e -> getMessage ( ) ) ; } if ( $ model -> delete ( ) ) { GalleryPhoto :: deleteAll ( [ 'gallery_id' => $ galleryId ] ) ; } if ( $ request -> isAjax ) { Yii :: $ app -> response -> format = Response :: FORMAT_JSON ; return [ 'forceClose' => false , 'forceReload' => true , 'title' => "Deliting gallery" , 'content' => 'Success!' , 'hideActionButton' => true ] ; } else { return $ this -> redirect ( [ 'index' ] ) ; } }
|
Delete an existing Gallery model . For ajax request will return json object and for non - ajax request if deletion is successful the browser will be redirected to the index page .
|
56,449
|
public function validateSchema ( $ command ) { if ( $ command -> option ( 'schema' ) ) { $ definitions = $ this -> calibrateDefinitions ( $ command -> option ( 'schema' ) ) ; foreach ( $ definitions as $ column ) { $ columnDefinition = explode ( ':' , $ column ) ; if ( ! isset ( $ columnDefinition [ 1 ] ) ) { throw new Exception ( 'All schema columns require a column type.' , 1 ) ; } $ columnDetails = explode ( '|' , $ columnDefinition [ 1 ] ) ; preg_match ( '(' . self :: VALID_COLUMN_NAME_REGEX . ')' , $ columnDetails [ 0 ] , $ columnDetailsType ) ; if ( ! in_array ( camel_case ( $ columnDetailsType [ 0 ] ) , $ command -> columnTypes ) ) { throw new Exception ( $ columnDetailsType [ 0 ] . ' is not in the array of valid column types: ' . implode ( ', ' , $ command -> columnTypes ) , 1 ) ; } } } return true ; }
|
Validate the Schema .
|
56,450
|
public function validateOptions ( $ command ) { if ( $ command -> option ( 'ui' ) && ! in_array ( $ command -> option ( 'ui' ) , [ 'bootstrap' , 'semantic' ] ) ) { throw new Exception ( 'The UI you selected is not suppported. It must be: bootstrap or semantic.' , 1 ) ; } if ( ( ! is_null ( $ command -> option ( 'schema' ) ) && ! $ command -> option ( 'migration' ) ) || ( ! is_null ( $ command -> option ( 'relationships' ) ) && ! $ command -> option ( 'migration' ) ) ) { throw new Exception ( 'In order to use Schema or Relationships you need to use Migrations' , 1 ) ; } return true ; }
|
Validate the options .
|
56,451
|
private function sliceResult ( SolrResponse $ result ) { $ pageSize = $ this -> getParamsBuilder ( ) -> getPageSize ( ) ; $ firstItemNumber = ( $ this -> getParamsBuilder ( ) -> getCurrentPage ( ) - 1 ) * $ pageSize ; $ result -> slice ( $ firstItemNumber , $ pageSize ) ; return $ result ; }
|
Remove all but last page from multipage result
|
56,452
|
public function add ( $ rawPost ) { $ service = $ this -> _selectWriteService ( ) ; do { try { return $ service -> add ( $ rawPost ) ; } catch ( Apache_Solr_HttpTransportException $ e ) { if ( $ e -> getCode ( ) != 0 ) { throw $ e ; } } $ service = $ this -> _selectWriteService ( true ) ; } while ( $ service ) ; return false ; }
|
Raw Add Method . Takes a raw post body and sends it to the update service . Post body should be a complete and well formed add xml document .
|
56,453
|
public function delete ( $ rawPost , $ timeout = 3600 ) { $ service = $ this -> _selectWriteService ( ) ; do { try { return $ service -> delete ( $ rawPost , $ timeout ) ; } catch ( Apache_Solr_HttpTransportException $ e ) { if ( $ e -> getCode ( ) != 0 ) { throw $ e ; } } $ service = $ this -> _selectWriteService ( true ) ; } while ( $ service ) ; return false ; }
|
Raw Delete Method . Takes a raw post body and sends it to the update service . Body should be a complete and well formed delete xml document
|
56,454
|
protected function _getProductData ( Product $ product , ProductIterator $ children ) { $ categoryIds = $ this -> categoryRepository -> getCategoryIds ( $ product ) ; $ productData = new IndexDocument ( array ( 'id' => $ product -> getSolrId ( ) , 'product_id' => $ product -> getId ( ) , 'category' => $ categoryIds , 'category_name_t_mv' => $ this -> categoryRepository -> getCategoryNames ( $ categoryIds , $ product -> getStoreId ( ) ) , 'store_id' => $ product -> getStoreId ( ) , 'content_type' => self :: CONTENT_TYPE , 'is_visible_in_catalog_i' => intval ( $ product -> isVisibleInCatalog ( ) ) , 'is_visible_in_search_i' => intval ( $ product -> isVisibleInSearch ( ) ) , 'has_special_price_i' => intval ( $ product -> hasSpecialPrice ( ) ) , 'is_in_stock_i' => intval ( $ product -> isInStock ( ) ) , ) ) ; $ this -> _addBoostToProductData ( $ product , $ productData ) ; $ this -> _addFacetsToProductData ( $ product , $ productData , $ children ) ; $ this -> _addSearchDataToProductData ( $ product , $ productData , $ children ) ; $ this -> _addSortingDataToProductData ( $ product , $ productData ) ; $ this -> _addResultHtmlToProductData ( $ product , $ productData ) ; $ this -> _addCategoryProductPositionsToProductData ( $ product , $ productData ) ; $ this -> eventDispatcher -> dispatch ( 'integernet_solr_get_product_data' , array ( 'product' => $ product , 'product_data' => $ productData , 'children' => $ children , ) ) ; return $ productData ; }
|
Generate single product data for Solr
|
56,455
|
protected function _isInteger ( $ rawValue ) { $ rawValues = explode ( ',' , $ rawValue ) ; foreach ( $ rawValues as $ value ) { if ( ! is_numeric ( $ value ) ) { return false ; } } return true ; }
|
The schema expected for facet attributes integer values
|
56,456
|
public function install ( string $ path = null , bool $ isDevMode = true , int $ timeout = null ) { if ( $ isDevMode ) { $ arguments = [ 'install' ] ; } else { $ arguments = [ 'install' , '--production' ] ; } if ( $ timeout === null ) { $ timeout = self :: DEFAULT_TIMEOUT ; } $ this -> executeNpm ( $ arguments , $ path , $ timeout ) ; }
|
Install NPM dependencies for the project at the supplied path .
|
56,457
|
public function update ( string $ path = null , int $ timeout = null ) { if ( $ timeout === null ) { $ timeout = self :: DEFAULT_TIMEOUT ; } $ this -> executeNpm ( [ 'update' ] , $ path , $ timeout ) ; }
|
Update NPM dependencies for the project at the supplied path .
|
56,458
|
public function setBoost ( $ boost ) { $ boost = ( float ) $ boost ; if ( $ boost > 0.0 ) { $ this -> _documentBoost = $ boost ; } else { $ this -> _documentBoost = false ; } }
|
Set document boost factor
|
56,459
|
public function addField ( $ key , $ value , $ boost = false ) { if ( ! isset ( $ this -> _fields [ $ key ] ) ) { $ this -> _fields [ $ key ] = array ( ) ; } else if ( ! is_array ( $ this -> _fields [ $ key ] ) ) { $ this -> _fields [ $ key ] = array ( $ this -> _fields [ $ key ] ) ; } if ( $ this -> getFieldBoost ( $ key ) === false ) { $ this -> setFieldBoost ( $ key , $ boost ) ; } else if ( ( float ) $ boost > 0.0 ) { $ this -> _fieldBoosts [ $ key ] *= ( float ) $ boost ; } $ this -> _fields [ $ key ] [ ] = $ value ; }
|
Add a value to a multi - valued field
|
56,460
|
public function setMultiValue ( $ key , $ value , $ boost = false ) { $ this -> addField ( $ key , $ value , $ boost ) ; }
|
Handle the array manipulation for a multi - valued field
|
56,461
|
public function getFieldBoost ( $ key ) { return isset ( $ this -> _fieldBoosts [ $ key ] ) ? $ this -> _fieldBoosts [ $ key ] : false ; }
|
Get the currently set field boost for a document field
|
56,462
|
public function setFieldBoost ( $ key , $ boost ) { $ boost = ( float ) $ boost ; if ( $ boost > 0.0 ) { $ this -> _fieldBoosts [ $ key ] = $ boost ; } else { $ this -> _fieldBoosts [ $ key ] = false ; } }
|
Set the field boost for a document field
|
56,463
|
public static function map ( $ scheme = null , $ adapter = null ) { if ( is_array ( $ scheme ) ) { foreach ( $ scheme as $ s => $ adapter ) { static :: map ( $ s , $ adapter ) ; } return static :: $ adapterMap ; } if ( $ scheme === null ) { return static :: $ adapterMap ; } if ( $ adapter === null ) { return isset ( static :: $ adapterMap [ $ scheme ] ) ? static :: $ adapterMap [ $ scheme ] : null ; } if ( $ adapter === false ) { unset ( $ adapterMap [ $ scheme ] ) ; return ; } return static :: $ adapterMap [ $ scheme ] = $ adapter ; }
|
Read or change the adapter map
|
56,464
|
public function toArray ( ) { $ raw = $ this -> dsn -> toArray ( ) ; $ allKeys = array_unique ( array_merge ( static :: $ mandatoryKeys , array_keys ( $ raw ) ) ) ; $ return = [ ] ; foreach ( $ allKeys as $ key ) { if ( isset ( $ this -> keyMap [ $ key ] ) ) { $ key = $ this -> keyMap [ $ key ] ; if ( ! $ key ) { continue ; } } $ val = $ this -> $ key ; if ( $ val !== null ) { $ return [ $ key ] = $ val ; } } return $ return ; }
|
Return the array representation of this dsn
|
56,465
|
public function keyMap ( $ keyMap = null ) { if ( ! is_null ( $ keyMap ) ) { $ this -> keyMap = $ keyMap ; } return $ this -> keyMap ; }
|
Get or set the key map
|
56,466
|
public function replacements ( $ replacements = null ) { if ( ! is_null ( $ replacements ) ) { $ this -> replacements = $ replacements ; } return $ this -> replacements ; }
|
Get or set replacements
|
56,467
|
protected function replace ( $ data , $ replacements = null ) { if ( ! is_array ( $ data ) && ! is_string ( $ data ) ) { return $ data ; } if ( ! $ replacements ) { $ replacements = $ this -> replacements ( ) ; if ( ! $ replacements ) { return $ data ; } } if ( is_array ( $ data ) ) { foreach ( $ data as $ key => & $ value ) { $ value = $ this -> replace ( $ value , $ replacements ) ; } return $ data ; } return str_replace ( array_keys ( $ replacements ) , array_values ( $ replacements ) , $ data ) ; }
|
perform string replacements on a string
|
56,468
|
public function parse ( $ data , $ chunkSize = 1024 ) { if ( ! is_string ( $ data ) && ( ! is_resource ( $ data ) || get_resource_type ( $ data ) !== 'stream' ) ) { throw new Exception ( 'Data must be a string or a stream resource' ) ; } if ( ! is_int ( $ chunkSize ) ) { throw new Exception ( 'Chunk size must be an integer' ) ; } $ this -> init ( ) ; $ this -> parse = TRUE ; $ parser = xml_parser_create ( ) ; xml_set_object ( $ parser , $ this ) ; xml_set_element_handler ( $ parser , 'start' , 'end' ) ; xml_set_character_data_handler ( $ parser , 'addCdata' ) ; xml_set_default_handler ( $ parser , 'addData' ) ; if ( is_resource ( $ data ) ) { @ fseek ( $ data , 0 ) ; while ( $ this -> parse && $ chunk = fread ( $ data , $ chunkSize ) ) { $ this -> parseString ( $ parser , $ chunk , feof ( $ data ) ) ; } } else { $ this -> parseString ( $ parser , $ data , TRUE ) ; } xml_parser_free ( $ parser ) ; return $ this ; }
|
Parses the XML provided using streaming and callbacks
|
56,469
|
public function registerCallback ( $ path , $ callback ) { if ( ! is_string ( $ path ) ) { throw new Exception ( 'Path must be a string' ) ; } if ( ! is_callable ( $ callback ) ) { throw new Exception ( 'Callback must be callable' ) ; } $ path = strtolower ( $ path ) ; if ( substr ( $ path , - 1 , 1 ) !== '/' ) { $ path .= '/' ; } if ( ! isset ( $ this -> callbacks [ $ path ] ) ) { $ this -> callback [ $ path ] = array ( ) ; } $ this -> callbacks [ $ path ] [ ] = $ callback ; return $ this ; }
|
Registers a single callback for a specified XML path
|
56,470
|
protected function init ( ) { $ this -> namespaces = array ( ) ; $ this -> currentPath = '/' ; $ this -> pathData = array ( ) ; $ this -> parse = FALSE ; }
|
Initialise the object variables
|
56,471
|
protected function parseString ( $ parser , $ data , $ isFinal ) { if ( ! xml_parse ( $ parser , $ data , $ isFinal ) ) { throw new Exception ( xml_error_string ( xml_get_error_code ( $ parser ) ) . ' At line: ' . xml_get_current_line_number ( $ parser ) ) ; } return $ parser ; }
|
Parse data using xml_parse
|
56,472
|
protected function start ( $ parser , $ tag , $ attributes ) { $ tag = strtolower ( $ tag ) ; $ this -> currentPath .= $ tag . '/' ; $ this -> fireCurrentAttributesCallbacks ( $ attributes ) ; foreach ( $ this -> callbacks as $ path => $ callbacks ) { if ( $ path === $ this -> currentPath ) { $ this -> pathData [ $ this -> currentPath ] = '' ; } } $ data = '<' . $ tag ; foreach ( $ attributes as $ key => $ val ) { $ options = ENT_QUOTES ; if ( defined ( 'ENT_XML1' ) ) { $ options |= ENT_XML1 ; } $ val = htmlentities ( $ val , $ options , "UTF-8" ) ; $ data .= ' ' . strtolower ( $ key ) . '="' . $ val . '"' ; if ( stripos ( $ key , 'xmlns:' ) !== false ) { $ key = strtolower ( $ key ) ; $ key = str_replace ( 'xmlns:' , '' , $ key ) ; $ this -> namespaces [ strtolower ( $ key ) ] = $ val ; } } $ data .= '>' ; $ this -> addData ( $ parser , $ data ) ; return $ parser ; }
|
Parses the start tag
|
56,473
|
protected function addData ( $ parser , $ data ) { foreach ( $ this -> pathData as $ key => $ val ) { if ( strpos ( $ this -> currentPath , $ key ) !== FALSE ) { $ this -> pathData [ $ key ] .= $ data ; } } return $ parser ; }
|
Adds data to any paths that require it
|
56,474
|
protected function end ( $ parser , $ tag ) { $ tag = strtolower ( $ tag ) ; $ data = '</' . $ tag . '>' ; $ this -> addData ( $ parser , $ data ) ; foreach ( $ this -> callbacks as $ path => $ callbacks ) { if ( $ this -> parse && $ this -> currentPath === $ path ) { if ( ! $ this -> fireCallbacks ( $ path , $ callbacks ) ) { break ; } } } unset ( $ this -> pathData [ $ this -> currentPath ] ) ; $ this -> currentPath = substr ( $ this -> currentPath , 0 , strlen ( $ this -> currentPath ) - ( strlen ( $ tag ) + 1 ) ) ; return $ parser ; }
|
Parses the end of a tag
|
56,475
|
protected function fireCallbacks ( $ path , array $ callbacks ) { $ namespaceStr = '' ; $ namespaces = $ this -> namespaces ; $ matches = array ( ) ; $ pathData = $ this -> pathData [ $ path ] ; $ regex = '/xmlns:(?P<namespace>[^=]+)="[^\"]+"/sm' ; if ( preg_match_all ( $ regex , $ pathData , $ matches ) ) { foreach ( $ matches [ 'namespace' ] as $ key => $ value ) { unset ( $ namespaces [ $ value ] ) ; } } foreach ( $ namespaces as $ key => $ val ) { $ namespaceStr .= ' xmlns:' . $ key . '="' . $ val . '"' ; } $ data = new SimpleXMLElement ( preg_replace ( '/^(<[^\s>]+)/' , '$1' . $ namespaceStr , $ pathData ) , LIBXML_COMPACT | LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NOCDATA ) ; foreach ( $ callbacks as $ callback ) { call_user_func_array ( $ callback , array ( $ this , $ data ) ) ; if ( ! $ this -> parse ) { return false ; } } return true ; }
|
Generates a SimpleXMLElement and passes it to each of the callbacks
|
56,476
|
protected function fireCurrentAttributesCallbacks ( $ attributes ) { foreach ( $ attributes as $ key => $ val ) { $ path = $ this -> currentPath . '@' . strtolower ( $ key ) . '/' ; if ( isset ( $ this -> callbacks [ $ path ] ) ) { foreach ( $ this -> callbacks [ $ path ] as $ callback ) { call_user_func_array ( $ callback , array ( $ this , $ val ) ) ; } } } }
|
Traverses the passed attributes assuming the currentPath and invokes registered callbacks if there are any
|
56,477
|
public function find ( Composer $ composer , NpmBridge $ bridge ) : array { $ packages = $ composer -> getRepositoryManager ( ) -> getLocalRepository ( ) -> getPackages ( ) ; $ dependantPackages = [ ] ; foreach ( $ packages as $ package ) { if ( $ bridge -> isDependantPackage ( $ package , false ) ) { $ dependantPackages [ ] = $ package ; } } return $ dependantPackages ; }
|
Find all NPM bridge enabled vendor packages .
|
56,478
|
private function hasOperatorInStack ( ) { $ hasOperatorInStack = false ; if ( ! $ this -> operatorStack -> isEmpty ( ) ) { $ top = $ this -> operatorStack -> top ( ) ; if ( Token :: T_OPERATOR == $ top -> getType ( ) ) { $ hasOperatorInStack = true ; } } return $ hasOperatorInStack ; }
|
Determine if there is operator token in operato stack
|
56,479
|
public function createCommitXml ( $ expungeDeletes = false , $ waitFlush = true , $ waitSearcher = true , $ timeout = 3600 , $ softCommit = false ) { $ expungeValue = $ expungeDeletes ? 'true' : 'false' ; $ searcherValue = $ waitSearcher ? 'true' : 'false' ; $ softCommitValue = $ softCommit ? 'true' : 'false' ; $ rawPost = '<commit expungeDeletes="' . $ expungeValue . '" softCommit="' . $ softCommitValue . '" waitSearcher="' . $ searcherValue . '" />' ; return $ rawPost ; }
|
Creates a commit command XML string .
|
56,480
|
public function createOptimizeXml ( $ waitFlush = true , $ waitSearcher = true ) { $ searcherValue = $ waitSearcher ? 'true' : 'false' ; $ rawPost = '<optimize waitSearcher="' . $ searcherValue . '" />' ; return $ rawPost ; }
|
Creates an optimize command XML string .
|
56,481
|
public function createAddDocumentXmlFragment ( $ rawDocuments , $ allowDups = false , $ overwritePending = true , $ overwriteCommitted = true , $ commitWithin = 0 ) { $ dupValue = ! $ allowDups ? 'true' : 'false' ; $ commitWithin = ( int ) $ commitWithin ; $ commitWithinString = $ commitWithin > 0 ? " commitWithin=\"{$commitWithin}\"" : '' ; $ addXmlFragment = "<add overwrite=\"{$dupValue}\"{$commitWithinString}>" ; $ addXmlFragment .= $ rawDocuments ; $ addXmlFragment .= '</add>' ; return $ addXmlFragment ; }
|
Creates an add command XML string
|
56,482
|
public function validate ( $ attribute , $ value , $ parameters ) { if ( $ parameters ) { $ this -> dictionary -> setDictionary ( $ parameters ) ; $ this -> badwords = $ this -> dictionary -> getDictionary ( ) ; } return ! $ this -> isProfane ( $ value ) ; }
|
Method to extends to Validator .
|
56,483
|
public function addConnection ( $ uriString ) { if ( ! isset ( self :: $ connectionList [ $ uriString ] ) ) { self :: $ connectionList [ $ uriString ] = Factory :: getDbRelationalInstance ( $ uriString ) ; if ( self :: $ transaction ) { self :: $ connectionList [ $ uriString ] -> beginTransaction ( ) ; } } return self :: $ connectionList [ $ uriString ] ; }
|
Add or reuse a connection
|
56,484
|
public function beginTransaction ( ) { if ( self :: $ transaction ) { throw new TransactionException ( "Transaction Already Started" ) ; } self :: $ transaction = true ; foreach ( self :: $ connectionList as $ dbDriver ) { $ dbDriver -> beginTransaction ( ) ; } }
|
Start a database transaction with the opened connections
|
56,485
|
public function commitTransaction ( ) { if ( ! self :: $ transaction ) { throw new TransactionException ( "There is no Active Transaction" ) ; } self :: $ transaction = false ; foreach ( self :: $ connectionList as $ dbDriver ) { $ dbDriver -> commitTransaction ( ) ; } }
|
Commit all open transactions
|
56,486
|
public function rollbackTransaction ( ) { if ( ! self :: $ transaction ) { throw new TransactionException ( "There is no Active Transaction" ) ; } self :: $ transaction = false ; foreach ( self :: $ connectionList as $ dbDriver ) { $ dbDriver -> rollbackTransaction ( ) ; } }
|
Rollback all open transactions
|
56,487
|
public function destroy ( ) { foreach ( self :: $ connectionList as $ dbDriver ) { if ( self :: $ transaction ) { $ dbDriver -> commitTransaction ( ) ; } } self :: $ transaction = false ; self :: $ connectionList = [ ] ; }
|
Destroy all connections
|
56,488
|
public function activate ( Composer $ composer , IOInterface $ io ) { class_exists ( NpmBridge :: class ) ; class_exists ( NpmBridgeFactory :: class ) ; class_exists ( NpmClient :: class ) ; class_exists ( NpmBridge :: class ) ; class_exists ( NpmVendorFinder :: class ) ; }
|
Activate the plugin .
|
56,489
|
public function onPostUpdateCmd ( Event $ event ) { $ this -> bridgeFactory -> createBridge ( $ event -> getIO ( ) ) -> update ( $ event -> getComposer ( ) ) ; }
|
Handle post update command events .
|
56,490
|
public function evaluate ( $ expression ) { $ lexer = $ this -> getLexer ( ) ; $ tokens = $ lexer -> tokenize ( $ expression ) ; $ translationStrategy = new \ Math \ TranslationStrategy \ ShuntingYard ( ) ; return $ this -> evaluateRPN ( $ translationStrategy -> translate ( $ tokens ) ) ; }
|
Evaluate string representing mathematical expression .
|
56,491
|
public static function checkIBAN ( $ iban , $ options = null ) { $ iban = preg_replace ( '/\s+/u' , '' , $ iban ) ; $ iban = strtoupper ( $ iban ) ; if ( ! preg_match ( '/^' . self :: PATTERN_IBAN . '$/' , $ iban ) ) return false ; $ ibanCopy = $ iban ; if ( ! isset ( $ options [ 'checkByFormat' ] ) || $ options [ 'checkByFormat' ] ) { $ countryCode = substr ( $ iban , 0 , 2 ) ; if ( isset ( self :: $ ibanPatterns [ $ countryCode ] ) && ! preg_match ( '/^' . self :: $ ibanPatterns [ $ countryCode ] . '$/' , $ iban ) ) return false ; } if ( ! isset ( $ options [ 'checkByCheckSum' ] ) || $ options [ 'checkByCheckSum' ] ) { $ iban = $ check = str_replace ( self :: $ alphabet , self :: $ alphabetValues , $ iban ) ; $ bban = substr ( $ iban , 6 ) ; $ check = substr ( $ iban , 0 , 6 ) ; $ concat = $ bban . $ check ; if ( ! self :: iso7064Mod97m10ChecksumCheck ( $ concat ) ) return false ; } return $ ibanCopy ; }
|
Checks if an iban is valid . Note that also if the iban is valid it does not have to exist
|
56,492
|
public static function checkBIC ( $ bic , array $ options = null ) { $ bic = preg_replace ( '/\s+/u' , '' , $ bic ) ; if ( ! empty ( $ options [ 'forceLongBic' ] ) && strlen ( $ bic ) === 8 ) $ bic .= empty ( $ options [ 'forceLongBicStr' ] ) ? 'XXX' : $ options [ 'forceLongBicStr' ] ; if ( empty ( $ bic ) && ! empty ( $ options [ 'allowEmptyBic' ] ) ) return '' ; $ bic = strtoupper ( $ bic ) ; if ( preg_match ( '/^' . self :: PATTERN_BIC . '$/' , $ bic ) ) return $ bic ; else return false ; }
|
Checks if a bic is valid . Note that also if the bic is valid it does not have to exist
|
56,493
|
public static function isNationalTransaction ( $ iban1 , $ iban2 ) { $ iban1 = preg_replace ( '#\s+#' , '' , $ iban1 ) ; $ iban2 = preg_replace ( '#\s+#' , '' , $ iban2 ) ; if ( stripos ( $ iban1 , substr ( $ iban2 , 0 , 2 ) ) === 0 ) return true ; else return false ; }
|
Checks if both IBANs do belong to the same country . This function does not check if the IBANs are valid .
|
56,494
|
public static function crossCheckIbanBic ( $ iban , $ bic ) { if ( in_array ( strtoupper ( $ bic ) , self :: $ exceptionalBics ) ) return true ; $ iban = preg_replace ( '#\s+#' , '' , $ iban ) ; $ bic = preg_replace ( '#\s+#' , '' , $ bic ) ; $ ibanCountryCode = strtoupper ( substr ( $ iban , 0 , 2 ) ) ; $ bicCountryCode = strtoupper ( substr ( $ bic , 4 , 2 ) ) ; if ( $ ibanCountryCode === $ bicCountryCode || ( isset ( self :: $ bicIbanCountryCodeExceptions [ $ ibanCountryCode ] ) && in_array ( $ bicCountryCode , self :: $ bicIbanCountryCodeExceptions [ $ ibanCountryCode ] ) ) ) return true ; else return false ; }
|
Checks if IBAN and BIC belong to the same country . If not they also can not belong to each other .
|
56,495
|
public static function getDateWithMinOffsetFromToday ( $ target , $ workdayMinOffset , $ inputFormat = 'd.m.Y' , $ today = null ) { $ targetDateObj = \ DateTime :: createFromFormat ( $ inputFormat , $ target ) ; $ earliestDate = self :: getDateWithOffset ( $ workdayMinOffset , $ today , $ inputFormat ) ; if ( $ targetDateObj === false || $ earliestDate === false ) return false ; $ earliestDateObj = new \ DateTime ( $ earliestDate ) ; $ isTargetDay = self :: dateIsTargetDay ( $ targetDateObj ) ; while ( ! $ isTargetDay ) { $ targetDateObj -> modify ( '+1 day' ) ; $ isTargetDay = self :: dateIsTargetDay ( $ targetDateObj ) ; } if ( strcmp ( $ targetDateObj -> format ( 'Y-m-d' ) , $ earliestDateObj -> format ( 'Y-m-d' ) ) > 0 ) return $ targetDateObj -> format ( 'Y-m-d' ) ; else return $ earliestDateObj -> format ( 'Y-m-d' ) ; }
|
Returns the target date if it has at least the given offset of TARGET2 days form today . Else the earliest date that respects the offset is returned .
|
56,496
|
public static function check ( $ field , $ input , array $ options = null , $ version = null ) { $ field = strtolower ( $ field ) ; switch ( $ field ) { case 'orgnlcdtrschmeid_id' : case 'ci' : return self :: checkCreditorIdentifier ( $ input ) ; case 'msgid' : case 'pmtid' : case 'pmtinfid' : return self :: checkRestrictedIdentificationSEPA1 ( $ input ) ; case 'orgnlmndtid' : case 'mndtid' : return $ version === self :: SEPA_PAIN_008_001_02 || $ version === self :: SEPA_PAIN_008_001_02_GBIC ? self :: checkRestrictedIdentificationSEPA1 ( $ input ) : self :: checkRestrictedIdentificationSEPA2 ( $ input ) ; case 'initgpty' : case 'cdtr' : case 'dbtr' : if ( empty ( $ input ) ) return false ; case 'orgid_id' : return ( self :: checkLength ( $ input , self :: TEXT_LENGTH_VERY_SHORT ) && self :: checkCharset ( $ input ) ) ? $ input : false ; case 'orgnlcdtrschmeid_nm' : case 'ultmtcdtr' : case 'ultmtdbtr' : return ( self :: checkLength ( $ input , self :: TEXT_LENGTH_SHORT ) && self :: checkCharset ( $ input ) ) ? $ input : false ; case 'rmtinf' : return ( self :: checkLength ( $ input , self :: TEXT_LENGTH_LONG ) && self :: checkCharset ( $ input ) ) ? $ input : false ; case 'orgnldbtracct_iban' : case 'iban' : return self :: checkIBAN ( $ input , $ options ) ; case 'orgnldbtragt_bic' : case 'orgid_bob' : case 'bic' : return self :: checkBIC ( $ input , $ options ) ; case 'ccy' : return self :: checkActiveOrHistoricCurrencyCode ( $ input ) ; case 'amdmntind' : case 'btchbookg' : return self :: checkBoolean ( $ input ) ; case 'instdamt' : return self :: checkAmountFormat ( $ input ) ; case 'seqtp' : return self :: checkSeqType ( $ input ) ; case 'lclinstrm' : return self :: checkLocalInstrument ( $ input , $ options ) ; case 'elctrncsgntr' : return ( self :: checkLength ( $ input , 1025 ) && self :: checkCharset ( $ input ) ) ? $ input : false ; case 'dtofsgntr' : case 'reqdcolltndt' : case 'reqdexctndt' : return self :: checkDateFormat ( $ input ) ; case 'purp' : return self :: checkPurpose ( $ input ) ; case 'ctgypurp' : return self :: checkCategoryPurpose ( $ input ) ; case 'orgnldbtragt' : return $ input ; default : return false ; } }
|
Checks if the input holds for the field .
|
56,497
|
public static function checkAndSanitize ( $ field , $ input , $ flags = 0 , array $ options = null ) { $ checkedInput = self :: check ( $ field , $ input , $ options ) ; if ( $ checkedInput !== false ) return $ checkedInput ; return self :: sanitize ( $ field , $ input , $ flags ) ; }
|
Checks the input and if it is not valid it tries to sanitize it .
|
56,498
|
public static function sanitize ( $ field , $ input , $ flags = 0 ) { $ field = strtolower ( $ field ) ; switch ( $ field ) { case 'orgid_id' : return self :: sanitizeText ( self :: TEXT_LENGTH_VERY_SHORT , $ input , true , $ flags ) ; case 'ultmtcdrt' : case 'ultmtdebtr' : return self :: sanitizeText ( self :: TEXT_LENGTH_SHORT , $ input , true , $ flags ) ; case 'orgnlcdtrschmeid_nm' : case 'initgpty' : case 'cdtr' : case 'dbtr' : return self :: sanitizeText ( self :: TEXT_LENGTH_SHORT , $ input , false , $ flags ) ; case 'rmtinf' : return self :: sanitizeText ( self :: TEXT_LENGTH_LONG , $ input , true , $ flags ) ; default : return false ; } }
|
Tries to sanitize the the input so it fits in the field .
|
56,499
|
public static function sanitizeLength ( $ input , $ maxLen ) { if ( isset ( $ input [ $ maxLen ] ) ) return substr ( $ input , 0 , $ maxLen ) ; else return $ input ; }
|
Shortens the input string to the max length if it is to long .
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.