idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
240,700
public function set ( $ key , $ value ) { $ this -> values [ $ this -> normalizeKey ( $ key ) ] = $ value ; return $ this ; }
Set data key to value
240,701
public function get ( $ key , $ default = null ) { if ( $ this -> has ( $ key ) ) { $ isInvokable = is_object ( $ this -> values [ $ this -> normalizeKey ( $ key ) ] ) && method_exists ( $ this -> values [ $ this -> normalizeKey ( $ key ) ] , '__invoke' ) ; return $ isInvokable ? $ this -> values [ $ this -> normalizeK...
Get values value with key
240,702
function identity ( ) { if ( ! $ this -> identity ) $ this -> identity = new BaseIdentity ( get_class ( $ this ) ) ; return $ this -> identity ; }
Get Authorized User Identity
240,703
public function set ( $ name , $ value , $ scope = null ) { if ( strpos ( $ name , ':' ) ) { list ( $ entry , $ name ) = explode ( ':' , $ name ) ; $ cfg = $ this -> getConfig ( $ entry , array ( ) , $ scope ) ; $ cfg [ $ name ] = $ value ; return $ this -> setConfig ( $ entry , $ cfg , $ scope ) ; } else { return $ th...
Set the value of a specific option with depth
240,704
public function setConfigs ( array $ options , $ scope = null ) { if ( ! is_null ( $ scope ) ) { $ this -> registry [ $ scope ] = $ options ; } else { $ this -> registry = $ options ; } return $ this ; }
Set an array of options
240,705
public function addConfig ( $ name , $ value , $ scope = null ) { return $ this -> setConfig ( $ name , $ value , $ scope ) ; }
Alias of the setConfig method
240,706
static function bytes ( $ bytes = Constants :: BYTES ) { Helpers :: rangeCheck ( $ bytes , Constants :: BYTES_MAX , Constants :: BYTES_MIN , 'Entropy' , 'bytes' ) ; return \ Sodium \ randombytes_buf ( $ bytes ) ; }
Returns a string of random bytes to the client .
240,707
static function integer ( $ range = Constants :: RANGE ) { Helpers :: rangeCheck ( $ range , Constants :: RANGE_MAX , Constants :: RANGE_MIN , 'Entropy' , 'integer' ) ; return \ Sodium \ randombytes_uniform ( $ range ) + 1 ; }
Returns a random integer to the client .
240,708
public function index ( ) { $ argv = \ Console_Getopt :: readPHPArgv ( ) ; $ opts = \ Console_Getopt :: getopt ( array_slice ( $ argv , 2 , count ( $ argv ) - 2 ) , 'h::p::d::r::' , null , true ) ; if ( ! empty ( $ opts [ 0 ] ) && is_array ( $ opts [ 0 ] ) ) { foreach ( $ opts [ 0 ] as $ val ) { if ( ! empty ( $ val [ ...
Runs PHP built - in web server
240,709
public static function decompress ( $ compressedFile , $ destinationFolder , $ originalFilename = null , $ format = 'gz' , $ allowedExtensions = [ 'csv' , 'tsv' ] ) { $ supported_formats = [ 'gz' , 'zip' , 'tar' ] ; if ( ! in_array ( $ format , $ supported_formats ) ) { throw new \ Exception ( 'Unsupported compression ...
decompress a file archive
240,710
public function getConfig ( $ configKey = null ) { $ default = clone $ this -> config -> configs -> default ; if ( null !== $ configKey ) { $ default -> merge ( clone $ this -> config -> configs -> { $ configKey } ) ; } return $ default -> toArray ( ) ; }
Get the default config merged with an option overriding config .
240,711
private function findRootPages ( ) : array { $ result = [ 'source' => null , 'target' => null , 'main' => null , ] ; $ this -> logger -> debug ( 'Searching root pages for source "{source}" and target "{target}"' , [ 'source' => $ this -> sourceLanguage , 'target' => $ this -> targetLanguage ] ) ; foreach ( $ this -> da...
Determine the root pages .
240,712
private function buildPageMap ( int $ mainRoot , int $ otherRoot , array & $ map , array & $ inverse ) : array { $ map [ $ otherRoot ] = $ mainRoot ; $ inverse [ $ mainRoot ] = $ otherRoot ; $ isMain = $ mainRoot === $ otherRoot ; $ lookupQueue = [ $ otherRoot ] ; do { $ children = $ this -> database -> getPagesByPidLi...
Build a map for a language and returns the map from source to main .
240,713
private function determineMapFor ( int $ index , int $ parentId , array $ inverseList ) : ? int { if ( ! isset ( $ inverseList [ $ parentId ] ) ) { throw new \ InvalidArgumentException ( 'Page id ' . $ parentId . ' has not been mapped' ) ; } $ mainSiblings = $ this -> database -> getPagesByPidList ( [ $ inverseList [ $...
Determine the mapping for the passed index .
240,714
public function getCommandToExecute ( ) { $ command = implode ( " " , array ( $ this -> bin , $ this -> script , $ this -> command , ) ) ; return trim ( preg_replace ( '/\s+/' , ' ' , $ command ) ) ; }
Returns the executable command for the task instance
240,715
public function preView ( $ output ) { $ purifierConfig = \ HTMLPurifier_Config :: createDefault ( ) ; $ purifierConfig -> set ( 'Core.Encoding' , 'UTF-8' ) ; $ purifierConfig -> set ( 'HTML.TidyLevel' , 'medium' ) ; $ purifier = new \ HTMLPurifier ( $ purifierConfig ) ; $ output = $ purifier -> purify ( $ output ) ; r...
Callback method to sanitize HTML output
240,716
public function login ( ) { $ result = $ this -> adapter -> getResult ( ) ; if ( $ result === self :: PHAVOUR_AUTH_SERVICE_SUCCESS ) { $ auth = Auth :: getInstance ( ) ; $ auth -> login ( $ this -> adapter -> getIdentity ( ) ) ; $ auth -> setRoles ( $ this -> adapter -> getRoles ( ) ) ; return true ; } elseif ( $ resul...
Log a user in using the given adapter from the construct
240,717
public function build ( ) { $ options_data = $ this -> buildOptionsData ( ) ; $ out_text = $ this -> buildUsageLine ( $ this -> arguments_spec -> getUsage ( ) , $ options_data ) ; $ options_text = '' ; if ( $ options_data [ 'lines' ] ) { foreach ( $ options_data [ 'lines' ] as $ option_line_data ) { $ options_text .= $...
Builds nicely formatted help text
240,718
protected function buildUsageLine ( $ usage_data , $ options_data ) { if ( $ usage_data [ 'use_argv_self' ] ) { $ self_name = $ _SERVER [ 'argv' ] [ 0 ] ; } else { $ self_name = $ usage_data [ 'self' ] ; } $ has_options = ( count ( $ options_data [ 'lines' ] ) > 0 ? true : false ) ; $ has_named_args = ( count ( $ usage...
builds the usage line
240,719
protected function buildOptionLine ( $ option_line_data , $ options_data ) { $ padding = $ options_data [ 'padding' ] ; $ required = $ option_line_data [ 'spec' ] [ 'required' ] ; $ out = str_pad ( $ option_line_data [ 'switch_text' ] , $ padding ) ; $ out .= ( strlen ( $ option_line_data [ 'spec' ] [ 'help' ] ) ? ' ' ...
builds an option line
240,720
protected function generateValueNamesHelp ( $ named_args_spec ) { $ first = true ; $ out = '' ; foreach ( $ named_args_spec as $ named_arg_spec ) { $ out .= ( $ first ? '' : ' ' ) ; if ( $ named_arg_spec [ 'required' ] ) { $ out .= ConsoleFormat :: applyformatToText ( 'bold' , 'yellow' , '<' . $ named_arg_spec [ 'name'...
gerenates the value names in the usage line
240,721
protected function buildOptionsData ( ) { $ options_data = array ( 'lines' => array ( ) , 'padding' => 0 , ) ; foreach ( $ this -> arguments_spec as $ option_line_spec ) { $ options_data [ 'lines' ] [ ] = $ this -> buildOptionLineData ( $ option_line_spec ) ; } $ options_data [ 'padding' ] = $ this -> buildSwitchTextPa...
builds options data from the arguments spec
240,722
protected function buildOptionLineData ( $ option_line_spec ) { $ data = array ( ) ; $ switch_text = '' ; if ( strlen ( $ option_line_spec [ 'short' ] ) ) { $ switch_text .= "-" . $ option_line_spec [ 'short' ] ; } if ( strlen ( $ option_line_spec [ 'long' ] ) ) { $ switch_text .= ( $ switch_text ? ", " : "" ) . "--" ....
builds a line of options data from a line of the argument spec
240,723
protected function buildSwitchTextPaddingLength ( $ options_data ) { $ padding_len = 0 ; foreach ( $ options_data [ 'lines' ] as $ option_line_data ) { $ padding_len = max ( $ padding_len , strlen ( $ option_line_data [ 'switch_text' ] ) ) ; } return $ padding_len ; }
calculates the maximum padding for all options
240,724
public function addObjects ( SplObjectStorage $ models ) { foreach ( $ models as $ model ) { $ this -> add ( $ model ) ; } return $ this ; }
Link all models from the SplObjectStorage
240,725
public function addAll ( Models $ other ) { if ( $ other -> count ( ) > 0 ) { $ this -> models -> addAll ( $ other -> models ) ; } return $ this ; }
Add all models from a different Models collection
240,726
public function sort ( Closure $ closure ) { $ sorted = clone $ this ; $ sorted -> models = Objects :: sort ( $ sorted -> models , $ closure ) ; return $ sorted ; }
Sort the models collection using a comparation closure
240,727
public function byRepo ( Closure $ yield ) { $ repos = Objects :: groupBy ( $ this -> models , function ( AbstractModel $ model ) { return $ model -> getRepo ( ) -> getRootRepo ( ) ; } ) ; foreach ( $ repos as $ repo ) { $ models = new Models ( ) ; $ models -> addObjects ( $ repos -> getInfo ( ) ) ; $ yield ( $ repo , ...
Group models by repo call yield for each repo
240,728
public function pluckProperty ( $ property ) { $ values = [ ] ; foreach ( $ this -> models as $ model ) { $ values [ ] = $ model -> $ property ; } return $ values ; }
Return the value of a property for each model
240,729
public function isEmptyProperty ( $ property ) { foreach ( $ this -> models as $ model ) { if ( $ model -> $ property ) { return false ; } } return true ; }
Return false if there is at least one non - empty property of a model .
240,730
public function toSplit ( $ name , $ splitor = '-' , $ to = self :: LOWER ) { switch ( $ to ) { case self :: UPPER : return strtoupper ( preg_replace ( "/(.)([A-Z])/" , "$1{$splitor}$2" , $ name ) ) ; default : return strtolower ( preg_replace ( "/(.)([A-Z])/" , "$1{$splitor}$2" , $ name ) ) ; } }
usage example . CmsPageSort = > cms - page - sort
240,731
public static function getConstantValuesByPrefix ( $ className , $ prefix ) { $ prefixLength = strlen ( $ prefix ) ; $ result = [ ] ; $ reflection = new \ ReflectionClass ( $ className ) ; foreach ( $ reflection -> getConstants ( ) as $ constKey => $ constValue ) { if ( $ prefix === substr ( $ constKey , 0 , $ prefixLe...
Get Contant Values By Prefix
240,732
public function emptyData ( FormInterface $ form ) { $ file = $ form -> get ( 'bengor_file' ) -> getData ( ) ; if ( null === $ file ) { return ; } return new UploadFileCommand ( $ file -> getClientOriginalName ( ) , file_get_contents ( $ file -> getPathname ( ) ) , $ file -> getMimeType ( ) ) ; }
Method that encapsulates all the logic of build empty data . It returns an instance of data class object .
240,733
public function createDateTimeByUnixTime ( $ unixTime ) { $ dateTime = new \ DateTime ( '@' . $ unixTime ) ; $ dateTime -> setTimezone ( $ this -> specifiedTimeZone ) ; return $ dateTime ; }
Returns the created DateTime object specified the timezone .
240,734
private function createMultiLanguageController ( stdClass $ data ) { $ this -> createFileFromTemplate ( [ "destination" => $ data -> controllerDestination , "templateDestination" => __DIR__ . '/../templates/service/controller/multiLanguage.hctpl' , "content" => [ "namespace" => $ data -> controllerNamespace , "controll...
Creating multi language controller
240,735
private function getAdminListHeader ( stdClass $ data ) { $ output = '' ; $ model = $ data -> mainModel ; $ output .= $ this -> gatherHeaders ( $ model , array_merge ( $ this -> getAutoFill ( ) , [ 'id' ] ) , $ data -> translationsLocation , false ) ; if ( isset ( $ model -> multiLanguage ) ) $ output .= $ this -> gath...
Get list header from model data
240,736
private function getInputData ( stdClass $ data ) { $ output = '' ; $ skip = array_merge ( $ this -> getAutoFill ( ) , [ 'id' ] ) ; if ( ! empty ( $ data -> database ) ) { if ( isset ( $ data -> multiLanguage ) ) $ path = '/templates/service/controller/multilanguage/input.data.hctpl' ; else $ path = '/templates/service...
Get input keys from model data
240,737
private function getUseFiles ( stdClass $ data , bool $ multiLanguage = false ) { $ output = '' ; $ list = [ ] ; $ list [ ] = [ "nameSpace" => $ data -> modelNamespace , "name" => $ data -> mainModel -> modelName , ] ; if ( $ multiLanguage ) $ list [ ] = [ "nameSpace" => $ data -> modelNamespace , "name" => $ data -> m...
get use files
240,738
private function getSearchableFields ( stdClass $ data , bool $ multiLanguage = false ) { $ output = '' ; $ model = $ data -> mainModel ; $ whereTpl = file_get_contents ( __DIR__ . '/../templates/shared/where.hctpl' ) ; $ orWhereTpl = file_get_contents ( __DIR__ . '/../templates/shared/or.where.hctpl' ) ; $ skip = arra...
Get searchable fields from model data
240,739
private function getPropertyPath ( $ propertyPath ) { if ( ! isset ( $ this -> propertyPaths [ $ propertyPath ] ) ) { $ this -> propertyPaths [ $ propertyPath ] = new \ Symfony \ Component \ Form \ Util \ PropertyPath ( $ propertyPath ) ; } return $ this -> propertyPaths [ $ propertyPath ] ; }
Get property path object .
240,740
public function addCustomLayoutSectionsHook ( DataContainer $ dc ) { $ arrSections = $ this -> getActiveLayoutSections ( $ dc ) ; if ( isset ( $ GLOBALS [ 'TL_HOOKS' ] [ 'addLayoutSections' ] ) && is_array ( $ GLOBALS [ 'TL_HOOKS' ] [ 'addLayoutSections' ] ) ) { foreach ( $ GLOBALS [ 'TL_HOOKS' ] [ 'addLayoutSections' ...
Costum Column Hack
240,741
protected function saveModelData ( Model $ model , \ Ideil \ GenericFile \ Interpolator \ InterpolatorResult $ input ) { $ model_map = $ model -> getFileAssignMap ( ) ; $ model_fields = [ ] ; foreach ( $ input -> getData ( ) as $ field => $ value ) { $ model_fields [ isset ( $ model_map [ $ field ] ) ? $ model_map [ $ ...
Save file attributes required for interpolation to model .
240,742
public function moveUploadedFile ( File $ file , $ path_pattern = null , $ existing_model = null ) { $ model_class = $ this -> getConfig ( 'store.model' ) ; if ( ( $ model_class || $ existing_model ) && $ existing_model !== false ) { $ model_instance = $ existing_model ? : new $ model_class ( ) ; if ( ! $ model_instanc...
Move uploaded file to path by pattern and update model .
240,743
public function makeUrlToUploadedFile ( $ model , $ path_pattern = null , array $ model_map = array ( ) , $ domain = null ) { return parent :: makeUrlToUploadedFile ( $ model , $ path_pattern , $ model instanceof Model ? $ model -> getFileAssignMap ( ) : $ model_map , $ domain ) ; }
Make url to stored file .
240,744
public function makePathToUploadedFile ( $ model , $ path_pattern = null , array $ model_map = array ( ) ) { return parent :: makePathToUploadedFile ( $ model , $ path_pattern , $ model instanceof Model ? $ model -> getFileAssignMap ( ) : $ model_map ) ; }
Full path to stored file .
240,745
protected function flash ( string $ type , string $ message , string $ level ) { $ group = Session :: get ( $ type , new MessageBag ( ) ) ; Session :: flash ( $ type , $ group -> add ( $ level , $ message ) ) ; return $ this ; }
Flash message to the Session .
240,746
public function exist ( ) { $ this -> resCallback = $ this -> callback -> filter ( function ( HttpCallBack $ call ) { return $ this -> rutesManager -> existRutes ( $ call -> getPath ( ) , $ this -> peticion ) ; } ) ; }
Filtrar si existe algun controlador que pueda ser ejecutado sin importar si es el solicitado esto se verifica con la longitud de la rutas almacenada si coinciden con la ruta de la peticion .
240,747
public function compare ( ) { $ this -> resFilter = $ this -> resCallback -> filter ( function ( HttpCallBack $ call ) { return $ this -> rutesManager -> compareRute ( $ call -> getPath ( ) , $ this -> peticion ) ; } ) ; }
Filtrar si existe alguna ruta que sea identica a la ruta de la peticion esto se realiza a travez de la verificacion de patrones en las rutas .
240,748
public function execute ( ) { if ( $ this -> resFilter -> isEmpty ( ) && $ this -> rutesManager -> isRoot ( $ this -> actual , $ this -> peticion ) ) { $ this -> root ( ) ; return ; } if ( $ this -> resFilter -> isEmpty ( ) ) { $ this -> default ( ) ; return ; } $ this -> resFilter -> each ( function ( HttpCallBack $ c...
Ejecutar la ruta encontrada en caso de no encontrar nada ejecutar una por defecto
240,749
private function default ( ) { $ this -> callback -> filter ( function ( HttpCallBack $ test ) { return ! strcmp ( $ test -> getPath ( ) , $ this -> actual . '/**' ) ; } ) -> each ( function ( HttpCallBack $ test ) { $ test -> call ( $ this -> rutesManager -> getParameter ( ) ) ; } ) ; }
Metodo quen ejecuta el controlador por defecto cuando no existe una ruta posible a ejecutar .
240,750
protected function selfValidate ( ) { if ( $ this -> _isUndefined && $ this -> onUndefinedIgnore ) { $ this -> _safeVar = null ; $ this -> _isValid = true ; goto finish ; } if ( $ this -> isEmpty ( $ this -> _unsafeVar ) ) { if ( $ this -> onEmptyIgnore ) { $ this -> _safeVar = null ; $ this -> _isValid = true ; $ this...
Start validate the valley itself
240,751
final public function validate ( callable $ onDataInvalid = null ) : Validator { $ shell = $ this -> shell ; if ( count ( $ shell -> subValidators ) ) { $ shell -> _safeVar = [ ] ; foreach ( $ shell -> subValidators as $ key => $ validator ) { $ validator -> selfValidate ( ) ; if ( $ validator -> _isUndefined && $ vali...
Start validate the whole chain include the sub valleys
240,752
private function dispatchMetadataEvent ( $ eventName , EntityMetadata $ metadata ) { $ metadataArgs = new Events \ MetadataArguments ( $ metadata ) ; $ this -> dispatcher -> dispatch ( $ eventName , $ metadataArgs ) ; }
Dispatches a Metadata event
240,753
private function loadPersistenceMetadata ( EntityMetadata $ metadata ) { $ persisterKey = $ metadata -> persistence -> getKey ( ) ; $ persistenceFactory = $ this -> driver -> getPersistenceMetadataFactory ( $ persisterKey ) ; $ persistenceFactory -> handleLoad ( $ metadata ) ; $ persistenceFactory -> handleValidate ( $...
Handles persistence specific metadata loading .
240,754
private function loadSearchMetadata ( EntityMetadata $ metadata ) { if ( false === $ metadata -> isSearchEnabled ( ) ) { return $ metadata ; } $ clientKey = $ metadata -> search -> getKey ( ) ; $ searchFactory = $ this -> driver -> getSearchMetadataFactory ( $ clientKey ) ; $ searchFactory -> handleLoad ( $ metadata ) ...
Handles search specific metadata loading .
240,755
public function less ( $ num ) { self :: mustBeNumeric ( $ num , 'Tested number' ) ; if ( is_object ( $ num ) ) { return $ this -> value < $ num -> value ; } else { return $ this -> value < $ num ; } }
Checks whether current number is less than given one .
240,756
public function lte ( $ num ) { self :: mustBeNumeric ( $ num , 'Tested number' ) ; if ( is_object ( $ num ) ) { return $ this -> value <= $ num -> value ; } else { return $ this -> value <= $ num ; } }
Tests whether current number is less than or equal to given one .
240,757
public function greater ( $ num ) { self :: mustBeNumeric ( $ num , 'Tested number' ) ; if ( is_object ( $ num ) ) { return $ this -> value > $ num -> value ; } else { return $ this -> value > $ num ; } }
Tests whether current number is greater than given one .
240,758
public function gte ( $ num ) { self :: mustBeNumeric ( $ num , 'Tested number' ) ; if ( is_object ( $ num ) ) { return $ this -> value >= $ num -> value ; } else { return $ this -> value >= $ num ; } }
Tests whether current number is greater than or equal to the given number .
240,759
public function mod ( $ mod ) { self :: mustBeNumeric ( $ mod , 'Divisor' ) ; if ( $ mod instanceof N ) { $ mod = $ mod -> double ; } if ( $ mod == 0 ) { throw new \ InvalidArgumentException ( 'Cannot divide by 0!' ) ; } return new N ( fmod ( $ this -> value , $ mod ) ) ; }
Computes modulo of current number
240,760
protected function _prime ( ) { if ( $ this -> value < 2 ) { return false ; } if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'You cannot test if number is prime numer if it is not an integer' ) ; } $ max = floor ( sqrt ( $ this -> value ) ) ; for ( $ i = 2 ; $ i <= $ max ; $ i ++ ) { if ( $ th...
Checks if current number is prime number
240,761
protected function _divisors ( ) { if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'You can only get divisors from integers!' ) ; } $ n = abs ( $ this -> value ) ; $ a = new A ( ) ; for ( $ i = 1 ; $ i <= $ n ; $ i ++ ) { if ( $ n % $ i == 0 ) { $ a -> add ( new self ( $ i ) ) ; } } return $ a ...
Gets divisors for the current integer numbers .
240,762
public function pow ( $ num ) { self :: mustBeNumeric ( $ num , 'Power calculus' ) ; return new N ( pow ( $ this -> value , is_object ( $ num ) ? $ num -> value : $ num ) ) ; }
Computes current number at given power .
240,763
public function root ( $ num ) { self :: mustBeNumeric ( $ num , 'Root' ) ; $ n = is_object ( $ num ) ? $ num -> value : $ num ; if ( $ n == 0 ) { throw new \ InvalidArgumentException ( 'Root must be not nul' ) ; } return new N ( pow ( $ this -> value , 1 / $ n ) ) ; }
Gets nth root of current number .
240,764
protected function _factorial ( ) { if ( $ this -> value == 0 ) { return new N ( 1 ) ; } if ( $ this -> value < 0 ) { throw new \ RuntimeException ( 'Cannot get factorial of negative number!' ) ; } if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot get factorial of non integer!' ) ; } retu...
Computes the factorial of current number .
240,765
public function equal ( $ num ) { self :: mustBeNumeric ( $ num , 'Test of equality' ) ; if ( is_object ( $ num ) ) { return $ this -> value == $ num -> value ; } else { return $ this -> value == $ num ; } }
Checks if current number is equal to given argument .
240,766
protected function _decimal ( ) { $ sign = 1 ; if ( $ this -> value < 0 ) { $ sign = - 1 ; } return new N ( $ sign * ( abs ( $ this -> value ) - floor ( abs ( $ this -> value ) ) ) ) ; }
Gets decimal part .
240,767
protected function _odd ( ) { if ( ( abs ( $ this -> value ) - floor ( abs ( $ this -> value ) ) ) != 0 ) { throw new \ RuntimeException ( 'Testing if number is odd or even only if it is an integer!' ) ; } return ( boolean ) ( $ this -> value & 1 ) ; }
Tests whether current number is odd .
240,768
public function plus ( $ number ) { self :: mustBeNumeric ( $ number , 'Value to add' ) ; $ number = is_object ( $ number ) ? $ number -> value : $ number ; return new self ( $ this -> value + $ number ) ; }
Adds current number to given argument .
240,769
public function minus ( $ number ) { self :: mustBeNumeric ( $ number , 'Value to substract' ) ; $ number = is_object ( $ number ) ? $ number -> value : $ number ; return new self ( $ this -> value - $ number ) ; }
Substract current number with other .
240,770
public function multiply ( $ number ) { self :: mustBeNumeric ( $ number , 'Value to multiply' ) ; $ number = is_object ( $ number ) ? $ number -> value : $ number ; return new self ( $ this -> value * $ number ) ; }
Creates new N by multipling the current to the given one
240,771
public function divide ( $ number ) { self :: mustBeNumeric ( $ number , 'Value to divide' ) ; $ number = is_object ( $ number ) ? $ number -> value : $ number ; if ( $ number == 0 ) { throw new \ InvalidArgumentException ( 'You cannot divide by zero!' ) ; } return new self ( $ this -> value / $ number ) ; }
Divide current number with given argument .
240,772
protected function _roman ( ) { if ( ! $ this -> _decimal ( ) -> zero || $ this -> value < 0 ) { throw new \ RuntimeException ( 'Converting into roman numerals uses only positive integers.' ) ; } $ arr_numerals = array ( ( object ) array ( 'integer' => 1000 , 'roman' => 'm' ) , ( object ) array ( 'integer' => 900 , 'ro...
Converts current number to roman number .
240,773
protected function _hex ( ) { if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot get hexadecimal numbers from non integer.' ) ; } if ( $ this -> value < 0 ) { return new S ( '-' . dechex ( abs ( $ this -> value ) ) ) ; } else { return new S ( dechex ( $ this -> value ) ) ; } }
Converts to hexadecimal number .
240,774
protected function _oct ( ) { if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot get octal numbers from non integer.' ) ; } if ( $ this -> value < 0 ) { return new S ( '-' . decoct ( abs ( $ this -> value ) ) ) ; } else { return new S ( decoct ( $ this -> value ) ) ; } }
Converts to octal number .
240,775
protected function _bin ( ) { if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot get binary numbers from non integer.' ) ; } if ( $ this -> value < 0 ) { return new S ( '-' . decbin ( abs ( $ this -> value ) ) ) ; } else { return new S ( decbin ( $ this -> value ) ) ; } }
Converts to binary number .
240,776
public function base ( $ n ) { self :: mustBeInteger ( $ n , 'Base' ) ; if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot convert to another base from non integer value.' ) ; } $ n = is_object ( $ n ) ? $ n -> int : $ n ; if ( ! is_numeric ( $ n ) || $ n < 2 || $ n > 36 ) { throw new \ In...
Converts current number into another base .
240,777
public function times ( $ callback ) { self :: mustBeCallable ( $ callback ) ; if ( ! $ this -> _decimal ( ) -> zero ) { throw new \ RuntimeException ( 'Cannot iterate given callback when number is not integer.' ) ; } if ( $ this -> value == 0 ) { throw new \ RuntimeException ( 'Cannot iterate given callback on a void ...
Repeats given callable param .
240,778
public function id ( String $ name = 'id' , int $ length = 15 , Bool $ null = false ) { return $ this -> integer ( $ name , $ length , $ null , true , [ 'primary' => true ] ) ; }
Represents an auto incremented field with a primary key index .
240,779
public function varchar ( String $ name , int $ length = 15 , Bool $ null = false , Bool $ autoIncrement = false , Array $ options = [ ] ) { return $ this -> setType ( 'Varchar' , $ name , $ length , $ null , $ autoIncrement , $ options ) ; }
Represents a variable - length non - binary string field .
240,780
public function decimal ( String $ name , $ length = 15 , Bool $ null = false , Bool $ autoIncrement = false , Array $ options = [ ] ) { return $ this -> setType ( 'Decimal' , $ name , $ length , $ null , $ autoIncrement , $ options ) ; }
Represents a fixed - point number field .
240,781
public function date ( String $ name , Bool $ null = false , Array $ options = [ ] ) { return $ this -> setType ( 'Date' , $ name , null , $ null , false , $ options ) ; }
Represents a date field .
240,782
public function foreign ( String $ keyName , Array $ options = [ ] , String $ onDelete = 'NO ACTION' , String $ onUpdate = 'NO ACTION' ) { $ columns = $ options [ 'columns' ] ; $ referenceTable = $ options [ 'references' ] ; $ refColumns = $ options [ 'refColumns' ] ; $ clauseList = [ 'CASCADE' , 'RESTRICT' , 'NO ACTIO...
Generates a foreign key constraint .
240,783
public function getDefinition ( $ separator = ',' ) { $ commands = self :: $ commands ; if ( sizeof ( $ commands ) > 0 ) { return implode ( $ separator , $ commands ) ; } return null ; }
Returns type sql definition .
240,784
protected function convertMultiFileArray ( array $ filesArr ) { $ files = array ( ) ; $ filesCount = count ( $ filesArr [ self :: VALUE_NAME ] ) ; for ( $ i = 0 ; $ i < $ filesCount ; ++ $ i ) { $ files [ ] = array ( self :: VALUE_NAME => $ filesArr [ self :: VALUE_NAME ] [ $ i ] , self :: VALUE_TYPE => $ filesArr [ se...
Restructures an input array of multiple files
240,785
protected function printLog ( $ sMessage ) { $ oDate = new \ DateTime ( ) ; echo $ oDate -> format ( 'H:i:s' ) . "\t{$sMessage}" . PHP_EOL ; return '(' . $ oDate -> format ( 'H:i:s' ) . ') ' . preg_replace ( '#(\[[0-9]+m)#' , '' , $ sMessage ) ; }
Print message to console
240,786
public static function createFromSapWeek ( $ sapWeek , $ timezone = null ) { if ( preg_match ( static :: $ sapWeekRegex , $ sapWeek , $ matches ) !== 1 ) { return false ; } $ week = sprintf ( '%sW%s' , $ matches [ 1 ] , $ matches [ 2 ] ) ; return new parent ( $ week , $ timezone ) ; }
Parse an SAP week string into a new DateTime object .
240,787
protected function getElementData ( ContainerInterface $ container , & $ data = [ ] ) { foreach ( $ container as $ element ) { if ( $ element instanceof InputInterface ) { $ data [ $ element -> getName ( ) ] = $ element -> getValue ( ) ; continue ; } if ( $ element instanceof ContainerInterface ) { $ this -> getElement...
Recursively collects all posted data
240,788
public function wasSubmitted ( ) { $ formMethod = strtoupper ( $ this -> getAttribute ( 'method' , 'post' ) ) ; $ formId = $ this -> getRequest ( ) -> getPost ( 'form-id' , false ) ; $ formId = $ formId ? $ formId : $ this -> getRequest ( ) -> getQuery ( 'form-id' , null ) ; $ submitted = $ this -> request -> getMethod...
Check if for was submitted or not
240,789
protected function updateValuesFromRequest ( ) { $ data = $ this -> getRequest ( ) -> isPost ( ) ? $ this -> getRequest ( ) -> getPost ( ) : $ this -> getRequest ( ) -> getQuery ( ) ; if ( isset ( $ _FILES ) ) { $ data = array_merge ( $ data , $ this -> request -> getUploadedFiles ( ) ) ; } $ this -> setValues ( $ data...
Assign form values from request
240,790
public function resolve ( ) { $ this -> zone = new $ this -> zoneClass ( ) ; $ this -> zone -> setZoneType ( $ this -> zoneType ) ; $ this -> zone -> setComponents ( $ this -> components -> buildRanking ( ) ) ; $ this -> assertEntityIsValid ( $ this -> zone , array ( 'Zone' , 'creation' ) ) ; $ this -> fireEvent ( Zone...
Zone creation method .
240,791
public function addRow ( array $ data = [ ] ) : int { $ this -> crudEnabled ( ) ; $ table_name = static :: $ table_name ; if ( 0 == count ( $ data ) ) { $ sql = "INSERT INTO {$table_name} DEFAULT VALUES" ; $ this -> dbc -> query ( $ sql ) ; } else { $ components = $ this -> dbc -> generateParameterizedComponents ( $ da...
Add a row to the table represented by this grid . If a table name id column or structure for the table is not defined above this function will not work .
240,792
public function deleteRow ( int $ id ) : void { $ this -> crudEnabled ( ) ; $ table_name = static :: $ table_name ; $ id_column = static :: $ id_column ; $ sql = "DELETE FROM {$table_name} WHERE {$id_column} = :key" ; $ this -> dbc -> query ( $ sql , [ 'params' => [ ':key' => $ id ] ] ) ; }
Delete the row specified by the passed identifier . If the necessary crud fields have not been identified in the child class this function will throw an exception .
240,793
public function updateRow ( $ id , array $ data ) : void { $ this -> crudEnabled ( ) ; $ components = $ this -> dbc -> generateParameterizedComponents ( $ data ) ; $ table_name = static :: $ table_name ; $ id_column = static :: $ id_column ; $ fields = $ components [ 'update' ] ; $ params = $ components [ 'params' ] ; ...
Updates an existing row based on the passed identifier . If the necessary crud fields have not been identified in the child class this function will throw an exception .
240,794
public function store ( $ key = '' , $ value = array ( ) , $ lock = true ) { if ( $ key == '' ) { $ this -> fault ( '[Error] Cannot store data without a key. Key is "' . $ key . '".' ) ; } if ( ! $ this -> has_key ( $ key ) ) { $ this -> create ( $ key , $ lock ) ; $ this -> store_data ( $ key , $ value ) ; } else { if...
Saves some data by key value .
240,795
static function forceLogin ( \ Db \ Connection $ db , $ user_id ) { User :: $ instance = User :: findUser ( $ db , $ user_id ) ; }
Login as the given user_id .
240,796
function delete ( \ Db \ Connection $ db ) { $ q = $ db -> prepare ( "DELETE FROM user_passwords WHERE user_id=?" ) ; $ q -> execute ( array ( $ this -> getId ( ) ) ) ; $ q = $ db -> prepare ( "DELETE FROM user_openid_identities WHERE user_id=?" ) ; $ q -> execute ( array ( $ this -> getId ( ) ) ) ; $ q = $ db -> prepa...
Delete the given user . Triggers a user_deleted event with the current user as an argument .
240,797
public function toString ( ) { $ content = "<VirtualHost {$this->address}:{$this->port}>" . PHP_EOL ; foreach ( $ this -> directives as $ directive ) { $ content .= $ directive -> toString ( ) . PHP_EOL ; } $ content .= PHP_EOL ; foreach ( $ this -> directories as $ directory ) { $ content .= $ directory -> toString ( ...
Converts vh to plain text
240,798
public function handleRequest ( Request $ request , Application $ app ) { if ( $ this -> isAutoRebuildMode ( $ app ) ) { $ this -> rebuildDatabase ( ) ; return ; } if ( $ this -> dbHasNotBeenBuilt ( ) ) { $ this -> rebuildDatabase ( ) ; return ; } if ( $ this -> isValidRebuildRequest ( $ request , $ app ) ) { $ this ->...
If the request includes an instruction to rebuild the db do that
240,799
protected function rebuildDatabase ( ) { $ this -> populator -> populate ( ) ; $ path = $ this -> buildIndicator -> getPathname ( ) ; $ content = 'Initial Build: ' . date ( 'Y-m-d H:i:s' ) ; $ this -> filesystem -> remove ( $ path ) ; $ this -> filesystem -> dumpFile ( $ path , $ content ) ; }
Builds the DB and creates a file indicating that the DB has been built at least once .