idx int64 0 60.3k | question stringlengths 101 6.21k | target stringlengths 7 803 |
|---|---|---|
20,000 | protected function resolveFormat ( \ DateInterval $ interval ) : string { $ baseFormat = $ this -> resolveBaseFormat ( $ interval ) ; $ timeFormat = $ this -> resolveTimeFormat ( $ interval ) ; if ( $ baseFormat === '' ) { if ( $ timeFormat === '' ) { return '' ; } return 'PT' . $ timeFormat ; } if ( $ timeFormat === '' ) { return 'P' . $ baseFormat ; } return 'P' . $ baseFormat . 'T' . $ timeFormat ; } | Resolve ISO_8601 duration format |
20,001 | protected function resolveBaseFormat ( \ DateInterval $ interval ) : string { $ format = '' ; if ( $ interval -> y > 0 ) { $ format .= '%yY' ; } if ( $ interval -> m > 0 ) { $ format .= '%mM' ; } if ( $ interval -> d > 0 ) { $ format .= '%dD' ; } return $ format ; } | Resolve base part of interval format |
20,002 | protected function resolveTimeFormat ( \ DateInterval $ interval ) : string { $ format = '' ; if ( $ interval -> h > 0 ) { $ format .= '%hH' ; } if ( $ interval -> i > 0 ) { $ format .= '%iM' ; } if ( $ interval -> s > 0 ) { $ format .= '%sS' ; } return $ format ; } | Resolve time part of interval format |
20,003 | public static function getInstance ( ServerRequestInterface $ request ) { if ( is_null ( self :: $ instance ) ) { $ class = get_called_class ( ) ; self :: $ instance = new $ class ( $ request ) ; } return self :: $ instance ; } | Singleton pour une classe abstraite . |
20,004 | public function run ( ) { $ request = clone $ this -> request ; $ response = new Response ( 404 , new Stream ( null ) ) ; $ this -> container -> callHook ( 'app.response.before' , [ & $ request , & $ response ] ) ; if ( ( $ route = $ this -> router -> parse ( $ request ) ) && $ response -> getStatusCode ( ) == 404 ) { $ this -> container -> callHook ( $ route [ 'key' ] . '.response.before' , [ & $ request , & $ response ] ) ; $ exec = $ this -> router -> execute ( $ route , $ request ) ; $ response = $ this -> parseResponse ( $ exec ) ; $ this -> container -> callHook ( $ route [ 'key' ] . '.response.after' , [ $ this -> request , & $ response ] ) ; } $ this -> container -> callHook ( 'app.' . $ response -> getStatusCode ( ) , [ $ this -> request , & $ response ] ) ; $ this -> container -> callHook ( 'app.response.after' , [ $ this -> request , & $ response ] ) ; return $ response ; } | Lance l application . |
20,005 | protected function loadRoutesAndServices ( ) { foreach ( $ this -> modules as $ module ) { if ( $ module -> getPathRoutes ( ) ) { $ routesConfig = Util :: getJson ( $ module -> getPathRoutes ( ) ) ; $ this -> routes += $ routesConfig ; } if ( $ module -> getPathServices ( ) ) { $ servicesConfig = Util :: getJson ( $ module -> getPathServices ( ) ) ; $ this -> services += $ servicesConfig ; } } } | Cherche les routes des modules et les charge dans l application . |
20,006 | protected function readConfig ( string $ path ) : array { if ( ! is_readable ( $ path ) ) { throw new DefinitionProviderException ( sprintf ( 'File "%s" with definition is not readable.' , $ path ) ) ; } $ content = file_get_contents ( $ path ) ; $ config = $ this -> parser -> parse ( $ content ) ; $ schema = $ this -> getSchema ( ) ; return $ this -> processor -> process ( $ schema , [ $ config ] ) ; } | Read configuration of mapping definition |
20,007 | protected function getSchema ( ) : NodeInterface { if ( $ this -> schema === null ) { $ this -> schema = $ this -> config -> getConfigTreeBuilder ( ) -> buildTree ( ) ; } return $ this -> schema ; } | Get schema of mapping definition |
20,008 | public function create ( int $ fleetId , string $ fullname , string $ identification , array $ optional = [ ] ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> sendJson ( 'POST' , "fleets/{$fleetId}/drivers" , $ this -> getApiHeaders ( ) , \ array_merge ( $ optional , \ compact ( 'fullname' , 'identification' ) ) ) ; } | Create driver for a fleet . |
20,009 | protected function createDefinition ( \ ReflectionClass $ reflection ) : Definition { $ definition = new Definition ( $ reflection -> getName ( ) ) ; foreach ( $ this -> processors as $ processor ) { $ processor -> process ( $ reflection , $ definition ) ; } $ parent = $ reflection -> getParentClass ( ) ; if ( $ parent !== false ) { $ definition -> merge ( $ this -> createDefinition ( $ parent ) ) ; } foreach ( $ reflection -> getTraits ( ) as $ trait ) { $ definition -> merge ( $ this -> createDefinition ( $ trait ) ) ; } return $ definition ; } | Create definition for given class |
20,010 | protected function createLink ( LinkDefinition $ definition , LinkData $ data ) : LinkObject { $ reference = $ data -> getReference ( ) ; $ metadata = array_replace ( $ data -> getMetadata ( ) , $ definition -> getMetadata ( ) ) ; return new LinkObject ( $ reference , $ metadata ) ; } | Create link - object |
20,011 | function run ( ) { ini_set ( 'display_errors' , 'Off' ) ; error_reporting ( E_ALL | E_STRICT ) ; if ( ! defined ( 'SERVER_MODE' ) ) { define ( 'SERVER_MODE' , 'fpm' ) ; } try { $ route = ( \ ePHP \ Core \ Route :: init ( ) ) -> findRoute ( ) ; if ( empty ( $ route ) ) { \ show_404 ( ) ; } $ _GET [ 'controller' ] = $ route [ 0 ] ; $ _GET [ 'action' ] = $ route [ 1 ] ; $ controller_name = $ route [ 2 ] ; $ action_name = $ _GET [ 'action' ] ; $ _REQUEST = array_merge ( $ _COOKIE , $ _GET , $ _POST ) ; if ( ! method_exists ( $ controller_name , $ action_name ) ) { if ( defined ( 'RUN_ENV' ) && RUN_ENV == 'prod' ) { \ show_404 ( ) ; } else { \ show_error ( "method {$action_name}() is not defined in {$controller_name}" ) ; } } if ( SERVER_MODE === 'fpm' ) { call_user_func ( [ new $ controller_name ( ) , $ action_name ] ) ; } else if ( SERVER_MODE === 'swoole' ) { try { call_user_func ( [ new $ controller_name ( ) , $ action_name ] ) ; } catch ( \ Swoole \ ExitException $ e ) { return ; } } } catch ( \ ePHP \ Exception \ CommonException $ e ) { if ( $ e -> getCode ( ) === - 99 ) { return ; } echo $ e ; } } | Start run the application |
20,012 | public function update ( array $ payload ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> sendJson ( 'PATCH' , 'profile' , $ this -> getApiHeaders ( ) , $ this -> mergeApiBody ( $ payload ) ) ; } | Update user profile . |
20,013 | public function verifyPassword ( string $ password ) : bool { $ this -> requiresAccessToken ( ) ; try { $ response = $ this -> send ( 'POST' , 'auth/verify' , $ this -> getApiHeaders ( ) , $ this -> mergeApiBody ( compact ( 'password' ) ) ) ; } catch ( UnauthorizedException $ e ) { return false ; } return $ response -> toArray ( ) [ 'success' ] === true ; } | Verify user password . |
20,014 | public function uploadAvatar ( string $ file ) : Response { $ this -> requiresAccessToken ( ) ; return $ this -> stream ( 'POST' , 'profile/avatar' , $ this -> getApiHeaders ( ) , $ this -> getApiBody ( ) , compact ( 'file' ) ) ; } | Upload profile avatar . |
20,015 | protected function registerContactMailer ( ) { $ this -> app -> bind ( 'contact.mailer' , function ( $ app ) { $ mail = $ app [ 'mailer' ] ; $ home = $ app [ 'url' ] -> to ( '/' ) ; $ path = $ app [ 'config' ] [ 'contact.path' ] ; $ email = $ app [ 'config' ] [ 'contact.email' ] ; $ name = $ app [ 'config' ] [ 'app.name' ] ; return new Mailer ( $ mail , $ home , $ path , $ email , $ name ) ; } ) ; $ this -> app -> alias ( 'contact.mailer' , Mailer :: class ) ; } | Register the contact mailer class . |
20,016 | protected function registerContactController ( ) { $ this -> app -> bind ( ContactController :: class , function ( $ app ) { $ throttler = $ app [ 'throttle' ] -> get ( $ app [ 'request' ] , 2 , 30 ) ; $ path = $ app [ 'config' ] [ 'contact.path' ] ; return new ContactController ( $ throttler , $ path ) ; } ) ; } | Register the contact controller class . |
20,017 | public function verifyRequiredFields ( ) { foreach ( $ this -> Fields ( ) as $ field ) { if ( ! $ field [ "required" ] ) { continue ; } if ( ! $ this -> verifyRequiredFieldIsAvailable ( $ field [ "id" ] ) ) { return Splash :: log ( ) -> err ( "ErrLocalFieldMissing" , __CLASS__ , __FUNCTION__ , $ field [ "name" ] . "(" . $ field [ "id" ] . ")" ) ; } } return true ; } | Check Required Fields are Available |
20,018 | private function setObjectData ( ) { $ fields = is_a ( $ this -> in , "ArrayObject" ) ? $ this -> in -> getArrayCopy ( ) : $ this -> in ; foreach ( $ fields as $ fieldName => $ fieldData ) { foreach ( $ this -> identifySetMethods ( ) as $ method ) { $ this -> { $ method } ( $ fieldName , $ fieldData ) ; } } if ( count ( $ this -> in ) ) { foreach ( $ this -> in as $ fieldName => $ fieldData ) { Splash :: log ( ) -> err ( "ErrLocalWrongField" , __CLASS__ , __FUNCTION__ , $ fieldName ) ; } return false ; } return true ; } | Execute Write Operations on Object |
20,019 | private static function identifyMethods ( $ prefix ) { $ result = array ( ) ; foreach ( get_class_methods ( __CLASS__ ) as $ method ) { if ( 0 !== strpos ( $ method , $ prefix ) ) { continue ; } if ( false === strpos ( $ method , "Fields" ) ) { continue ; } $ result [ ] = $ method ; } return $ result ; } | Identify Generic Functions |
20,020 | private function verifyRequiredFieldIsAvailable ( $ fieldId ) { if ( ! method_exists ( $ this , "Lists" ) || ! self :: lists ( ) -> listName ( $ fieldId ) ) { if ( empty ( $ this -> in [ $ fieldId ] ) ) { return false ; } return true ; } $ listName = self :: lists ( ) -> ListName ( $ fieldId ) ; $ fieldName = self :: lists ( ) -> FieldName ( $ fieldId ) ; if ( empty ( $ this -> in [ $ listName ] ) ) { return false ; } if ( ! is_array ( $ this -> in [ $ listName ] ) && ! is_a ( $ this -> in [ $ listName ] , "ArrayObject" ) ) { return false ; } foreach ( $ this -> in [ $ listName ] as $ item ) { if ( empty ( $ item [ $ fieldName ] ) ) { return false ; } } return true ; } | Check Required Fields |
20,021 | private function getConfigurationValue ( $ key1 , $ key2 = null ) { $ config = $ this -> getConfiguration ( ) ; if ( ! is_array ( $ config ) || empty ( $ config ) ) { return null ; } if ( ! isset ( $ config [ $ key1 ] ) ) { return null ; } if ( is_null ( $ key2 ) ) { return $ config [ $ key1 ] ; } return isset ( $ config [ $ key1 ] [ $ key2 ] ) ? $ config [ $ key1 ] [ $ key2 ] : null ; } | Read Configuration Value |
20,022 | private static function sercureParameters ( & $ parameters ) { if ( ! empty ( Splash :: input ( 'SPLASH_TRAVIS' ) ) ) { return ; } foreach ( self :: UNSECURED_PARAMETERS as $ index ) { if ( isset ( $ parameters [ $ index ] ) ) { unset ( $ parameters [ $ index ] ) ; } } } | Remove Potentially Unsecure Parameters from Configuration |
20,023 | private static function updateField ( $ field , $ values ) { Splash :: log ( ) -> trace ( ) ; if ( ! is_array ( $ values ) ) { return $ field ; } self :: updateFieldStrVal ( $ field , $ values , "type" ) ; self :: updateFieldStrVal ( $ field , $ values , "name" ) ; self :: updateFieldStrVal ( $ field , $ values , "desc" ) ; self :: updateFieldStrVal ( $ field , $ values , "group" ) ; self :: updateFieldMeta ( $ field , $ values ) ; self :: updateFieldStrVal ( $ field , $ values , "syncmode" ) ; self :: updateFieldBoolVal ( $ field , $ values , "required" ) ; self :: updateFieldBoolVal ( $ field , $ values , "read" ) ; self :: updateFieldBoolVal ( $ field , $ values , "write" ) ; self :: updateFieldBoolVal ( $ field , $ values , "inlist" ) ; self :: updateFieldBoolVal ( $ field , $ values , "log" ) ; return $ field ; } | Override a Field Definition |
20,024 | private static function updateFieldStrVal ( & $ field , $ values , $ key ) { if ( isset ( $ values [ $ key ] ) && is_string ( $ values [ $ key ] ) ) { $ field -> { $ key } = $ values [ $ key ] ; } } | Override a Field String Definition |
20,025 | private static function updateFieldBoolVal ( & $ field , $ values , $ key ) { if ( isset ( $ values [ $ key ] ) && is_scalar ( $ values [ $ key ] ) ) { $ field -> { $ key } = ( bool ) $ values [ $ key ] ; } } | Override a Field Bool Definition |
20,026 | private static function updateFieldMeta ( & $ field , $ values ) { self :: updateFieldStrVal ( $ field , $ values , "itemtype" ) ; self :: updateFieldStrVal ( $ field , $ values , "itemprop" ) ; if ( isset ( $ values [ "itemprop" ] ) || isset ( $ values [ "itemtype" ] ) ) { if ( is_string ( $ field -> itemprop ) && is_string ( $ field -> itemtype ) ) { $ field -> tag = md5 ( $ field -> itemprop . IDSPLIT . $ field -> itemtype ) ; } } } | Override a Field Meta Definition |
20,027 | public function get ( $ id ) { if ( empty ( $ this -> instances [ $ id ] ) ) { $ declarations = $ this -> getFeatureTypeDeclarations ( ) ; if ( empty ( $ declarations [ $ id ] ) ) { throw new \ RuntimeException ( "No FeatureType with id " . var_export ( $ id , true ) ) ; } $ this -> instances [ $ id ] = new FeatureType ( $ this -> container , $ declarations [ $ id ] ) ; } return $ this -> instances [ $ id ] ; } | Get feature type by name |
20,028 | public function search ( ) { foreach ( $ this -> getFeatureTypeDeclarations ( ) as $ id => $ declaration ) { if ( empty ( $ this -> instances [ $ id ] ) ) { $ this -> instances [ $ id ] = new FeatureType ( $ this -> container , $ declaration ) ; } } return $ this -> instances ; } | Search feature types |
20,029 | public function createMessage ( $ charset = 'UTF-8' ) { $ closure = $ this -> closure ; return new \ Aimeos \ MW \ Mail \ Message \ Typo3 ( $ closure ( ) , $ charset ) ; } | Creates a new e - mail message object . |
20,030 | public function send ( \ Aimeos \ MW \ Mail \ Message \ Iface $ message ) { $ message -> getObject ( ) -> send ( ) ; } | Sends the e - mail message to the mail server . |
20,031 | public function merge ( self $ attribute ) { if ( $ this -> propertyName === null && $ attribute -> hasPropertyName ( ) ) { $ this -> propertyName = $ attribute -> getPropertyName ( ) ; } if ( $ this -> type === null && $ attribute -> hasType ( ) ) { $ this -> type = $ attribute -> getType ( ) ; } if ( $ this -> many === null && $ attribute -> hasManyDefined ( ) ) { $ this -> many = $ attribute -> isMany ( ) ; } if ( empty ( $ this -> typeParameters ) ) { $ this -> typeParameters = $ attribute -> getTypeParameters ( ) ; } if ( $ this -> processNull === null && $ attribute -> hasProcessNull ( ) ) { $ this -> processNull = $ attribute -> getProcessNull ( ) ; } } | Merge a attribute into this one |
20,032 | public function execute ( array $ args , array $ options = array ( ) ) { if ( ! count ( $ args ) ) { throw new ConsoleException ( "Missing subcommand name" ) ; } $ command = ucfirst ( Utils :: camelize ( array_shift ( $ args ) ) ) ; $ methodName = "execute$command" ; if ( ! method_exists ( $ this , $ methodName ) ) { throw new ConsoleException ( "Command '$command' does not exist" ) ; } $ method = new ReflectionMethod ( $ this , $ methodName ) ; $ params = Utils :: computeFuncParams ( $ method , $ args , $ options ) ; return $ method -> invokeArgs ( $ this , $ params ) ; } | If not overriden will execute the command specified as the first argument |
20,033 | public function writeerr ( $ text ) { return $ this -> write ( $ text , Colors :: RED | Colors :: BOLD , TextWriter :: STDERR ) ; } | Writes a message in bold red to STDERR |
20,034 | protected function includes ( $ includes ) { $ includes = \ is_array ( $ includes ) ? $ includes : \ func_get_args ( ) ; $ this -> includes = $ includes ; return $ this ; } | Set includes data . |
20,035 | protected function onTimeZone ( ? string $ timeZoneCode ) { if ( \ is_null ( $ timeZoneCode ) ) { $ this -> timezone = null ; } elseif ( \ in_array ( $ timeZoneCode , \ timezone_identifiers_list ( ) ) ) { $ this -> timezone = $ timeZoneCode ; } return $ this ; } | Set timezone for the request input . |
20,036 | protected function excludes ( $ excludes ) { $ excludes = \ is_array ( $ excludes ) ? $ excludes : \ func_get_args ( ) ; $ this -> excludes = $ excludes ; return $ this ; } | Set excludes data . |
20,037 | public function build ( callable $ callback ) : array { $ data = [ ] ; foreach ( [ 'includes' , 'excludes' ] as $ key ) { if ( ! empty ( $ this -> { $ key } ) ) { $ data [ $ key ] = \ implode ( ',' , $ this -> { $ key } ) ; } } if ( ! \ is_null ( $ this -> timezone ) ) { $ data [ 'timezone' ] = $ this -> timezone ; } if ( \ is_int ( $ this -> page ) && $ this -> page > 0 ) { $ data [ 'page' ] = $ this -> page ; if ( \ is_int ( $ this -> perPage ) && $ this -> perPage > 5 ) { $ data [ 'per_page' ] = $ this -> perPage ; } } return \ call_user_func ( $ callback , $ data , $ this -> customs ) ; } | Build query string . |
20,038 | protected function getApiHeaders ( ) : array { $ headers = [ 'Accept' => "application/vnd.KATSANA.{$this->getVersion()}+json" , 'Time-Zone' => $ this -> requestHeaderTimezoneCode ?? 'UTC' , ] ; if ( ! \ is_null ( $ accessToken = $ this -> client -> getAccessToken ( ) ) ) { $ headers [ 'Authorization' ] = "Bearer {$accessToken}" ; } return $ headers ; } | Get API Header . |
20,039 | final public function onTimeZone ( string $ timeZoneCode ) : self { if ( \ in_array ( $ timeZoneCode , \ timezone_identifiers_list ( ) ) ) { $ this -> requestHeaderTimezoneCode = $ timeZoneCode ; } return $ this ; } | Set timezone code . |
20,040 | public function setDebug ( $ debug ) { $ this -> debug = $ debug ; if ( ( 0 == $ debug ) && isset ( $ this -> debug ) ) { $ this -> deb = array ( ) ; } return true ; } | Set Debug Flag & Clean buffers if needed |
20,041 | public function err ( $ text = null , $ param1 = '' , $ param2 = '' , $ param3 = '' , $ param4 = '' ) { if ( is_null ( $ text ) ) { return false ; } $ message = Splash :: trans ( $ text , ( string ) $ param1 , ( string ) $ param2 , ( string ) $ param3 , ( string ) $ param4 ) ; $ this -> coreAddLog ( 'err' , $ message ) ; self :: addLogToFile ( $ message , 'ERROR' ) ; return false ; } | Log WebServer Error Messages |
20,042 | public function war ( $ text = null , $ param1 = '' , $ param2 = '' , $ param3 = '' , $ param4 = '' ) { if ( is_null ( $ text ) ) { return true ; } $ message = Splash :: trans ( $ text , ( string ) $ param1 , ( string ) $ param2 , ( string ) $ param3 , ( string ) $ param4 ) ; $ this -> coreAddLog ( 'war' , $ message ) ; self :: addLogToFile ( $ message , 'WARNING' ) ; return true ; } | Log WebServer Warning Messages |
20,043 | public function trace ( ) { if ( ! isset ( $ this -> debug ) || ! $ this -> debug ) { return ; } $ trace = ( new Exception ( ) ) -> getTrace ( ) [ 1 ] ; Splash :: translator ( ) -> load ( 'main' ) ; return self :: deb ( "DebTraceMsg" , $ trace [ "class" ] , $ trace [ "function" ] ) ; } | Log a Debug Message With Trace from Stack |
20,044 | public function cleanLog ( ) { if ( isset ( $ this -> err ) ) { $ this -> err = array ( ) ; } if ( isset ( $ this -> war ) ) { $ this -> war = array ( ) ; } if ( isset ( $ this -> msg ) ) { $ this -> msg = array ( ) ; } if ( isset ( $ this -> deb ) ) { $ this -> deb = array ( ) ; } $ this -> deb ( 'Log Messages Buffer Cleaned' ) ; return true ; } | Clean WebServer Class Logs Messages |
20,045 | public function getRawLog ( $ clean = false ) { $ raw = new ArrayObject ( array ( ) , ArrayObject :: ARRAY_AS_PROPS ) ; if ( $ this -> err ) { $ raw -> err = $ this -> err ; } if ( $ this -> war ) { $ raw -> war = $ this -> war ; } if ( $ this -> msg ) { $ raw -> msg = $ this -> msg ; } if ( $ this -> deb ) { $ raw -> deb = $ this -> deb ; } if ( $ clean ) { $ this -> cleanLog ( ) ; } return $ raw ; } | Return All WebServer current Log WebServer in an arrayobject variable |
20,046 | public function merge ( $ logs ) { if ( ! empty ( $ logs -> msg ) ) { $ this -> mergeCore ( 'msg' , $ logs -> msg ) ; $ this -> addLogBlockToFile ( $ logs -> msg , 'MESSAGE' ) ; } if ( ! empty ( $ logs -> err ) ) { $ this -> mergeCore ( 'err' , $ logs -> err ) ; $ this -> addLogBlockToFile ( $ logs -> err , 'ERROR' ) ; } if ( ! empty ( $ logs -> war ) ) { $ this -> mergeCore ( 'war' , $ logs -> war ) ; $ this -> addLogBlockToFile ( $ logs -> war , 'WARNING' ) ; } if ( ! empty ( $ logs -> deb ) ) { $ this -> mergeCore ( 'deb' , $ logs -> deb ) ; $ this -> addLogBlockToFile ( $ logs -> deb , 'DEBUG' ) ; } return true ; } | Merge All Messages from a second class with current class |
20,047 | public function flushOuputBuffer ( ) { $ contents = ob_get_contents ( ) ; ob_end_clean ( ) ; if ( $ contents ) { Splash :: translator ( ) -> load ( 'main' ) ; $ this -> war ( 'UnexOutputs' , $ contents ) ; $ this -> war ( 'UnexOutputsMsg' ) ; } } | Read & Store Outputs Buffer Contents in a warning message |
20,048 | private function coreAddLog ( $ type , $ message ) { if ( is_null ( $ message ) ) { return ; } if ( ! isset ( $ this -> { $ type } ) ) { $ this -> { $ type } = array ( ) ; } $ prefix = empty ( $ this -> prefix ) ? '' : '[' . $ this -> prefix . '] ' ; array_push ( $ this -> { $ type } , $ prefix . $ message ) ; } | Add Message to WebServer Log |
20,049 | private function mergeCore ( $ logType , $ logArray ) { if ( empty ( $ logArray ) ) { return ; } if ( $ logArray instanceof ArrayObject ) { $ logArray = $ logArray -> getArrayCopy ( ) ; } if ( ! isset ( $ this -> { $ logType } ) ) { $ this -> { $ logType } = $ logArray ; } else { foreach ( $ logArray as $ message ) { array_push ( $ this -> { $ logType } , $ message ) ; } } } | Merge Messages from a second class with current class |
20,050 | public static function isValid ( string $ nif ) : bool { return self :: isValidDni ( $ nif ) || self :: isValidNie ( $ nif ) || self :: isValidCif ( $ nif ) || self :: isValidOtherPersonalNif ( $ nif ) ; } | Validate Spanish NIFS Input is not uppercased or stripped of any incorrect characters |
20,051 | public static function isValidPersonal ( string $ nif ) : bool { return self :: isValidDni ( $ nif ) || self :: isValidNie ( $ nif ) || self :: isValidOtherPersonalNif ( $ nif ) ; } | Validate Spanish NIFS given to persons |
20,052 | public static function isValidDni ( string $ dni ) : bool { if ( ! preg_match ( self :: DNI_REGEX , $ dni , $ matches ) ) { return false ; } if ( '00000000' === $ matches [ 'number' ] ) { return false ; } return self :: DNINIE_CHECK_TABLE [ $ matches [ 'number' ] % 23 ] === $ matches [ 'check' ] ; } | DNI validation is pretty straight forward . Just mod 23 the 8 digit number and compare it to the check table |
20,053 | public static function isValidNie ( string $ nie ) : bool { if ( ! preg_match ( self :: NIE_REGEX , $ nie , $ matches ) ) { return false ; } $ nieType = strpos ( self :: NIE_TYPES , $ matches [ 'type' ] ) ; $ nie = $ nieType . $ matches [ 'number' ] ; return self :: DNINIE_CHECK_TABLE [ $ nie % 23 ] === $ matches [ 'check' ] ; } | NIE validation is similar to the DNI . The first letter needs an equivalent number before the mod operation |
20,054 | public static function isValidOtherPersonalNif ( string $ nif ) : bool { if ( ! preg_match ( self :: OTHER_PERSONAL_NIF_REGEX , $ nif , $ matches ) ) { return false ; } return self :: isValidNifCheck ( $ nif , $ matches ) ; } | Other personal NIFS are meant for temporary residents that do not qualify for a NIE but nonetheless need a NIF |
20,055 | public static function isValidCif ( string $ cif ) : bool { if ( ! preg_match ( self :: CIF_REGEX , $ cif , $ matches ) ) { return false ; } return self :: isValidNifCheck ( $ cif , $ matches ) ; } | CIFS are only meant for non - personal entities |
20,056 | private function prepareDB ( ) { $ dbpool = DBPool :: init ( $ this -> db_config ) ; if ( $ dbpool -> queue -> isEmpty ( ) && ( $ dbpool -> cap + $ dbpool -> activeCount >= $ this -> config [ 'max_pool_size' ] ) ) { \ throw_error ( 'MySQL pool is empty...' , 12009 ) ; } if ( $ dbpool -> cap < $ this -> config [ 'idle_pool_size' ] || ( $ dbpool -> queue -> isEmpty ( ) && $ dbpool -> cap < $ this -> config [ 'max_pool_size' ] ) ) { $ this -> reconnect ( ) ; $ dbpool -> activeCount ++ ; return false ; } else { $ this -> db = $ dbpool -> out ( $ this -> config [ 'idle_pool_size' ] ) ; return true ; } } | Get one MySQL connect from pool |
20,057 | public function get ( $ url , $ params = array ( ) , $ options = array ( ) ) { return $ this -> request ( $ url , self :: GET , $ params , $ options ) ; } | Make a HTTP GET request . |
20,058 | public function post ( $ url , $ params = array ( ) , $ options = array ( ) ) { return $ this -> request ( $ url , self :: POST , $ params , $ options ) ; } | Make a HTTP POST request . |
20,059 | public function put ( $ url , $ params = array ( ) , $ options = array ( ) ) { return $ this -> request ( $ url , self :: PUT , $ params , $ options ) ; } | Make a HTTP PUT request . |
20,060 | public function patch ( $ url , $ params = array ( ) , $ options = array ( ) ) { return $ this -> request ( $ url , self :: PATCH , $ params , $ options ) ; } | Make a HTTP PATCH request . |
20,061 | public function delete ( $ url , $ params = array ( ) , $ options = array ( ) ) { return $ this -> request ( $ url , self :: DELETE , $ params , $ options ) ; } | Make a HTTP DELETE request . |
20,062 | protected function splitHeaders ( $ rawHeaders ) { $ headers = array ( ) ; $ lines = explode ( "\n" , trim ( $ rawHeaders ) ) ; $ headers [ 'HTTP' ] = array_shift ( $ lines ) ; foreach ( $ lines as $ h ) { $ h = explode ( ':' , $ h , 2 ) ; if ( isset ( $ h [ 1 ] ) ) { $ headers [ $ h [ 0 ] ] = trim ( $ h [ 1 ] ) ; } } return ( object ) $ headers ; } | Split the HTTP headers . |
20,063 | protected function doCurl ( ) { $ response = curl_exec ( $ this -> curl ) ; if ( curl_errno ( $ this -> curl ) ) { throw new \ Exception ( curl_error ( $ this -> curl ) , 1 ) ; } $ curlInfo = curl_getinfo ( $ this -> curl ) ; $ results = array ( 'curl_info' => $ curlInfo , 'response' => $ response , ) ; return $ results ; } | Perform the Curl request . |
20,064 | public function translate ( $ value ) { switch ( $ value ) { case \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_MR : return 0 ; case \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_MRS : return 1 ; case \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_MISS : return 2 ; case \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_COMPANY : return 10 ; } return 99 ; } | Translates the MShop value into its TYPO3 equivalent . |
20,065 | public function reverse ( $ value ) { switch ( $ value ) { case 0 : return \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_MR ; case 1 : return \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_MRS ; case 2 : return \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_MISS ; case 10 : return \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_COMPANY ; } return \ Aimeos \ MShop \ Common \ Item \ Address \ Base :: SALUTATION_UNKNOWN ; } | Reverses the translation from the TYPO3 value to the MShop constant . |
20,066 | protected function createJsonApi ( $ source , DocumentHydrator $ hydrator ) : JsonApiObject { $ jsonApi = isset ( $ source -> version ) ? new JsonApiObject ( $ source -> version ) : new JsonApiObject ( ) ; $ hydrator -> hydrateObject ( $ jsonApi , $ source ) ; return $ jsonApi ; } | Create JsonAPI - object |
20,067 | public function preview ( $ attachmentId = null ) { $ attachment = $ this -> Attachments -> get ( $ attachmentId ) ; $ this -> _checkAuthorization ( $ attachment ) ; switch ( $ attachment -> filetype ) { case 'image/png' : case 'image/jpg' : case 'image/jpeg' : case 'image/gif' : $ image = new \ Imagick ( $ attachment -> getAbsolutePath ( ) ) ; if ( Configure :: read ( 'Attachments.autorotate' ) ) { $ this -> _autorotate ( $ image ) ; } break ; case 'application/pdf' : $ image = new \ Imagick ( $ attachment -> getAbsolutePath ( ) . '[0]' ) ; break ; default : $ image = new \ Imagick ( Plugin :: path ( 'Attachments' ) . '/webroot/img/file.png' ) ; break ; } $ image -> setImageFormat ( 'png' ) ; $ image -> thumbnailImage ( 80 , 80 , true , false ) ; $ image -> setImageCompression ( \ Imagick :: COMPRESSION_JPEG ) ; $ image -> setImageCompressionQuality ( 75 ) ; $ image -> stripImage ( ) ; header ( 'Content-Type: image/' . $ image -> getImageFormat ( ) ) ; echo $ image ; $ image -> destroy ( ) ; exit ; } | Renders a JPEG preview of the given attachment . Will fall back to a file icon if a preview can not be generated . |
20,068 | public function view ( $ attachmentId = null ) { $ attachment = $ this -> Attachments -> get ( $ attachmentId ) ; $ this -> _checkAuthorization ( $ attachment ) ; switch ( $ attachment -> filetype ) { case 'image/png' : case 'image/jpg' : case 'image/jpeg' : case 'image/gif' : $ image = new \ Imagick ( $ attachment -> getAbsolutePath ( ) ) ; if ( Configure :: read ( 'Attachments.autorotate' ) ) { $ this -> _autorotate ( $ image ) ; } break ; case 'application/pdf' : header ( 'Content-Type: ' . $ attachment -> filetype ) ; $ file = new File ( $ attachment -> getAbsolutePath ( ) ) ; echo $ file -> read ( ) ; exit ; break ; default : $ image = new \ Imagick ( Plugin :: path ( 'Attachments' ) . '/webroot/img/file.png' ) ; break ; } $ image -> setImageFormat ( 'png' ) ; $ image -> setImageCompression ( \ Imagick :: COMPRESSION_JPEG ) ; $ image -> setImageCompressionQuality ( 75 ) ; $ image -> stripImage ( ) ; header ( 'Content-Type: image/' . $ image -> getImageFormat ( ) ) ; echo $ image ; $ image -> destroy ( ) ; exit ; } | Renders a JPEG of the given attachment . Will fall back to a file icon if a image can not be generated . |
20,069 | public function download ( $ attachmentId = null ) { $ attachment = $ this -> Attachments -> get ( $ attachmentId ) ; $ this -> _checkAuthorization ( $ attachment ) ; $ this -> response -> file ( $ attachment -> getAbsolutePath ( ) , [ 'download' => true , 'name' => $ attachment -> filename ] ) ; return $ this -> response ; } | Download the file |
20,070 | protected function _checkAuthorization ( Attachment $ attachment ) { if ( $ attachmentsBehavior = $ attachment -> getRelatedTable ( ) -> behaviors ( ) -> get ( 'Attachments' ) ) { $ behaviorConfig = $ attachmentsBehavior -> config ( ) ; if ( is_callable ( $ behaviorConfig [ 'downloadAuthorizeCallback' ] ) ) { $ relatedEntity = $ attachment -> getRelatedEntity ( ) ; $ authorized = $ behaviorConfig [ 'downloadAuthorizeCallback' ] ( $ attachment , $ relatedEntity , $ this -> request ) ; if ( $ authorized !== true ) { throw new UnauthorizedException ( __d ( 'attachments' , 'attachments.unauthorized_for_attachment' ) ) ; } } } } | Checks if a downloadAuthorizeCallback was configured and calls it . Will throw an UnauthorizedException if the callback returns false . |
20,071 | protected function _autorotate ( \ Imagick $ image ) { switch ( $ image -> getImageOrientation ( ) ) { case \ Imagick :: ORIENTATION_TOPRIGHT : $ image -> flopImage ( ) ; break ; case \ Imagick :: ORIENTATION_BOTTOMRIGHT : $ image -> rotateImage ( '#000' , 180 ) ; break ; case \ Imagick :: ORIENTATION_BOTTOMLEFT : $ image -> flopImage ( ) ; $ image -> rotateImage ( '#000' , 180 ) ; break ; case \ Imagick :: ORIENTATION_LEFTTOP : $ image -> flopImage ( ) ; $ image -> rotateImage ( '#000' , - 90 ) ; break ; case \ Imagick :: ORIENTATION_RIGHTTOP : $ image -> rotateImage ( '#000' , 90 ) ; break ; case \ Imagick :: ORIENTATION_RIGHTBOTTOM : $ image -> flopImage ( ) ; $ image -> rotateImage ( '#000' , 90 ) ; break ; case \ Imagick :: ORIENTATION_LEFTBOTTOM : $ image -> rotateImage ( '#000' , - 90 ) ; break ; } $ image -> setImageOrientation ( \ Imagick :: ORIENTATION_TOPLEFT ) ; } | rotate image depending on exif info |
20,072 | public function saveTags ( $ attachmentId = null ) { $ this -> request -> allowMethod ( 'post' ) ; $ attachment = $ this -> Attachments -> get ( $ attachmentId ) ; $ this -> _checkAuthorization ( $ attachment ) ; if ( ! TableRegistry :: get ( $ attachment -> model ) ) { throw new \ Cake \ ORM \ Exception \ MissingTableClassException ( 'Could not find Table ' . $ attachment -> model ) ; } $ inputArray = explode ( '&' , $ this -> request -> input ( 'urldecode' ) ) ; $ tags = explode ( '$' , explode ( '=' , $ inputArray [ 0 ] ) [ 1 ] ) ; unset ( $ inputArray [ 0 ] ) ; $ options = [ ] ; foreach ( $ inputArray as $ option ) { $ option = substr ( $ option , 8 ) ; $ optionParts = explode ( ']=' , $ option ) ; $ options [ $ optionParts [ 0 ] ] = $ optionParts [ 1 ] ; } $ options [ 'isAjax' ] = true ; $ Model = TableRegistry :: get ( $ attachment -> model ) ; $ Model -> saveTags ( $ attachment , $ tags ) ; $ entity = $ Model -> get ( $ attachment -> foreign_key , [ 'contain' => 'Attachments' ] ) ; $ this -> set ( compact ( 'entity' , 'options' ) ) ; } | endpoint for Json action to save tags of an attachment |
20,073 | public function autoload ( $ class ) { $ parts = preg_split ( '#\\\#' , $ class ) ; $ className = array_pop ( $ parts ) ; $ path = implode ( '\\' , $ parts ) ; $ file = $ className . '.php' ; if ( isset ( $ this -> prefix [ $ path ] ) ) { $ filepath = $ this -> relplaceSlash ( $ this -> prefix [ $ path ] . self :: DS . $ file ) ; if ( $ this -> requireFile ( $ filepath ) ) { return $ filepath ; } } foreach ( $ this -> lib as $ nameSpace => $ src ) { $ filepath = $ this -> relplaceSlash ( str_replace ( $ nameSpace , $ src , $ class ) . '.php' ) ; if ( $ this -> requireFile ( $ filepath ) ) { return $ filepath ; } } foreach ( $ this -> map as $ map ) { $ filepath = $ this -> relplaceSlash ( $ map . self :: DS . $ path . self :: DS . $ file ) ; if ( $ this -> requireFile ( $ filepath ) ) { return $ filepath ; } } return false ; } | Pour tous les fichiers de la librairie on cherche le fichier requit . Le nom de l objet le namespace l emplacement doit respecter les recommandations PSR - 4 . |
20,074 | protected function sizeMin ( $ key , $ lengthValue , $ min , $ not = true ) { if ( $ lengthValue < $ min && $ not ) { $ this -> addReturn ( $ key , 'must' , [ ':min' => $ min ] ) ; } elseif ( ! ( $ lengthValue < $ min ) && ! $ not ) { $ this -> addReturn ( $ key , 'not' , [ ':min' => $ min ] ) ; } } | Test si une valeur est plus petite que la valeur de comparaison . |
20,075 | public function listAction ( ) { $ featureService = $ this -> container -> get ( "features" ) ; $ featureTypes = $ featureService -> getFeatureTypeDeclarations ( ) ; return new JsonResponse ( array ( 'list' => $ featureTypes , ) ) ; } | List data stores |
20,076 | final public function verify ( string $ header , string $ body , int $ threshold = 3600 ) : bool { $ signature = new Verify ( $ this -> key , 'sha256' , $ threshold ) ; return $ signature ( $ body , $ header ) ; } | Verify signature from header and body . |
20,077 | final public function verifyFrom ( ResponseInterface $ message , int $ threshold = 3600 ) : bool { $ response = new Response ( $ message ) ; return $ this -> verify ( $ response -> getHeader ( 'HTTP_X_SIGNATURE' ) [ 0 ] , $ response -> getBody ( ) , $ threshold ) ; } | Verify signature from PSR7 response object . |
20,078 | protected function processMethod ( \ ReflectionMethod $ method , Definition $ definition ) { $ annotations = $ this -> reader -> getMethodAnnotations ( $ method ) ; foreach ( $ annotations as $ annotation ) { if ( $ annotation instanceof AttributeAnnotation ) { $ this -> validateMethodAttribute ( $ annotation , $ method ) ; $ attribute = $ this -> createAttributeByMethod ( $ annotation , $ method ) ; $ definition -> addAttribute ( $ attribute ) ; } } } | Process method of class |
20,079 | protected function validateMethodAttribute ( AttributeAnnotation $ annotation , \ ReflectionMethod $ method ) { if ( ! $ method -> isPublic ( ) ) { throw new \ LogicException ( sprintf ( 'Attribute annotation can be applied only to non public method "%s".' , $ method -> getName ( ) ) ) ; } if ( $ annotation -> getter !== null ) { throw new \ LogicException ( sprintf ( 'The "getter" property of Attribute annotation applied to method "%s" is useless.' , $ method -> getName ( ) ) ) ; } } | Validate method with attribute definition |
20,080 | protected function createAttributeByProperty ( AttributeAnnotation $ annotation , \ ReflectionProperty $ property ) : Attribute { $ name = ( $ annotation -> name === null ) ? $ property -> getName ( ) : $ annotation -> name ; $ getter = ( $ annotation -> getter === null ) ? $ this -> resolveGetter ( $ property ) : $ annotation -> getter ; $ setter = ( $ annotation -> setter === null ) ? $ this -> resolveSetter ( $ property ) : $ annotation -> setter ; $ attribute = new Attribute ( $ name , $ getter ) ; $ attribute -> setPropertyName ( $ property -> getName ( ) ) ; if ( $ setter !== null ) { $ attribute -> setSetter ( $ setter ) ; } $ this -> processAttributeOptions ( $ annotation , $ attribute ) ; return $ attribute ; } | Create attribute by annotation of property |
20,081 | protected function createAttributeByMethod ( AttributeAnnotation $ annotation , \ ReflectionMethod $ method ) : Attribute { $ name = ( $ annotation -> name === null ) ? $ this -> resolveNameByMethod ( $ method ) : $ annotation -> name ; $ attribute = new Attribute ( $ name , $ method -> getName ( ) ) ; if ( $ annotation -> setter !== null ) { $ attribute -> setSetter ( $ annotation -> setter ) ; } if ( $ annotation -> type !== null ) { $ this -> processDataType ( $ annotation -> type , $ attribute ) ; } return $ attribute ; } | Create attribute by annotation of method |
20,082 | protected function resolveNameByMethod ( \ ReflectionMethod $ method ) : string { $ name = $ method -> getName ( ) ; if ( preg_match ( '~^(?:get|is)(?<name>[a-z0-9_]+)~i' , $ name , $ matches ) ) { return lcfirst ( $ matches [ 'name' ] ) ; } return $ name ; } | Resolve name of attribute by method |
20,083 | public function executeQuery ( $ queryName , PaymentTransaction $ paymentTransaction ) { $ query = $ this -> getQuery ( $ queryName ) ; $ response = null ; try { $ request = $ query -> createRequest ( $ paymentTransaction ) ; $ response = $ this -> makeRequest ( $ request ) ; $ query -> processResponse ( $ paymentTransaction , $ response ) ; } catch ( Exception $ e ) { $ this -> handleException ( $ e , $ paymentTransaction , $ response ) ; return ; } $ this -> handleQueryResult ( $ paymentTransaction , $ response ) ; return $ response ; } | Executes payment API query |
20,084 | public function processCustomerReturn ( CallbackResponse $ callbackResponse , PaymentTransaction $ paymentTransaction ) { $ callbackResponse -> setType ( 'customer_return' ) ; return $ this -> processPaynetEasyCallback ( $ callbackResponse , $ paymentTransaction ) ; } | Executes payment gateway processor for customer return from payment form or 3D - auth |
20,085 | public function processPaynetEasyCallback ( CallbackResponse $ callbackResponse , PaymentTransaction $ paymentTransaction ) { try { $ this -> getCallback ( $ callbackResponse -> getType ( ) ) -> processCallback ( $ paymentTransaction , $ callbackResponse ) ; } catch ( Exception $ e ) { $ this -> handleException ( $ e , $ paymentTransaction , $ callbackResponse ) ; return ; } $ this -> handleQueryResult ( $ paymentTransaction , $ callbackResponse ) ; return $ callbackResponse ; } | Executes payment gateway processor for PaynetEasy payment callback |
20,086 | public function setHandler ( $ handlerName , $ handlerCallback ) { $ this -> checkHandlerName ( $ handlerName ) ; if ( ! is_callable ( $ handlerCallback ) ) { throw new RuntimeException ( "Handler callback must be callable" ) ; } $ this -> handlers [ $ handlerName ] = $ handlerCallback ; return $ this ; } | Set handler callback for processing action . |
20,087 | protected function callHandler ( $ handlerName ) { $ this -> checkHandlerName ( $ handlerName ) ; $ arguments = func_get_args ( ) ; array_shift ( $ arguments ) ; if ( $ this -> hasHandler ( $ handlerName ) ) { call_user_func_array ( $ this -> handlers [ $ handlerName ] , $ arguments ) ; } return $ this ; } | Executes handler callback . Method receives at least one parameter - handler name all other parameters will be passed to handler callback . |
20,088 | public function merge ( self $ link ) { $ this -> parameters = array_replace ( $ link -> getParameters ( ) , $ this -> parameters ) ; $ this -> metadata = array_replace ( $ link -> getMetadata ( ) , $ this -> metadata ) ; } | Merge a link into this one |
20,089 | public function authenticate ( string $ username , string $ password , ? string $ scope = '*' ) : Response { $ body = $ this -> mergeApiBody ( \ array_filter ( \ compact ( 'username' , 'password' , 'scope' ) ) ) ; return $ this -> send ( 'POST' , 'oauth/token' , $ this -> getApiHeaders ( ) , $ body ) -> validateWith ( function ( $ statusCode , $ response ) { if ( $ statusCode !== 200 ) { throw new RuntimeException ( 'Unable to generate access token!' ) ; } $ this -> client -> setAccessToken ( $ response -> toArray ( ) [ 'access_token' ] ) ; } ) ; } | Create access token . |
20,090 | protected function getApiBody ( ) : array { $ clientId = $ this -> client -> getClientId ( ) ; $ clientSecret = $ this -> client -> getClientSecret ( ) ; if ( empty ( $ clientId ) || empty ( $ clientSecret ) ) { throw new InvalidArgumentException ( 'Missing client_id and client_secret information!' ) ; } return [ 'scope' => '*' , 'grant_type' => 'password' , 'client_id' => $ clientId , 'client_secret' => $ clientSecret , ] ; } | Get API Body . |
20,091 | public function isValid ( ) { $ this -> key = [ ] ; $ this -> errors = [ ] ; $ this -> correctInputs ( ) ; foreach ( $ this -> rules as $ key => $ test ) { if ( $ this -> isRequiredWhith ( $ key ) && $ this -> isOneVoidValue ( $ key ) ) { continue ; } if ( $ this -> isRequiredWhithout ( $ key ) && ! $ this -> isAllVoidValue ( $ key ) ) { continue ; } if ( $ this -> isNotRequired ( $ key ) && $ this -> isVoidValue ( $ key ) ) { continue ; } foreach ( explode ( '|' , $ test ) as $ rule ) { $ this -> parseRules ( $ key , $ rule ) ; } } return empty ( $ this -> errors ) ; } | Lance les tests |
20,092 | protected function isNotRequired ( $ key ) { return strstr ( $ this -> rules [ $ key ] , '!required' ) && ! strstr ( $ this -> rules [ $ key ] , '!required_' ) ; } | Si la valeur n est pas strictement requise . |
20,093 | protected function isVoidValue ( $ key ) { $ require = new Rules \ Required ; $ require -> execute ( 'required' , $ key , $ this -> inputs [ $ key ] , false , true ) ; return $ require -> hasErrors ( ) ; } | Si la valeur est vide . |
20,094 | protected function setNeededAction ( Response $ response ) { if ( $ response -> hasHtml ( ) ) { $ response -> setNeededAction ( Response :: NEEDED_SHOW_HTML ) ; } elseif ( $ response -> isProcessing ( ) ) { $ response -> setNeededAction ( Response :: NEEDED_STATUS_UPDATE ) ; } } | Sets action that library client have to execute . |
20,095 | protected function setFieldsFromResponse ( PaymentTransaction $ paymentTransaction , Response $ response ) { $ payment = $ paymentTransaction -> getPayment ( ) ; $ card = $ payment -> getRecurrentCardFrom ( ) ; if ( $ response -> offsetExists ( 'card-ref-id' ) ) { $ card -> setPaynetId ( $ response [ 'card-ref-id' ] ) ; } if ( $ response -> offsetExists ( 'last-four-digits' ) ) { $ card -> setLastFourDigits ( $ response [ 'last-four-digits' ] ) ; } if ( $ response -> offsetExists ( 'bin' ) ) { $ card -> setBin ( $ response [ 'bin' ] ) ; } if ( $ response -> offsetExists ( 'cardholder-name' ) ) { $ card -> setCardPrintedName ( $ response [ 'cardholder-name' ] ) ; } if ( $ response -> offsetExists ( 'card-exp-month' ) ) { $ card -> setExpireMonth ( $ response [ 'card-exp-month' ] ) ; } if ( $ response -> offsetExists ( 'card-exp-year' ) ) { $ card -> setExpireYear ( $ response [ 'card-exp-year' ] ) ; } if ( $ response -> offsetExists ( 'card-hash-id' ) ) { $ card -> setCardHashId ( $ response [ 'card-hash-id' ] ) ; } if ( $ response -> offsetExists ( 'card-type' ) ) { $ card -> setCardType ( $ response [ 'card-type' ] ) ; } } | Fill fields of payment data objects by date from PaynetEasy response . |
20,096 | public static function colorize ( $ text , $ fgcolor = null , $ bgcolor = null ) { $ colors = '' ; if ( $ bgcolor ) { $ colors .= self :: getBgColorString ( self :: getColorCode ( $ bgcolor ) ) ; } if ( $ fgcolor ) { $ colors .= self :: getFgColorString ( self :: getColorCode ( $ fgcolor ) ) ; } if ( $ colors ) { $ text = $ colors . $ text . self :: RESET ; } return $ text ; } | Returns a colorized string |
20,097 | public static function colorizeLines ( $ text , $ fgcolor = null , $ bgcolor = null ) { $ lines = explode ( "\n" , $ text ) ; foreach ( $ lines as & $ line ) { $ line = self :: colorize ( $ line , $ fgcolor , $ bgcolor ) ; } return implode ( "\n" , $ lines ) ; } | Returns a text with each lines colorized independently |
20,098 | public static function getColorCode ( $ color , $ options = array ( ) ) { $ code = ( int ) $ color ; if ( is_string ( $ color ) ) { $ options = array_merge ( explode ( '+' , strtolower ( $ color ) ) , $ options ) ; $ color = array_shift ( $ options ) ; if ( ! isset ( self :: $ colors [ $ color ] ) ) { throw new ConsoleException ( "Unknown color '$color'" ) ; } $ code = self :: $ colors [ $ color ] ; } foreach ( $ options as $ opt ) { $ opt = strtolower ( $ opt ) ; if ( ! isset ( self :: $ options [ $ opt ] ) ) { throw new ConsoleException ( "Unknown option '$color'" ) ; } $ code = $ code | self :: $ options [ $ opt ] ; } return $ code ; } | Returns a color code |
20,099 | public static function getFgColorString ( $ colorCode ) { list ( $ color , $ options ) = self :: extractColorAndOptions ( $ colorCode ) ; $ codes = array_filter ( array_merge ( $ options , array ( "3{$color}" ) ) ) ; return sprintf ( "\033[%sm" , implode ( ';' , $ codes ) ) ; } | Returns a foreground color string |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.