idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
46,100 | public function publish ( $ message ) { $ serializedMessage = $ this -> serializer -> wrapAndSerialize ( $ message ) ; $ routingKey = $ this -> routingKeyResolver -> resolveRoutingKeyFor ( $ message ) ; $ additionalProperties = $ this -> additionalPropertiesResolver -> resolveAdditionalPropertiesFor ( $ message ) ; $ t... | Publish the given Message by serializing it and handing it over to a RabbitMQ producer |
46,101 | public function handleProviderCallback ( Request $ request , string $ provider ) { $ providerUser = Socialite :: driver ( $ provider ) -> user ( ) ; $ fullName = explode ( ' ' , $ providerUser -> name ) ; $ attributes = [ 'id' => $ providerUser -> id , 'email' => $ providerUser -> email , 'username' => $ providerUser -... | Obtain the user information from Provider . |
46,102 | protected function getLocalUser ( string $ provider , string $ providerUserId ) { return app ( 'cortex.auth.admin' ) -> whereHas ( 'socialites' , function ( Builder $ builder ) use ( $ provider , $ providerUserId ) { $ builder -> where ( 'provider' , $ provider ) -> where ( 'provider_uid' , $ providerUserId ) ; } ) -> ... | Get local user for the given provider . |
46,103 | public static function isSupported ( ) { if ( version_compare ( PHP_VERSION , '7.2' , '>=' ) && \ defined ( 'PASSWORD_ARGON2I' ) ) { return true ; } if ( class_exists ( '\\ParagonIE_Sodium_Compat' ) && method_exists ( '\\ParagonIE_Sodium_Compat' , 'crypto_pwhash_is_available' ) ) { return \ ParagonIE_Sodium_Compat :: c... | Check that the password handler is supported in this environment |
46,104 | public function login ( AuthenticationRequest $ request ) { $ loginField = get_login_field ( $ request -> input ( $ this -> username ( ) ) ) ; $ credentials = [ 'is_active' => true , $ loginField => $ request -> input ( 'loginfield' ) , 'password' => $ request -> input ( 'password' ) , ] ; if ( $ this -> hasTooManyLogi... | Process to the login form . |
46,105 | protected function processLogout ( Request $ request ) : void { auth ( ) -> guard ( $ this -> getGuard ( ) ) -> logout ( ) ; $ request -> session ( ) -> invalidate ( ) ; } | Process logout . |
46,106 | protected function overrideMiddleware ( Router $ router ) : void { $ router -> pushMiddlewareToGroup ( 'web' , UpdateLastActivity :: class ) ; $ router -> aliasMiddleware ( 'reauthenticate' , Reauthenticate :: class ) ; $ router -> aliasMiddleware ( 'guest' , RedirectIfAuthenticated :: class ) ; } | Override middleware . |
46,107 | public function ifCan ( string $ ability , $ params = null , $ guard = null ) { $ this -> hideCallbacks -> push ( function ( ) use ( $ ability , $ params , $ guard ) { return ! optional ( auth ( ) -> guard ( $ guard ) -> user ( ) ) -> can ( $ ability , $ params ) ; } ) ; return $ this ; } | Set authorization callback for current menu item . |
46,108 | public function activateOnRoute ( string $ route ) { $ this -> activeWhen = function ( ) use ( $ route ) { return str_contains ( Route :: currentRouteName ( ) , $ route ) ; } ; return $ this ; } | Set active callback on the given route . |
46,109 | protected function add ( array $ properties = [ ] ) { $ properties [ 'attributes' ] [ 'id' ] = $ properties [ 'attributes' ] [ 'id' ] ?? md5 ( json_encode ( $ properties ) ) ; $ this -> childs -> push ( $ item = new static ( $ properties ) ) ; return $ item ; } | Add new child item . |
46,110 | protected function hasActiveStateFromChilds ( ) : bool { return $ this -> getChilds ( ) -> contains ( function ( MenuItem $ child ) { return ( $ child -> hasChilds ( ) && $ child -> hasActiveStateFromChilds ( ) ) || ( $ child -> route && $ child -> hasActiveStateFromRoute ( ) ) || $ child -> isActive ( ) || $ child -> ... | Check if the item has active state from childs . |
46,111 | private function isClassName ( $ value , array $ options ) { if ( preg_match ( '/^([a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*)(\\\\(?1))*$/' , $ value ) !== 1 ) { return false ; } return array_intersect ( iterator_to_array ( $ this -> iterateNamespaces ( $ value ) ) , $ options [ 'string.classes' ] ) !== [ ] ; } | Tests if the given value is a string that could be encoded as a class name constant . |
46,112 | private function getClassName ( $ value , array $ options ) { foreach ( $ this -> iterateNamespaces ( $ value ) as $ partial ) { if ( isset ( $ options [ 'string.imports' ] [ $ partial ] ) ) { $ trimmed = substr ( $ value , \ strlen ( rtrim ( $ partial , '\\' ) ) ) ; return ltrim ( sprintf ( '%s%s::class' , rtrim ( $ o... | Encodes the given string as a class name constant based on used imports . |
46,113 | private function iterateNamespaces ( $ value ) { yield $ value ; $ parts = explode ( '\\' , '\\' . $ value ) ; $ count = \ count ( $ parts ) ; for ( $ i = 1 ; $ i < $ count ; $ i ++ ) { yield ltrim ( implode ( '\\' , \ array_slice ( $ parts , 0 , - $ i ) ) , '\\' ) . '\\' ; } } | Iterates over the variations of the namespace for the given class name . |
46,114 | private function getComplexString ( $ value , array $ options ) { if ( $ this -> isBinaryString ( $ value , $ options ) ) { return $ this -> encodeBinaryString ( $ value ) ; } if ( $ options [ 'string.escape' ] ) { return $ this -> getDoubleQuotedString ( $ value , $ options ) ; } return $ this -> getSingleQuotedString... | Returns the PHP code representation for the string that is not just simple ascii characters . |
46,115 | private function getDoubleQuotedString ( $ string , $ options ) { $ string = strtr ( $ string , [ "\n" => '\n' , "\r" => '\r' , "\t" => '\t' , '$' => '\$' , '"' => '\"' , '\\' => '\\\\' , ] ) ; if ( $ options [ 'string.utf8' ] ) { $ string = $ this -> encodeUtf8 ( $ string , $ options ) ; } $ hexFormat = function ( $ m... | Returns the string wrapped in double quotes and all but print characters escaped . |
46,116 | private function encodeUtf8 ( $ string , $ options ) { $ pattern = '/ [\xC2-\xDF][\x80-\xBF] | \xE0[\xA0-\xBF][\x80-\xBF] | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} | \xED[\x80-\x9F][\x80-\xBF] | \xF0[\x90-\xBF][\x80-\xBF]{2} | [\xF1-\xF3][\x80-\xBF]{3} ... | Encodes all multibyte UTF - 8 characters into PHP7 string encoding . |
46,117 | private function getCodePoint ( $ bytes ) { if ( \ strlen ( $ bytes ) === 2 ) { return ( ( \ ord ( $ bytes [ 0 ] ) & 0b11111 ) << 6 ) | ( \ ord ( $ bytes [ 1 ] ) & 0b111111 ) ; } if ( \ strlen ( $ bytes ) === 3 ) { return ( ( \ ord ( $ bytes [ 0 ] ) & 0b1111 ) << 12 ) | ( ( \ ord ( $ bytes [ 1 ] ) & 0b111111 ) << 6 ) |... | Returns the unicode code point for the given multibyte UTF - 8 character . |
46,118 | public function setTenantsAttribute ( $ tenants ) : void { static :: saved ( function ( self $ model ) use ( $ tenants ) { $ tenants = collect ( $ tenants ) -> filter ( ) ; $ model -> tenants -> pluck ( 'id' ) -> similar ( $ tenants ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attributes' => [ 't... | Attach the given tenants to the model . |
46,119 | public function messageConsumptionFailed ( MessageConsumptionFailed $ event ) { $ this -> logger -> log ( $ this -> logLevel , $ this -> logMessage , [ 'exception' => $ event -> exception ( ) , 'message' => $ event -> message ( ) ] ) ; } | Log the failed message and the related exception |
46,120 | public function scopeGuestsBySeconds ( Builder $ builder , $ seconds = 60 ) : Builder { return $ builder -> where ( 'last_activity' , '>=' , time ( ) - $ seconds ) -> whereNull ( 'user_id' ) ; } | Constrain the query to retrieve only sessions of guests who have been active within the specified number of seconds . |
46,121 | public function scopeUsersBySeconds ( Builder $ builder , $ seconds = 60 ) : Builder { return $ builder -> with ( [ 'user' ] ) -> where ( 'last_activity' , '>=' , now ( ) -> subSeconds ( $ seconds ) ) -> whereNotNull ( 'user_id' ) ; } | Constrain the query to retrieve only sessions of users who have been active within the specified number of seconds . |
46,122 | public function destroy ( Admin $ admin , Media $ media ) { $ admin -> media ( ) -> where ( $ media -> getKeyName ( ) , $ media -> getKey ( ) ) -> first ( ) -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.admins.edit' , [ 'admin' => $ admin ] ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messag... | Destroy given admin media . |
46,123 | public function import ( Guardian $ guardian , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ guardian , 'tabs' => 'adminarea.guardians.tabs' , 'url' => route ( 'adminarea.guardians.stash' ) , 'id' => "adminarea-attributes-{$guardian->getRouteKey()}-impor... | Import guardians . |
46,124 | public function destroy ( Guardian $ guardian ) { $ guardian -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.guardians.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.guardian' ) , 'identifier' => $ guardian -> usern... | Destroy given guardian . |
46,125 | protected function attemptTwoFactor ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { return $ this -> isValidTwoFactorTotp ( $ user , $ token ) || $ this -> isValidTwoFactorBackup ( $ user , $ token ) || $ this -> isValidTwoFactorPhone ( $ user , $ token ) ; } | Verify TwoFactor authentication . |
46,126 | protected function invalidateTwoFactorBackup ( AuthenticatableTwoFactorContract $ user , int $ token ) : void { $ settings = $ user -> getTwoFactor ( ) ; $ backup = array_get ( $ settings , 'totp.backup' ) ; unset ( $ backup [ array_search ( $ token , $ backup ) ] ) ; array_set ( $ settings , 'totp.backup' , $ backup )... | Invalidate given backup code for the given user . |
46,127 | protected function isValidTwoFactorPhone ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { $ settings = $ user -> getTwoFactor ( ) ; $ authyId = array_get ( $ settings , 'phone.authy_id' ) ; return in_array ( mb_strlen ( $ token ) , [ 6 , 7 , 8 ] ) && app ( 'rinvex.authy.token' ) -> verify ( $ token , ... | Determine if the given token is a valid TwoFactor Phone token . |
46,128 | protected function isValidTwoFactorBackup ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { $ backup = array_get ( $ user -> getTwoFactor ( ) , 'totp.backup' , [ ] ) ; $ result = mb_strlen ( $ token ) === 10 && in_array ( $ token , $ backup ) ; ! $ result || $ this -> invalidateTwoFactorBackup ( $ user... | Determine if the given token is a valid TwoFactor Backup code . |
46,129 | protected function isValidTwoFactorTotp ( AuthenticatableTwoFactorContract $ user , int $ token ) : bool { $ totpProvider = app ( Google2FA :: class ) ; $ secret = array_get ( $ user -> getTwoFactor ( ) , 'totp.secret' ) ; return mb_strlen ( $ token ) === 6 && $ totpProvider -> verifyKey ( $ secret , $ token ) ; } | Determine if the given token is a valid TwoFactor TOTP token . |
46,130 | protected function createAdmin ( string $ password ) : Admin { $ admin = [ 'is_active' => true , 'username' => 'Admin' , 'given_name' => 'Admin' , 'family_name' => 'User' , 'email' => 'admin@example.com' , ] ; return tap ( app ( 'cortex.auth.admin' ) -> firstOrNew ( $ admin ) -> fill ( [ 'remember_token' => str_random ... | Create admin model . |
46,131 | protected function createGuardian ( string $ password ) : Guardian { $ guardian = [ 'is_active' => true , 'username' => 'Guardian' , 'email' => 'guardian@example.com' , ] ; return tap ( app ( 'cortex.auth.guardian' ) -> firstOrNew ( $ guardian ) -> fill ( [ 'remember_token' => str_random ( 10 ) , 'password' => $ passwo... | Create guardian model . |
46,132 | public function setAbilitiesAttribute ( $ abilities ) : void { static :: saved ( function ( self $ model ) use ( $ abilities ) { $ abilities = collect ( $ abilities ) -> filter ( ) ; $ model -> abilities -> pluck ( 'id' ) -> similar ( $ abilities ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attri... | Attach the given abilities to the model . |
46,133 | public function setRolesAttribute ( $ roles ) : void { static :: saved ( function ( self $ model ) use ( $ roles ) { $ roles = collect ( $ roles ) -> filter ( ) ; $ model -> roles -> pluck ( 'id' ) -> similar ( $ roles ) || activity ( ) -> performedOn ( $ model ) -> withProperties ( [ 'attributes' => [ 'roles' => $ rol... | Attach the given roles to the model . |
46,134 | public function routeNotificationForAuthy ( ) : ? int { if ( ! ( $ authyId = array_get ( $ this -> getTwoFactor ( ) , 'phone.authy_id' ) ) && $ this -> getEmailForVerification ( ) && $ this -> getPhoneForVerification ( ) && $ this -> getCountryForVerification ( ) ) { $ result = app ( 'rinvex.authy.user' ) -> register (... | Route notifications for the authy channel . |
46,135 | public function getManagedRoles ( ) : Collection { if ( $ this -> isA ( 'superadmin' ) ) { $ roles = app ( 'cortex.auth.role' ) -> all ( ) ; } elseif ( $ this -> isA ( 'supermanager' ) ) { $ roles = $ this -> roles -> merge ( config ( 'rinvex.tenants.active' ) ? app ( 'cortex.auth.role' ) -> where ( 'scope' , config ( ... | Get managed roles . |
46,136 | public function getManagedAbilities ( ) : Collection { $ abilities = $ this -> isA ( 'superadmin' ) ? app ( 'cortex.auth.ability' ) -> all ( ) : $ this -> getAbilities ( ) ; return $ abilities -> groupBy ( 'entity_type' ) -> map -> pluck ( 'title' , 'id' ) -> sortKeys ( ) ; } | Get managed abilites . |
46,137 | public function import ( Admin $ admin , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ admin , 'tabs' => 'adminarea.admins.tabs' , 'url' => route ( 'adminarea.admins.stash' ) , 'id' => "adminarea-attributes-{$admin->getRouteKey()}-import-table" , ] ) -> ... | Import admins . |
46,138 | public function destroy ( Admin $ admin ) { $ admin -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.admins.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.admin' ) , 'identifier' => $ admin -> username ] ) ] , ] ) ; ... | Destroy given admin . |
46,139 | public static function language ( $ code , $ hydrate = true ) { $ code = mb_strtolower ( $ code ) ; if ( ! isset ( static :: $ languages ) ) { static :: $ languages = json_decode ( static :: getFile ( __DIR__ . '/../resources/languages.json' ) , true ) ; } if ( ! isset ( static :: $ languages [ $ code ] ) ) { throw Lan... | Get the language by it s ISO ISO 639 - 1 code . |
46,140 | public static function scripts ( ) { if ( ! isset ( static :: $ languages ) ) { static :: $ languages = json_decode ( static :: getFile ( __DIR__ . '/../resources/languages.json' ) , true ) ; } return static :: pluck ( static :: $ languages , 'script.name' , 'script.iso_15924' ) ; } | Get all language scripts . |
46,141 | public static function families ( ) { if ( ! isset ( static :: $ languages ) ) { static :: $ languages = json_decode ( static :: getFile ( __DIR__ . '/../resources/languages.json' ) , true ) ; } return static :: pluck ( static :: $ languages , 'family.name' , 'family.iso_639_5' ) ; } | Get all language families . |
46,142 | public function lockout ( Lockout $ event ) : void { if ( config ( 'cortex.auth.emails.throttle_lockout' ) ) { switch ( $ event -> request -> route ( 'accessarea' ) ) { case 'managerarea' : $ model = app ( 'cortex.auth.manager' ) ; break ; case 'adminarea' : $ model = app ( 'cortex.auth.admin' ) ; break ; case 'frontar... | Listen to the authentication lockout event . |
46,143 | public function destroy ( Session $ session ) { $ session -> delete ( ) ; return intend ( [ 'back' => true , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.session' ) , 'identifier' => $ session -> getKey ( ) ] ) ] , ] ) ; } | Destroy given session . |
46,144 | public function flush ( Request $ request ) { $ request -> user ( $ this -> getGuard ( ) ) -> sessions ( ) -> delete ( ) ; return intend ( [ 'back' => true , 'with' => [ 'warning' => trans ( 'cortex/auth::messages.auth.session.flushed' ) ] , ] ) ; } | Flush all sessions . |
46,145 | public function edit ( Request $ request ) { $ countries = collect ( countries ( ) ) -> map ( function ( $ country , $ code ) { return [ 'id' => $ code , 'text' => $ country [ 'name' ] , 'emoji' => $ country [ 'emoji' ] , ] ; } ) -> values ( ) ; $ languages = collect ( languages ( ) ) -> pluck ( 'name' , 'iso_639_1' ) ... | Edit account settings . |
46,146 | public function update ( AccountSettingsRequest $ request ) { $ data = $ request -> validated ( ) ; $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; ! $ request -> hasFile ( 'profile_picture' ) || $ currentUser -> addMediaFromRequest ( 'profile_picture' ) -> sanitizingFileName ( function ( $ fileName ) { ... | Update account settings . |
46,147 | public function update ( AccountAttributesRequest $ request ) { $ data = $ request -> validated ( ) ; $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ currentUser -> fill ( $ data ) -> save ( ) ; return intend ( [ 'back' => true , 'with' => [ 'success' => trans ( 'cortex/auth::messages.account.updated_a... | Update account attributes . |
46,148 | private function getAlignedArray ( array $ array , $ depth , array $ options , callable $ encode ) { $ next = 0 ; $ omit = $ options [ 'array.omit' ] ; foreach ( array_keys ( $ array ) as $ key ) { if ( $ key !== $ next ++ ) { $ omit = false ; break ; } } return $ omit ? $ this -> getFormattedArray ( $ array , $ depth ... | Returns the PHP code for aligned array accounting for omitted keys and inline arrays . |
46,149 | private function getFormattedArray ( array $ array , $ depth , array $ options , callable $ encode ) { $ lines = $ this -> getPairs ( $ array , ' ' , $ options [ 'array.omit' ] , $ encode , $ omitted ) ; if ( $ omitted && $ options [ 'array.inline' ] !== false ) { $ output = $ this -> getInlineArray ( $ lines , $ optio... | Returns the PHP code for the array as inline or multi line array . |
46,150 | private function getInlineArray ( array $ lines , array $ options ) { $ output = $ this -> wrap ( implode ( ', ' , $ lines ) , $ options [ 'array.short' ] ) ; if ( preg_match ( '/[\r\n\t]/' , $ output ) ) { return false ; } elseif ( $ options [ 'array.inline' ] === true || \ strlen ( $ output ) <= ( int ) $ options [ '... | Returns the code for the inline array if possible . |
46,151 | private function buildArray ( array $ lines , $ depth , array $ options ) { $ indent = $ this -> buildIndent ( $ options [ 'array.base' ] , $ options [ 'array.indent' ] , $ depth + 1 ) ; $ last = $ this -> buildIndent ( $ options [ 'array.base' ] , $ options [ 'array.indent' ] , $ depth ) ; $ eol = $ options [ 'array.e... | Builds the complete array from the encoded key and value pairs . |
46,152 | private function buildIndent ( $ base , $ indent , $ depth ) { $ base = \ is_int ( $ base ) ? str_repeat ( ' ' , $ base ) : ( string ) $ base ; return $ depth === 0 ? $ base : $ base . str_repeat ( \ is_int ( $ indent ) ? str_repeat ( ' ' , $ indent ) : ( string ) $ indent , $ depth ) ; } | Builds the indentation based on the options . |
46,153 | private function getAlignedPairs ( array $ array , callable $ encode ) { $ keys = [ ] ; $ values = [ ] ; foreach ( $ array as $ key => $ value ) { $ keys [ ] = $ encode ( $ key , 1 ) ; $ values [ ] = $ encode ( $ value , 1 ) ; } $ format = sprintf ( '%%-%ds => %%s' , max ( array_map ( 'strlen' , $ keys ) ) ) ; $ pairs ... | Returns each encoded key and value pair with aligned assignment operators . |
46,154 | private function getPairs ( array $ array , $ space , $ omit , callable $ encode , & $ omitted = true ) { $ pairs = [ ] ; $ nextIndex = 0 ; $ omitted = true ; $ format = '%s' . $ space . '=>' . $ space . '%s' ; foreach ( $ array as $ key => $ value ) { if ( $ omit && $ this -> canOmitKey ( $ key , $ nextIndex ) ) { $ p... | Returns each key and value pair encoded as array assignment . |
46,155 | private function canOmitKey ( $ key , & $ nextIndex ) { $ result = $ key === $ nextIndex ; if ( \ is_int ( $ key ) ) { $ nextIndex = max ( $ key + 1 , $ nextIndex ) ; } return $ result ; } | Tells if the key can be omitted from array output based on expected index . |
46,156 | public function import ( Ability $ ability , ImportRecordsDataTable $ importRecordsDataTable ) { return $ importRecordsDataTable -> with ( [ 'resource' => $ ability , 'tabs' => 'adminarea.abilities.tabs' , 'url' => route ( 'adminarea.abilities.stash' ) , 'id' => "adminarea-abilities-{$ability->getRouteKey()}-import-tab... | Import abilities . |
46,157 | public function destroy ( Ability $ ability ) { $ ability -> delete ( ) ; return intend ( [ 'url' => route ( 'adminarea.abilities.index' ) , 'with' => [ 'warning' => trans ( 'cortex/foundation::messages.resource_deleted' , [ 'resource' => trans ( 'cortex/auth::common.ability' ) , 'identifier' => $ ability -> title ] ) ... | Destroy given ability . |
46,158 | public function addEncoder ( Encoder \ Encoder $ encoder , $ prepend = false ) { $ prepend ? array_unshift ( $ this -> encoders , $ encoder ) : array_push ( $ this -> encoders , $ encoder ) ; } | Adds a new encoder . |
46,159 | public function setOption ( $ option , $ value ) { if ( ! $ this -> isValidOption ( $ option ) ) { throw new InvalidOptionException ( sprintf ( "Invalid encoder option '%s'" , $ option ) ) ; } $ this -> options [ $ option ] = $ value ; } | Sets the value for an encoder option . |
46,160 | private function isValidOption ( $ option ) { if ( array_key_exists ( $ option , $ this -> options ) ) { return true ; } foreach ( $ this -> encoders as $ encoder ) { if ( array_key_exists ( $ option , $ encoder -> getDefaultOptions ( ) ) ) { return true ; } } return false ; } | Tells if the given string is a valid option name . |
46,161 | public function getAllOptions ( array $ overrides = [ ] ) { $ options = $ this -> options ; foreach ( $ this -> encoders as $ encoder ) { $ options += $ encoder -> getDefaultOptions ( ) ; } foreach ( $ overrides as $ name => $ value ) { if ( ! array_key_exists ( $ name , $ options ) ) { throw new InvalidOptionException... | Returns a list of all encoder options . |
46,162 | private function generate ( $ value , $ depth , array $ options , array $ recursion = [ ] ) { if ( $ this -> detectRecursion ( $ value , $ options , $ recursion ) ) { $ recursion [ ] = $ value ; } if ( $ options [ 'recursion.max' ] !== false && $ depth > ( int ) $ options [ 'recursion.max' ] ) { throw new \ RuntimeExce... | Generates the code for the given value recursively . |
46,163 | private function detectRecursion ( & $ value , array $ options , array $ recursion ) { if ( $ options [ 'recursion.detect' ] ) { if ( array_search ( $ value , $ recursion , true ) !== false ) { if ( $ options [ 'recursion.ignore' ] ) { $ value = null ; } else { throw new \ RuntimeException ( 'A recursive value was dete... | Attempts to detect circular references in values . |
46,164 | private function encodeValue ( $ value , $ depth , array $ options , callable $ encode ) { foreach ( $ this -> encoders as $ encoder ) { if ( $ encoder -> supports ( $ value ) ) { return $ encoder -> encode ( $ value , $ depth , $ options , $ encode ) ; } } throw new \ InvalidArgumentException ( sprintf ( "Unsupported ... | Encodes the value using one of the encoders that supports the value type . |
46,165 | private function encodeObject ( $ object , array $ options , callable $ encode ) { if ( $ options [ 'object.format' ] === 'string' ) { return $ encode ( ( string ) $ object ) ; } elseif ( $ options [ 'object.format' ] === 'serialize' ) { return sprintf ( 'unserialize(%s)' , $ encode ( serialize ( $ object ) ) ) ; } els... | Encodes the object as string according to encoding options . |
46,166 | private function encodeObjectArray ( $ object , array $ options , callable $ encode ) { if ( ! \ in_array ( ( string ) $ options [ 'object.format' ] , [ 'array' , 'vars' , 'iterate' ] , true ) ) { throw new \ RuntimeException ( 'Invalid object encoding format: ' . $ options [ 'object.format' ] ) ; } $ output = $ encode... | Encodes the object into one of the array formats . |
46,167 | private function getObjectArray ( $ object , $ format ) { if ( $ format === 'array' ) { return ( array ) $ object ; } elseif ( $ format === 'vars' ) { return get_object_vars ( $ object ) ; } $ array = [ ] ; foreach ( $ object as $ key => $ value ) { $ array [ $ key ] = $ value ; } return $ array ; } | Converts the object into array that can be encoded . |
46,168 | private function getObjectState ( $ object ) { $ class = new \ ReflectionClass ( $ object ) ; $ visibility = \ ReflectionProperty :: IS_PRIVATE | \ ReflectionProperty :: IS_PROTECTED ; $ values = [ ] ; do { foreach ( $ class -> getProperties ( $ visibility ) as $ property ) { $ property -> setAccessible ( true ) ; $ va... | Returns an array of object properties as would be generated by var_export . |
46,169 | private function encodeNumber ( $ float , array $ options , callable $ encode ) { if ( $ this -> isInteger ( $ float , $ options [ 'float.integers' ] ) ) { return $ this -> encodeInteger ( $ float , $ encode ) ; } elseif ( $ float === 0.0 ) { return '0.0' ; } elseif ( $ options [ 'float.export' ] ) { return var_export ... | Encodes the number as a PHP number representation . |
46,170 | private function isInteger ( $ float , $ allowIntegers ) { if ( ! $ allowIntegers || round ( $ float ) !== $ float ) { return false ; } elseif ( abs ( $ float ) < self :: FLOAT_MAX ) { return true ; } return $ allowIntegers === 'all' ; } | Tells if the number can be encoded as an integer . |
46,171 | private function encodeInteger ( $ float , callable $ encode ) { $ minimum = \ defined ( 'PHP_INT_MIN' ) ? \ PHP_INT_MIN : ~ \ PHP_INT_MAX ; if ( $ float >= $ minimum && $ float <= \ PHP_INT_MAX ) { return $ encode ( ( int ) $ float ) ; } return number_format ( $ float , 0 , '.' , '' ) ; } | Encodes the given float as an integer . |
46,172 | private function determinePrecision ( $ options ) { $ precision = $ options [ 'float.precision' ] ; if ( $ precision === false ) { $ precision = ini_get ( 'serialize_precision' ) ; } return max ( 1 , ( int ) $ precision ) ; } | Determines the float precision based on the options . |
46,173 | private function encodeFloat ( $ float , $ precision ) { $ log = ( int ) floor ( log ( abs ( $ float ) , 10 ) ) ; if ( $ log > - 5 && abs ( $ float ) < self :: FLOAT_MAX && abs ( $ log ) < $ precision ) { return $ this -> formatFloat ( $ float , $ precision - $ log - 1 ) ; } $ log += ( int ) ( round ( abs ( $ float ) /... | Encodes the number using a floating point representation . |
46,174 | private function formatFloat ( $ float , $ digits ) { $ digits = max ( ( int ) $ digits , 1 ) ; $ string = rtrim ( number_format ( $ float , $ digits , '.' , '' ) , '0' ) ; return substr ( $ string , - 1 ) === '.' ? $ string . '0' : $ string ; } | Formats the number as a decimal number . |
46,175 | public function getMultiLevelDropdownWrapper ( MenuItem $ item ) : string { return '<li class="treeview' . ( $ item -> hasActiveOnChild ( ) ? ' active' : '' ) . '"> <a href="#"> ' . ( $ item -> icon ? '<i class="' . $ item -> icon . '"></i>' : '' ) . ' <s... | Get multilevel menu wrapper . |
46,176 | public function update ( AccountPasswordRequest $ request ) { $ currentUser = $ request -> user ( $ this -> getGuard ( ) ) ; $ currentUser -> fill ( [ 'password' => $ request -> get ( 'new_password' ) ] ) -> forceSave ( ) ; return intend ( [ 'back' => true , 'with' => [ 'success' => trans ( 'cortex/auth::messages.accou... | Update account password . |
46,177 | protected static function parse ( \ ReflectionClass $ oReflectionClass ) { $ sContent = file_get_contents ( $ oReflectionClass -> getFileName ( ) ) ; $ aTokens = token_get_all ( $ sContent ) ; $ sDocComment = null ; $ bIsConst = false ; foreach ( $ aTokens as $ aToken ) { if ( ! is_array ( $ aToken ) || count ( $ aToke... | Parses a class for constants and DocComments |
46,178 | public static function getEventNamespace ( ) { $ oComponent = Components :: detectClassComponent ( get_called_class ( ) ) ; if ( empty ( $ oComponent ) ) { throw new NailsException ( 'Could not detect class\' component' ) ; } return $ oComponent -> slug ; } | Calculates the event s namespace |
46,179 | public static function info ( ) { $ oReflectionClass = new \ ReflectionClass ( get_called_class ( ) ) ; static :: parse ( $ oReflectionClass ) ; $ aOut = [ ] ; foreach ( $ oReflectionClass -> getConstants ( ) as $ sConstant => $ sValue ) { $ aOut [ $ sConstant ] = ( object ) [ 'constant' => get_called_class ( ) . '::' ... | Returns an array of the available events with supporting information |
46,180 | public function setHeader ( $ sHeader , $ mValue ) { if ( empty ( $ this -> aHeaders ) ) { $ this -> aHeaders = [ ] ; } $ this -> aHeaders [ $ sHeader ] = $ mValue ; return $ this ; } | Sets a header |
46,181 | public function getHeader ( $ sHeader ) { return isset ( $ this -> aHeaders [ $ sHeader ] ) ? $ this -> aHeaders [ $ sHeader ] : null ; } | Returns a single header |
46,182 | public function asUser ( $ iUserId ) { return $ this -> setHeader ( Testing :: TEST_HEADER_NAME , Testing :: TEST_HEADER_VALUE ) -> setHeader ( Testing :: TEST_HEADER_USER_NAME , $ iUserId ) ; } | Set the required headers for imitating a user |
46,183 | public function execute ( ) { $ aClientConfig = [ 'base_uri' => $ this -> sBaseUri , 'verify' => ! ( Environment :: is ( Environment :: ENV_DEV ) || Environment :: is ( Environment :: ENV_TEST ) ) , 'allow_redirects' => Environment :: not ( Environment :: ENV_TEST ) , 'http_errors' => Environment :: not ( Environment :... | Configures and executes the HTTP request |
46,184 | public function detect ( ) : \ Nails \ Common \ Factory \ Locale { $ oLocale = $ this -> getDefautLocale ( ) ; if ( static :: ENABLE_SNIFF ) { if ( static :: ENABLE_SNIFF_HEADER ) { $ this -> sniffHeader ( $ oLocale ) ; } if ( static :: ENABLE_SNIFF_USER ) { $ this -> sniffActiveUser ( $ oLocale ) ; } if ( static :: EN... | Attempts to detect the locale from the request |
46,185 | public function sniffLocale ( \ Nails \ Common \ Factory \ Locale $ oLocale = null ) : \ Nails \ Common \ Factory \ Locale { if ( ! $ oLocale ) { $ oLocale = $ this -> getDefautLocale ( ) ; } $ this -> sniffHeader ( $ oLocale ) -> sniffActiveUser ( $ oLocale ) -> sniffUrl ( $ oLocale ) -> sniffCookie ( $ oLocale ) -> s... | Sniff various items to determine the user s locale |
46,186 | public function sniffQuery ( \ Nails \ Common \ Factory \ Locale & $ oLocale ) { $ this -> setFromString ( $ oLocale , $ this -> oInput -> get ( static :: QUERY_PARAM ) ?? null ) ; return $ this ; } | Looks for a locale in the query string and updates the locale object |
46,187 | public static function parseLocaleString ( ? string $ sLocale ) : array { return [ \ Locale :: getPrimaryLanguage ( $ sLocale ) , \ Locale :: getRegion ( $ sLocale ) , \ Locale :: getScript ( $ sLocale ) , ] ; } | Parses a locale string into it s respective framgments |
46,188 | public function set ( \ Nails \ Common \ Factory \ Locale $ oLocale = null ) : self { $ this -> oLocale = $ oLocale ; return $ this ; } | Manually sets a locale |
46,189 | public function getDefautLocale ( ) : \ Nails \ Common \ Factory \ Locale { return Factory :: factory ( 'Locale' ) -> setLanguage ( Factory :: factory ( 'LocaleLanguage' , null , static :: DEFAULT_LANGUAGE ) ) -> setRegion ( Factory :: factory ( 'LocaleRegion' , null , static :: DEFAULT_REGION ) ) -> setScript ( Factor... | Returns the default locale to use for the system |
46,190 | public function isSupportedLocale ( \ Nails \ Common \ Factory \ Locale $ oLocale ) : bool { return in_array ( $ oLocale , $ this -> getSupportedLocales ( ) ) ; } | Returns whetehr the supplied locale is supported or not |
46,191 | public function getUrlRegex ( ) : string { $ aSupportedLocales = $ this -> getSupportedLocales ( ) ; $ aUrlLocales = [ ] ; foreach ( $ aSupportedLocales as $ oLocale ) { $ sVanity = $ this -> getUrlSegment ( $ oLocale ) ; $ aUrlLocales [ ] = $ sVanity ; } return '/^(' . implode ( '|' , array_filter ( $ aUrlLocales ) ) ... | Returns a regex suitable for detecting a language flag at the beginning of the URL |
46,192 | public static function flagEmoji ( \ Nails \ Common \ Factory \ Locale $ oLocale ) : string { $ sRegion = $ oLocale -> getRegion ( ) ; $ aCountries = json_decode ( file_get_contents ( NAILS_APP_PATH . 'vendor/annexare/countries-list/dist/countries.emoji.json' ) ) ; return ! empty ( $ aCountries -> { $ sRegion } -> emoj... | Returns an emoji flag for a locale |
46,193 | public function getUrlSegment ( \ Nails \ Common \ Factory \ Locale $ oLocale ) : string { if ( $ oLocale == $ this -> getDefautLocale ( ) ) { return '' ; } else { return getFromArray ( ( string ) $ oLocale , static :: URL_VANITY_MAP , ( string ) $ oLocale ) ; } } | Returns the URL prefix for a given locale considering any vanity preferences |
46,194 | public static function encode ( $ mValue , $ sSalt = '' ) { try { return Crypto :: encryptWithPassword ( $ mValue , static :: getKey ( $ sSalt ) ) ; } catch ( EnvironmentIsBrokenException $ e ) { throw new EnvironmentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } } | Encodes a given value using the supplied key |
46,195 | public static function decode ( $ sCipher , $ sSalt = '' ) { try { return Crypto :: decryptWithPassword ( $ sCipher , static :: getKey ( $ sSalt ) ) ; } catch ( EnvironmentIsBrokenException $ e ) { throw new EnvironmentException ( $ e -> getMessage ( ) , $ e -> getCode ( ) ) ; } catch ( WrongKeyOrModifiedCiphertextExce... | Decodes a given value using the supplied key |
46,196 | public static function migrate ( $ sCipher , $ sOldKey , $ sNewSalt = '' ) { require_once NAILS_CI_SYSTEM_PATH . 'libraries/Encrypt.php' ; $ oEncryptCi = new \ CI_Encrypt ( ) ; $ oEncrypt = Factory :: service ( 'Encrypt' ) ; return $ oEncrypt :: encode ( $ oEncryptCi -> decode ( $ sCipher , $ sOldKey ) , $ sNewSalt ) ;... | Migrates a cipher from CI encrypt library to Defuse \ Crypto library |
46,197 | public static function isValidIp ( $ sIp , $ sType = null ) { switch ( strtoupper ( $ sType ) ) { case 'IPV4' : return filter_var ( $ sIp , FILTER_VALIDATE_IP , FILTER_FLAG_IPV4 ) ; break ; case 'IPV6' : return filter_var ( $ sIp , FILTER_VALIDATE_IP , FILTER_FLAG_IPV6 ) ; break ; default : return filter_var ( $ sIp , ... | Validate an IP address |
46,198 | private function getContentType ( Content $ content ) : EzContentType { if ( method_exists ( $ content , 'getContentType' ) ) { return $ content -> getContentType ( ) ; } return $ this -> contentTypeService -> loadContentType ( $ content -> contentInfo -> contentTypeId ) ; } | Loads the content type for provided content . |
46,199 | private function createSeeder ( ) : void { $ aFields = $ this -> getArguments ( ) ; $ aCreated = [ ] ; try { $ aModels = array_filter ( explode ( ',' , $ aFields [ 'MODEL_NAME' ] ) ) ; sort ( $ aModels ) ; foreach ( $ aModels as $ sModel ) { $ aFields [ 'MODEL_NAME' ] = $ sModel ; $ this -> oOutput -> write ( 'Creating... | Create the Seeder |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.