idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
51,300 | public function mapOneEmbedded ( ClassMetadata $ class ) { $ this -> embedded = true ; $ this -> type = self :: TYPE_ONE ; $ this -> mapAttribute ( $ class ) ; } | Map this property as a single embedded document . |
51,301 | public function mapOneReference ( ClassMetadata $ class ) { $ this -> reference = true ; $ this -> type = self :: TYPE_ONE ; $ this -> mapAttribute ( $ class ) ; } | Map this property as a single document reference . |
51,302 | public function setValueAndWakeProxy ( $ document , $ value ) { if ( $ document instanceof Proxy && ! $ document -> __isInitialized ( ) ) { $ document -> __load ( ) ; } $ this -> setValue ( $ document , $ value ) ; return $ this ; } | Sets this mapped attribute to the specified value on the given document waking the document if proxied . |
51,303 | public function addOpeningHour ( $ day , $ hours ) { $ openingHour = new OpeningHours ( $ day , $ hours ) ; $ this -> openingHours [ $ day ] = $ openingHour ; } | Adds an opening schedule for a day . |
51,304 | public function sanitize ( $ value ) { if ( $ value instanceof Traversable ) { return $ this -> sanitize ( iterator_to_array ( $ value ) ) ; } elseif ( is_array ( $ value ) ) { return array_map ( [ $ this , 'sanitize' ] , $ value ) ; } elseif ( is_object ( $ value ) ) { return $ this -> sanitizeObject ( $ value ) ; } e... | Sanitize recursively a value |
51,305 | public function indexAction ( ) { $ configForm = $ this -> getForm ( ) ; $ configForm -> setData ( $ this -> getConfig ( ) ) ; $ view = new ViewModel ( array ( 'title' => $ this -> getEditTitle ( ) , 'configForm' => $ configForm ) ) ; $ view -> setTemplate ( 'xelax-site-config/site-config/index.phtml' ) ; return $ view... | Show current config |
51,306 | public static function create ( string $ name , $ value , array $ expectedTypes ) : self { return new static ( sprintf ( '%s expected to be %s, %s returned' , ucfirst ( $ name ) , implode ( ' or ' , $ expectedTypes ) , is_object ( $ value ) ? get_class ( $ value ) : gettype ( $ value ) ) ) ; } | Makes an exception instance . |
51,307 | protected function loadExchangeRates ( $ targetCurrency ) { if ( ! isset ( $ this -> exchangeRates [ $ targetCurrency ] ) ) { $ currencyRates = $ this -> currencyRateRepository -> findBy ( [ 'currencyTo' => $ targetCurrency ] ) ; if ( count ( $ currencyRates ) === 0 ) { throw new MissingCurrencyRatesException ( $ targe... | Sets exchange rates for target currency |
51,308 | public function get ( $ ressourceToGrab , array $ parameters = null ) { $ this -> apiRequest -> clean ( ) ; $ this -> apiRequest -> setHeaders ( $ this -> apiConfiguration -> getHeaders ( ) ) ; $ this -> apiRequest -> setParameters ( $ this -> apiConfiguration -> getParameters ( ) ) ; return $ this -> apiRequest -> get... | Request a ressource of an api with the get http method |
51,309 | protected function substituteBindings ( $ route ) { foreach ( $ route -> parameters ( ) as $ key => $ value ) { if ( isset ( $ this -> binders [ $ key ] ) ) { $ route -> setParameter ( $ key , $ this -> performBinding ( $ key , $ value , $ route ) ) ; } } $ this -> substituteImplicitBindings ( $ route ) ; return $ rout... | Substitute the route bindings onto the route . |
51,310 | protected function substituteImplicitBindings ( $ route ) { $ parameters = $ route -> parameters ( ) ; foreach ( $ route -> signatureParameters ( Model :: class ) as $ parameter ) { $ class = $ parameter -> getClass ( ) ; if ( array_key_exists ( $ parameter -> name , $ parameters ) && ! $ route -> getParameter ( $ para... | Substitute the implicit Eloquent model bindings for the route . |
51,311 | public function bindParam ( $ param , & $ variable , $ type = null , int $ length = null ) : bool { try { return $ this -> pdoStatement -> bindParam ( $ param , $ variable , $ type , $ length , null ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | bind a parameter of a prepared query to the specified variable |
51,312 | public function bindValue ( $ param , $ value , $ type = null ) : bool { try { return $ this -> pdoStatement -> bindValue ( $ param , $ value , $ type ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseException ( $ pdoe -> getMessage ( ) , $ pdoe ) ; } } | bind a value to the parameter of a prepared query |
51,313 | public function execute ( array $ values = [ ] ) : QueryResult { try { if ( $ this -> pdoStatement -> execute ( $ values ) ) { return new PdoQueryResult ( $ this -> pdoStatement ) ; } throw new DatabaseException ( 'Executing the prepared statement failed.' ) ; } catch ( PDOException $ pdoe ) { throw new DatabaseExcepti... | executes a prepared statement |
51,314 | public function filterByHost ( $ host = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ host ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SourceTableMap :: COL_HOST , $ host , $ comparison ) ; } | Filter the query on the host column |
51,315 | public function filterByEndpoint ( $ endpoint = null , $ comparison = null ) { if ( null === $ comparison ) { if ( is_array ( $ endpoint ) ) { $ comparison = Criteria :: IN ; } } return $ this -> addUsingAlias ( SourceTableMap :: COL_ENDPOINT , $ endpoint , $ comparison ) ; } | Filter the query on the endpoint column |
51,316 | public function indexAction ( ) { $ instances = $ this -> getManager ( ) -> findAll ( ) ; $ worker = $ this -> get ( 'ringo_php_redmon.instance_worker' ) ; if ( is_array ( $ instances ) ) { foreach ( $ instances as $ index => $ instance ) { $ working = $ worker -> setInstance ( $ instance ) -> ping ( ) ; $ instances [ ... | List of instances action |
51,317 | public function editAction ( $ id ) { $ instance = $ this -> getManager ( ) -> find ( $ id ) ; if ( ! $ instance ) { return new RedirectResponse ( $ this -> generateUrl ( 'ringo_php_redmon' ) ) ; } $ form = $ this -> getForm ( $ instance ) ; return $ this -> render ( $ this -> getTemplatePath ( ) . 'edit.html.twig' , a... | Edit instance action |
51,318 | public function updateAction ( $ id ) { $ form = $ this -> getForm ( ) ; $ request = $ this -> get ( 'request' ) ; if ( 'POST' == $ request -> getMethod ( ) ) { $ form -> submit ( $ request ) ; if ( $ form -> isValid ( ) ) { $ this -> getManager ( ) -> create ( $ form -> getData ( ) ) ; $ this -> get ( 'session' ) -> g... | Update instance action |
51,319 | public function deleteAction ( $ id ) { $ instance = $ this -> getManager ( ) -> find ( $ id ) ; if ( $ instance ) { $ this -> getManager ( ) -> delete ( $ instance ) ; $ this -> get ( 'session' ) -> getFlashBag ( ) -> add ( 'success' , 'Instance Redis has been deleted successfully' ) ; } else { $ this -> get ( 'sessio... | Delete instance action |
51,320 | protected function getForm ( Instance $ instance = null ) { if ( $ instance == null ) { $ instance = $ this -> getManager ( ) -> createNew ( ) ; } return $ this -> createForm ( $ this -> container -> get ( 'ringo_php_redmon.form.instance_type' ) , $ instance ) ; } | Create Form instance |
51,321 | public function attribute ( $ name ) { $ exists = isset ( $ this -> attributes [ $ name ] ) ; return $ exists ? $ this -> attributes [ $ name ] : null ; } | Returns an instance with the specified derived request attribute . |
51,322 | public function query ( $ name ) { $ exists = isset ( $ this -> queries [ $ name ] ) ; return $ exists ? $ this -> queries [ $ name ] : null ; } | Returns the specified query string argument . |
51,323 | protected function longestCommonSubsequence ( array $ from , array $ to ) { $ common = array ( ) ; $ matrix = array ( ) ; $ fromLength = count ( $ from ) ; $ toLength = count ( $ to ) ; for ( $ i = 0 ; $ i <= $ fromLength ; ++ $ i ) { $ matrix [ $ i ] [ 0 ] = 0 ; } for ( $ j = 0 ; $ j <= $ toLength ; ++ $ j ) { $ matri... | Calculates the longest common subsequence of two arrays . |
51,324 | private function getDwnlLog ( $ datestamp ) { $ result = [ ] ; $ tsFrom = $ this -> hlpPeriod -> getTimestampFrom ( $ datestamp ) ; $ periodTo = $ this -> hlpPeriod -> getPeriodCurrent ( ) ; $ tsTo = $ this -> hlpPeriod -> getTimestampTo ( $ periodTo ) ; $ query = $ this -> qGetChanges -> build ( ) ; $ conn = $ query -... | Load change log starting from the given date . |
51,325 | private function getDwnlSnap ( $ datestamp ) { $ result = [ ] ; $ query = $ this -> qSnapOnDate -> build ( ) ; $ query -> order ( QSnapOnDate :: AS_DWNL_SNAP . '.' . ESnap :: A_DEPTH ) ; $ conn = $ query -> getConnection ( ) ; $ bind = [ QSnapOnDate :: BND_ON_DATE => $ datestamp ] ; $ rows = $ conn -> fetchAll ( $ quer... | Load downline snapshot on the given date . |
51,326 | public static function getAnonymous ( ) : Principal { if ( self :: $ anon === null ) { self :: $ anon = new self ( null , [ ] , true ) ; } return self :: $ anon ; } | Gets a token representing an anonymous authentication . |
51,327 | public function validateConnection ( ) { if ( $ this -> validate ( ) ) { try { $ connection = new CDbConnection ( "mysql:host={$this->host};dbname={$this->dbname}" , $ this -> username , $ this -> password ) ; $ connection -> setActive ( true ) ; $ connection -> setActive ( false ) ; $ this -> dsn = $ connection -> con... | Validator for connection to MySQL |
51,328 | private function contents ( ) : array { if ( ! $ this -> contents ) { if ( ! file_exists ( $ this -> path ) ) { throw new \ LogicException ( vsprintf ( 'The PHP configuration file does not exist (%s)' , [ realpath ( $ this -> path ) , ] ) ) ; } $ contents = require $ this -> path ; if ( ! is_array ( $ contents ) ) { th... | Return the content of the file and cache it . |
51,329 | private function keyNotArrayErrorMessage ( array $ contents , string ... $ path ) : string { $ value = array_reduce ( $ path , function ( array $ arr , string $ key ) { return $ arr [ $ key ] ; } , $ contents ) ; return vsprintf ( 'The key [%s] of the configuration array must be an array, %s given (%s)' , [ implode ( '... | Return the error message of the exception thrown when a key of the configuration array is not an array . |
51,330 | private function arrayKeyTypeErrorMessage ( array $ contents , string $ key , string $ type , string ... $ path ) : string { $ arr = array_reduce ( $ path , function ( array $ arr , string $ key ) { return $ arr [ $ key ] ; } , $ contents ) ; return vsprintf ( 'The key [%s] of the configuration array must be an array o... | Return the error message of the exception thrown when a key of an array is associated to a value with an unexpected type . |
51,331 | static function instance ( array $ whitelist , array $ blacklist , array $ aliaslist , $ main_entity_id = \ hlin \ Auth :: Unidentified , $ main_entity_role = \ hlin \ Auth :: Guest , \ hlin \ archetype \ Logger $ logger = null ) { $ i = new static ; $ i -> whitelist = $ whitelist ; $ i -> blacklist = $ blacklist ; $ i... | Most operations are on the current entity so we require the current entity is set to facilitate the process ; some operations also require the current entity to resolve . |
51,332 | public function overrideGlobals ( ) { $ this -> server -> set ( 'QUERY_STRING' , static :: normalizeQueryString ( http_build_query ( $ this -> query -> all ( ) , NULL , '&' ) ) ) ; $ _GET = $ this -> query -> all ( ) ; $ _POST = $ this -> request -> all ( ) ; $ _SERVER = $ this -> server -> all ( ) ; $ _COOKIE = $ this... | Overrides the PHP global variables according to this request instance . |
51,333 | public static function setTrustedHosts ( array $ hostPatterns ) { self :: $ trustedHostPatterns = array_map ( function ( $ hostPattern ) { return sprintf ( '#%s#i' , $ hostPattern ) ; } , $ hostPatterns ) ; self :: $ trustedHosts = [ ] ; } | Sets a list of trusted host patterns . You should only list the hosts you manage using regexs . |
51,334 | protected function getContents ( $ path ) { $ contents = @ file_get_contents ( $ path ) ; if ( false === $ contents ) { throw new NotFoundException ( Message :: get ( Message :: CONFIG_FILE_NOTFOUND , $ path ) , Message :: CONFIG_FILE_NOTFOUND ) ; } return $ contents ; } | Read contents from a local file system |
51,335 | protected function matchEnv ( $ name ) { if ( '_' === $ name [ 0 ] ) { $ pos = strpos ( $ name , '.' ) ; if ( false !== $ pos ) { $ pref = substr ( $ name , 0 , $ pos ) ; $ suff = substr ( $ name , $ pos + 1 ) ; if ( isset ( $ GLOBALS [ $ pref ] [ $ suff ] ) ) { return $ GLOBALS [ $ pref ] [ $ suff ] ; } } } return get... | Find the env value base one the name |
51,336 | public static function permissionType ( $ type ) { if ( $ type == Teamspeak :: PERM_TYPE_SERVERGROUP ) { return "Server Group" ; } if ( $ type == Teamspeak :: PERM_TYPE_CLIENT ) { return "Client" ; } if ( $ type == Teamspeak :: PERM_TYPE_CHANNEL ) { return "Channel" ; } if ( $ type == Teamspeak :: PERM_TYPE_CHANNELGROU... | Converts a given permission type ID to a human readable name . |
51,337 | public function validateUniqueness ( $ entity , $ parameters ) { $ errors = new Collection ( ) ; foreach ( $ this -> getManager ( ) -> getUnique ( ) as $ name => $ attributes ) { $ q = $ this -> getManager ( ) -> getRepository ( ) -> getQuery ( ) ; $ where = collect ( ) ; foreach ( $ attributes as $ attribute ) { $ att... | Validate uniqueness . |
51,338 | protected function achieveSerializer ( string $ mime ) : S \ ASerializer { $ this -> checkSerializerSupported ( $ mime ) ; $ serializer = $ this -> getSerializer ( $ mime ) ; return static :: instantiateSerializer_ ( $ serializer ) ; } | Static method achieveSerializer |
51,339 | public function handler ( $ severity , $ message , $ file , $ line ) { throw new ErrorException ( $ message , 0 , $ severity , $ file , $ line ) ; } | Error handler . Throw new Eureka ErrorException |
51,340 | public function toObject ( ) { $ array = $ this -> get ( ) ; foreach ( $ array as $ key => $ value ) { if ( is_array ( $ value ) ) { $ array [ $ key ] = ( new \ PHY \ Variable \ Arr ( $ value ) ) -> toObject ( ) ; } } return ( object ) $ array ; } | Recursively convert our array into a stdClass . |
51,341 | public function offsetGet ( $ offset ) { $ get = $ this -> chaining ? 'chain' : 'current' ; return array_key_exists ( $ offset , $ this -> $ get ) ? $ this -> $ get [ $ offset ] : null ; } | Grab an offset if it s defined . |
51,342 | public function offsetSet ( $ offset , $ value ) { $ get = $ this -> chaining ? 'chain' : 'current' ; $ this -> $ get [ $ offset ] = $ value ; } | Set an offset . |
51,343 | public function sort ( $ sort_flags = SORT_REGULAR ) { $ array = $ this -> get ( ) ; sort ( $ array , $ sort_flags ) ; $ this -> update ( $ array ) ; return $ this ; } | Sort our Array . |
51,344 | public function slice ( $ offset = 0 , $ length = null , $ preserve_keys = false ) { $ array = array_slice ( $ this -> get ( ) , $ offset , $ length , $ preserve_keys ) ; $ this -> update ( $ array ) ; return $ this ; } | Slice an Array . |
51,345 | public function splice ( $ offset = 0 , $ length = 0 , $ replacement = null ) { $ array = $ this -> get ( ) ; if ( null !== $ replacement ) { array_splice ( $ array , $ offset , $ length , $ replacement ) ; } else { array_splice ( $ array , $ offset , $ length ) ; } $ this -> update ( $ array ) ; return $ this ; } | Splice an array . |
51,346 | public function create ( $ keyName = 'id' , $ route_key_name = 'id' , $ timestamps = true , $ softDeletes = false , $ fields = [ ] ) { $ path = $ this -> getpath ( $ this -> name ) ; if ( $ this -> files -> exists ( $ path ) ) { throw new \ Exception ( "Model [$this->name] already exists!" ) ; } $ stub = $ this -> file... | Create a new migration file . |
51,347 | protected function replaceFillable ( & $ stub , $ fields ) { $ fillable = [ ] ; foreach ( $ fields as $ f ) { if ( $ f [ 'add_to' ] == 'fillable' ) $ fillable [ ] = "\"{$f['name']}\"" ; } if ( count ( $ fillable ) ) $ fillable = "protected \$fillable = [" . implode ( ',' , $ fillable ) . "];" ; else $ fillable = "" ; $... | Replace fillable dummy . |
51,348 | protected function replaceGuarded ( & $ stub , $ fields ) { $ guarded = [ ] ; foreach ( $ fields as $ f ) { if ( $ f [ 'add_to' ] == 'guarded' ) $ guarded [ ] = "\"{$f['name']}\"" ; } if ( count ( $ guarded ) ) $ guarded = "protected \$guarded = [" . implode ( ',' , $ guarded ) . "];" ; else $ guarded = "" ; $ stub = s... | Replace guarded dummy . |
51,349 | protected function replaceCasts ( & $ stub , $ fields ) { $ casts = [ ] ; foreach ( $ fields as $ f ) { if ( ! empty ( $ f [ 'casts' ] ) ) $ casts [ ] = "\"{$f['name']}\"=>\"{$f['casts']}\"" ; } if ( count ( $ casts ) ) $ casts = "protected \$casts = [" . implode ( ',' , $ casts ) . "];" ; else $ casts = "" ; $ stub = ... | Replace casts dummy . |
51,350 | protected function replaceRouteKeyName ( & $ stub , $ route_key_name ) { if ( $ route_key_name == 'id' ) $ replace = "" ; else { $ replace = "public function getRouteKeyName(){ return \"{$route_key_name}\"; }" ; } $ stub = str_replace ( 'DummyRouteKeyName' , $ replace , $ stub ) ; return $ this ; } | Replace RouteKeyName dummy . |
51,351 | public function getFileByName ( $ folderName , $ mimeType , $ includeTrash = false , \ Google_Service_Drive_DriveFile $ parent = null , $ createIfNotFound = false ) { $ query = 'title = \'' . $ folderName . '\' and mimeType = \'' . $ mimeType . '\'' ; if ( ! $ includeTrash ) { $ query .= ' and trashed = false' ; } if (... | Get a file |
51,352 | public function downloadFileFromURL ( $ url ) { $ request = new \ Google_Http_Request ( $ url , 'GET' , null , null ) ; $ httpRequest = $ this -> service -> getClient ( ) -> getAuth ( ) -> authenticatedRequest ( $ request ) ; if ( $ httpRequest -> getResponseHttpCode ( ) == 200 ) { return $ httpRequest -> getResponseBo... | Download a file from a url |
51,353 | public function getFilesInFolder ( \ Google_Service_Drive_DriveFile $ folder ) { $ query = 'trashed = false and \'' . $ folder -> getId ( ) . '\' in parents' ; $ fileList = $ this -> service -> files -> listFiles ( array ( 'q' => $ query ) ) ; return $ fileList ; } | Get Files in a folder |
51,354 | private function checkImage ( $ path ) { if ( ! file_exists ( $ this -> getWebDirectory ( ) . '/' . $ path ) && ! file_exists ( $ path ) ) { throw new NotFoundException ( sprintf ( "Unable to find the image \"%s\" to cache" , $ path ) ) ; } if ( ! is_file ( $ this -> getWebDirectory ( ) . '/' . $ path ) && ! is_file ( ... | Validates that an image exists |
51,355 | public static function translate ( $ url , $ options = array ( ) ) { if ( ( $ embed = \ Phata \ Widgetfy \ Site :: translate ( $ url , $ options ) ) != NULL ) { return $ embed ; } elseif ( ( $ embed = \ Phata \ Widgetfy \ MediaFile :: translate ( $ url , $ options ) ) != NULL ) { return $ embed ; } return NULL ; } | simplified interface to translate a url into embed code |
51,356 | public static function between ( int $ min , int $ max , string $ encoding = 'UTF-8' ) : Length { $ length = [ $ min , $ max ] ; sort ( $ length ) ; return new Length ( 'bt' , $ length , $ encoding ) ; } | Gets a rule that requires strings to have a minimum and maximum length . |
51,357 | protected function BeforeGather ( ) { if ( $ this -> IsTriggered ( ) && $ this -> Elements ( ) -> Check ( Request :: MethodArray ( $ this -> Method ( ) ) ) ) { return $ this -> OnSuccess ( ) ; } return parent :: BeforeGather ( ) ; } | Overrides the template module method to realize form logic |
51,358 | protected function SetRequired ( $ name , $ errorPrefix = '' ) { $ field = $ this -> GetElement ( $ name ) ; if ( ! $ field instanceof FormField ) { throw new \ InvalidArgumentException ( "$name is not a field in the form elements" ) ; } if ( ! $ errorPrefix ) { $ errorPrefix = $ this -> ErrorPrefix ( $ name ) ; } $ fi... | Sets the field as required |
51,359 | public function GetElement ( $ name ) { $ element = $ this -> Elements ( ) -> GetElement ( $ name ) ; if ( ! $ element ) { throw new \ Exception ( Trans ( 'Core.Form.Error.ElementNotFound.Name_{0}' , $ name ) ) ; } return $ element ; } | Gets the element with the given name |
51,360 | protected function AddValidator ( $ name , Validator $ validator , $ errorPrefix = '' ) { $ field = $ this -> GetElement ( $ name ) ; if ( ! $ errorPrefix ) { $ errorPrefix = $ this -> ErrorPrefix ( $ name ) ; } $ validator -> SetErrorLabelPrefix ( $ errorPrefix ) ; $ field -> AddValidator ( $ validator ) ; } | Adds a validator to the name |
51,361 | protected function AddSubmit ( $ name = '' , $ label = '' ) { $ defaultLabel = $ this -> Label ( 'Submit' ) ; if ( ! $ name ) { $ name = str_replace ( '.' , '-' , $ defaultLabel ) ; } if ( ! $ label ) { $ label = Worder :: Replace ( $ defaultLabel ) ; } $ this -> triggerName = $ name ; $ field = new Submit ( $ name , $... | Adds a submit button that triggers the form logic on submit |
51,362 | protected function Value ( $ name , $ trim = true ) { $ value = Request :: MethodData ( $ this -> Method ( ) , $ name ) ; if ( $ trim ) { return Str :: Trim ( $ value ) ; } return $ value ; } | The form value as submitted |
51,363 | protected function FindSnippet ( IFormField $ field ) { if ( $ field instanceof Input && ( $ field -> GetType ( ) == Input :: TypeText || $ field -> GetType ( ) == Input :: TypePassword || $ field -> GetType ( ) == Input :: TypeColor ) ) { return new FormFields \ TextInputField ( $ field ) ; } if ( $ field instanceof I... | Finds the snippet for a form field ; can be overriden for customization |
51,364 | protected function SetTransAttribute ( $ name , $ attribute ) { $ field = $ this -> GetElement ( $ name ) ; $ field -> SetHtmlAttribute ( $ attribute , Worder :: Replace ( $ this -> AttributePlaceholder ( $ name , $ attribute ) ) ) ; } | Sets a translatable attribute of the field to a default placeholder |
51,365 | protected function SetTransDescription ( $ name ) { $ field = $ this -> GetElement ( $ name ) ; $ field -> SetDescription ( Worder :: Replace ( $ this -> FieldDescription ( $ name ) ) ) ; } | Sets a description with a default placeholder for translation |
51,366 | protected function _loadDocument ( ) { $ this -> _Document = new DOMDocument ( ) ; $ reporting = error_reporting ( 0 ) ; $ loaded = $ this -> _Document -> loadHTML ( $ this -> _html ) ; error_reporting ( $ reporting ) ; if ( ! $ loaded ) { throw new Exception ( 'Unable to load HTML document.' ) ; } } | Builds a DOMDocument from the HTML source . |
51,367 | public static function path ( string $ path ) : string { if ( ! isset ( self :: $ cache [ $ path ] ) ) { $ _path = preg_replace ( '#\\' . static :: DIRECTORY_SEPARATOR . '+#' , static :: DIRECTORY_SEPARATOR , ltrim ( $ path , static :: DIRECTORY_SEPARATOR ) ) ; $ tmp = explode ( static :: DIRECTORY_SEPARATOR , $ _path ... | Normalize the given path |
51,368 | public static function directory ( string $ path ) : string { return ltrim ( rtrim ( $ path , static :: DIRECTORY_SEPARATOR ) . static :: DIRECTORY_SEPARATOR , static :: DIRECTORY_SEPARATOR ) ; } | Force path to be a directory |
51,369 | public static function setNestedObjectProperty ( $ value , & $ object , $ memberPath ) { $ explodedPath = explode ( "." , $ memberPath ) ; $ finalBit = array_pop ( $ explodedPath ) ; if ( sizeof ( $ explodedPath ) > 0 ) { $ nestedProperty = ObjectUtils :: getNestedObjectProperty ( $ object , implode ( "." , $ explodedP... | Set a nested object property value on an object using a member path to locate it . |
51,370 | public static function getDifferingMembers ( $ object1 , $ object2 , $ membersToConsider = array ( ) , $ recursive = false ) { if ( ! ( $ object1 instanceof SerialisableObject ) || ! ( $ object2 instanceof SerialisableObject ) ) { throw new Exception ( "You cannot compare for differing members of none serialisable obje... | Get differing members between two serialisable source objects - this will return a structured array detailing the differences . If the membersToConsider array is passed only members contained within the array will be considered otherwise all members will be considered by default . |
51,371 | public static function getDifferingMembersFormattedString ( $ object1 , $ object2 , $ formatString , $ separator , $ displayMemberKeys = array ( ) , $ recursive = false ) { $ differingMembers = ObjectUtils :: getDifferingMembers ( $ object1 , $ object2 , array_keys ( $ displayMemberKeys ) , $ recursive ) ; $ elements =... | Get a formatted string encoding the differing members . |
51,372 | public function getset ( $ property , $ args ) { if ( count ( $ args ) ) { $ this -> $ property = $ args [ 0 ] ; } return $ this -> $ property ; } | Get and optionally set the value for a property . |
51,373 | protected function resolveDefitions ( PropertyDefinitionCollectionInterface $ propertyDefinitionCollection = null ) { if ( $ propertyDefinitionCollection instanceof PropertyDefinitionCollectionInterface ) { return $ propertyDefinitionCollection -> import ( $ this -> propertiesAndTypes ( ) ) ; } $ className = $ this -> ... | Resolve and if necessary initialize the property definition collection . |
51,374 | public static function appendDataToFile ( $ filePath , $ data , $ newLine = false ) { if ( $ newLine ) { file_put_contents ( $ filePath , $ data . PHP_EOL , FILE_APPEND ) ; } else { file_put_contents ( $ filePath , $ data , FILE_APPEND ) ; } } | Add data to the end of a file . |
51,375 | public static function removeLineFromFile ( $ filePath , $ match ) { $ allLines = file ( $ filePath ) ; $ matches = preg_grep ( '/' . $ match . '/i' , $ allLines , PREG_GREP_INVERT ) ; $ cleanMatches = array_map ( function ( $ str ) { return str_replace ( PHP_EOL , '' , $ str ) ; } , $ matches ) ; file_put_contents ( $... | Find matching line of text from file and remove it . |
51,376 | public static function returnMatchingLinesFromFile ( $ filePath , $ textMatch ) { $ allLines = file ( $ filePath ) ; $ matches = preg_grep ( "/" . $ textMatch . "/i" , $ allLines ) ; $ cleanMatches = array_map ( function ( $ str ) { return str_replace ( PHP_EOL , '' , $ str ) ; } , $ matches ) ; return $ cleanMatches ;... | Return lines matching the text supplied . |
51,377 | public function createMenu ( string $ id , string $ class ) : string { $ output = $ this -> addOpeningNav ( $ id ) ; if ( $ this -> options [ 'brand' ] [ 'name' ] !== '' ) $ output .= $ this -> addBranding ( ) ; if ( $ this -> options [ 'mobile' ] ) $ output .= $ this -> addMobileButton ( ) ; $ output .= '<div class="c... | 1 . 0 Start of creating the bootstrap menu |
51,378 | private function addOpeningNav ( string $ id ) : string { $ output = '<nav ' ; if ( $ id !== '' ) $ output .= 'id="' . $ id . '" ' ; $ output .= 'class="navbar navbar-' . $ this -> options [ 'theme' ] [ 'fore' ] ; if ( ! empty ( $ this -> options [ 'theme' ] [ 'back' ] ) ) $ output .= " bg-" . $ this -> options [ 'them... | 1 . 1 Creating opening tag navigation |
51,379 | private function addBranding ( ) : string { $ output = '<a class="navbar-brand" href="' . BASE_URL . '/">' ; if ( $ this -> options [ 'brand' ] [ 'image' ] [ 'link' ] !== 'none' ) $ output .= '<img src="' . BASE_URL . $ this -> options [ 'brand' ] [ 'image' ] [ 'link' ] . '" height="' . $ this -> options [ 'brand' ] [ ... | 1 . 2 Adding the brand of the website to the menu |
51,380 | private function createLeftMenu ( ) : string { $ argsCount = 0 ; $ arrayKey = $ this -> getArrayKey ( $ this -> menuData ) ; $ output = '<ul class="navbar navbar-nav mr-auto">' ; foreach ( $ arrayKey as $ menuItem ) { list ( $ url , $ text , $ place , $ id , $ class ) = $ this -> getLinkInformation ( [ $ menuItem ] ) ;... | 2 . 0 Creating Bootstrap s Left Menu |
51,381 | private function createSubmenu ( array $ arguments , array $ subMenu ) : string { $ argsCount = count ( $ arguments ) ; $ arrayKey = $ this -> getArrayKey ( $ subMenu ) ; list ( $ url , $ text , $ place , $ id , $ class ) = $ this -> getLinkInformation ( $ arguments ) ; $ output = '<a class="nav-link dropdown-toggle' ;... | 4 . 0 Create the drop down submenu |
51,382 | private function createDropDownItemSubUrl ( array $ args ) : string { list ( $ url , $ text , $ place , $ id , $ class ) = $ this -> getLinkInformation ( $ args ) ; $ output = '<a class="dropdown-item dropdown-toggle' ; $ output = ! empty ( $ class ) ? $ output . ' ' . $ class . '"' : $ output . '"' ; if ( ! empty ( $ ... | G . 2 Create the URL for the dropdown - item |
51,383 | private function getLinkInformation ( array $ args ) : array { $ arg = Menu :: getIndexes ( $ args ) ; $ url = $ this -> menuData [ $ arg [ 0 ] ] [ $ arg [ 1 ] ] [ $ arg [ 2 ] ] [ $ arg [ 3 ] ] [ $ arg [ 4 ] ] [ $ arg [ 5 ] ] [ $ arg [ 6 ] ] [ $ arg [ 7 ] ] [ $ arg [ 8 ] ] [ $ arg [ 9 ] ] [ 'url' ] ; $ text = $ this ->... | G . 3 Get the menu information |
51,384 | private function getArrayKey ( array $ menuData ) : array { $ arrayKey = array_keys ( $ menuData ) ; $ arrayKey = array_diff ( $ arrayKey , $ this -> remove ) ; $ arrayKey = array_values ( $ arrayKey ) ; return $ arrayKey ; } | G . 4 Get the keys of the current level in the menu |
51,385 | private function overviewUrl ( string $ url , string $ id , string $ class ) : string { $ output = '<li>' ; $ output .= '<a class="dropdown-item' ; $ output = ! empty ( $ class ) ? $ output . ' ' . $ class . '"' : $ output . '"' ; if ( ! empty ( $ id ) ) $ output .= ' id="' . $ id . '"' ; $ output .= ' href="' . $ url ... | G . 5 Add Overview Menu option |
51,386 | function var_dump ( $ message , $ data ) { try { $ export = trim ( str_replace ( "\n" , "\n\t" , var_export ( $ data , true ) ) , "\n\t " ) ; $ this -> log ( "$message\n\n\t$export\n" ) ; } catch ( Exception $ e ) { $ this -> failedLogging ( $ e , $ message ) ; } } | Save the data passed in as data . |
51,387 | protected function becloud ( $ clear ) { if ( $ this -> beclouding === null ) { return $ clear ; } else { $ to_hide = [ ] ; foreach ( $ this -> beclouding as $ key => $ str ) { $ to_hide [ $ str ] = $ key ; } return strtr ( $ clear , $ to_hide ) ; } } | This method is hook for implementation that can handle hiding or need hiding . |
51,388 | public function getText ( String $ text = null , String $ colour = 'green' , String $ backgroundColor = 'black' ) { $ colours = [ 'green' => Attributes :: COLOR_GREEN , 'red' => Attributes :: COLOR_RED , 'yellow' => Attributes :: COLOR_YELLOW , 'blue' => Attributes :: COLOR_BLUE , 'cyan' => Attributes :: COLOR_CYAN , '... | Returns text with option to set the text colour . |
51,389 | public function sendOutput ( String $ output , String $ colour = 'white' , String $ backgroundColor = 'black' ) { fwrite ( STDOUT , $ this -> getText ( $ output , $ colour , $ backgroundColor ) ) ; } | Sends output to the environment . |
51,390 | public function getAlternatesortstring1ByUserId ( $ userID ) { return DB :: table ( 'email_messages' ) -> join ( 'email_attachments' , 'email_messages.id' , '=' , 'email_attachments.email_messages_id' ) -> select ( 'email_attachments.alternate_sort_string1' ) -> where ( 'email_messages.user_id' , '=' , $ userID ) -> di... | Get a list of alternatesortstring1 field values by user ID |
51,391 | public static function convert ( int $ error_code ) { return isset ( self :: $ levels [ $ error_code ] ) ? self :: $ levels [ $ error_code ] : "GENERIC_ERROR" ; } | Convert a PHP error level to its name |
51,392 | public function errorInfo ( ) { if ( $ this -> getConnection ( ) instanceof PDO ) { $ message = isset ( $ this -> connection -> errorInfo ( ) [ 'message' ] ) ? $ this -> getConnection ( ) -> errorInfo ( ) [ 'message' ] : 'Something Went Wrong!' ; } elseif ( $ this -> getConnection ( ) instanceof mysqli ) { $ message = ... | return the last query error |
51,393 | public function dir ( $ path = null , $ create = false ) { if ( ! isset ( $ this -> _baseDir ) ) { throw new App \ Exception ( 'Base directory not set' ) ; } return isset ( $ path ) ? $ this -> _baseDir -> dir ( $ path , $ create ) : $ this -> _baseDir ; } | Get child directory . |
51,394 | public function file ( $ path ) { if ( ! isset ( $ this -> _baseDir ) ) { throw new App \ Exception ( 'Base directory not set' ) ; } return $ this -> _baseDir -> file ( $ path ) ; } | Get child file . |
51,395 | public function load ( $ file , array $ vars = array ( ) ) { $ file = ! $ file instanceof File ? new File ( "{$file}" ) : $ file ; $ file = $ file -> isRelative ( ) ? $ this -> file ( $ file ) : $ file ; return \ Coast \ load ( $ file , array_merge ( [ 'app' => $ this ] , $ vars ) ) ; } | Load a file without leaking variables include app object in vars . |
51,396 | public function lazy ( $ source , array $ vars = array ( ) ) { if ( is_string ( $ source ) ) { $ source = new File ( "{$source}" ) ; $ source = $ source -> isRelative ( ) ? $ this -> file ( $ source ) : $ source ; } return new Lazy ( $ source , array_merge ( [ 'app' => $ this ] , $ vars ) ) ; } | Lazy load a file without leaking variables include app object in vars . |
51,397 | public function executable ( $ executable , $ subpath = null ) { if ( ! $ executable instanceof Closure && ! $ executable instanceof Executable ) { throw new App \ Exception ( "Object is not a closure or instance of Coast\App\Executable" ) ; } if ( isset ( $ subpath ) ) { $ executable = new App \ Subpath ( $ executable... | Add executable to the stack . |
51,398 | public function execute ( Request $ req = null , Response $ res = null ) { $ auto = false ; if ( ! isset ( $ req ) ) { $ auto = true ; $ req = ( new Request ( ) ) -> fromGlobals ( ) ; $ res = ( new Response ( $ req ) ) ; } else if ( ! isset ( $ res ) ) { throw new App \ Exception ( 'You must pass a Response object when... | Execute the application running middleware in order . |
51,399 | public function addPostFilter ( FilterInterface $ filter , $ priority = 0 ) { $ this -> post_transformation -> add ( $ filter , $ priority ) ; return $ this ; } | add a post - processing filter to be always executed |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.