idx
int64
0
241k
question
stringlengths
64
6.21k
target
stringlengths
5
803
228,500
function getSchema ( ) { $ schema = 'CREATE TABLE IF NOT EXISTS ' . $ this -> table . ' (' ; $ sep = PHP_EOL ; foreach ( $ this -> schema as $ fld ) { $ schema .= $ sep . $ fld ; $ sep = ', ' . PHP_EOL ; } $ schema .= PHP_EOL . ');' . PHP_EOL ; foreach ( $ this -> indecies as $ index ) { foreach ( $ index as $ type => ...
Creates the schema of the DB according to the defined
228,501
public function getFirst ( $ q = [ ] , $ data = [ ] ) { $ q [ 'limit' ] = 1 ; $ list = $ this -> get ( $ q , $ data ) ; return ( count ( $ list ) ) ? $ list [ 0 ] : null ; }
Gets the first item as predfined by any previous functional operators
228,502
public function where ( $ column , $ value , $ operator = '=' , $ table = null ) { $ table = $ table ? $ table : $ this -> table ; $ this -> db ( ) -> where ( $ column , $ value , $ operator , $ table ) ; return $ this ; }
Sets a where condition
228,503
public function whereIn ( $ column , $ values , $ table = null ) { $ this -> db ( ) -> whereIn ( $ column , $ values , $ table ) ; return $ this ; }
Sets a where in condition
228,504
public function search ( $ filters = [ ] ) { $ resolved = [ ] ; if ( ! isset ( $ filters ) || ! is_array ( $ filters ) ) { throw new \ InvalidArgumentException ( 'Undefined search filters' , 400 ) ; } if ( isset ( $ filters [ 'limit' ] ) ) { $ this -> limit ( $ filters [ 'limit' ] ) ; } if ( isset ( $ filters [ 'offset...
Sets an array of filters as where conditions
228,505
public function get ( ) { $ this -> beforeGet ( ) ; $ this -> db ( ) -> table ( $ this -> table ) -> select ( $ this -> columns ) -> limit ( $ this -> limit ) -> offset ( $ this -> offset ) -> orderBy ( $ this -> orderBy ) ; $ this -> hasOne ( ) -> belongsToMany ( ) ; $ this -> records = $ this -> db ( ) -> get ( ) ; $...
Returns an array of models
228,506
public function count ( ) { $ this -> db ( ) -> table ( $ this -> table ) -> groupBy ( $ this -> table . '.' . $ this -> primaryKey ) ; $ this -> hasOne ( ) -> belongsToMany ( ) ; $ count = $ this -> db ( ) -> count ( $ this -> primaryKey ) ; return $ count ; }
Returns the total number of models
228,507
public function find ( $ id = null ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to find' , 400 ) ; } $ result = $ this -> where ( $ this -> primaryKey , $ id , '=' , $ this -> table ) -> limit ( 1 ) -> first ( ) ; return $ result ; }
Returns a single model by primary key
228,508
public function first ( ) { $ result = $ this -> get ( ) ; if ( ! $ result || ! is_array ( $ result ) || empty ( $ result ) ) { return false ; } return reset ( $ result ) ; }
Returns the first model found
228,509
public function create ( $ attributes = [ ] ) { if ( ! ( isset ( $ attributes ) ) || ! is_array ( $ attributes ) ) { throw new \ InvalidArgumentException ( 'Undefined attributes' , 400 ) ; } $ attributes = $ this -> beforeCreate ( $ attributes ) ; $ fields = array_intersect_key ( $ attributes , array_flip ( $ this -> f...
Creates a new model
228,510
public function update ( $ id = null , $ attributes = [ ] ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to update' , 400 ) ; } if ( ! ( isset ( $ attributes ) ) || ! is_array ( $ attributes ) ) { throw new \ InvalidArgumentException ( 'Undefined attributes' , 400 ) ; } $ attributes ...
Updates a model
228,511
public function destroy ( $ id = null ) { if ( ! isset ( $ id ) ) { throw new \ InvalidArgumentException ( 'Undefined ID to destroy' , 400 ) ; } $ this -> beforeDestroy ( $ id ) ; $ result = $ this -> db ( ) -> table ( $ this -> table ) -> where ( $ this -> primaryKey , $ id ) -> limit ( 1 ) -> delete ( ) ; if ( ! $ re...
Destroys a model
228,512
private function hasOne ( ) { if ( ! isset ( $ this -> relationships [ 'hasOne' ] ) || empty ( $ this -> relationships [ 'hasOne' ] ) ) { return $ this ; } foreach ( $ this -> relationships [ 'hasOne' ] as $ join ) { $ this -> db ( ) -> join ( $ join [ 'table' ] , $ join [ 'localKey' ] , '=' , $ join [ 'foreignKey' ] )...
Resolves one to one relationships
228,513
private function hasMany ( ) { if ( ! isset ( $ this -> relationships [ 'hasMany' ] ) || empty ( $ this -> relationships [ 'hasMany' ] ) ) { return $ this ; } $ ids = array_column ( $ this -> records , 'id' ) ; if ( empty ( $ ids ) ) { return $ this ; } $ records = array_combine ( $ ids , $ this -> records ) ; foreach ...
Resolves one to many relationships
228,514
private function belongsToMany ( ) { if ( ! isset ( $ this -> relationships [ 'belongsToMany' ] ) || empty ( $ this -> relationships [ 'belongsToMany' ] ) ) { return $ this ; } $ this -> db ( ) -> groupBy ( $ this -> table . '.' . $ this -> primaryKey ) ; foreach ( $ this -> relationships [ 'belongsToMany' ] as $ join ...
Resolves many to many relationships
228,515
private function sync ( $ id , $ attributes ) { if ( ! isset ( $ id ) || ! isset ( $ attributes ) || empty ( $ attributes ) ) { return $ this ; } if ( ! isset ( $ this -> relationships [ 'belongsToMany' ] ) || empty ( $ this -> relationships [ 'belongsToMany' ] ) ) { return $ this ; } foreach ( $ this -> relationships ...
Syncs many to many relationships
228,516
private function formatBelongsToMany ( ) { if ( ! isset ( $ this -> relationships [ 'belongsToMany' ] ) || empty ( $ this -> relationships [ 'belongsToMany' ] ) ) { return $ this ; } foreach ( $ this -> relationships [ 'belongsToMany' ] as $ join ) { $ this -> records = array_map ( function ( $ record ) use ( $ join ) ...
Format many to many relationships results
228,517
private function formatHasOne ( ) { if ( ! isset ( $ this -> relationships [ 'hasOne' ] ) || empty ( $ this -> relationships [ 'hasOne' ] ) ) { return $ this ; } foreach ( $ this -> relationships [ 'hasOne' ] as $ join ) { $ this -> records = array_map ( function ( $ record ) use ( $ join ) { foreach ( $ record as $ ke...
Format has many relationships results
228,518
public function validationErrors ( $ attributes , $ rules = null ) { $ this -> rules = $ this -> setValidationRules ( ) ; $ ruleSet = isset ( $ rules ) ? $ rules : $ this -> validate ; $ errors = [ ] ; $ attributes = array_intersect_key ( $ attributes , array_flip ( array_keys ( $ ruleSet ) ) ) ; foreach ( $ ruleSet as...
Validates a model
228,519
public function onLogin ( Login $ event ) { $ ip = $ this -> request -> getClientIp ( ) ; $ this -> updateFields ( $ this -> auth , $ ip ) ; }
Listener for the login event .
228,520
public function classExists ( $ className ) { if ( ! $ className ) { return false ; } if ( false === isset ( $ this -> existingClassList [ $ className ] ) ) { $ this -> existingClassList [ $ className ] = class_exists ( $ className ) || interface_exists ( $ className ) ; } return $ this -> existingClassList [ $ classNa...
Internal function which will check if the given class exists . This is useful because of the calls to undefined class which can lead to a lack of performance due to the auto - loader called if the name of the class is not registered yet .
228,521
public function getGettablePropertiesOfObject ( $ object ) { $ className = get_class ( $ object ) ; if ( false === isset ( $ this -> gettablePropertiesOfObjects [ $ className ] ) ) { $ this -> gettablePropertiesOfObjects [ $ className ] = [ ] ; $ properties = $ this -> getReflectionService ( ) -> getClassPropertyNames ...
Returns the list of properties which are accessible for this given object .
228,522
public function preparing ( Promised $ started , Promised $ stopping ) : Promised { $ starts = [ ] ; foreach ( $ this -> dr ( ) -> servers ( ) as $ api ) { foreach ( $ this -> dr ( ) -> services ( $ api ) as $ service => $ route ) { DI :: set ( $ class = $ route [ 1 ] , $ server = DI :: object ( $ class ) ) ; if ( $ se...
bind service implementer
228,523
public static function getNonce ( string $ action , Session $ session , array $ context = [ ] , int $ timestamp = null ) { $ timestamp = $ timestamp ?? time ( ) ; $ hashable = $ action . $ timestamp . $ session -> getSessionSalt ( ) ; foreach ( $ context as $ key => $ value ) { if ( $ value === null ) $ value = "NULL" ...
Get a nonce for the specified action optionally including context
228,524
public static function validateNonce ( string $ action , Session $ session , Dictionary $ arguments , array $ context = [ ] ) { if ( ! $ arguments -> has ( self :: $ nonce_parameter , Type :: STRING ) ) { return null ; } $ context_values = [ ] ; foreach ( $ context as $ key => $ value ) { if ( is_int ( $ key ) ) { $ ke...
Check if a nonce was posted and if it matches the data
228,525
public function required ( string $ alias , string $ type ) : EntityDefinitionOptions { return $ this -> required [ $ alias ] = new EntityDefinitionOptions ( $ alias , $ type ) ; }
Adds a required column
228,526
public function optional ( string $ alias , string $ type ) : EntityDefinitionOptions { return $ this -> optional [ $ alias ] = new EntityDefinitionOptions ( $ alias , $ type ) ; }
Adds an optional column
228,527
public function timestamps ( ) : void { $ this -> optional ( 'created_at' , Timestamp :: class ) -> readOnly ( ) ; $ this -> optional ( 'updated_at' , Timestamp :: class ) -> readOnly ( ) ; }
Adds created_at and updated_at timestamps
228,528
public function hasMany ( string $ alias , string $ entity ) : Relation { return $ this -> has_many [ $ entity ] = new Relation ( $ alias , $ this -> full_name , $ entity ) ; }
Add a has many relationship
228,529
public function hasManyThrough ( string $ alias , string $ entity_join , string $ entity_foreign ) : HasManyThrough { return $ this -> has_many_through [ ] = new HasManyThrough ( $ alias , $ entity_join , $ entity_foreign ) ; }
Add a has many through relationship
228,530
public function belongsTo ( string $ alias , string $ entity ) : Relation { return $ this -> belongs_to [ $ entity ] = new Relation ( $ alias , $ this -> full_name , $ entity ) ; }
Add a belongs to relationship
228,531
public function associates ( string $ alias_join , string $ alias_left , string $ entity_left , string $ alias_right , string $ entity_right ) : ManyToMany { return $ this -> many_to_many [ ] = new ManyToMany ( $ alias_join , $ alias_left , $ this -> full_name , $ entity_left , $ alias_right , $ entity_right ) ; }
Adds a has many through relationship to the left and right Entity s through this Entity
228,532
public function virtual ( string $ name , string $ type , callable $ callback ) : void { $ this -> virtuals [ $ name ] = new VirtualField ( $ name , $ type , $ callback ) ; }
Adds a virtual field to the Entity . The callable will be executed whenever the virtual field is accessed and passed the Entity .
228,533
public function setUserId ( int $ id ) { if ( $ id !== $ this -> userId ) { if ( $ this -> user !== null && $ this -> user -> getId ( ) !== $ id ) { $ this -> user = null ; } ; $ this -> userId = $ id ; } return $ this ; }
Set associated userId
228,534
protected function _replaceTokens ( $ input , $ source , $ tokenStart , $ tokenEnd , $ default = null ) { $ input = $ this -> _normalizeString ( $ input ) ; $ default = $ default === null ? '' : $ this -> _normalizeString ( $ default ) ; $ regexDelimiter = '/' ; $ tokenStart = $ this -> _quoteRegex ( $ tokenStart , $ r...
Replaces all tokens in a string with corresponding values .
228,535
public function createClass ( string $ name , string $ location , string $ extends = "" ) : bool { $ namespace = trim ( $ this -> getNameSpace ( $ name ) ) ; $ name = trim ( $ this -> getClassName ( $ name ) ) ; $ className = $ name ; if ( $ extends !== "" ) { $ className .= " extends {$extends}" ; } if ( $ namespace !...
Create a class
228,536
public function getNameSpace ( string $ name ) : string { $ segs = [ ] ; $ name = str_replace ( "/" , "\\" , $ name ) ; $ namespace = explode ( "\\" , $ name ) ; array_pop ( $ namespace ) ; array_walk ( $ namespace , function ( & $ value ) { $ value = $ this -> removeNoneAlpherNumeric ( $ value ) ; } ) ; return implode...
Work out name space of the class
228,537
public function getClassName ( string $ name ) : string { $ name = str_replace ( "/" , "\\" , $ name ) ; $ name = explode ( "\\" , $ name ) ; $ name = array_pop ( $ name ) ; $ name = $ this -> removeNoneAlpherNumeric ( $ name ) ; return $ name ; }
Work out the class name from a namespace string
228,538
public function Equals ( $ item1 , $ item2 ) { if ( $ item1 === null && $ item2 !== null ) { return false ; } else if ( $ item1 !== null && $ item2 === null ) { return false ; } else if ( $ item1 === null && $ item2 === null ) { return true ; } return $ item1 -> Equals ( $ item2 ) ; }
Compares the items
228,539
private function convertDbToApi ( $ db ) { $ result = new AResponse ( ) ; if ( $ db ) { $ custId = $ db [ QBGetCustomer :: A_ID ] ; $ email = $ db [ QBGetCustomer :: A_EMAIL ] ; $ nameFirst = $ db [ QBGetCustomer :: A_NAME_FIRST ] ; $ nameLast = $ db [ QBGetCustomer :: A_NAME_LAST ] ; $ mlmId = $ db [ QBGetCustomer :: ...
Convert database query result set to response object .
228,540
public function getMappingFiles ( ) : array { $ mappingPaths = [ ] ; foreach ( $ this -> paths as $ mappingPath ) { if ( \ is_dir ( $ mappingPath ) ) { $ mappingPaths [ ] = $ this -> getFilesFromDirectory ( $ mappingPath ) ; } elseif ( \ is_file ( $ mappingPath ) ) { $ mappingPaths [ ] = [ $ mappingPath ] ; } else { th...
Get mapping files .
228,541
protected function getFilesFromDirectory ( string $ mappingDirectory ) : array { $ mappingPaths = [ ] ; $ filePattern = \ sprintf ( '/^.+\.(%s)$/i' , \ implode ( '|' , $ this -> extensions ) ) ; $ recursiveIterator = new \ RecursiveIteratorIterator ( new \ RecursiveDirectoryIterator ( $ mappingDirectory ) ) ; $ regexIt...
Get mapping files from directory .
228,542
public static function createInstance ( $ driver , $ options ) { if ( ! in_array ( $ driver , self :: $ _validDrivers ) ) { throw new \ Exception ( "Driver '{$driver}' not implemented" ) ; } $ class = __NAMESPACE__ . '\\Driver\\' . $ driver ; $ driver = new $ class ; $ driver -> setOptions ( $ options ) ; return new St...
Create new instance of G4 \ Storage \ Storage
228,543
public function merge ( ClassMetadata $ object ) { $ properties = $ this -> properties ; $ methods = $ this -> methods ; foreach ( $ object -> getProperties ( ) as $ property ) { $ properties [ $ property -> getName ( ) ] = $ property ; } foreach ( $ object -> getMethods ( ) as $ method ) { $ methods [ $ method -> getN...
Merge the ClassMetadata of the object with the current ClassMetadata into a new object .
228,544
private function mapQueryToActionParameters ( RouteEndpoint $ route , RequestInterface $ request ) : array { $ reflection = new ReflectionClass ( $ route -> getFullyQualifiedName ( ) ) ; $ method = $ reflection -> getMethod ( $ route -> getAction ( true ) ) ; $ query = $ request -> getQuery ( ) ; $ mapper = [ ] ; forea...
Maps all the query parameters to the controller action parameters
228,545
protected function setThumbnailer ( Thumbnailer $ thumbnailer ) { if ( ! $ thumbnailer instanceof Thumbnailer ) { throw new \ Exception ( 'The thumbnailer service given is not instance of Thumbnailer\Thumbnailer\Thumbnailer' ) ; } $ this -> options [ 'thumbnailer' ] = $ thumbnailer ; return $ this ; }
Set the thumbnailer given with the options
228,546
public function get ( $ key ) { if ( array_key_exists ( $ key , $ this -> _map ) ) { return $ this -> _map [ $ key ] ; } return null ; }
Get attribute from web context .
228,547
public function query ( $ name , $ val = null ) { return isset ( $ this -> _queries [ $ name ] ) ? $ this -> _queries [ $ name ] : $ val ; }
Get query string from url
228,548
public function queries ( array $ names , $ default = null ) { $ var = [ ] ; foreach ( $ names as $ in ) { $ var [ $ in ] = isset ( $ this -> _queries [ $ in ] ) ? $ this -> _queries [ $ in ] : $ default ; } return $ var ; }
Getting querie from url parameters
228,549
public function only ( array $ names , $ default = null ) { $ var = [ ] ; foreach ( $ names as $ in ) { $ var [ $ in ] = isset ( $ this -> _requests [ $ in ] ) ? $ this -> _requests [ $ in ] : $ default ; } return $ var ; }
Getting segments of inputs
228,550
public function except ( array $ name ) { $ var = [ ] ; foreach ( $ this -> _requests as $ k => $ v ) { if ( ! in_array ( $ k , $ name ) ) { $ var [ $ k ] = $ v ; } } return $ var ; }
Get data input except some
228,551
public function hasInputs ( array $ names ) { foreach ( $ names as $ name ) { if ( ! $ this -> has ( $ name ) ) return false ; } return true ; }
Check if inputs are received
228,552
public function hasQueries ( array $ names ) { foreach ( $ names as $ name ) { if ( ! $ this -> hasQuery ( $ name ) ) return false ; } return true ; }
Check if queries exists
228,553
public function url ( $ component = - 1 ) { $ active_url = URL :: here ( ) ; if ( $ component > - 1 ) { return parse_url ( $ active_url , $ component ) ; } return $ active_url ; }
Get request URL
228,554
public function header ( $ header ) { foreach ( $ this -> _headers as $ k => $ v ) { if ( ! strcasecmp ( $ k , $ header ) ) { return $ v ; } } return null ; }
Get request header value
228,555
public function getPageResult ( $ url , $ attributes = [ ] ) { $ request = new Request ( ) ; $ request -> setService ( self :: SERVICE_PAGE ) ; $ request -> setParam ( 'url' , $ url ) ; $ request -> setAttributes ( $ attributes ) ; return $ this -> execute ( $ request ) ; }
Get details for a page
228,556
public function execute ( RequestInterface $ request ) { $ httpRequest = $ this -> httpRequestBuilder -> build ( $ request ) ; $ httpResponse = $ this -> transport -> execute ( $ httpRequest ) ; return $ this -> resultBuilderEngine -> build ( $ request , $ httpResponse ) ; }
Execute a OneHydra request and return the result
228,557
public static function targetGet ( $ needle , array $ haystack , $ default = null ) { if ( $ needle === null ) { return $ haystack ; } $ parts = preg_split ( '/(?<!\\\\)\./' , $ needle ) ; foreach ( $ parts as $ part ) { $ key = str_replace ( '\\.' , '.' , $ part ) ; if ( is_array ( $ haystack ) === false || array_key_...
Get an value from an array via a dotted notation
228,558
public static function targetSet ( $ needle , $ value , array $ haystack = array ( ) ) { $ keys = explode ( '.' , $ needle ) ; $ loop = & $ haystack ; foreach ( $ keys as $ key ) { if ( is_array ( $ loop ) === false ) { $ loop = array ( ) ; } if ( array_key_exists ( $ key , $ loop ) === false ) { $ loop [ $ key ] = arr...
Set an value on a multi dimensional array via a dotted string notation
228,559
public function __isset ( $ helper ) { if ( isset ( $ this -> _helpers [ $ helper ] ) ) { $ isset = true ; } else { $ isset = ! is_null ( $ this -> _getHelper ( $ helper ) ) ; } return $ isset ; }
Is helper presents ?
228,560
private function _getHelper ( $ helper ) { $ instance = null ; foreach ( $ this -> _prefixes as $ prefix ) { $ className = $ prefix . "\\" . $ helper ; if ( Loader :: loadClass ( $ className ) ) { if ( is_subclass_of ( $ className , __NAMESPACE__ . "\\Helper_Interface" ) ) { $ instance = new $ className ( ) ; $ instanc...
Creates a new helper s instance
228,561
public function prependPrefix ( $ prefix ) { $ this -> deletePrefix ( $ prefix ) ; $ prepend = array ( $ prefix => $ prefix ) ; $ this -> _prefixes = array_merge ( $ prepend , $ this -> _prefixes ) ; }
Prepend namespace - prefix
228,562
public static function fromString ( $ string ) { $ matched = preg_match ( "/[^0-9a-fA-F]+/" , $ string , $ matches ) ; if ( $ matched || strlen ( $ string ) % 2 != 0 ) { throw XPath2Exception :: withErrorCodeAndParams ( "FORG0001" , Resources :: InvalidFormat , array ( $ string , "xs:hexBinary" ) ) ; } $ binary = hex2b...
Convert a string representation of a hex value to is binary version and create a HexBinaryValue instance
228,563
public function classUsesParentsTrait ( $ className ) { if ( is_object ( $ className ) ) { $ className = get_class ( $ className ) ; } if ( false === isset ( $ this -> classUsingParentsTrait [ $ className ] ) ) { $ this -> classUsingParentsTrait [ $ className ] = $ this -> checkClassUsesParentsTrait ( $ className ) ; }...
Will check and store the class names which use the trait ParentsTrait .
228,564
protected function checkClassUsesParentsTrait ( $ className ) { $ flag = false ; $ classes = array_merge ( [ $ className ] , class_parents ( $ className ) ) ; foreach ( $ classes as $ class ) { $ traits = class_uses ( $ class ) ; $ flag = $ flag || ( true === isset ( $ traits [ ParentsTrait :: class ] ) ) ; } return $ ...
Will check if the given class name uses the trait ParentsTrait .
228,565
function ask ( $ question , array $ answers ) { $ optstr = implode ( "|" , $ answers ) ; do { $ this -> printf ( "$question [$optstr] " ) ; $ answer = $ this -> fgets ( ) ; } while ( ! in_array ( $ answer , $ answers ) ) ; return $ answer ; }
Shorthand for retrieving confirmation from console . Common console task for input .
228,566
public static function plural ( string $ word ) : string { if ( in_array ( $ word , Inflector :: $ _uncontable ) ) { return $ word ; } if ( isset ( Inflector :: $ _plural [ "irregular" ] [ $ word ] ) ) { return Inflector :: $ _plural [ "irregular" ] [ $ word ] ; } foreach ( Inflector :: $ _plural [ "uninflected" ] as $...
Returns the plural form of the word .
228,567
public static function singular ( string $ word ) : string { if ( in_array ( $ word , Inflector :: $ _uncontable ) ) { return $ word ; } if ( isset ( Inflector :: $ _singular [ "irregular" ] [ $ word ] ) ) { return Inflector :: $ _singular [ "irregular" ] [ $ word ] ; } foreach ( Inflector :: $ _singular [ "uninflected...
Returns the singular form of the word .
228,568
public function addCharacters ( $ chars ) { if ( WF :: is_array_like ( $ chars ) ) { foreach ( $ chars as $ char ) { if ( ! is_string ( $ char ) ) throw new InvalidArgumentException ( "Invalid type: " . WF :: str ( $ chars ) ) ; $ this -> characters [ $ char ] = true ; } } elseif ( is_string ( $ chars ) ) { for ( $ i =...
Add one or more characters to the list of eligible characters
228,569
public function generatePassword ( int $ length = 8 ) { if ( $ length <= 0 ) throw new DomainException ( "Cannot generate zero-length passwords" ) ; if ( empty ( $ this -> characters ) ) throw new UnderflowException ( "First add characters used to generate the password" ) ; $ chars = implode ( '' , array_keys ( $ this ...
Generate a password of the specified length
228,570
public function loadDictionary ( string $ filename , $ append = false , $ regexp = "/^[a-z]{4,6}$/" ) { if ( ! file_exists ( $ filename ) || ! is_readable ( $ filename ) ) { $ orig = $ filename ; $ filename = "/usr/share/dict/" . $ filename ; if ( ! file_exists ( $ filename ) ) throw new IOException ( "Cannot open file...
Load a dictionary file for passphrase generation
228,571
public function generatePassphrase ( $ num_words = 4 ) { if ( count ( $ this -> dictionary ) < $ num_words ) { throw new UnderflowException ( "Not enough words loaded to generate a passphrase of $num_words words" ) ; } $ words = array ( ) ; $ attempt = 0 ; while ( count ( $ words ) < $ num_words ) { ++ $ attempt ; $ s ...
Generate a passphrase of the specified amount of words
228,572
protected function normalizeMappingSources ( array $ mappingSources ) : array { return \ array_map ( function ( $ mappingSource ) : array { if ( ! \ is_array ( $ mappingSource ) ) { $ mappingSource = [ 'type' => DriverFactoryInterface :: DRIVER_ANNOTATION , 'path' => $ mappingSource , ] ; } return $ mappingSource ; } ,...
Normalize mapping sources format .
228,573
function RenderScript ( ) { $ templateFile = Path :: RemoveExtension ( $ this -> TemplateFile ( ) ) ; $ scriptFile = Path :: AddExtension ( $ templateFile , 'Script' ) ; ob_start ( ) ; require Path :: AddExtension ( $ scriptFile , 'phtml' ) ; return ob_get_clean ( ) ; }
Renderst necessary javascript
228,574
public function Check ( $ data ) { $ value = $ data [ $ this -> prefix . 'Page' ] ; return $ this -> pageField -> Check ( $ value ) ; }
Check the selector
228,575
public function Save ( PageUrl $ pageUrl = null ) { $ exists = $ pageUrl && $ pageUrl -> Exists ( ) ; $ page = $ this -> Value ( 'Page' ) ? Page :: Schema ( ) -> ByID ( $ this -> Value ( 'Page' ) ) : null ; if ( ! $ page ) { if ( $ exists ) { $ pageUrl -> Delete ( ) ; } return null ; } if ( ! $ exists ) { $ pageUrl = n...
Saves the page url and returns it
228,576
private function SaveParams ( PageUrl $ pageUrl ) { $ this -> ClearParams ( $ pageUrl ) ; $ params = $ this -> serializer -> LinesToArray ( $ this -> Value ( 'Params' ) ) ; $ prev = null ; foreach ( $ params as $ name => $ value ) { $ param = new PageUrlParameter ( ) ; $ param -> SetPageUrl ( $ pageUrl ) ; $ param -> S...
Saves the page paramters after the page url is saved
228,577
private function Value ( $ name ) { $ value = Request :: PostData ( $ this -> prefix . $ name ) ; return Str :: Trim ( $ value ) ; }
Gets the value by pure name
228,578
private function ClearParams ( PageUrl $ pageUrl ) { $ sql = Access :: SqlBuilder ( ) ; $ tblParams = PageUrlParameter :: Schema ( ) -> Table ( ) ; $ where = $ sql -> Equals ( $ tblParams -> Field ( 'PageUrl' ) , $ sql -> Value ( $ pageUrl -> GetID ( ) ) ) ; PageUrlParameter :: Schema ( ) -> Delete ( $ where ) ; }
Clears the parameters of the page url
228,579
public function append ( string $ postfix ) : Utility { return new static ( $ this -> string . new static ( $ postfix , $ this -> encoding ) , $ this -> encoding ) ; }
Append the string with a given value
228,580
public function at ( int $ position ) : Utility { if ( $ position < 0 ) { return new static ( '' , $ this -> encoding ) ; } return $ this -> substring ( $ position , 1 ) ; }
Get the character at a specific index
228,581
public function clean ( string $ allowedTags = null ) : Utility { $ string = strip_tags ( trim ( $ this -> string ) , $ allowedTags ) ; return new static ( $ string , $ this -> encoding ) ; }
Remove tags and trim the string
228,582
public function containsAll ( $ contains , int $ offset = 0 ) : bool { if ( empty ( $ contains ) ) { return false ; } $ parameters = $ this -> parameters ( $ contains ) ; if ( $ offset > $ this -> length ( ) ) { return false ; } foreach ( $ parameters as $ needle ) { if ( strpos ( $ this -> string , $ needle -> value (...
Check if a string contains all of the given values
228,583
public function explode ( $ delimiter , $ limit = PHP_INT_MAX ) : array { return array_slice ( array_map ( 'trim' , array_filter ( explode ( $ delimiter , $ this -> string , $ limit ) ) ) , 0 ) ; }
Explode the string on a given
228,584
public function first ( int $ count ) : Utility { if ( $ count < 0 ) { return new static ( '' , $ this -> encoding ) ; } return $ this -> substring ( 0 , $ count ) ; }
Get the first x characters from the string
228,585
public function format ( ... $ replacements ) : Utility { $ string = $ this -> string ; foreach ( $ replacements as $ index => $ value ) { if ( ! is_scalar ( $ value ) || ( is_object ( $ value ) && ! method_exists ( $ value , '__toString' ) ) ) { $ type = is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ valu...
Inserts the given values into the chronological placeholders
228,586
public function isFalse ( ) : bool { return ( in_array ( $ this -> string , [ '' ] ) || ( false === filter_var ( $ this -> string , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ) ) ; }
Check if a given value can be perceived as false . Will only return false if the value looks false - y by being a value of false 0 no off
228,587
public function isTrue ( ) : bool { return ( in_array ( $ this -> string , [ 'ok' ] ) || ( true === filter_var ( $ this -> string , FILTER_VALIDATE_BOOLEAN , FILTER_NULL_ON_FAILURE ) ) ) ; }
Check if a given value can be perceived as true Will on return true if the value looks true - y true 1 yes on ok
228,588
public function limit ( int $ length ) { $ string = $ this -> string ; if ( $ this -> length ( ) > $ length ) { $ string = substr ( $ string , 0 , $ length ) ; } return new static ( $ string , $ this -> encoding ) ; }
Limit the length of the string to a given value
228,589
public function minimise ( ) : Utility { $ replace = [ '/\>[^\S ]+/s' => '>' , '/[^\S ]+\</s' => '<' , '/([\t ])+/s' => ' ' , '/^([\t ])+/m' => '' , '/([\t ])+$/m' => '' , '~//[a-zA-Z0-9 ]+$~m' => '' , '/[\r\n]+([\t ]?[\r\n]+)+/s' => "\n" , '/\>[\r\n\t ]+\</s' => '><' , '/}[\r\n\t ]+/s' => '}' , '/}[\r\n\t ]+,[\r\n\t ]...
Minimise string removing all extra spaces new lines and any unneeded html content
228,590
public function occurrences ( string $ needle ) : array { $ offset = 0 ; $ allPositions = [ ] ; while ( ( $ position = strpos ( $ this -> string , $ needle , $ offset ) ) !== false ) { $ offset = $ position + 1 ; $ allPositions [ ] = $ position ; } return $ allPositions ; }
Find all the positions of occurrences of the given needle in the string
228,591
public function pad ( int $ length , string $ padding = ' ' ) : Utility { $ padLength = $ length - $ this -> length ( ) ; return $ this -> applyPadding ( floor ( $ padLength / 2 ) , ceil ( $ padLength / 2 ) , $ padding ) ; }
Pad the string with a value until it is the given length
228,592
public function padLeft ( $ length , $ padding = ' ' ) : Utility { return $ this -> applyPadding ( $ length - $ this -> length ( ) , 0 , $ padding ) ; }
Pad the left the string with a value until it is the given length
228,593
public function padRight ( $ length , $ padding = ' ' ) : Utility { return $ this -> applyPadding ( 0 , $ length - $ this -> length ( ) , $ padding ) ; }
Pad the right the string with a value until it is the given length
228,594
private function parameters ( $ parameters ) : array { $ values = ( ! is_array ( $ parameters ) ) ? [ $ parameters ] : $ parameters ; $ strings = [ ] ; foreach ( $ values as $ value ) { $ strings [ ] = self :: make ( $ value , $ this -> encoding ) ; } return $ strings ; }
Transform user input into a collection of Utility
228,595
private function prepareForCasing ( $ string ) : array { $ string = str_replace ( [ '.' , '_' , '-' ] , ' ' , $ string ) ; $ string = implode ( ' ' , preg_split ( '/(?<=\\w)(?=[A-Z])/' , $ string ) ) ; $ parts = preg_split ( '/(,?\s+)|((?<=[a-z])(?=\d))|((?<=\d)(?=[a-z]))/i' , $ string ) ; return array_values ( array_f...
Clean up and chunk a string ready for use in casing the string value
228,596
public function prepend ( $ prefix ) : Utility { return new static ( new static ( $ prefix , $ this -> encoding ) . $ this -> string , $ this -> encoding ) ; }
Prepend the string with a given value
228,597
public function removeRepeating ( string $ repeatingValue = ' ' ) : Utility { $ string = preg_replace ( '{(' . preg_quote ( $ repeatingValue ) . ')\1+}' , $ repeatingValue , $ this -> string ) ; return new static ( $ string , $ this -> encoding ) ; }
Remove repeating characters from the value
228,598
public function removeSpace ( ) : Utility { $ string = preg_replace ( '~[[:cntrl:][:space:]]~' , '' , trim ( $ this -> string ) ) ; return new static ( $ string , $ this -> encoding ) ; }
Remove all spaces and white space from the string
228,599
public function repeat ( int $ multiplier ) : Utility { $ string = str_repeat ( $ this -> string , $ multiplier ) ; return new static ( $ string , $ this -> encoding ) ; }
Repeat the string by the amount of the multiplier