idx int64 0 60.3k | question stringlengths 64 4.24k | target stringlengths 5 618 |
|---|---|---|
54,800 | final protected function addRole ( object $ data , AbstractRole $ role ) : BoundedRoleInterface { return new class ( $ role , $ data ) implements BoundedRoleInterface { use DelegatorTrait ; public function __construct ( AbstractRole $ role , object $ data ) { if ( false === $ role -> supports ( $ data ) ) { throw new I... | Add a role to data . |
54,801 | final protected function addRoles ( object $ data , array $ roles ) : BoundedRoleInterface { foreach ( $ roles as $ role ) { $ data = $ this -> addRole ( $ data , $ role ) ; } return $ data ; } | Add multiple roles to data . |
54,802 | protected function mergeStack ( array $ stack , $ silent = true , $ direct_output = false ) { $ this -> __compressor -> reset ( ) ; if ( false === $ silent ) { $ this -> __compressor -> setSilent ( false ) ; } if ( true === $ direct_output ) { $ this -> __compressor -> setDirectOutput ( true ) ; } return $ this -> __co... | Merge a stack of files |
54,803 | protected function minifyStack ( array $ stack , $ silent = true , $ direct_output = false ) { $ this -> __compressor -> reset ( ) ; if ( false === $ silent ) { $ this -> __compressor -> setSilent ( false ) ; } if ( true === $ direct_output ) { $ this -> __compressor -> setDirectOutput ( true ) ; } return $ this -> __c... | Minify a stack of files |
54,804 | public function apply ( $ testable , array $ config = array ( ) ) { $ tokens = $ testable -> tokens ( ) ; $ pathinfo = pathinfo ( $ testable -> config ( 'path' ) ) ; if ( $ pathinfo [ 'extension' ] !== 'php' ) { return ; } $ filtered = $ testable -> findAll ( array ( T_CLASS ) ) ; foreach ( $ filtered as $ key ) { $ to... | Will iterate the tokens looking for a T_CLASS which should be in CamelCase and match the file name |
54,805 | public function getModels ( ) { $ all = new Models ( ) ; foreach ( $ this -> items as $ item ) { $ all -> addAll ( $ item -> getCurrentAndOriginal ( ) ) ; } return $ all ; } | Get all of the linked models |
54,806 | public function connect ( ) { $ this -> resource = stream_context_create ( ) ; if ( $ this -> configuration -> getDir ( ) == '' ) { return true ; } if ( $ this -> driver -> chdir ( $ this -> configuration -> getDir ( ) ) == true ) { return true ; } return false ; } | Create local connection . |
54,807 | public function cd ( $ dir = '' ) { $ this -> errorHandler -> start ( ) ; if ( $ this -> driver -> chdir ( $ dir ) ) { $ this -> errorHandler -> stop ( ) ; return true ; } $ this -> errorHandler -> stop ( ) ; return false ; } | Change the current working directory on the Local machine . |
54,808 | public function mv ( $ sourcepath , $ destpath ) { $ this -> errorHandler -> start ( ) ; if ( $ this -> driver -> rename ( $ sourcepath , $ destpath , $ this -> resource ) ) { $ this -> errorHandler -> stop ( ) ; return true ; } $ this -> errorHandler -> stop ( ) ; return false ; } | Move a remote file to a new location on the local machine . |
54,809 | public function cp ( $ sourcepath , $ destpath ) { $ this -> errorHandler -> start ( ) ; if ( $ this -> driver -> copy ( $ sourcepath , $ destpath , $ this -> resource ) ) { $ this -> errorHandler -> stop ( ) ; return true ; } $ this -> errorHandler -> stop ( ) ; return false ; } | Copy a file on the local machine to a new location on the local machine . |
54,810 | public function rm ( $ sourcepath ) { $ this -> errorHandler -> start ( ) ; if ( $ this -> driver -> delete ( $ sourcepath , $ this -> resource ) ) { $ this -> errorHandler -> stop ( ) ; return true ; } $ this -> errorHandler -> stop ( ) ; return false ; } | Remove a file from the local file system . |
54,811 | private function addProcessInfo ( Process $ process , Project $ project , ProgressBar $ progressBar , int $ index ) { $ this -> processes [ $ project -> getName ( ) ] = [ 'process' => $ process , 'project' => $ project , 'progressBar' => $ progressBar , 'index' => $ index , ] ; } | Adds the process to the list of processes . |
54,812 | private function createProgressBar ( BufferedOutputInterface $ output , Project $ project ) : ProgressBar { $ progressBar = new ProgressBar ( $ output , 1 ) ; $ progressBar -> setFormatDefinition ( 'custom' , '%project%: [%bar%] %message%' ) ; $ progressBar -> setFormat ( 'custom' ) ; $ progressBar -> setMessage ( spri... | Creates a new progress bar for a project . |
54,813 | private function startProgressBars ( BufferedOutputInterface $ output ) { foreach ( $ this -> processes as $ processInfo ) { $ processInfo [ 'progressBar' ] -> start ( ) ; $ output -> write ( "\n" ) ; $ this -> currentIndex = $ processInfo [ 'index' ] ; } } | Starts and renders the progress bars . |
54,814 | private function setCursorToProgressBar ( int $ index , BufferedOutputInterface $ output ) { if ( $ this -> currentIndex > $ index ) { $ this -> moveCursorUp ( $ this -> currentIndex - $ index , $ output ) ; } elseif ( $ this -> currentIndex < $ index ) { $ this -> moveCursorDown ( $ index - $ this -> currentIndex , $ ... | Sets the cursor to the line where the progress bar with given index is displayed . |
54,815 | public function getSubscribedEvents ( ) { $ events = [ $ this -> command . '.resolve' => 'resolveDnsQuery' , $ this -> command . '.resolver' => 'getResolverEvent' , ] ; if ( $ this -> enableCommand ) { $ events [ 'command.' . $ this -> command ] = 'handleDnsCommand' ; } return $ events ; } | Indicates that the plugin provides DNS resolving services . |
54,816 | public function encryptByConfig ( $ str ) { if ( $ this -> isSingle ( ) ) { if ( $ security_key = $ this -> getConfigByName ( 'security_key' ) ) { $ str = $ this -> encrypt ( $ str , hex2bin ( md5 ( $ security_key ) ) ) ; } return $ str ; } return '' ; } | Encrypt By Config |
54,817 | public function decryptByConfig ( $ str ) { if ( $ this -> isSingle ( ) ) { if ( $ security_key = $ this -> getConfigByName ( 'security_key' ) ) { $ str = $ this -> decrypt ( $ str , hex2bin ( md5 ( $ security_key ) ) ) ; } return $ str ; } return '' ; } | Decrypt By Config |
54,818 | protected function mergeIncludes ( & $ config ) { if ( ! empty ( $ config [ 'includes' ] ) ) { foreach ( $ config [ 'includes' ] as $ path ) { if ( ! array_key_exists ( $ path , $ this -> loadedFiles ) ) { $ this -> loadedFiles [ $ path ] = true ; $ config = array_merge_recursive ( $ this -> load ( $ path ) , $ config ... | Merges in all include files . |
54,819 | private function getCurrentUrlPath ( ) { if ( $ this -> path ) { return $ this -> path ; } $ this -> path = ! empty ( $ _SERVER [ 'REQUEST_URI' ] ) ? $ _SERVER [ 'REQUEST_URI' ] : null ; $ this -> urlPart = $ this -> parsePath ( $ this -> path ) ; return $ this -> path ; } | if no path has been specified get a fallback path |
54,820 | public function getRoute ( $ path = null ) { if ( ! $ path || ( $ this -> path && $ path != $ this -> path ) ) { $ urlParts = $ this -> urlPart ; } else { $ urlParts = $ this -> parsePath ( $ path ) ; } return $ this -> routeSystem -> getRoute ( $ urlParts ) ; } | the real routing should happen here |
54,821 | public function setFormat ( $ format ) { if ( $ format !== self :: FORMAT_BINARY && $ format !== self :: FORMAT_TEXT ) { throw new InvalidArgumentException ( "Invalid message format" ) ; } $ this -> format = $ format ; } | Low level method making possible to set message format . |
54,822 | public function finalizeUpload ( ServiceEvent $ event ) { $ id = spl_object_hash ( $ event -> getCommand ( ) ) ; $ this -> removeTmpFiles ( $ id ) ; } | Finalizes upload by removing any tmp files left from prepareUpload |
54,823 | protected function removeTmpFiles ( $ id ) { if ( isset ( $ this -> tmpFiles [ $ id ] ) ) { foreach ( $ this -> tmpFiles [ $ id ] as $ tmpFile ) { if ( file_exists ( $ tmpFile ) ) { if ( is_dir ( $ tmpFile ) ) { rmdir ( $ tmpFile ) ; } else { unlink ( $ tmpFile ) ; } } } unset ( $ this -> tmpFiles [ $ id ] ) ; } return... | Remove any temp files by event ID |
54,824 | protected function isPhpFileUpload ( $ value ) { if ( is_array ( $ value ) && isset ( $ value [ 'tmp_name' ] ) && isset ( $ value [ 'name' ] ) ) { return true ; } else { return false ; } } | Test whether given value contains typical PHP s upload parameters |
54,825 | protected function movePhpUploadTmpFiles ( array $ upload ) { $ asArray = is_array ( $ upload [ 'tmp_name' ] ) ; $ tmpFiles = ( array ) $ upload [ 'tmp_name' ] ; $ filenames = ( array ) $ upload [ 'name' ] ; $ files = array ( ) ; foreach ( $ tmpFiles as $ key => $ tmpFile ) { if ( ! is_uploaded_file ( $ tmpFile ) ) { t... | Move uploaded files to a new location where the real filename is used instead of the temporary one |
54,826 | protected function handleUploadError ( $ error ) { switch ( $ error ) { case UPLOAD_ERR_OK : return ; break ; case UPLOAD_ERR_INI_SIZE : case UPLOAD_ERR_FORM_SIZE : throw new Exception \ UploadException ( 'Maximum upload file size exceeded' , array ( ) , 10100 + $ error ) ; break ; case UPLOAD_ERR_PARTIAL : throw new E... | Handle file upload errors |
54,827 | protected function _get_description ( $ post = null ) { $ post = get_post ( $ post ) ; if ( ! $ post ) { return ; } $ description = $ this -> _strip_linebreaks ( wp_strip_all_tags ( strip_shortcodes ( $ post -> post_excerpt ) ) ) ; if ( $ description ) { return $ description ; } $ description = $ this -> _strip_linebre... | Return post|page description |
54,828 | public static function guid ( $ need_braces = false , $ lowercase = false , $ existed = null ) { if ( ! $ existed ) { $ existed = static :: guid_bin ( ) ; } $ charid = '' ; for ( $ i = 0 ; $ i < strlen ( $ existed ) ; $ i ++ ) { $ charid .= bin2hex ( $ existed [ $ i ] ) ; } $ hyphen = chr ( 45 ) ; $ guid = chr ( 123 ) ... | Generate the guid with parameters . |
54,829 | public static function guid_bin ( $ existed = null ) { if ( is_string ( $ existed ) ) { $ guid = trim ( $ existed , '{}' ) ; if ( preg_match ( static :: GUID_REGEX , $ guid ) ) { return hex2bin ( str_replace ( [ ' ' , '-' ] , '' , $ guid ) ) ; } } mt_srand ( ( double ) microtime ( ) * 1000 ) ; $ uniqid = uniqid ( rand ... | Generate raw GUID binary . |
54,830 | public static function divide_guid_bin ( $ guids ) { if ( ! is_string ( $ guids ) || strlen ( $ guids ) == 0 || strlen ( $ guids ) % 16 > 0 ) { return [ ] ; } return str_split ( $ guids , 16 ) ; } | Divide composited guid binary into chunk . |
54,831 | public static function composite_guid ( $ guids ) { if ( ! is_array ( $ guids ) || empty ( $ guids ) ) { return '' ; } if ( is_string ( $ guids [ 0 ] ) && strlen ( $ guids [ 0 ] ) == 16 ) { return implode ( '' , $ guids ) ; } $ validGuids = static :: unsetInvalidGUIDs ( $ guids ) ; $ composited = '' ; foreach ( $ valid... | Composited guid binary chunk into one string . |
54,832 | public static function unsetInvalidGUIDs ( $ guids ) { foreach ( $ guids as $ key => $ guid ) { if ( ! preg_match ( self :: GUID_REGEX , $ guid ) ) { unset ( $ guids [ $ key ] ) ; } } return $ guids ; } | Unset invalid GUID element of an array . |
54,833 | public static function randomNumber ( $ prefix = '4' , $ length = 8 ) { if ( function_exists ( 'random_int' ) ) { $ length = $ length - strlen ( $ prefix ) ; $ result = $ prefix ; while ( $ length > 0 ) { $ result .= static :: randomNumberUsingRandomInt ( '' , $ length > 9 ? 9 : $ length ) ; $ length -= 9 ; } return $ ... | Generate the random number . |
54,834 | public static function randomNumberUsingRandomInt ( $ prefix = '4' , $ length = 8 ) { $ max = ( int ) str_pad ( "9" , $ length - strlen ( $ prefix ) , "9" ) ; return $ prefix . ( string ) str_pad ( random_int ( 0 , $ max ) , $ length - strlen ( $ prefix ) , "0" , STR_PAD_LEFT ) ; } | Generate the random number using random_int method . This method is only available for PHP 7 and above . |
54,835 | static function file ( string $ file , ? int $ activeLine = null , ? array $ lineRange = null , ? string $ className = null ) : string { return static :: process ( ( string ) @ highlight_file ( $ file , true ) , $ activeLine , $ lineRange , $ className ) ; } | Preview code from a PHP file |
54,836 | static function code ( string $ phpCode , ? int $ activeLine = null , ? array $ lineRange = null , ? string $ className = null ) : string { return static :: process ( ( string ) @ highlight_string ( $ phpCode , true ) , $ activeLine , $ lineRange , $ className ) ; } | Preview code from a string containing PHP code |
54,837 | public static function parseArgvWithSpec ( $ argv , ArgumentsSpec $ arguments_spec ) { $ data_offset_count = 0 ; $ usage = $ arguments_spec -> getUsage ( ) ; $ args_data_out = array ( 'self' => $ argv [ 0 ] , 'options' => array ( ) , 'data' => array ( ) , 'numbered_data' => array ( ) , ) ; $ argv_tokens = self :: token... | Parses command line options from an argv array |
54,838 | protected function getAttributeValue ( $ key ) { $ value = $ this -> getAttributeFromArray ( $ key ) ; if ( $ this -> hasGetMutator ( $ key ) ) { return $ this -> mutateAttribute ( $ key , $ value ) ; } if ( $ this -> hasCast ( $ key ) ) { $ value = $ this -> castAttribute ( $ key , $ value ) ; } return $ value ; } | Get a plain attribute . |
54,839 | public function clean ( ) { $ instance = $ this -> replicate ( ) ; $ instance -> setVisible ( [ ] ) ; $ instance -> setHidden ( [ ] ) ; $ instance -> setAppends ( [ ] ) ; return $ instance ; } | Replicate model with empty attribute filters |
54,840 | public function addConfigPath ( $ path ) { if ( ! file_exists ( $ path ) || ! is_dir ( $ path ) || ! is_readable ( $ path ) ) { throw new Exception ( 'Invalid or unreadable path: ' . $ path , Exception :: INVALID_PATH ) ; } $ this -> configPaths [ ] = $ path ; return $ this ; } | Adds a path to look in for config files . This should be the top level directory as this class will explore downwards for environment specific config . |
54,841 | public function get ( $ key , $ default = null ) { $ keyparts = explode ( '.' , $ key ) ; $ file = $ keyparts [ 0 ] ; if ( ! array_key_exists ( $ file , $ this -> values ) ) { $ this -> loadFile ( $ file ) ; } return $ this -> config -> get ( $ key , $ default ) ; } | Returns a value from the config . You can also provide a default if that key is not present . |
54,842 | protected function loadFile ( $ file ) { $ requiredFiles = $ this -> getRequiredFiles ( $ file ) ; $ this -> values [ $ file ] = true ; foreach ( $ requiredFiles as $ fileToRequire ) { $ overrideConfig = require $ fileToRequire [ 'path' ] ; $ this -> config -> addConfig ( [ $ file => $ overrideConfig ] , $ fileToRequir... | Load a file including the environment config if present . If the file does not exist this won t throw it ll just quietly insert null into the array preventing another load attempt . |
54,843 | public function show ( Notification $ notification ) { $ this -> authorize ( 'view' , $ notification ) ; $ notification -> markAsRead ( ) ; return view ( 'laralum_notifications::show' , [ 'notification' => $ notification ] ) ; } | Display the notification . |
54,844 | public function store ( Request $ request ) { $ this -> authorize ( 'create' , Notification :: class ) ; $ this -> validate ( $ request , [ 'email' => 'required|email|exists:users,email' , 'subject' => 'required|min:10|max:30' , 'message' => 'required|max:1500' , ] ) ; $ me = User :: findOrFail ( Auth :: id ( ) ) ; Use... | Store a newly created notification in storage . |
54,845 | public function settings ( Request $ request ) { $ this -> authorize ( 'update' , Settings :: class ) ; $ settings = Settings :: first ( ) ; $ settings -> update ( [ 'mail_enabled' => $ request -> mail_enabled ? true : false , ] ) ; $ settings -> touch ( ) ; return redirect ( ) -> route ( 'laralum::settings.index' , [ ... | Save the notification settings . |
54,846 | public static function write ( $ type , $ message , $ prettyPrint = false ) { if ( ! isset ( static :: $ _logFile ) ) { static :: $ _logFile = LOGS_PATH . DS . date ( 'Y-m-d' ) . '.log' ; } if ( ! File :: exists ( static :: $ _logFile ) ) { File :: create ( static :: $ _logFile ) ; } $ message = false !== $ prettyPrint... | Write a message to the log file . |
54,847 | public function itemsList ( ) { $ this -> breadcrumbs -> register ( self :: $ name , function ( $ breadcrumbs ) { $ breadcrumbs -> push ( 'Items' , handles ( 'antares::sample_module/index' ) ) ; } ) ; $ this -> shareOnView ( self :: $ name ) ; } | On item list |
54,848 | public function onItem ( Model $ model ) { $ this -> itemsList ( ) ; $ this -> breadcrumbs -> register ( 'item' , function ( $ breadcrumbs ) use ( $ model ) { $ name = $ model -> exists ? trans ( 'antares/sample_module::messages.breadcrumb.item_edit' , [ 'name' => $ model -> name ] ) : trans ( 'antares/sample_module::m... | On item create or edit |
54,849 | public function setUserValue ( string $ value ) : FormElement { parent :: setUserValue ( $ value ) ; $ this -> attributes [ 'value' ] = $ value ; return $ this ; } | Make sure the user submitted value shows up when the form element is rendered . |
54,850 | public function setChecked ( bool $ checked = true ) : FormElement { if ( true === $ checked ) { $ this -> attributes [ 'checked' ] = 'checked' ; } else { unset ( $ this -> attributes [ 'checked' ] ) ; } return $ this ; } | Set the checked state of the form element . |
54,851 | public function validate ( ) : void { if ( null === $ this -> is_valid ) { if ( null === $ this -> user_value && null !== $ this -> default_value ) { $ this -> is_valid = true ; } elseif ( true == $ this -> user_value || 1 == $ this -> user_value ) { $ this -> user_value = 1 ; $ this -> is_valid = true ; } elseif ( fal... | Overrides the default validation to make sure the value is 0 or 1 or true or false |
54,852 | public function create ( array $ config ) { $ dashboard = new Dashboard ( ) ; foreach ( $ config as $ name => $ cfg ) { $ widget = $ this -> widgetFactory -> create ( $ name , $ cfg [ 'type' ] , $ cfg [ 'options' ] ) ; $ dashboard -> addWidget ( $ widget ) ; } return $ dashboard ; } | Creates the dashboard . |
54,853 | public static function humanize ( $ text ) { preg_match_all ( '!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!' , $ text , $ matches ) ; $ ret = $ matches [ 0 ] ; foreach ( $ ret as & $ match ) { $ match = $ match == strtoupper ( $ match ) ? strtolower ( $ match ) : lcfirst ( $ match ) ; } return ucfirst ( impl... | Humanize the camelcase text . |
54,854 | public static function display ( OutputInterface $ output , $ instance ) { $ ref = new \ ReflectionClass ( $ instance ) ; $ methods = $ ref -> getMethods ( \ ReflectionMethod :: IS_PUBLIC ) ; $ table = new Table ( $ output ) ; $ table -> setStyle ( 'compact' ) ; foreach ( $ methods as $ method ) { $ methodName = $ meth... | Display the detail of object . |
54,855 | protected static function getFieldValue ( $ instance , $ methodName ) { try { $ value = static :: formatValue ( $ instance -> $ methodName ( ) ) ; } catch ( \ Exception $ e ) { $ value = '<error>format error</error>' ; } return $ value ; } | Get the formatted value of field . |
54,856 | protected static function formatValue ( $ value ) { if ( $ value instanceof \ DateTime ) { $ value = $ value -> format ( \ DateTime :: ISO8601 ) ; } elseif ( \ is_bool ( $ value ) ) { $ value = $ value ? 'True' : 'False' ; } elseif ( \ is_array ( $ value ) || $ value instanceof \ IteratorAggregate ) { $ itValue = $ val... | Format the value of field . |
54,857 | protected function closeItem ( TokenList $ tokenList , $ position ) { $ this -> parseListContent ( $ tokenList ) ; $ this -> open [ $ this -> level ] = false ; $ tokenList -> addToken ( $ this -> name . '_ITEM_CLOSE' , $ position ) ; } | Add close element |
54,858 | public function email ( $ msg ) { $ email = $ this -> _value ; if ( ! $ email ) { return true ; } $ isValid = true ; $ atIndex = strrpos ( $ email , '@' ) ; if ( is_bool ( $ atIndex ) && ! $ atIndex ) { $ isValid = false ; } else { $ domain = substr ( $ email , $ atIndex + 1 ) ; $ local = substr ( $ email , 0 , $ atInd... | Checks the that the input value is an email . Will perform format and DNS checks . |
54,859 | public function float ( $ msg ) { if ( filter_var ( $ this -> _value , FILTER_VALIDATE_FLOAT ) === FALSE ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value is a floating point number . |
54,860 | public function integer ( $ msg ) { if ( filter_var ( $ this -> _value , FILTER_VALIDATE_INT ) === FALSE ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value is an integer number . |
54,861 | public function digits ( $ msg ) { if ( strlen ( $ this -> _value ) > 0 && ! ctype_digit ( ( string ) $ this -> _value ) ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value only contains digits . |
54,862 | public function minLength ( $ len , $ msg ) { if ( strlen ( trim ( $ this -> _value ) ) < $ len ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value is at least the specified number of characters . |
54,863 | public function ip ( $ msg ) { if ( strlen ( trim ( $ this -> _value ) ) > 0 && filter_var ( $ this -> _value , FILTER_VALIDATE_IP ) === FALSE ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value is an IP address . This checks both for IPv4 and IPv6 . |
54,864 | public function url ( $ msg ) { if ( strlen ( trim ( $ this -> _value ) ) > 0 && filter_var ( $ this -> _value , FILTER_VALIDATE_URL ) === FALSE ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value is a URL . |
54,865 | public function date ( $ msg ) { if ( strlen ( trim ( $ this -> _value ) ) > 0 ) { try { $ dt = new \ DateTime ( $ this -> _value , new \ DateTimeZone ( "UTC" ) ) ; } catch ( Exception $ e ) { $ this -> _errors [ ] = $ msg ; } } return $ this ; } | Checks that the value is a date . |
54,866 | public function oneOf ( array $ choices , $ msg ) { if ( ! in_array ( $ this -> _value , $ choices ) ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value is one of multiple choices . |
54,867 | public function regexp ( $ pattern , $ msg ) { if ( ! preg_match ( $ pattern , ( string ) $ this -> _value ) ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value matches a regexp pattern . |
54,868 | public function notRegexp ( $ pattern , $ msg ) { if ( preg_match ( $ pattern , ( string ) $ this -> _value ) ) { $ this -> _errors [ ] = $ msg ; } return $ this ; } | Checks that the value doesn t match a regexp pattern . |
54,869 | function resolve ( $ name ) { $ name = ( string ) $ name ; if ( ! array_key_exists ( $ name , $ this -> _t_loader_map_resource_MapRes ) ) return false ; return $ this -> _t_loader_map_resource_MapRes [ $ name ] ; } | Resolve To Resource By Map |
54,870 | public function postUser ( $ username , $ originId , $ parameters = [ ] ) { $ user = [ 'username' => $ username , 'originId' => $ originId , ] ; $ user += $ parameters ; return $ this -> jsonCall ( 'POST' , 'users' , $ user ) ; } | Create an user . |
54,871 | public static function concat ( $ params = null ) { $ args = func_get_args ( ) ; if ( ! is_null ( $ params ) ) { if ( $ params instanceof A || $ params instanceof H ) { $ args = array_values ( $ params -> array ) ; } elseif ( is_array ( $ params ) ) { $ args = $ params ; } } $ str_out = '' ; foreach ( $ args as $ s ) {... | Concatenates string or object having toString feature together . |
54,872 | protected function _chars ( ) { if ( is_null ( $ this -> col_chars ) ) { $ a = new A ( ) ; $ i = new N ( 0 ) ; while ( $ i -> less ( $ this -> _length ( ) ) ) { $ a -> add ( new C ( $ this -> sub ( $ i -> value ) -> value ) ) ; $ i -> incr ; } $ this -> col_chars = $ a ; unset ( $ a ) ; unset ( $ i ) ; } return $ this ... | Create \ Malenki \ Bah \ C collection from the string |
54,873 | protected function _bytes ( ) { if ( is_null ( $ this -> col_bytes ) ) { $ a = new A ( ) ; $ this -> _chars ( ) ; while ( $ this -> col_chars -> valid ( ) ) { while ( $ this -> col_chars -> current ( ) -> bytes -> valid ( ) ) { $ a -> add ( $ this -> col_chars -> current ( ) -> bytes -> current ( ) ) ; $ this -> col_ch... | Create bytes collection from the string . |
54,874 | protected function _to ( $ name ) { if ( $ name == 'to_c' ) { if ( count ( $ this ) != 1 ) { throw new \ RuntimeException ( 'Cannot converting \Malenki\Bah\S object having length ' . 'not equal to one to C object.' ) ; } return new C ( $ this -> value ) ; } if ( $ name == 'to_n' ) { if ( ! is_numeric ( $ this -> value ... | Convert current object to other object type . |
54,875 | protected function _trans ( ) { if ( ! extension_loaded ( 'intl' ) ) { throw new \ RuntimeException ( 'Missing Intl extension. This is required to use ' . __CLASS__ . '::trans' ) ; } if ( ! function_exists ( '\transliterator_transliterate' ) ) { throw new \ RuntimeException ( 'Intl extension does not provide transliter... | Transliterates the string . |
54,876 | protected function _swapCase ( ) { $ coll_upper = $ this -> _upper ( ) -> chunk ( ) ; $ coll_original = $ this -> chunk ( ) ; $ out = '' ; while ( $ coll_original -> valid ( ) ) { $ c_upper = $ coll_upper -> take ( $ coll_original -> key ) ; $ c_orig = $ coll_original -> current ( ) ; if ( $ c_upper -> string === $ c_o... | Swaps cases . |
54,877 | public function squeeze ( $ seq = null ) { $ str_pattern = '/(.)\1+/' ; if ( ! is_null ( $ seq ) ) { if ( is_array ( $ seq ) ) { $ seq = new A ( $ seq ) ; $ seq = $ seq -> join ; } elseif ( $ seq instanceof A ) { $ seq = $ seq -> join ; } elseif ( $ seq instanceof H ) { $ seq = $ seq -> to_a -> join ; } elseif ( ( is_o... | Removes duplicate sequance of characters . |
54,878 | public function strip ( $ str = null , $ type = null ) { $ func = 'trim' ; if ( ! is_null ( $ type ) ) { self :: mustBeString ( $ type , 'Type' ) ; $ type = "$type" ; if ( ! in_array ( $ type , array ( 'left' , 'right' , 'both' ) ) ) { throw new \ InvalidArgumentException ( 'Type of strip must be `left`, `right` or `bo... | Trims the string by default removing white spaces on the left and on the right sides . |
54,879 | public function surround ( $ before , $ after ) { self :: mustBeString ( $ before , 'Starting string' ) ; self :: mustBeString ( $ after , 'Ending string' ) ; return static :: concat ( $ before , $ this , $ after ) ; } | Surrounds current string using starting string and ending string . |
54,880 | public function insert ( $ str , $ pos ) { self :: mustBeString ( $ str , 'String to insert' ) ; self :: mustBeInteger ( $ pos , 'Position' ) ; if ( $ pos instanceof N ) { $ pos = $ pos -> int ; } if ( $ pos < 0 ) { throw new \ InvalidArgumentException ( 'Position must be positive or null integer.' ) ; } if ( $ pos > c... | Inserts new content at given position . |
54,881 | protected function _underscore ( ) { return new self ( trim ( preg_replace ( '/_+/' , '_' , preg_replace ( '/[^\p{Ll}\p{Lu}0-9_]/u' , '_' , preg_replace ( '/[\s]+/u' , '_' , mb_strtolower ( trim ( $ this -> value ) , C :: ENCODING ) ) ) ) , '_' ) ) ; } | Convert string using underscore |
54,882 | public function camelCase ( $ is_upper = false ) { $ func = function ( & $ v , $ k , $ is_upper ) { $ v = new S ( $ v ) ; $ c = $ v -> chunk ; if ( $ is_upper || $ k != 0 ) { $ first = $ c -> key_0 -> upper ; } else { $ first = $ c -> key_0 -> lower ; } $ c -> replace ( 0 , $ first ) ; $ v = $ c -> join ; } ; $ a = new... | Convert current string in camelCase or CamelCase . |
54,883 | public function sub ( $ offset = 0 , $ limit = 1 ) { self :: mustBeInteger ( $ offset , 'Offset' ) ; self :: mustBeInteger ( $ limit , 'Limit' ) ; if ( $ offset instanceof N ) $ offset = $ offset -> int ; if ( $ limit instanceof N ) $ limit = $ limit -> int ; if ( $ offset < 0 ) { throw new \ InvalidArgumentException (... | Get substring from the original string . |
54,884 | public function position ( $ needle ) { self :: mustBeString ( $ needle , 'Needle' ) ; if ( is_object ( $ needle ) ) { $ needle = "$needle" ; } if ( empty ( $ needle ) ) { throw new \ InvalidArgumentException ( 'Needle must be not empty!' ) ; } $ length = mb_strlen ( $ needle , C :: ENCODING ) ; $ offset = 0 ; $ a = ar... | Gets all available positions of given string needle . |
54,885 | public function delete ( $ offset = 0 , $ limit = 1 ) { self :: mustBeInteger ( $ offset , 'Offset' ) ; self :: mustBeInteger ( $ limit , 'Limit' ) ; if ( $ offset instanceof N ) $ offset = $ offset -> int ; if ( $ limit instanceof N ) $ limit = $ limit -> int ; if ( $ offset < 0 ) { throw new \ InvalidArgumentExceptio... | Removes string part using offset and limit size . |
54,886 | public function startsWith ( $ str ) { self :: mustBeString ( $ str , 'Searched starting string' ) ; $ str = preg_quote ( $ str , '/' ) ; return ( boolean ) preg_match ( "/^$str/" , $ this -> value ) ; } | Checks that current string starts with the given string or not |
54,887 | public function match ( $ expr ) { self :: mustBeString ( $ expr , 'Expression' ) ; return ( boolean ) preg_match ( $ expr , $ this -> value ) ; } | Checks string using Regexp |
54,888 | public function title ( $ sep = null ) { if ( is_null ( $ sep ) ) { return new self ( mb_convert_case ( $ this -> value , MB_CASE_TITLE , C :: ENCODING ) ) ; } $ str_prov = mb_convert_case ( mb_strtolower ( mb_strtolower ( $ this -> value , C :: ENCODING ) , C :: ENCODING ) , MB_CASE_TITLE , C :: ENCODING ) ; if ( $ se... | Converts the string to upper case words . |
54,889 | protected function _upperCaseFirst ( ) { if ( ! $ this -> _isVoid ( ) ) { $ first_char = $ this -> _first ( ) -> _upper ( ) ; $ other_chars = $ this -> sub ( 1 , $ this -> int_count ) ; return self :: concat ( $ first_char , $ other_chars ) ; } return $ this ; } | Converts to upper case first . |
54,890 | public function charAt ( $ idx ) { self :: mustBeInteger ( $ idx , 'Index' ) ; if ( $ idx instanceof N ) { $ idx = $ idx -> int ; } if ( $ idx < 0 || $ idx >= count ( $ this ) ) { throw new \ InvalidArgumentException ( 'Cannot get chars at non-existing position!' ) ; } return new C ( mb_substr ( $ this -> value , $ idx... | Get character at the given position . |
54,891 | public function count ( ) { if ( is_null ( $ this -> int_count ) ) { $ this -> int_count = mb_strlen ( $ this -> value , C :: ENCODING ) ; } return $ this -> int_count ; } | Implements Countable interface . |
54,892 | public function times ( $ n ) { self :: mustBeInteger ( $ n , 'Number of repetition' ) ; if ( $ n instanceof N ) $ n = $ n -> int ; if ( $ n < 0 ) { throw new \ InvalidArgumentException ( 'Number of repeats cannot be negative' ) ; } return new self ( str_repeat ( $ this , $ n ) ) ; } | Repeats N times current string . |
54,893 | public function wrap ( $ width = 79 , $ cut = PHP_EOL ) { self :: mustBeInteger ( $ width , 'Width' ) ; self :: mustBeString ( $ cut , 'Cut' ) ; $ arr_lines = array ( ) ; if ( strlen ( $ this -> value ) === count ( $ this ) ) { $ arr_lines = explode ( $ cut , wordwrap ( $ this -> value , $ width , $ cut ) ) ; } else { ... | Wraps the string to fit given width . |
54,894 | public function margin ( $ left = 5 , $ right = 0 , $ alinea = 0 ) { self :: mustBeInteger ( $ left , 'Left margin' ) ; self :: mustBeInteger ( $ right , 'Right margin' ) ; self :: mustBeInteger ( $ alinea , 'Alinea' ) ; $ int_left = $ left ; $ int_right = $ right ; $ int_alinea = $ alinea ; if ( $ left instanceof N ) ... | Adds margin to the text . By default left but right and alinea are possible too . |
54,895 | public function center ( $ width = 79 , $ cut = PHP_EOL ) { self :: mustBeInteger ( $ width , 'Width' ) ; self :: mustBeString ( $ cut , 'Cut character' ) ; if ( is_object ( $ width ) ) { $ width = $ width -> int ; } if ( $ width <= 0 ) { throw new \ InvalidArgumentException ( 'Width cannot be null or negative!' ) ; } ... | Centers text to fit on given width padding with spaces . |
54,896 | public function justify ( $ width = 79 , $ last_line = 'left' , $ cut = PHP_EOL ) { self :: mustBeInteger ( $ width , 'Width' ) ; self :: mustBeString ( $ cut , 'Cut character' ) ; if ( ! in_array ( $ last_line , array ( 'left' , 'right' ) ) ) { throw new \ InvalidArgumentException ( 'Alignment of last line must be "le... | Justify text into given width . |
54,897 | public function explode ( $ sep ) { self :: mustBeString ( $ sep , 'Separator regexp' ) ; if ( is_object ( $ sep ) ) { $ sep = ( string ) $ sep ; } if ( strlen ( $ sep ) == 0 ) { throw new \ InvalidArgumentException ( 'Separator regexp must be a not null string or S instance.' ) ; } $ arr = preg_split ( $ sep , $ this ... | Splits the string using Regexp . |
54,898 | public function replace ( $ pattern , $ string ) { self :: mustBeString ( $ pattern , 'Pattern' ) ; self :: mustBeString ( $ string , 'Replacement string' ) ; return new S ( preg_replace ( $ pattern , $ string , $ this -> value ) ) ; } | Replace some parts of current string using Regexp |
54,899 | public function set ( $ idx , $ char ) { self :: mustBeInteger ( $ idx , 'Index' ) ; if ( $ idx instanceof N ) $ idx = $ idx -> int ; if ( $ idx < 0 || $ idx >= count ( $ this ) ) { throw new \ RuntimeException ( sprintf ( 'Index %d is not defined into this string!' , $ idx ) ) ; } self :: mustBeString ( $ char , 'New ... | Sets one character at given position . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.