idx int64 0 60.3k | question stringlengths 92 4.62k | target stringlengths 7 635 |
|---|---|---|
55,100 | private function doSub ( string $ a , string $ b ) : string { if ( $ a === $ b ) { return '0' ; } $ cmp = $ this -> doCmp ( $ a , $ b ) ; $ invert = ( $ cmp === - 1 ) ; if ( $ invert ) { $ c = $ a ; $ a = $ b ; $ b = $ c ; } $ length = $ this -> pad ( $ a , $ b ) ; $ carry = 0 ; $ result = '' ; $ complement = 10 ** $ t... | Performs the subtraction of two non - signed large integers . |
55,101 | private function doMul ( string $ a , string $ b ) : string { $ x = \ strlen ( $ a ) ; $ y = \ strlen ( $ b ) ; $ maxDigits = \ intdiv ( $ this -> maxDigits , 2 ) ; $ complement = 10 ** $ maxDigits ; $ result = '0' ; for ( $ i = $ x - $ maxDigits ; ; $ i -= $ maxDigits ) { $ blockALength = $ maxDigits ; if ( $ i < 0 ) ... | Performs the multiplication of two non - signed large integers . |
55,102 | private function doDiv ( string $ a , string $ b ) : array { $ cmp = $ this -> doCmp ( $ a , $ b ) ; if ( $ cmp === - 1 ) { return [ '0' , $ a ] ; } $ x = \ strlen ( $ a ) ; $ y = \ strlen ( $ b ) ; $ q = '0' ; $ r = $ a ; $ z = $ y ; for ( ; ; ) { $ focus = \ substr ( $ a , 0 , $ z ) ; $ cmp = $ this -> doCmp ( $ focu... | Performs the division of two non - signed large integers . |
55,103 | private function doCmp ( string $ a , string $ b ) : int { $ x = \ strlen ( $ a ) ; $ y = \ strlen ( $ b ) ; $ cmp = $ x <=> $ y ; if ( $ cmp !== 0 ) { return $ cmp ; } return \ strcmp ( $ a , $ b ) <=> 0 ; } | Compares two non - signed large numbers . |
55,104 | private function pad ( string & $ a , string & $ b ) : int { $ x = \ strlen ( $ a ) ; $ y = \ strlen ( $ b ) ; if ( $ x > $ y ) { $ b = \ str_repeat ( '0' , $ x - $ y ) . $ b ; return $ x ; } if ( $ x < $ y ) { $ a = \ str_repeat ( '0' , $ y - $ x ) . $ a ; return $ y ; } return $ x ; } | Pads the left of one of the given numbers with zeros if necessary to make both numbers the same length . |
55,105 | public static function ofUnscaledValue ( $ value , int $ scale = 0 ) : BigDecimal { if ( $ scale < 0 ) { throw new \ InvalidArgumentException ( 'The scale cannot be negative.' ) ; } return new BigDecimal ( ( string ) BigInteger :: of ( $ value ) , $ scale ) ; } | Creates a BigDecimal from an unscaled value and a scale . |
55,106 | public function dividedBy ( $ that , int $ scale = null , int $ roundingMode = RoundingMode :: UNNECESSARY ) : BigDecimal { $ that = BigDecimal :: of ( $ that ) ; if ( $ that -> isZero ( ) ) { throw DivisionByZeroException :: divisionByZero ( ) ; } if ( $ scale === null ) { $ scale = $ this -> scale ; } elseif ( $ scal... | Returns the result of the division of this number by the given one at the given scale . |
55,107 | public function exactlyDividedBy ( $ that ) : BigDecimal { $ that = BigDecimal :: of ( $ that ) ; if ( $ that -> value === '0' ) { throw DivisionByZeroException :: divisionByZero ( ) ; } $ this -> scaleValues ( $ this , $ that , $ a , $ b ) ; $ d = \ rtrim ( $ b , '0' ) ; $ scale = \ strlen ( $ b ) - \ strlen ( $ d ) ;... | Returns the exact result of the division of this number by the given one . |
55,108 | public function quotient ( $ that ) : BigDecimal { $ that = BigDecimal :: of ( $ that ) ; if ( $ that -> isZero ( ) ) { throw DivisionByZeroException :: divisionByZero ( ) ; } $ p = $ this -> valueWithMinScale ( $ that -> scale ) ; $ q = $ that -> valueWithMinScale ( $ this -> scale ) ; $ quotient = Calculator :: get (... | Returns the quotient of the division of this number by this given one . |
55,109 | public function remainder ( $ that ) : BigDecimal { $ that = BigDecimal :: of ( $ that ) ; if ( $ that -> isZero ( ) ) { throw DivisionByZeroException :: divisionByZero ( ) ; } $ p = $ this -> valueWithMinScale ( $ that -> scale ) ; $ q = $ that -> valueWithMinScale ( $ this -> scale ) ; $ remainder = Calculator :: get... | Returns the remainder of the division of this number by this given one . |
55,110 | public function sqrt ( int $ scale ) : BigDecimal { if ( $ scale < 0 ) { throw new \ InvalidArgumentException ( 'Scale cannot be negative.' ) ; } if ( $ this -> value === '0' ) { return new BigDecimal ( '0' , $ scale ) ; } if ( $ this -> value [ 0 ] === '-' ) { throw new NegativeNumberException ( 'Cannot calculate the ... | Returns the square root of this number rounded down to the given number of decimals . |
55,111 | public function stripTrailingZeros ( ) : BigDecimal { if ( $ this -> scale === 0 ) { return $ this ; } $ trimmedValue = \ rtrim ( $ this -> value , '0' ) ; if ( $ trimmedValue === '' ) { return BigDecimal :: zero ( ) ; } $ trimmableZeros = \ strlen ( $ this -> value ) - \ strlen ( $ trimmedValue ) ; if ( $ trimmableZer... | Returns a copy of this BigDecimal with any trailing zeros removed from the fractional part . |
55,112 | public function negated ( ) : BigDecimal { return new BigDecimal ( Calculator :: get ( ) -> neg ( $ this -> value ) , $ this -> scale ) ; } | Returns the negated value of this number . |
55,113 | public function getIntegralPart ( ) : string { if ( $ this -> scale === 0 ) { return $ this -> value ; } $ value = $ this -> getUnscaledValueWithLeadingZeros ( ) ; return \ substr ( $ value , 0 , - $ this -> scale ) ; } | Returns a string representing the integral part of this decimal number . |
55,114 | public function getFractionalPart ( ) : string { if ( $ this -> scale === 0 ) { return '' ; } $ value = $ this -> getUnscaledValueWithLeadingZeros ( ) ; return \ substr ( $ value , - $ this -> scale ) ; } | Returns a string representing the fractional part of this decimal number . |
55,115 | private function getUnscaledValueWithLeadingZeros ( ) : string { $ value = $ this -> value ; $ targetLength = $ this -> scale + 1 ; $ negative = ( $ value [ 0 ] === '-' ) ; $ length = \ strlen ( $ value ) ; if ( $ negative ) { $ length -- ; } if ( $ length >= $ targetLength ) { return $ this -> value ; } if ( $ negativ... | Adds leading zeros if necessary to the unscaled value to represent the full decimal number . |
55,116 | final public static function get ( ) : Calculator { if ( self :: $ instance === null ) { self :: $ instance = self :: detect ( ) ; } return self :: $ instance ; } | Returns the Calculator instance to use . |
55,117 | private static function detect ( ) : Calculator { if ( \ extension_loaded ( 'gmp' ) ) { return new Calculator \ GmpCalculator ( ) ; } if ( \ extension_loaded ( 'bcmath' ) ) { return new Calculator \ BcMathCalculator ( ) ; } return new Calculator \ NativeCalculator ( ) ; } | Returns the fastest available Calculator implementation . |
55,118 | final protected function init ( string $ a , string $ b , & $ aDig , & $ bDig , & $ aNeg , & $ bNeg ) : void { $ aNeg = ( $ a [ 0 ] === '-' ) ; $ bNeg = ( $ b [ 0 ] === '-' ) ; $ aDig = $ aNeg ? \ substr ( $ a , 1 ) : $ a ; $ bDig = $ bNeg ? \ substr ( $ b , 1 ) : $ b ; } | Extracts the digits and sign of the operands . |
55,119 | public function gcd ( string $ a , string $ b ) : string { if ( $ a === '0' ) { return $ this -> abs ( $ b ) ; } if ( $ b === '0' ) { return $ this -> abs ( $ a ) ; } return $ this -> gcd ( $ b , $ this -> divR ( $ a , $ b ) ) ; } | Returns the greatest common divisor of the two numbers . |
55,120 | public function fromBase ( string $ number , int $ base ) : string { return $ this -> fromArbitraryBase ( \ strtolower ( $ number ) , self :: ALPHABET , $ base ) ; } | Converts a number from an arbitrary base . |
55,121 | public function toBase ( string $ number , int $ base ) : string { $ negative = ( $ number [ 0 ] === '-' ) ; if ( $ negative ) { $ number = \ substr ( $ number , 1 ) ; } $ number = $ this -> toArbitraryBase ( $ number , self :: ALPHABET , $ base ) ; if ( $ negative ) { return '-' . $ number ; } return $ number ; } | Converts a number to an arbitrary base . |
55,122 | final public function fromArbitraryBase ( string $ number , string $ alphabet , int $ base ) : string { $ number = \ ltrim ( $ number , $ alphabet [ 0 ] ) ; if ( $ number === '' ) { return '0' ; } if ( $ number === $ alphabet [ 1 ] ) { return '1' ; } $ result = '0' ; $ power = '1' ; $ base = ( string ) $ base ; for ( $... | Converts a non - negative number in an arbitrary base using a custom alphabet to base 10 . |
55,123 | final public function toArbitraryBase ( string $ number , string $ alphabet , int $ base ) : string { if ( $ number === '0' ) { return $ alphabet [ 0 ] ; } $ base = ( string ) $ base ; $ result = '' ; while ( $ number !== '0' ) { [ $ number , $ remainder ] = $ this -> divQR ( $ number , $ base ) ; $ remainder = ( int )... | Converts a non - negative number to an arbitrary base using a custom alphabet . |
55,124 | final public function divRound ( string $ a , string $ b , int $ roundingMode ) : string { [ $ quotient , $ remainder ] = $ this -> divQR ( $ a , $ b ) ; $ hasDiscardedFraction = ( $ remainder !== '0' ) ; $ isPositiveOrZero = ( $ a [ 0 ] === '-' ) === ( $ b [ 0 ] === '-' ) ; $ discardedFractionSign = function ( ) use (... | Performs a rounded division . |
55,125 | private function bitwise ( string $ operator , string $ a , string $ b ) : string { $ this -> init ( $ a , $ b , $ aDig , $ bDig , $ aNeg , $ bNeg ) ; $ aBin = $ this -> toBinary ( $ aDig ) ; $ bBin = $ this -> toBinary ( $ bDig ) ; $ aLen = \ strlen ( $ aBin ) ; $ bLen = \ strlen ( $ bBin ) ; if ( $ aLen > $ bLen ) { ... | Performs a bitwise operation on a decimal number . |
55,126 | private function toBinary ( string $ number ) : string { $ result = '' ; while ( $ number !== '0' ) { [ $ number , $ remainder ] = $ this -> divQR ( $ number , '256' ) ; $ result .= \ chr ( ( int ) $ remainder ) ; } return \ strrev ( $ result ) ; } | Converts a decimal number to a binary string . |
55,127 | private function toDecimal ( string $ bytes ) : string { $ result = '0' ; $ power = '1' ; for ( $ i = \ strlen ( $ bytes ) - 1 ; $ i >= 0 ; $ i -- ) { $ index = \ ord ( $ bytes [ $ i ] ) ; if ( $ index !== 0 ) { $ result = $ this -> add ( $ result , ( $ index === 1 ) ? $ power : $ this -> mul ( $ power , ( string ) $ i... | Returns the positive decimal representation of a binary number . |
55,128 | public static function fromBase ( string $ number , int $ base ) : BigInteger { if ( $ number === '' ) { throw new NumberFormatException ( 'The number cannot be empty.' ) ; } if ( $ base < 2 || $ base > 36 ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Base %d is not in range 2 to 36.' , $ base ) ) ; } if ( $ ... | Creates a number from a string in a given base . |
55,129 | public static function fromArbitraryBase ( string $ number , string $ alphabet ) : BigInteger { if ( $ number === '' ) { throw new NumberFormatException ( 'The number cannot be empty.' ) ; } $ base = \ strlen ( $ alphabet ) ; if ( $ base < 2 ) { throw new \ InvalidArgumentException ( 'The alphabet must contain at least... | Parses a string containing an integer in an arbitrary base using a custom alphabet . |
55,130 | public function quotient ( $ that ) : BigInteger { $ that = BigInteger :: of ( $ that ) ; if ( $ that -> value === '1' ) { return $ this ; } if ( $ that -> value === '0' ) { throw DivisionByZeroException :: divisionByZero ( ) ; } $ quotient = Calculator :: get ( ) -> divQ ( $ this -> value , $ that -> value ) ; return ... | Returns the quotient of the division of this number by the given one . |
55,131 | public function remainder ( $ that ) : BigInteger { $ that = BigInteger :: of ( $ that ) ; if ( $ that -> value === '0' ) { throw DivisionByZeroException :: divisionByZero ( ) ; } $ remainder = Calculator :: get ( ) -> divR ( $ this -> value , $ that -> value ) ; return new BigInteger ( $ remainder ) ; } | Returns the remainder of the division of this number by the given one . |
55,132 | public function gcd ( $ that ) : BigInteger { $ that = BigInteger :: of ( $ that ) ; if ( $ that -> value === '0' && $ this -> value [ 0 ] !== '-' ) { return $ this ; } if ( $ this -> value === '0' && $ that -> value [ 0 ] !== '-' ) { return $ that ; } $ value = Calculator :: get ( ) -> gcd ( $ this -> value , $ that -... | Returns the greatest common divisor of this number and the given one . |
55,133 | public function sqrt ( ) : BigInteger { if ( $ this -> value [ 0 ] === '-' ) { throw new NegativeNumberException ( 'Cannot calculate the square root of a negative number.' ) ; } $ value = Calculator :: get ( ) -> sqrt ( $ this -> value ) ; return new BigInteger ( $ value ) ; } | Returns the integer square root number of this number rounded down . |
55,134 | public function and ( $ that ) : BigInteger { $ that = BigInteger :: of ( $ that ) ; return new BigInteger ( Calculator :: get ( ) -> and ( $ this -> value , $ that -> value ) ) ; } | Returns the integer bitwise - and combined with another integer . |
55,135 | public function shiftedLeft ( int $ distance ) : BigInteger { if ( $ distance === 0 ) { return $ this ; } if ( $ distance < 0 ) { return $ this -> shiftedRight ( - $ distance ) ; } return $ this -> multipliedBy ( BigInteger :: of ( 2 ) -> power ( $ distance ) ) ; } | Returns the integer left shifted by a given number of bits . |
55,136 | public function shiftedRight ( int $ distance ) : BigInteger { if ( $ distance === 0 ) { return $ this ; } if ( $ distance < 0 ) { return $ this -> shiftedLeft ( - $ distance ) ; } $ operand = BigInteger :: of ( 2 ) -> power ( $ distance ) ; if ( $ this -> isPositiveOrZero ( ) ) { return $ this -> quotient ( $ operand ... | Returns the integer right shifted by a given number of bits . |
55,137 | public function toBase ( int $ base ) : string { if ( $ base === 10 ) { return $ this -> value ; } if ( $ base < 2 || $ base > 36 ) { throw new \ InvalidArgumentException ( \ sprintf ( 'Base %d is out of range [2, 36]' , $ base ) ) ; } return Calculator :: get ( ) -> toBase ( $ this -> value , $ base ) ; } | Returns a string representation of this number in the given base . |
55,138 | public function toArbitraryBase ( string $ alphabet ) : string { $ base = \ strlen ( $ alphabet ) ; if ( $ base < 2 ) { throw new \ InvalidArgumentException ( 'The alphabet must contain at least 2 chars.' ) ; } if ( $ this -> value [ 0 ] === '-' ) { throw new NegativeNumberException ( __FUNCTION__ . '() does not suppor... | Returns a string representation of this number in an arbitrary base with a custom alphabet . |
55,139 | private static function getCanonicalPath ( $ path ) : string { $ path = static :: normalizeWindowsPath ( $ path ) ; $ absolutePathPrefix = '' ; if ( static :: isAbsolutePath ( $ path ) ) { if ( static :: isWindows ( ) && strpos ( $ path , ':/' ) === 1 ) { $ absolutePathPrefix = substr ( $ path , 0 , 3 ) ; $ path = subs... | Resolves all dots slashes and removes spaces after or before a path ... |
55,140 | private function invokeInternalStreamWrapper ( string $ functionName , ... $ arguments ) { $ silentExecution = $ functionName { 0 } === '@' ; $ functionName = ltrim ( $ functionName , '@' ) ; $ this -> restoreInternalSteamWrapper ( ) ; try { if ( $ silentExecution ) { $ result = @ call_user_func_array ( $ functionName ... | Invokes commands on the native PHP Phar stream wrapper . |
55,141 | public function assert ( string $ path , string $ command ) : bool { if ( $ this -> invokeAssertions ( $ path , $ command ) ) { return true ; } throw new Exception ( sprintf ( 'Assertion failed in "%s"' , $ path ) , 1539625084 ) ; } | Executes assertions based on all contained assertions . |
55,142 | private function assertUniqueBaseName ( PharInvocation $ invocation , int $ flags ) : bool { if ( ! ( $ flags & static :: UNIQUE_BASE_NAME ) ) { return true ; } return $ this -> findByCallback ( function ( PharInvocation $ candidate ) use ( $ invocation ) { return $ candidate -> getBaseName ( ) === $ invocation -> getB... | Asserts that base - name is unique . This disallows having multiple invocations for same base - name but having different alias names . |
55,143 | public static function performQueryAnalysis ( $ sql , $ version = null , $ driver = null ) { $ hints = [ ] ; if ( preg_match ( '/^\\s*SELECT\\s*`?[a-zA-Z0-9]*`?\\.?\\*/i' , $ sql ) ) { $ hints [ ] = 'Use <code>SELECT *</code> only if you need all columns from table' ; } if ( preg_match ( '/ORDER BY RAND()/i' , $ sql ) ... | perform quer analysis hint . |
55,144 | public static function explain ( PDO $ pdo , $ sql , $ bindings = [ ] ) { $ explains = [ ] ; if ( preg_match ( '#\s*\(?\s*SELECT\s#iA' , $ sql ) ) { $ statement = $ pdo -> prepare ( 'EXPLAIN ' . $ sql ) ; $ statement -> execute ( $ bindings ) ; $ explains = $ statement -> fetchAll ( PDO :: FETCH_CLASS ) ; } return $ ex... | explain sql . |
55,145 | protected static function editorLink ( $ source ) { if ( is_string ( $ source ) === true ) { $ file = $ source ; $ line = null ; } else { $ file = $ source [ 0 ] ; $ line = $ source [ 1 ] ; } return Helpers :: editorLink ( $ file , $ line ) ; } | editor link . |
55,146 | protected function handleRoutes ( Router $ router , $ config = [ ] ) { if ( $ this -> app -> routesAreCached ( ) === false ) { $ router -> group ( array_merge ( [ 'namespace' => $ this -> namespace , ] , $ config ) , function ( Router $ router ) { require __DIR__ . '/../routes/web.php' ; } ) ; } } | register routes . |
55,147 | private function checkAsset ( $ name , array & $ previously ) { $ formula = $ this -> am -> hasFormula ( $ name ) ? serialize ( $ this -> am -> getFormula ( $ name ) ) : null ; $ asset = $ this -> am -> get ( $ name ) ; $ combinations = VarUtils :: getCombinations ( $ asset -> getVars ( ) , $ this -> getContainer ( ) -... | Checks if an asset should be dumped . |
55,148 | private function checkNode ( \ Twig_Node $ node , \ Twig_Environment $ env , & $ name = null ) { if ( $ node instanceof \ Twig_Node_Expression_Function ) { $ name = $ node -> getAttribute ( 'name' ) ; if ( $ env -> getFunction ( $ name ) instanceof AsseticFilterFunction ) { $ arguments = array ( ) ; foreach ( $ node ->... | Extracts formulae from filter function nodes . |
55,149 | public function javascripts ( $ inputs = array ( ) , $ filters = array ( ) , array $ options = array ( ) ) { if ( ! isset ( $ options [ 'output' ] ) ) { $ options [ 'output' ] = 'js/*.js' ; } return $ this -> getAssetUrls ( $ inputs , $ filters , $ options ) ; } | Returns an array of javascript urls . |
55,150 | public function stylesheets ( $ inputs = array ( ) , $ filters = array ( ) , array $ options = array ( ) ) { if ( ! isset ( $ options [ 'output' ] ) ) { $ options [ 'output' ] = 'css/*.css' ; } return $ this -> getAssetUrls ( $ inputs , $ filters , $ options ) ; } | Returns an array of stylesheet urls . |
55,151 | public function image ( $ inputs = array ( ) , $ filters = array ( ) , array $ options = array ( ) ) { if ( ! isset ( $ options [ 'output' ] ) ) { $ options [ 'output' ] = 'images/*' ; } $ options [ 'single' ] = true ; return $ this -> getAssetUrls ( $ inputs , $ filters , $ options ) ; } | Returns an array of one image url . |
55,152 | private function getAssetUrls ( $ inputs = array ( ) , $ filters = array ( ) , array $ options = array ( ) ) { $ explode = function ( $ value ) { return array_map ( 'trim' , explode ( ',' , $ value ) ) ; } ; if ( ! is_array ( $ inputs ) ) { $ inputs = $ explode ( $ inputs ) ; } if ( ! is_array ( $ filters ) ) { $ filte... | Gets the URLs for the configured asset . |
55,153 | public function dumpAsset ( $ name , OutputInterface $ stdout ) { $ asset = $ this -> am -> get ( $ name ) ; $ formula = $ this -> am -> hasFormula ( $ name ) ? $ this -> am -> getFormula ( $ name ) : array ( ) ; $ this -> doDump ( $ asset , $ stdout ) ; $ debug = isset ( $ formula [ 2 ] [ 'debug' ] ) ? $ formula [ 2 ]... | Writes an asset . |
55,154 | private function doDump ( AssetInterface $ asset , OutputInterface $ stdout ) { $ combinations = VarUtils :: getCombinations ( $ asset -> getVars ( ) , $ this -> getContainer ( ) -> getParameter ( 'assetic.variables' ) ) ; foreach ( $ combinations as $ combination ) { $ asset -> setValues ( $ combination ) ; $ target =... | Performs the asset dump . |
55,155 | private function loadRouteForAsset ( RouteCollection $ routes , AssetInterface $ asset , $ name , $ pos = null ) { $ defaults = array ( '_controller' => 'assetic.controller:render' , 'name' => $ name , 'pos' => $ pos , ) ; $ requirements = array ( ) ; $ pattern = str_replace ( '_controller/' , '' , $ asset -> getTarget... | Loads a route to serve an supplied asset . |
55,156 | protected function parseInput ( $ input , array $ options = array ( ) ) { $ input = $ this -> parameterBag -> resolveValue ( $ input ) ; if ( '@' == $ input [ 0 ] && false !== strpos ( $ input , '/' ) ) { $ bundle = substr ( $ input , 1 ) ; if ( false !== $ pos = strpos ( $ bundle , '/' ) ) { $ bundle = substr ( $ bund... | Adds support for bundle notation file and glob assets and parameter placeholders . |
55,157 | protected function registerBladeExtensions ( ) { $ blade = $ this -> app [ 'view' ] -> getEngineResolver ( ) -> resolve ( 'blade' ) -> getCompiler ( ) ; $ blade -> directive ( 'role' , function ( $ expression ) { return "<?php if (Auth::check() && Auth::user()->is{$expression}): ?>" ; } ) ; $ blade -> directive ( 'endr... | Register Blade extensions . |
55,158 | public function process ( $ text ) { $ iterations = $ this -> maxIterations === null ? 1 : $ this -> maxIterations ; $ context = new ProcessorContext ( ) ; $ context -> processor = $ this ; while ( $ iterations -- ) { $ context -> iterationNumber ++ ; $ newText = $ this -> processIteration ( $ text , $ context , null )... | Entry point for shortcode processing . Implements iterative algorithm for both limited and unlimited number of iterations . |
55,159 | public function withMaxIterations ( $ iterations ) { if ( null !== $ iterations && ! ( is_int ( $ iterations ) && $ iterations > 0 ) ) { $ msg = 'Maximum number of iterations must be null (infinite) or integer > 0!' ; throw new \ InvalidArgumentException ( $ msg ) ; } $ self = clone $ this ; $ self -> maxIterations = $... | Maximum number of iterations null means infinite any integer greater than zero sets value . Zero is invalid because there must be at least one iteration . Defaults to 1 . Loop breaks if result of two consequent iterations shows no change in processed text . |
55,160 | public function withAutoProcessContent ( $ flag ) { if ( ! is_bool ( $ flag ) ) { $ msg = 'Auto processing flag must be a boolean value!' ; throw new \ InvalidArgumentException ( $ msg ) ; } $ self = clone $ this ; $ self -> autoProcessContent = ( bool ) $ flag ; return $ self ; } | Whether shortcode content will be automatically processed and handler already receives shortcode with processed content . If false every shortcode handler needs to process content on its own . Default true . |
55,161 | public function processAll ( ) { $ content_range = $ this -> getContentRange ( ) ; $ size = $ this -> getSize ( ) ; $ this -> files = [ ] ; $ upload = $ this -> upload ; if ( $ this -> logger ) { $ this -> logger -> debug ( 'Processing uploads' , [ 'Content-range' => $ content_range , 'Size' => $ size , 'Upload array' ... | Process entire submitted request |
55,162 | protected function process ( $ tmp_name , $ name , $ size , $ type , $ error , $ index = 0 , $ content_range = null ) { $ this -> fileContainer = $ file = new File ( $ tmp_name , $ name ) ; $ file -> name = $ this -> getFilename ( $ name , $ type , $ index , $ content_range , $ tmp_name ) ; $ file -> size = $ this -> f... | Process single submitted file |
55,163 | protected function getFilename ( $ name , $ type , $ index , $ content_range , $ tmp_name ) { $ name = $ this -> trimFilename ( $ name , $ type , $ index , $ content_range ) ; return ( $ this -> fileNameGenerator -> getFileName ( $ name , $ type , $ tmp_name , $ index , $ content_range , $ this ) ) ; } | Get filename for submitted filename |
55,164 | protected function trimFilename ( $ name , $ type , $ index , $ content_range ) { $ name = trim ( basename ( stripslashes ( $ name ) ) , ".\x00..\x20" ) ; if ( ! $ name ) { $ name = str_replace ( '.' , '-' , microtime ( true ) ) ; } return $ name ; } | Remove harmful characters from filename |
55,165 | protected function processCallbacksFor ( $ eventName , File $ file ) { if ( ! array_key_exists ( $ eventName , $ this -> callbacks ) || empty ( $ this -> callbacks [ $ eventName ] ) ) { return ; } foreach ( $ this -> callbacks [ $ eventName ] as $ callback ) { $ callback ( $ file ) ; } } | Process callbacks for a given event |
55,166 | protected function getConfigBytes ( $ val ) { $ val = trim ( $ val ) ; $ bytes = ( int ) ( substr ( $ val , 0 , - 1 ) ) ; $ last = strtolower ( $ val [ strlen ( $ val ) - 1 ] ) ; switch ( $ last ) { case 'g' : $ bytes *= 1024 ; case 'm' : $ bytes *= 1024 ; case 'k' : $ bytes *= 1024 ; } return $ this -> fixIntegerOverf... | Convert size format from PHP config into bytes |
55,167 | protected function getFilesize ( $ path , $ clear_cache = false ) { if ( $ clear_cache ) { $ this -> filesystem -> clearStatCache ( $ path ) ; } return $ this -> fixIntegerOverflow ( $ this -> filesystem -> getFilesize ( $ path ) ) ; } | Get size of file |
55,168 | protected function getNewHeaders ( array $ files , $ content_range ) { $ headers = [ 'pragma' => 'no-cache' , 'cache-control' => 'no-store, no-cache, must-revalidate' , 'content-disposition' => 'inline; filename="files.json"' , 'x-content-type-options' => 'nosniff' ] ; if ( $ content_range && is_object ( $ files [ 0 ] ... | Generate headers for response |
55,169 | public function create ( $ upload , $ server ) { $ fileupload = new FileUpload ( $ upload , $ server ) ; $ fileupload -> setPathResolver ( $ this -> pathresolver ) ; $ fileupload -> setFileSystem ( $ this -> filesystem ) ; if ( null !== $ this -> fileNameGenerator ) { $ fileupload -> setFileNameGenerator ( $ this -> fi... | Create new instance of FileUpload with the preset modules |
55,170 | public function getFileName ( $ source_name , $ type , $ tmp_name , $ index , $ content_range , FileUpload $ upload ) { $ filename = pathinfo ( $ source_name , PATHINFO_FILENAME ) ; $ extension = pathinfo ( $ source_name , PATHINFO_EXTENSION ) ; $ md5ConcatenatedName = md5 ( $ filename ) . "." . $ extension ; if ( $ up... | Generate the md5 name of a file |
55,171 | public function setMaxSize ( $ max_size ) { if ( is_numeric ( $ max_size ) ) { $ this -> max_size = $ max_size ; } else { $ this -> max_size = Util :: humanReadableToBytes ( $ max_size ) ; } if ( $ this -> max_size < 0 || $ this -> max_size == null ) { throw new \ Exception ( 'invalid max_size value' ) ; } } | Sets the max file size |
55,172 | public function push ( ) : void { $ this -> stack [ $ this -> current + 1 ] = $ this -> stack [ $ this -> current ] ; ++ $ this -> current ; } | Add a new elements into the stack . |
55,173 | public function pop ( ) { $ value = $ this -> stack [ $ this -> current ] ; unset ( $ this -> stack [ $ this -> current ] ) ; -- $ this -> current ; if ( $ this -> current < 0 ) { $ this -> reset ( ) ; } return $ value ; } | Remove an element from the stack and return it . |
55,174 | public static function validate ( $ bban ) { if ( ! extension_loaded ( 'bcmath' ) ) { throw new \ RuntimeException ( __METHOD__ . ' needs the bcmath extension.' ) ; } if ( mb_strlen ( $ bban ) !== 23 ) { return false ; } $ key = substr ( $ bban , - 2 ) ; $ bank = substr ( $ bban , 0 , 5 ) ; $ branch = substr ( $ bban ,... | Bban validator . |
55,175 | public static function validate ( $ hetu ) { if ( ! is_string ( $ hetu ) || strlen ( $ hetu ) != 11 ) { return false ; } $ dd = substr ( $ hetu , 0 , 2 ) ; $ mm = substr ( $ hetu , 2 , 2 ) ; $ yy = substr ( $ hetu , 4 , 2 ) ; $ centuryCode = strtoupper ( $ hetu { 6 } ) ; $ id = ( int ) ( $ dd . $ mm . $ yy . substr ( $... | HETU validator . |
55,176 | public static function validate ( $ nif ) { $ nifCodes = 'TRWAGMYFPDXBNJZSQVHLCKE' ; if ( 9 !== strlen ( $ nif ) ) { return false ; } $ nif = strtoupper ( trim ( $ nif ) ) ; $ sum = ( string ) self :: getCifSum ( $ nif ) ; $ n = 10 - substr ( $ sum , - 1 ) ; if ( preg_match ( '/^[0-9]{8}[A-Z]{1}$/' , $ nif ) ) { $ num ... | NIF and DNI validation . |
55,177 | public static function getCifSum ( $ cif ) { $ sum = $ cif [ 2 ] + $ cif [ 4 ] + $ cif [ 6 ] ; for ( $ i = 1 ; $ i < 8 ; $ i += 2 ) { $ tmp = ( string ) ( 2 * $ cif [ $ i ] ) ; $ tmp = $ tmp [ 0 ] + ( ( strlen ( $ tmp ) == 2 ) ? $ tmp [ 1 ] : 0 ) ; $ sum += $ tmp ; } return $ sum ; } | Used to calculate the sum of the CIF DNI and NIE . |
55,178 | protected static function initialize ( ) { $ highgroup = static :: $ highgroup ; $ highgroup = trim ( ( string ) $ highgroup ) ; $ highgroup = str_replace ( array ( '*' , " \t" , "\n" , ' ' ) , array ( '' , "\t" , "\t" , "\t" ) , $ highgroup ) ; $ highgroup = explode ( "\t" , $ highgroup ) ; $ cleangroup = array ( ) ; ... | Cleans the high group number list so it is useful . |
55,179 | public static function generate ( $ state = false , $ separator = '-' ) { if ( ! static :: $ initialized ) { static :: initialize ( ) ; static :: $ initialized = true ; } $ states = static :: $ states ; $ statePrefixes = static :: $ statePrefixes ; $ highgroup = static :: $ highgroup ; $ possibleGroups = static :: $ po... | Generate an SSN based on state . |
55,180 | public static function validate ( $ ssn ) { if ( ! static :: $ initialized ) { static :: initialize ( ) ; static :: $ initialized = true ; } if ( ! is_string ( $ ssn ) ) { return false ; } if ( trim ( $ ssn ) === '' ) { return false ; } $ statePrefixes = static :: $ statePrefixes ; $ highgroup = static :: $ highgroup ;... | Validate a SSN . |
55,181 | public static function validate ( $ creditCard ) { if ( trim ( $ creditCard ) === '' ) { return false ; } if ( ! boolval ( preg_match ( '/.*[1-9].*/' , $ creditCard ) ) ) { return false ; } $ length = strlen ( $ creditCard ) ; $ tot = 0 ; for ( $ i = $ length - 1 ; $ i >= 0 ; -- $ i ) { $ digit = substr ( $ creditCard ... | Credit Card validator . |
55,182 | public static function validate ( $ cif ) { $ cifCodes = 'JABCDEFGHI' ; if ( 9 !== strlen ( $ cif ) ) { return false ; } $ cif = strtoupper ( trim ( $ cif ) ) ; $ sum = ( string ) Nif :: getCifSum ( $ cif ) ; $ n = ( 10 - substr ( $ sum , - 1 ) ) % 10 ; if ( preg_match ( '/^[ABCDEFGHJKNPQRSUVW]{1}/' , $ cif ) ) { if ( ... | CIF validation . |
55,183 | public static function validate ( $ insee , $ length = 9 ) { if ( ! is_numeric ( $ insee ) ) { return false ; } if ( strlen ( $ insee ) != $ length ) { return false ; } $ sum = 0 ; for ( $ i = 0 ; $ i < $ length ; ++ $ i ) { $ indice = ( $ length - $ i ) ; $ tmp = ( 2 - ( $ indice % 2 ) ) * $ insee [ $ i ] ; if ( $ tmp... | SIREN validator . |
55,184 | public function terminate ( $ signal = null ) { if ( $ this -> process === null ) { return false ; } if ( $ signal !== null ) { return \ proc_terminate ( $ this -> process , $ signal ) ; } return \ proc_terminate ( $ this -> process ) ; } | Terminate the process with an optional signal . |
55,185 | private function closeExitCodePipe ( ) { if ( $ this -> sigchildPipe === null ) { return ; } \ fclose ( $ this -> sigchildPipe ) ; $ this -> sigchildPipe = null ; } | Close the fourth pipe used to relay an exit code . |
55,186 | public function extract ( Parser $ parser , Node \ Variable $ var , $ data ) { $ value = $ data ; $ vals = array_filter ( explode ( $ this -> sep , $ data ) ) ; $ options = $ var -> options ; switch ( $ options [ 'modifier' ] ) { case '*' : $ data = array ( ) ; foreach ( $ vals as $ val ) { if ( strpos ( $ val , '=' ) ... | Extracts value from variable |
55,187 | public function expand ( $ uri , $ params = array ( ) ) { $ params += $ this -> params ; $ uri = $ this -> base_uri . $ uri ; $ result = array ( ) ; if ( ( $ start = strpos ( $ uri , '{' ) ) === false ) { return $ uri ; } $ parser = $ this -> parser ; $ nodes = $ parser -> parse ( $ uri ) ; foreach ( $ nodes as $ node ... | Expands URI Template |
55,188 | public function extract ( $ template , $ uri , $ strict = false ) { $ params = array ( ) ; $ nodes = $ this -> parser -> parse ( $ template ) ; foreach ( $ nodes as $ node ) { if ( $ strict && ! strlen ( $ uri ) ) { return null ; } $ match = $ node -> match ( $ this -> parser , $ uri , $ params , $ strict ) ; list ( $ ... | Extracts variables from URI |
55,189 | public function parse ( $ template ) { $ parts = preg_split ( '#(\{[^\}]+\})#' , $ template , null , PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ) ; $ nodes = array ( ) ; foreach ( $ parts as $ part ) { $ node = $ this -> createNode ( $ part ) ; if ( $ node instanceof Expression && $ node -> getOperator ( ) -> id ==... | Parses URI Template and returns nodes |
55,190 | protected function sortVariables ( array $ vars ) { usort ( $ vars , function ( $ a , $ b ) { return $ a -> options [ 'modifier' ] >= $ b -> options [ 'modifier' ] ? 1 : - 1 ; } ) ; return $ vars ; } | Sort variables before extracting data from uri . We have to sort vars by non - explode to explode . |
55,191 | public function isRelativePath ( $ path ) { if ( strlen ( $ path ) === 0 ) { return true ; } if ( strtoupper ( substr ( PHP_OS , 0 , 3 ) ) === 'WIN' ) { return ! preg_match ( '/^[a-z]+\:\\\\/i' , $ path ) ; } return strpos ( $ path , DIRECTORY_SEPARATOR ) !== 0 ; } | Return whether the path is relative path . |
55,192 | public function toAbsolutePath ( $ path , $ rootDir ) { if ( ! is_string ( $ path ) ) { return false ; } if ( $ this -> isRelativePath ( $ path ) ) { return $ rootDir . DIRECTORY_SEPARATOR . $ path ; } return $ path ; } | Cat file path . |
55,193 | public function getRealPath ( $ path , $ rootDir ) { if ( ! is_string ( $ path ) ) { return false ; } if ( $ this -> isRelativePath ( $ path ) ) { return realpath ( $ rootDir . DIRECTORY_SEPARATOR . $ path ) ; } return realpath ( $ path ) ; } | Return real file path . |
55,194 | public function getRealDir ( $ path , $ rootDir ) { if ( ! is_string ( $ path ) ) { return false ; } if ( $ this -> isRelativePath ( $ path ) ) { return realpath ( $ rootDir . DIRECTORY_SEPARATOR . dirname ( $ path ) ) ; } return realpath ( dirname ( $ path ) ) ; } | Return real directory path . |
55,195 | public function getRealWritingFilePath ( $ path , $ rootDir ) { $ realDir = $ this -> getRealDir ( $ path , $ rootDir ) ; if ( ! is_string ( $ realDir ) ) { return false ; } return $ realDir . DIRECTORY_SEPARATOR . basename ( $ path ) ; } | Return real file path to write . |
55,196 | public function persist ( ) { try { return $ this -> collectCloverXml ( ) -> collectGitInfo ( ) -> collectEnvVars ( ) -> dumpJsonFile ( ) -> send ( ) ; } catch ( \ PhpCoveralls \ Bundle \ CoverallsBundle \ Entity \ Exception \ RequirementsNotSatisfiedException $ e ) { $ this -> logger -> error ( sprintf ( '%s' , $ e ->... | Persist coverage data to Coveralls . |
55,197 | protected function dumpJsonFile ( ) { $ jsonPath = $ this -> config -> getJsonPath ( ) ; $ this -> logger -> info ( sprintf ( 'Dump submitting json file: %s' , $ jsonPath ) ) ; $ this -> api -> dumpJsonFile ( ) ; $ filesize = number_format ( filesize ( $ jsonPath ) / 1024 , 2 ) ; $ this -> logger -> info ( sprintf ( 'F... | Dump submitting json file . |
55,198 | protected function send ( ) { $ this -> logger -> info ( sprintf ( 'Submitting to %s' , Jobs :: URL ) ) ; try { $ response = $ this -> api -> send ( ) ; $ message = $ response ? sprintf ( 'Finish submitting. status: %s %s' , $ response -> getStatusCode ( ) , $ response -> getReasonPhrase ( ) ) : 'Finish dry run' ; $ th... | Send json_file to Jobs API . |
55,199 | protected function colorizeCoverage ( $ coverage , $ format ) { if ( $ coverage >= 90 ) { return sprintf ( '<info>%s</info>' , $ format ) ; } if ( $ coverage >= 80 ) { return sprintf ( '<comment>%s</comment>' , $ format ) ; } return sprintf ( '<fg=red>%s</fg=red>' , $ format ) ; } | Colorize coverage . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.