idx int64 0 241k | question stringlengths 64 6.21k | target stringlengths 5 803 |
|---|---|---|
16,400 | public static function getSalt ( ) : string { $ result = '' ; try { $ result = static :: readSaltFromFile ( ) ; } catch ( InvalidArgumentException $ e ) { Log :: warning ( "Failed to read salt from file" ) ; } if ( $ result ) { return $ result ; } try { $ salt = static :: generateSalt ( ) ; static :: writeSaltToFile ( ... | Get configured salt string |
16,401 | protected static function readSaltFromFile ( ) : string { Utility :: validatePath ( static :: $ saltFile ) ; $ result = file_get_contents ( static :: $ saltFile ) ; $ result = $ result ? : '' ; static :: validateSalt ( $ result ) ; return $ result ; } | Read salt string from file |
16,402 | protected static function writeSaltToFile ( string $ salt ) : void { static :: validateSalt ( $ salt ) ; $ result = @ file_put_contents ( static :: $ saltFile , $ salt ) ; if ( ( $ result === false ) || ( $ result <> strlen ( $ salt ) ) ) { throw new InvalidArgumentException ( "Failed to write salt to file [" . static ... | Write a valid salt string to file |
16,403 | protected static function validateSalt ( string $ salt ) : void { if ( ! ctype_print ( $ salt ) ) { throw new InvalidArgumentException ( "Salt is not a printable string" ) ; } static :: validateSaltMinLength ( ) ; $ saltLength = strlen ( $ salt ) ; if ( $ saltLength < static :: $ saltMinLength ) { throw new InvalidArgu... | Validate salt string |
16,404 | protected static function generateSalt ( ) : string { $ result = '' ; static :: validateSaltMinLength ( ) ; $ pool = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ' ; $ poolSize = strlen ( $ pool ) ; for ( $ i = 0 ; $ i < static :: $ saltMinLength ; $ i ++ ) { $ result .= $ pool [ rand ( 0 , $ poolSize... | Generate salt string |
16,405 | public function getBrowser ( $ startPage , $ type = '*firefox' ) { $ url = 'http://' . $ this -> host . ':' . $ this -> port . '/selenium-server/driver/' ; $ driver = new Driver ( $ url , $ this -> timeout ) ; $ class = $ this -> browserClass ; return new $ class ( $ driver , $ startPage , $ type ) ; } | Creates a new browser instance . |
16,406 | public function describeTable ( $ table ) { if ( ! $ this -> connection -> expr ( 'show tables like []' , [ $ table ] ) -> get ( ) ) { return [ ] ; } $ result = [ ] ; foreach ( $ this -> connection -> expr ( 'describe {}' , [ $ table ] ) as $ row ) { $ row2 = [ ] ; $ row2 [ 'name' ] = $ row [ 'Field' ] ; $ row2 [ 'pk' ... | Return database table descriptions . DB engine specific . |
16,407 | public function getHash ( ) { if ( null === $ this -> hash ) { $ this -> hash = $ this -> calculateHash ( ) ; } return $ this -> hash ; } | Returns the hash of the form object which should be calculated only once for performance concerns . |
16,408 | public function register ( $ handledErrors = E_ALL ) { $ errHandler = [ $ this , 'handleError' ] ; $ exHandler = [ $ this , 'handleException' ] ; $ handledErrors = is_int ( $ handledErrors ) ? $ handledErrors : E_ALL ; set_error_handler ( $ errHandler , $ handledErrors ) ; set_exception_handler ( $ exHandler ) ; return... | Register this handler as the exception and error handler . |
16,409 | public function registerShutdown ( ) { if ( self :: $ reservedMemory === null ) { self :: $ reservedMemory = str_repeat ( 'x' , 10240 ) ; register_shutdown_function ( __CLASS__ . '::handleFatalError' ) ; } self :: $ exceptionHandler = [ $ this , 'handleException' ] ; return $ this ; } | Register this handler as the shutdown handler . |
16,410 | protected function fetchProcessorInstanceFromCache ( $ cacheIdentifier , FormObject $ formObject ) { $ cacheInstance = CacheService :: get ( ) -> getCacheInstance ( ) ; if ( $ cacheInstance -> has ( $ cacheIdentifier ) ) { $ instance = $ cacheInstance -> get ( $ cacheIdentifier ) ; $ instance -> attachFormObject ( $ fo... | Will either fetch the processor instance from cache using the given identifier or calculate it and store it in cache . |
16,411 | public function verify ( $ response ) { $ result = $ this -> getVerificationResult ( $ response ) ; if ( $ result [ 'success' ] ) { return true ; } if ( ! empty ( $ result [ 'error-codes' ] ) ) { $ this -> errors = $ result [ 'error-codes' ] ; } return false ; } | Returns whether the given response was successful . |
16,412 | protected function getScriptSrc ( $ onloadCallbackName ) { $ url = static :: SCRIPT_URL ; $ queryArgs = [ ] ; \ parse_str ( \ parse_url ( $ url , PHP_URL_QUERY ) , $ queryArgs ) ; $ queryArgs [ 'onload' ] = $ onloadCallbackName ; $ queryArgs [ 'render' ] = 'explicit' ; $ url = \ sprintf ( '%s?%s' , \ strtok ( $ url , '... | Returns the recaptcha API script source with an onload callback . |
16,413 | private function getContentTypeHandler ( ServerRequestInterface $ request ) { $ acceptHeader = $ request -> getHeaderLine ( 'Accept' ) ; $ acceptedTypes = explode ( ',' , $ acceptHeader ) ; foreach ( $ this -> handlers as $ contentType => $ handler ) { if ( $ this -> doesTypeMatch ( $ acceptedTypes , $ contentType ) ) ... | Get a content handler based on Accept header in the request . |
16,414 | public function beforeSave ( Event $ event , EntityInterface $ entity , ArrayObject $ options ) : void { if ( ! is_callable ( $ this -> getConfig ( 'callback' ) ) ) { return ; } $ user = call_user_func ( $ this -> getConfig ( 'callback' ) ) ; if ( empty ( $ user [ 'id' ] ) ) { return ; } if ( $ entity -> isNew ( ) && e... | BeforeSave callback method . |
16,415 | public function build ( InputSettings $ settings ) { $ this -> settings = $ settings ; $ this -> setElement ( ) ; $ this -> setValidator ( ) ; $ this -> setLabel ( ) ; $ this -> setDefault ( ) ; $ this -> setAttributes ( ) ; $ this -> setData ( ) ; $ this -> setAdditionalOptions ( ) ; return $ this -> getElement ( ) ; ... | Method for building form element |
16,416 | public function initElement ( ) { if ( is_null ( $ this -> settings ) ) { $ this -> settings = new InputSettings ( ) ; } return $ this -> build ( $ this -> settings ) ; } | Method sets element and return object instance . Only for form builder purpose . |
16,417 | public function setLabel ( ) { if ( $ this -> settings -> getValue ( InputSettings :: LABEL_PARAM ) ) { $ this -> element -> setLabel ( $ this -> settings -> getValue ( InputSettings :: LABEL_PARAM ) ) ; } else { $ this -> element -> setLabel ( preg_replace ( '/.*\\\/' , '' , get_class ( $ this ) ) ) ; } } | Default setter for element label |
16,418 | public function setDefault ( ) { if ( $ this -> settings -> getValue ( InputSettings :: DEFAULTS_PARAM ) ) { $ this -> element -> setDefault ( $ this -> settings -> getValue ( InputSettings :: DEFAULTS_PARAM ) ) ; } } | Default setter for element default value |
16,419 | public function setAttributes ( ) { if ( $ this -> settings -> getValue ( InputSettings :: PLACEHOLDER_PARAM ) ) { $ this -> element -> setAttribute ( 'placeholder' , $ this -> settings -> getValue ( InputSettings :: PLACEHOLDER_PARAM ) ) ; } } | Default setter for placeholder attribute |
16,420 | protected function getNewInstance ( ) { $ className = $ this -> objectMetadata -> getName ( ) ; if ( class_exists ( $ className ) === false ) { throw new \ RuntimeException ( 'Unable to create new instance of ' . $ className ) ; } return new $ className ; } | Return a new instance of the object |
16,421 | protected function setValue ( $ object , $ value , $ setter ) { if ( method_exists ( $ object , $ setter ) ) { $ object -> $ setter ( $ value ) ; } } | Call a setter of the object |
16,422 | public function getAssetHandler ( $ className ) { if ( false === array_key_exists ( $ className , $ this -> instances ) ) { if ( false === class_exists ( $ className ) ) { throw ClassNotFoundException :: wrongAssetHandlerClassName ( $ className ) ; } $ instance = GeneralUtility :: makeInstance ( $ className , $ this ) ... | Return an instance of the wanted asset handler . Local storage is handled . |
16,423 | public function getFormInitializationJavaScriptCode ( ) { $ formName = GeneralUtility :: quoteJSvalue ( $ this -> getFormObject ( ) -> getName ( ) ) ; $ formConfigurationJson = $ this -> handleFormConfiguration ( $ this -> getFormConfiguration ( ) ) ; $ javaScriptCode = <<<JS(function() { Fz.Form.register($formName... | Generates and returns JavaScript code to instantiate a new form . |
16,424 | protected function getFormConfiguration ( ) { $ formConfigurationArray = $ this -> getFormObject ( ) -> getConfiguration ( ) -> toArray ( ) ; $ this -> removeFieldsValidationConfiguration ( $ formConfigurationArray ) -> addClassNameProperty ( $ formConfigurationArray ) ; return ArrayService :: get ( ) -> arrayToJavaScr... | Returns a JSON array containing the form configuration . |
16,425 | protected function removeFieldsValidationConfiguration ( array & $ formConfiguration ) { foreach ( $ formConfiguration [ 'fields' ] as $ fieldName => $ fieldConfiguration ) { if ( true === isset ( $ fieldConfiguration [ 'validation' ] ) ) { unset ( $ fieldConfiguration [ 'validation' ] ) ; unset ( $ fieldConfiguration ... | To lower the length of the JavaScript code we remove useless fields validation configuration . |
16,426 | public function getJavaScriptCode ( ) { $ realTranslations = [ ] ; $ translationsBinding = [ ] ; foreach ( $ this -> translations as $ key => $ value ) { $ hash = HashService :: get ( ) -> getHash ( $ value ) ; $ realTranslations [ $ hash ] = $ value ; $ translationsBinding [ $ key ] = $ hash ; } $ jsonRealTranslations... | Will generate and return the JavaScript code which add all registered translations to the JavaScript library . |
16,427 | public function getTranslationKeysForFieldValidation ( Field $ field , $ validationName ) { $ result = [ ] ; if ( true === $ field -> hasValidation ( $ validationName ) ) { $ key = $ field -> getName ( ) . '-' . $ validationName ; $ this -> storeTranslationsForFieldValidation ( $ field ) ; $ result = $ this -> translat... | Returns the keys which are bound to translations for a given field validation rule . |
16,428 | public function injectTranslationsForFormFieldsValidation ( ) { $ formConfiguration = $ this -> getFormObject ( ) -> getConfiguration ( ) ; foreach ( $ formConfiguration -> getFields ( ) as $ field ) { $ this -> storeTranslationsForFieldValidation ( $ field ) ; } return $ this ; } | Will loop on each field of the given form and get every translations for the validation rules messages . |
16,429 | protected function storeTranslationsForFieldValidation ( Field $ field ) { if ( false === $ this -> translationsForFieldValidationWereInjected ( $ field ) ) { $ fieldName = $ field -> getName ( ) ; foreach ( $ field -> getValidation ( ) as $ validationName => $ validation ) { $ messages = ValidatorService :: get ( ) ->... | Will loop on each validation rule of the given field and get the translations of the rule messages . |
16,430 | protected function translationsForFieldValidationWereInjected ( Field $ field ) { $ key = $ this -> getFormObject ( ) -> getClassName ( ) . '-' . $ field -> getName ( ) ; return true === isset ( $ this -> injectedTranslationKeysForFieldValidation [ $ key ] ) ; } | Checks if the given field validation rules were already handled by this asset handler . |
16,431 | public static function getConfigurationObjectServices ( ) { return ServiceFactory :: getInstance ( ) -> attach ( ServiceInterface :: SERVICE_CACHE ) -> with ( ServiceInterface :: SERVICE_CACHE ) -> setOption ( CacheService :: OPTION_CACHE_NAME , InternalCacheService :: CONFIGURATION_OBJECT_CACHE_IDENTIFIER ) -> setOpti... | Will initialize correctly the configuration object settings . |
16,432 | public function addForm ( FormObject $ form ) { if ( true === $ this -> hasForm ( $ form -> getClassName ( ) , $ form -> getName ( ) ) ) { throw DuplicateEntryException :: formWasAlreadyRegistered ( $ form ) ; } $ form -> getConfiguration ( ) -> setParents ( [ $ this ] ) ; $ this -> forms [ $ form -> getClassName ( ) ]... | Adds a form to the forms list of this FormZ configuration . Note that this function will also handle the parent service from the configuration_object extension . |
16,433 | public function calculateHash ( ) { $ fullArray = $ this -> toArray ( ) ; $ configurationArray = [ 'view' => $ fullArray [ 'view' ] , 'settings' => $ fullArray [ 'settings' ] ] ; $ this -> hash = HashService :: get ( ) -> getHash ( serialize ( $ configurationArray ) ) ; } | Calculates a hash for this configuration which can be used as a unique identifier . It should be called once before the configuration is put in cache so it is not needed to call it again after being fetched from cache . |
16,434 | public function buildCode ( ) { $ code = '' ; if ( $ this -> documentation ) { $ code .= ' /**' . "\n" ; $ code .= ' * ' . str_replace ( "\n" , "\n * " , wordwrap ( $ this -> documentation , 73 ) ) . "\n" ; $ code .= ' */' . "\n" ; } $ code .= ' public function ' . $ this -> name . '(' . implode ( ', ... | Builds the PHP code for the method . |
16,435 | public function createVocabulary ( $ name ) { if ( $ this -> vocabulary -> where ( 'name' , $ name ) -> count ( ) ) { throw new Exceptions \ VocabularyExistsException ( ) ; } return $ this -> vocabulary -> create ( [ 'name' => $ name ] ) ; } | Create a new Vocabulary with the given name |
16,436 | public function getVocabularyByNameAsArray ( $ name ) { $ vocabulary = $ this -> vocabulary -> where ( 'name' , $ name ) -> first ( ) ; if ( ! is_null ( $ vocabulary ) ) { return $ vocabulary -> terms -> pluck ( 'name' , 'id' ) -> toArray ( ) ; } return [ ] ; } | Get a Vocabulary by name |
16,437 | public function getVocabularyByNameOptionsArray ( $ name ) { $ vocabulary = $ this -> vocabulary -> where ( 'name' , $ name ) -> first ( ) ; if ( is_null ( $ vocabulary ) ) { return [ ] ; } $ parents = $ this -> term -> whereParent ( 0 ) -> whereVocabularyId ( $ vocabulary -> id ) -> orderBy ( 'weight' , 'ASC' ) -> get... | Get a Vocabulary by name as an options array for dropdowns |
16,438 | private function recurse_children ( $ parent , & $ options , $ depth = 1 ) { $ parent -> childrens -> map ( function ( $ child ) use ( & $ options , $ depth ) { $ options [ $ child -> id ] = str_repeat ( '-' , $ depth ) . ' ' . $ child -> name ; if ( $ child -> childrens ) { $ this -> recurse_children ( $ child , $ opt... | Recursively visit the children of a term and generate the - option array for dropdowns |
16,439 | public function deleteVocabularyByName ( $ name ) { $ vocabulary = $ this -> vocabulary -> where ( 'name' , $ name ) -> first ( ) ; if ( ! is_null ( $ vocabulary ) ) { return $ vocabulary -> delete ( ) ; } return FALSE ; } | Delete a Vocabulary by name |
16,440 | public function createTerm ( $ vid , $ name , $ parent = 0 , $ weight = 0 ) { $ vocabulary = $ this -> vocabulary -> findOrFail ( $ vid ) ; $ term = [ 'name' => $ name , 'vocabulary_id' => $ vid , 'parent' => $ parent , 'weight' => $ weight , ] ; return $ this -> term -> create ( $ term ) ; } | Create a new term in a specific vocabulary |
16,441 | public function isValid ( $ condition ) { $ conditionTree = ConditionParser :: get ( ) -> parse ( $ condition ) ; if ( true === $ conditionTree -> getValidationResult ( ) -> hasErrors ( ) ) { $ errorMessage = $ this -> translateErrorMessage ( 'validator.form.condition_is_valid.error' , 'formz' , [ $ condition -> getExp... | Checks if the value is a valid condition string . |
16,442 | protected function alias ( $ aliasKey , $ serviceKey ) { $ this -> bindFactory ( $ aliasKey , function ( Container $ app ) use ( $ serviceKey ) { return $ app [ $ serviceKey ] ; } ) ; } | Alias a service name to another one within the service container allowing for example concrete types to be aliased to an interface or legacy string service keys against concrete class names . |
16,443 | protected function autoBind ( $ className , callable $ parameterFactory = null ) { $ this -> bind ( $ className , $ this -> closureFactory -> createAutoWireClosure ( $ className , $ parameterFactory ) ) ; } | Automatically bind and wire a service using the Injector . Accepts an optional callable to build parameter overrides |
16,444 | protected function autoBindFactory ( $ className , callable $ parameterFactory = null ) { $ this -> bindFactory ( $ className , $ this -> closureFactory -> createAutoWireClosure ( $ className , $ parameterFactory ) ) ; } | Automatically bind and wire a factory using the Injector . Accepts an optional callable to build parameter overrides . |
16,445 | public function create ( $ className , $ parameters = [ ] ) { $ reflectionClass = new \ ReflectionClass ( $ className ) ; if ( ! $ reflectionClass -> hasMethod ( "__construct" ) ) { return $ reflectionClass -> newInstanceWithoutConstructor ( ) ; } if ( ! $ reflectionClass -> getMethod ( '__construct' ) -> isPublic ( ) ... | Instantiate an object and attempt to inject the dependencies for the class by mapping constructor parameter \ names to objects registered within the IoC container . |
16,446 | public function canAutoCreate ( $ className ) { foreach ( $ this -> autoCreateWhiteList as $ regex ) { if ( preg_match ( $ regex , $ className ) ) { return true ; } } return false ; } | Check whether the Injector has been configured to allow automatic construction of the given FQCN as a dependency |
16,447 | private function buildParameterArray ( $ methodSignature , $ providedParameters ) { $ parameters = [ ] ; foreach ( $ methodSignature as $ position => $ parameterData ) { if ( ! isset ( $ parameterData [ 'variadic' ] ) ) { $ parameters [ $ position ] = $ this -> resolveParameter ( $ position , $ parameterData , $ provid... | Construct the parameter array to be passed to a method call based on its parameter signature |
16,448 | public function getSignatureByReflectionClass ( \ ReflectionClass $ reflectionClass , $ methodName ) { $ className = $ reflectionClass -> getName ( ) ; return $ this -> getMethodSignature ( $ className , $ methodName , $ reflectionClass ) ; } | Fetch the method signature of a method when we have already created a \ ReflectionClass |
16,449 | public function createAutoWireClosure ( $ className , callable $ parameterFactory = null ) { return function ( Container $ app ) use ( $ className , $ parameterFactory ) { $ parameters = $ parameterFactory ? $ parameterFactory ( $ app ) : [ ] ; return $ this -> injector -> create ( $ className , $ parameters ) ; } ; } | Generate a closure that will use the Injector to auto - wire a service definition . |
16,450 | private function createProxy ( $ className , callable $ serviceFactory , Container $ app ) { return $ this -> proxyFactory -> createProxy ( $ className , function ( & $ wrappedObject , $ proxy , $ method , $ parameters , & $ initializer ) use ( $ className , $ serviceFactory , $ app ) { $ wrappedObject = $ serviceFacto... | Create a project object for the specified ClassName bound to the given ServiceFactory method . |
16,451 | public function classmap ( ) { $ path = $ this -> composerPath . $ this -> classmapName ; $ i = 0 ; if ( is_file ( $ path ) ) { $ data = include $ path ; foreach ( $ data as $ key => $ value ) { if ( false === empty ( $ value ) ) { $ this -> libs [ addcslashes ( $ key , '\\' ) ] = $ value ; $ i ++ ; } } $ this -> log [... | Load autoload_classmap . php classes |
16,452 | public function psr0 ( ) { $ i = $ this -> load ( $ this -> composerPath . $ this -> psrZeroName ) ; if ( $ i !== false ) { $ this -> log [ ] = 'Imported ' . $ i . ' classes from psr0' ; return $ i ; } $ this -> log [ ] = 'Warn: psr0 not found' ; return false ; } | Load autoload_namespaces . php classes used by PSR - 0 packages |
16,453 | public function psr4 ( ) { $ i = $ this -> load ( $ this -> composerPath . $ this -> psrFourName ) ; if ( $ i !== false ) { $ this -> log [ ] = 'Imported ' . $ i . ' classes from psr4' ; return $ i ; } $ this -> log [ ] = 'Warn: psr4 not found' ; return false ; } | Load autoload_psr4 . php classes used by PSR - 4 packages |
16,454 | public function save ( $ path ) { if ( count ( $ this -> libs ) === 0 ) { return false ; } $ handle = fopen ( $ path , 'w' ) ; if ( $ handle === false ) { throw new \ InvalidArgumentException ( 'This path is not writabled: ' . $ path ) ; } $ first = true ; $ eol = chr ( 10 ) ; fwrite ( $ handle , '<?php' . $ eol . 'ret... | Save imported packages path to file in PHP format |
16,455 | public static function version ( $ name ) { $ file = INPHINIT_ROOT . 'composer.lock' ; $ data = is_file ( $ file ) ? json_decode ( file_get_contents ( $ file ) ) : false ; if ( empty ( $ data -> packages ) ) { return false ; } $ version = false ; foreach ( $ data -> packages as $ package ) { if ( $ package -> name === ... | Get package version from composer . lock file |
16,456 | public function get ( $ object ) : array { $ values = $ this -> storage -> get ( $ object ) ; return ( $ values === null ) ? [ ] : $ values ; } | Returns the values associated to the given object . |
16,457 | public function add ( $ object , $ value ) : void { $ values = $ this -> get ( $ object ) ; $ values [ ] = $ value ; $ this -> storage -> set ( $ object , $ values ) ; } | Adds data associated with the given object . |
16,458 | private function getDimensions ( \ media_subdef $ subdef ) { $ outWidth = $ subdef -> get_width ( ) ; $ outHeight = $ subdef -> get_height ( ) | $ outWidth ; $ thumbnail_height = $ subdef -> get_height ( ) > 0 ? $ subdef -> get_height ( ) : 120 ; $ thumbnail_width = $ subdef -> get_width ( ) > 0 ? $ subdef -> get_width... | Php raw implementation of thumbnails . html . twig macro |
16,459 | public function getVideoTextTrackContent ( MediaInformation $ media , $ id ) { $ id = ( int ) $ id ; $ record = $ media -> getResource ( ) -> get_record ( ) ; $ videoTextTrack = false ; if ( $ record -> getType ( ) === 'video' ) { $ databox = $ record -> getDatabox ( ) ; $ vttIds = [ ] ; foreach ( $ databox -> get_meta... | Fetch vtt files content if exists |
16,460 | public static function ignoreif ( $ callback ) { if ( is_callable ( $ callback ) === false ) { throw new Exception ( 'Invalid callback' ) ; } App :: on ( 'init' , function ( ) use ( $ callback ) { if ( $ callback ( ) ) { App :: env ( 'maintenance' , false ) ; } } ) ; } | Up the site only in certain conditions eg . the site administrator of the IP . |
16,461 | public static function createFromFormat ( $ format , $ date , $ tz = null ) { if ( $ tz !== null ) { $ tz = static :: safeCreateDateTimeZone ( $ tz ) ; } $ instance = new static ( $ tz ) ; $ instance -> parseFormat ( $ format , $ date ) ; return $ instance ; } | Create a JDate instance from a specific format |
16,462 | private static function calculateYearInQuadCycle ( $ year ) { $ yearInGrandCycle = static :: calculateYearInGrandCycle ( $ year ) ; $ yearInQuadCycle = $ yearInGrandCycle % static :: FIRST_QUAD_CYCLE ; if ( ( static :: GRAND_CYCLE_LENGTH - static :: SECOND_QUAD_CYCLE ) < $ yearInGrandCycle ) { $ yearInQuadCycle = $ yea... | check the quad cycle type & count |
16,463 | private static function calculateYearInGrandCycle ( $ year ) { $ grandCycle = static :: calculateGrandCycle ( $ year ) ; if ( $ grandCycle < 0 ) { $ year = ( static :: GRAND_CYCLE_BEGINNING + ( $ grandCycle * static :: GRAND_CYCLE_LENGTH ) ) - $ year ; } elseif ( $ grandCycle > 0 ) { $ year = $ year - ( static :: GRAND... | returns the number of year in current grand cycle |
16,464 | private static function calculateGrandCycle ( $ year ) { $ endOfFirstGrandCycle = static :: GRAND_CYCLE_BEGINNING + static :: GRAND_CYCLE_LENGTH ; $ grandCycle = 0 ; if ( $ year < static :: GRAND_CYCLE_BEGINNING ) { $ beginningYear = static :: GRAND_CYCLE_BEGINNING ; while ( $ year < $ beginningYear ) { $ beginningYear... | calculate that which grand cycle we are in |
16,465 | private function setYear ( $ year ) { if ( $ year == $ this -> year ) { return ; } $ this -> year = ( int ) $ year ; $ maximumDayAvailable = static :: getMonthLength ( $ this -> year , $ this -> month ) ; if ( $ this -> day > $ maximumDayAvailable ) { $ this -> day = $ maximumDayAvailable ; } } | Update year in jalali date |
16,466 | private function setMonth ( $ month ) { if ( $ month == $ this -> month ) { return ; } $ yearToSet = $ this -> year ; $ monthToSet = $ month ; if ( $ monthToSet < 1 ) { $ monthToSet = abs ( $ monthToSet ) ; $ yearToSet -- ; $ yearToSet -= floor ( $ monthToSet / 12 ) ; $ monthToSet = 12 - ( $ monthToSet % 12 ) ; } elsei... | Update month in jalali date |
16,467 | private function setDay ( $ day ) { if ( $ day == $ this -> day ) { return ; } $ maximumDayOfMonth = static :: getMonthLength ( $ this -> month , $ this -> year ) ; $ dayToSet = $ day ; if ( $ dayToSet < 1 ) { $ dayToSet = abs ( $ dayToSet ) ; while ( $ dayToSet > $ maximumDayOfMonth ) { $ dayToSet -= $ maximumDayOfMon... | Update day in jalali date |
16,468 | public function year ( $ value ) { $ this -> setDate ( $ value , $ this -> month , $ this -> day ) ; return $ this ; } | Set the instance s year |
16,469 | public function setDate ( $ year , $ month , $ day ) { $ this -> setYear ( ( int ) $ year ) ; $ this -> setMonth ( ( int ) $ month ) ; $ this -> setDay ( ( int ) $ day ) ; $ this -> updateGeorgianFromJalali ( ) ; return $ this ; } | Sets the current date of the DateTime object to a different date . |
16,470 | public function setTime ( $ hour , $ minute , $ second = 0 ) { $ this -> carbon -> setTime ( $ hour , $ minute , $ second ) ; return $ this ; } | Sets the current time of the DateTime object to a different time . |
16,471 | private function updateJalaliFromGeorgian ( $ force = false ) { if ( $ this -> converted && ! $ force ) { return ; } list ( $ year , $ month , $ day ) = self :: julian2jalali ( self :: georgian2julian ( $ this -> carbon -> year , $ this -> carbon -> month , $ this -> carbon -> day ) ) ; $ this -> year = $ year ; $ this... | Update the Jalali Core from the Carbon As Georgian Core |
16,472 | protected static function jalali2julian ( $ year , $ month , $ day ) { $ parsed = self :: parseJalali ( $ year ) ; return self :: georgian2julian ( $ parsed [ 'gYear' ] , 3 , $ parsed [ 'march' ] ) + ( $ month - 1 ) * 31 - self :: division ( $ month , 7 ) * ( $ month - 7 ) + $ day - 1 ; } | Converts a date of the Jalali calendar to the Julian Day number . |
16,473 | protected static function julian2jalali ( $ julianDayNumber ) { $ gYear = self :: julian2georgian ( $ julianDayNumber ) [ 0 ] ; $ year = $ gYear - static :: HEGIRA_STARTING_YEAR ; $ parsed = self :: parseJalali ( $ year ) ; $ jdn1f = self :: georgian2julian ( $ gYear , 3 , $ parsed [ 'march' ] ) ; $ passed = $ julianDa... | Converts the Julian Day number to a date in the Jalali calendar . |
16,474 | public function fromArray ( array $ data ) { if ( empty ( $ data ) ) { throw new DomException ( 'Array is empty' , 2 ) ; } elseif ( count ( $ data ) > 1 ) { throw new DomException ( 'Root array accepts only a key' , 2 ) ; } elseif ( Helper :: seq ( $ data ) ) { throw new DomException ( 'Document accpet only a node' , 2... | Convert a array in node elements |
16,475 | public function toJson ( $ format = Document :: MININAL , $ options = 0 ) { $ this -> exceptionlevel = 4 ; $ json = json_encode ( $ this -> toArray ( $ format ) , $ options ) ; $ this -> exceptionlevel = 3 ; return $ json ; } | Convert DOM to JSON string |
16,476 | public function toArray ( $ type = Document :: SIMPLE ) { switch ( $ type ) { case Document :: MININAL : $ this -> simple = false ; $ this -> complete = false ; break ; case Document :: SIMPLE : $ this -> simple = true ; break ; case Document :: COMPLETE : $ this -> complete = true ; break ; default : throw new DomExce... | Convert DOM to Array |
16,477 | public function save ( $ path , $ format = Document :: XML ) { switch ( $ format ) { case Document :: XML : $ format = 'saveXML' ; break ; case Document :: HTML : $ format = 'saveHTML' ; break ; case Document :: JSON : $ format = 'toJson' ; break ; default : throw new DomException ( 'Invalid format' , 2 ) ; } $ tmp = S... | Save file to location |
16,478 | public function getNamespaces ( \ DOMElement $ element = null ) { if ( $ this -> xpath === null ) { $ this -> xpath = new \ DOMXPath ( $ this ) ; } if ( $ element === null ) { $ nodes = $ this -> xpath -> query ( 'namespace::*' ) ; } else { $ nodes = $ this -> xpath -> query ( 'namespace::*' , $ element ) ; } $ ns = ar... | Get namespace attributes from root element or specific element |
16,479 | public function query ( $ selector , \ DOMNode $ context = null ) { $ this -> enableRestoreInternal ( true ) ; if ( $ this -> selector === null ) { $ this -> selector = new Selector ( $ this ) ; } $ nodes = $ this -> selector -> get ( $ selector , $ context ) ; $ this -> raise ( $ this -> exceptionlevel ) ; $ this -> e... | Use query - selector like CSS jQuery querySelectorAll |
16,480 | public function first ( $ selector , \ DOMNode $ context = null ) { $ this -> exceptionlevel = 4 ; $ nodes = $ this -> query ( $ selector , $ context ) ; $ this -> exceptionlevel = 3 ; $ node = $ nodes -> length ? $ nodes -> item ( 0 ) : null ; $ nodes = null ; return $ node ; } | Use query - selector like CSS jQuery querySelector |
16,481 | public function getCard ( $ index = 0 , $ failOnNoCardFound = false ) { if ( ! array_key_exists ( $ index , $ this -> reel [ 'cards' ] ) ) { if ( $ failOnNoCardFound ) { throw new Exception \ NoCardFoundException ( sprintf ( "Cannot resolve a card value for the '%s' slot. (Perhaps you need to set a '_default' alias for... | Get a value of a card by its index . If the card does not exist resolve based on the slot s resolve_undefined setting . |
16,482 | public function getCardByAlias ( $ alias ) { if ( ! array_key_exists ( $ alias , $ this -> aliases ) ) { throw new Exception \ NoSuchAliasException ( sprintf ( 'Alias "%s" has not been assigned to any cards.' , $ alias ) ) ; } return $ this -> getCard ( $ this -> aliases [ $ alias ] ) ; } | Get a card from the reel by an alias . |
16,483 | function FrontMatter ( $ input ) { if ( ! $ this -> startsWith ( $ input , $ this -> yaml_separator ) ) { $ final [ 'content' ] = $ input ; return $ final ; } $ document = explode ( $ this -> yaml_separator , $ input , 3 ) ; switch ( sizeof ( $ document ) ) { case 0 : case 1 : $ front_matter = "" ; $ content = "" ; bre... | FrontMatter method rturns all the variables from a YAML Frontmatter input |
16,484 | protected function Read ( $ file ) { $ fh = fopen ( $ file , 'r' ) ; $ fileSize = filesize ( $ file ) ; if ( ! empty ( $ fileSize ) ) { $ data = fread ( $ fh , $ fileSize ) ; $ data = str_replace ( array ( "\r\n" , "\r" , "\n" ) , "\n" , $ data ) ; } else { $ data = '' ; } fclose ( $ fh ) ; return $ data ; } | Read Method Read file and returns it s contents |
16,485 | public static function parseVersion ( $ version ) { if ( preg_match ( '#^(\d+)\.(\d+)\.(\d+)(\-([\w.\-]+)|)$#' , $ version , $ match ) ) { return ( object ) array ( 'major' => $ match [ 1 ] , 'minor' => $ match [ 2 ] , 'patch' => $ match [ 3 ] , 'extra' => empty ( $ match [ 5 ] ) ? null : $ match [ 5 ] ) ; } return fal... | Parse version format |
16,486 | public static function toAscii ( $ text ) { $ encode = mb_detect_encoding ( $ text , mb_detect_order ( ) , true ) ; return 'ASCII' === $ encode ? $ text : iconv ( $ encode , 'ASCII//TRANSLIT//IGNORE' , $ text ) ; } | Convert string to ASCII |
16,487 | public static function capitalize ( $ text , $ delimiter = '-' , $ glue = '' ) { return implode ( $ glue , array_map ( 'ucfirst' , explode ( $ delimiter , strtolower ( $ text ) ) ) ) ; } | Capitalize words using hyphen or a custom delimiter . |
16,488 | public static function extract ( $ path , $ items ) { $ paths = explode ( '.' , $ path ) ; foreach ( $ paths as $ value ) { if ( self :: iterable ( $ items ) && array_key_exists ( $ value , $ items ) ) { $ items = $ items [ $ value ] ; } else { return false ; } } return $ items ; } | Read array by path using dot |
16,489 | public static function resolve ( $ path ) { if ( empty ( $ path ) ) { return false ; } $ path = Uri :: canonpath ( $ path ) ; if ( $ path . '/' === self :: path ( ) || strpos ( $ path , self :: path ( ) ) === 0 ) { return $ path ; } return self :: path ( ) . $ path ; } | Convert path to storage path |
16,490 | public static function autoclean ( $ path , $ time = - 1 ) { $ path = self :: resolve ( $ path ) ; if ( $ path !== false && is_dir ( $ path ) && ( $ dh = opendir ( $ path ) ) ) { if ( $ time < 0 ) { $ time = App :: env ( 'appdata_expires' ) ; } $ expires = REQUEST_TIME - $ time ; $ path .= '/' ; while ( false !== ( $ f... | Clear old files in a folder from storage path |
16,491 | public static function put ( $ path , $ data = null , $ flags = null ) { $ path = self :: resolve ( $ path ) ; if ( $ path === false ) { return false ; } $ data = is_numeric ( $ data ) === false && ! $ data ? '' : $ data ; if ( is_file ( $ path ) && ! $ data ) { return true ; } $ flags = $ flags ? $ flags : FILE_APPEND... | Create a file in a folder in storage or append data to existing file |
16,492 | public static function remove ( $ path ) { $ path = self :: resolve ( $ path ) ; return $ path && is_file ( $ path ) && unlink ( $ path ) ; } | Delete a file in storage |
16,493 | public static function removeFolder ( $ path ) { $ path = self :: resolve ( $ path ) ; return $ path && is_dir ( $ path ) && self :: rrmdir ( $ path ) ; } | Remove recursive folders in storage folder |
16,494 | private static function rrmdir ( $ path ) { $ path .= '/' ; foreach ( array_diff ( scandir ( $ path ) , array ( '..' , '.' ) ) as $ file ) { $ current = $ path . $ file ; if ( is_dir ( $ current ) ) { if ( self :: rrmdir ( $ current ) === false ) { return false ; } } elseif ( unlink ( $ current ) === false ) { return f... | Remove recursive folders |
16,495 | public function commit ( $ unlock = true ) { if ( empty ( $ this -> insertions ) && empty ( $ this -> deletions ) ) { return null ; } $ this -> lock ( ) ; $ data = '' ; rewind ( $ this -> handle ) ; $ data = trim ( stream_get_contents ( $ this -> handle ) ) ; if ( $ data !== '' ) { $ data = unserialize ( $ data ) ; $ t... | Lock session file and save variables |
16,496 | private function read ( ) { $ this -> lock ( ) ; $ data = '' ; rewind ( $ this -> handle ) ; $ data = trim ( stream_get_contents ( $ this -> handle ) ) ; if ( $ data !== '' ) { $ this -> data = unserialize ( $ data ) ; $ data = null ; } flock ( $ this -> handle , LOCK_UN ) ; $ this -> iterator = new \ ArrayIterator ( $... | Read session file |
16,497 | private function write ( ) { ftruncate ( $ this -> handle , 0 ) ; rewind ( $ this -> handle ) ; fwrite ( $ this -> handle , serialize ( $ this -> data ) ) ; } | Write variables in session file |
16,498 | public static function setup ( $ byType , array $ attributes ) { if ( 0 !== preg_match ( '#^(' . self :: $ alloweds . '|select|form)$#' , $ type ) ) { self :: $ preAttrs [ $ byType ] = $ attributes ; } } | Define default attributes for all elements |
16,499 | public static function comboRange ( $ name , $ low , $ high , $ step = null , $ value = null , array $ attributes = array ( ) ) { $ range = $ step !== null ? range ( $ low , $ high , $ step ) : range ( $ low , $ high ) ; $ range = array_combine ( $ range , $ range ) ; return self :: combo ( $ name , $ range , $ value ,... | Generate combo by range |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.