idx int64 0 60.3k | question stringlengths 99 4.85k | target stringlengths 5 718 |
|---|---|---|
10,600 | protected function initServices ( ) { $ dependencies = $ this -> config -> get ( 'dependencies' , null ) ; $ this -> getDI ( ) -> setShared ( 'registrant' , new Registrant ( $ dependencies ) ) ; $ this -> getDI ( ) -> setShared ( 'config' , $ this -> config ) ; $ this -> getDI ( ) -> get ( 'registrant' ) -> registratio... | Initializing services in dependency injection |
10,601 | public function getChroma ( ) { $ r = ( $ this -> rgb >> 16 ) & 0xff ; $ g = ( $ this -> rgb >> 8 ) & 0xff ; $ b = $ this -> rgb & 0xff ; return ( max ( $ r , $ g , $ b ) - min ( $ r , $ g , $ b ) ) / 255 ; } | Returns color chroma . |
10,602 | public function getHue ( ) { $ rgb = $ this -> rgb ; $ r = ( ( $ rgb >> 16 ) & 0xff ) / 255 ; $ g = ( ( $ rgb >> 8 ) & 0xff ) / 255 ; $ b = ( $ rgb & 0xff ) / 255 ; $ hue = rad2deg ( atan2 ( 1.7320508075688 * ( $ g - $ b ) , 2 * $ r - $ g - $ b ) ) ; return $ hue >= 0 ? $ hue : 360 + $ hue ; } | Returns color hue . |
10,603 | public function getSaturation ( $ colorMode = self :: HSL ) { $ r = ( ( $ this -> rgb >> 16 ) & 0xff ) / 255 ; $ g = ( ( $ this -> rgb >> 8 ) & 0xff ) / 255 ; $ b = ( $ this -> rgb & 0xff ) / 255 ; $ max = max ( $ r , $ g , $ b ) ; $ min = min ( $ r , $ g , $ b ) ; if ( $ max === 0 ) { return 0 ; } if ( $ colorMode ===... | Returns color saturation . |
10,604 | public function getLuminance ( $ mode = self :: HSL ) { $ r = ( $ this -> rgb >> 16 ) & 0xff ; $ g = ( $ this -> rgb >> 8 ) & 0xff ; $ b = $ this -> rgb & 0xff ; switch ( $ mode ) { case 0 : return ( ( $ r + $ r + $ r + $ b + $ g + $ g + $ g + $ g ) >> 3 ) / 255 ; break ; case 1 : return ( int ) ( 0.299 * $ r + 0.587 *... | Returns color luminance . |
10,605 | public function multiply ( $ x , $ y ) { $ this -> width *= $ x ; $ this -> height *= $ y ; return $ this ; } | Multiplies width and height by a given values . |
10,606 | public function add ( $ x = 0 , $ y = 0 ) { $ this -> width += $ x ; $ this -> height += $ y ; return $ this ; } | Adds values to width and height respectively . |
10,607 | public function getDiagonalWidth ( ) { return sqrt ( $ this -> width * $ this -> width + $ this -> height * $ this -> height ) ; } | Returns width of the diagonal line . |
10,608 | public function addNoise ( $ level ) { $ components = array ( ) ; foreach ( $ this -> components as $ component ) { $ components [ ] = $ component + rand ( ) * 2 * $ level - $ level ; } $ this -> components = $ components ; return $ this ; } | Adds noise to this vector . |
10,609 | public function add ( Vector $ v ) { if ( $ this -> dimension != $ v -> getDimensions ( ) ) { throw new Exception ( "Both vectors must have the same size" ) ; } $ components = array ( ) ; $ otherComponents = $ v -> toArray ( ) ; foreach ( $ this -> components as $ i => $ component ) { $ components [ ] = $ component + $... | Adds two vectors . |
10,610 | public function multiply ( $ v ) { $ components = array ( ) ; if ( is_object ( $ v ) ) { if ( ! ( $ v instanceof Vector ) ) { throw new Exception ( 'Unspupported data structure' ) ; } if ( $ this -> dimension != $ v -> getDimensions ( ) ) { throw new Exception ( "Both vectors must have the same size" ) ; } $ otherCompo... | Multiplies two vectors or by a given scalar value . |
10,611 | public function negate ( ) { $ components = array ( ) ; foreach ( $ this -> components as $ index => $ component ) { $ components [ $ index ] = - $ component ; } $ this -> components = $ components ; return $ this ; } | Negates this vector . |
10,612 | public function getSubstractedLength ( Vector $ v ) { if ( $ this -> dimension != $ v -> getDimensions ( ) ) { throw new Exception ( "Both vectors must have the same size" ) ; } $ j = 0 ; $ otherComponents = $ v -> toArray ( ) ; foreach ( $ this -> components as $ i => $ component ) { $ value = $ component - $ otherCom... | Returns substracted length |
10,613 | public function equals ( Vector $ v ) { if ( $ this -> dimension != $ v -> getDimensions ( ) ) { throw new Exception ( "Both vectors must have the same size" ) ; } $ otherComponents = $ v -> toArray ( ) ; $ ret = true ; for ( $ i = 0 ; $ ret && $ i < $ this -> dimension ; ++ $ i ) { $ ret = ( $ this -> components [ $ i... | Compares two vectors . |
10,614 | public function normalize ( ) { $ j = $ this -> getLength ( ) ; if ( $ j === 0 ) { throw new Exception ( 'Cannot normalize zero length vector' ) ; } $ j *= $ j ; $ components = array ( ) ; foreach ( $ this -> components as $ component ) { $ components [ ] = sqrt ( ( $ component * $ component ) / $ j ) ; } $ this -> com... | Performs Vector normalization . |
10,615 | public function addGlyph ( Vector $ v , $ identifier = null ) { $ v = $ v -> getCopy ( ) ; $ v -> setIdentifier ( $ identifier ) ; $ this -> glyphs [ ] = $ v ; return $ this ; } | Adds vector to the vectors database . |
10,616 | public function findNearestEuklid ( Vector $ v , $ noise = 0 ) { $ minDimension = 1000000 ; foreach ( $ this -> glyphs as $ index => $ w ) { $ w = $ w -> getCopy ( ) ; if ( $ noise ) { $ w = $ w -> addNoise ( $ noise ) ; } $ dimension = $ w -> getSubstractedLength ( $ v ) ; if ( $ dimension < $ minDimension ) { $ ret =... | Finds nearest euklid . |
10,617 | public function resize ( $ widthOrDimensions , $ height = null , $ useResampling = true ) { if ( is_object ( $ widthOrDimensions ) && $ widthOrDimensions instanceof Dimensions ) { $ y = $ widthOrDimensions -> height ; $ x = $ widthOrDimensions -> width ; } else { $ x = $ widthOrDimensions ; $ y = $ height ; } $ newImag... | Resizes this image . |
10,618 | public function resizeAndKeepAspect ( $ widthOrDimensions , $ height = null , $ useResampling = true ) { if ( is_object ( $ widthOrDimensions ) && $ widthOrDimensions instanceof Dimensions ) { $ y = $ widthOrDimensions -> height ; $ x = $ widthOrDimensions -> width ; } else { $ x = $ widthOrDimensions ; $ y = $ height ... | Resizes this image and keeps the image aspect . |
10,619 | public function rescale ( $ x , $ y ) { if ( is_object ( $ x ) && $ x instanceof Dimensions ) { $ y = $ x -> height ; $ x = $ x -> width ; } $ newImage = imagecreatetruecolor ( $ this -> width * $ x , $ this -> height * $ y ) ; $ x = imagesx ( $ newImage ) ; $ y = imagesy ( $ newImage ) ; imagecopyresampled ( $ newImag... | Scales this image . |
10,620 | public function getPointRgb ( Point $ position ) { return imagecolorat ( $ this -> image , $ position -> x , $ position -> y ) ; } | Returns a RGB value of the pixel at the coordinates described in the Point object . |
10,621 | public function getPointColor ( Point $ position ) { return new Color ( imagecolorat ( $ this -> image , $ position -> x , $ position -> y ) ) ; } | Returns a color of the pixel at the coordinates described in the Point object . |
10,622 | public function setPointColor ( Point $ position , Color $ color ) { imagesetpixel ( $ this -> image , $ position -> x , $ position -> y , $ color -> rgb ) ; return $ this ; } | Sets a color of the pixel at the coordinates described in the Point object . |
10,623 | public function setPointRgb ( Point $ position , $ rgb ) { imagesetpixel ( $ this -> image , $ position -> x , $ position -> y , $ rgb ) ; return $ this ; } | Sets a RGB value of the pixel at the coordinates described in the Point object . |
10,624 | public function setPixelColor ( $ x , $ y , Color $ color ) { imagesetpixel ( $ this -> image , $ x , $ y , $ color -> rgb ) ; return $ this ; } | Sets a color of the pixel at the X Y coordinates . |
10,625 | public function setPixelRgb ( $ x , $ y , $ rgb ) { imagesetpixel ( $ this -> image , $ x , $ y , $ rgb ) ; return $ this ; } | Sets a RGB value of the pixel at the X Y coordinates . |
10,626 | public function getSubImage ( Point $ position , Dimensions $ size ) { return new Image ( null , $ this -> image , $ position , $ size ) ; } | Returns a sub image of this image . |
10,627 | public function getVector ( Point $ position = null , Dimensions $ size = null , $ round = false , $ colorMask = 0 ) { if ( $ position === null ) { $ position = new Point ( 0 , 0 ) ; } if ( $ size === null ) { $ size = $ this -> getDimensions ( ) ; } $ x = $ position -> x ; $ y = $ position -> y ; $ width = $ size -> w... | Creates a vector from a part of an image . |
10,628 | public function rotate ( $ angle , $ backgroundColor = - 1 ) { if ( $ backgroundColor === - 1 ) { $ backgroundColor = hexdec ( $ this -> getBackgroundColor ( ) -> getHexValue ( ) ) ; } $ this -> image = imagerotate ( $ this -> image , $ angle , ( int ) $ backgroundColor ) ; $ this -> getSize ( ) ; return $ this ; } | Rotates image by a given angle . |
10,629 | public function crop ( Point $ position , Dimensions $ dimensions ) { $ newImage = imagecreate ( $ dimensions -> width , $ dimensions -> height ) ; imagecopy ( $ newImage , $ this -> image , 0 , 0 , $ position -> x , $ position -> y , $ dimensions -> width , $ dimensions -> height ) ; $ this -> image = $ newImage ; $ t... | Crops current image . |
10,630 | private function tiltAndCompare ( Image $ otherImage , $ minAngle = - 20 , $ maxAngle = 20 , $ backgroundColor = 0xffffff , & $ minDimension ) { if ( $ minAngle > $ maxAngle ) { $ tmp = $ maxAngle ; $ maxAngle = $ minAngle ; $ minAngle = $ tmp ; } $ quantization = new Quantizator ( ) ; $ vector = $ otherImage -> getVec... | Experimental functionality do not use! . |
10,631 | public function show ( $ die = false ) { header ( 'Content-Type: image/png' ) ; imagepng ( $ this -> image ) ; if ( $ die ) { die ( ) ; } return $ this ; } | Displays the image . |
10,632 | public function deskew ( $ backgroundColor = - 1 , $ precisionLevel = true , $ debugMode = false ) { if ( $ backgroundColor < 0 ) { $ backgroundColor = hexdec ( $ this -> getBackgroundColor ( 1 , $ precisionLevel === true ) -> getHexValue ( ) ) ; } if ( $ precisionLevel === false || $ precisionLevel === 2 ) { $ precisi... | Deskews the image . |
10,633 | public function getSize ( ) { list ( $ this -> width , $ this -> height ) = $ result = array ( imagesx ( $ this -> image ) , imagesy ( $ this -> image ) ) ; return $ result ; } | Calculates the size of this image . |
10,634 | protected function drawHoughLine ( $ distance , $ theta , $ color = 111111 ) { if ( $ theta === 0 || $ theta === 360 ) { return $ this ; } $ theta = deg2rad ( $ theta ) ; $ sizeX2 = $ this -> width / 2 ; $ sizeY2 = $ this -> height / 2 ; for ( $ x = 0 ; $ x < $ this -> width ; ++ $ x ) { $ y1 = ( int ) ( $ distance / s... | Draws the Hough line . |
10,635 | protected function getBinaryBuffer ( ) { ob_start ( ) ; imagewbmp ( $ this -> image ) ; $ wbmp = ob_get_clean ( ) ; $ i = 2 ; for ( $ j = 0 ; $ j < 2 ; ++ $ j ) { do { $ test = ord ( $ wbmp [ $ i ] ) & 0x80 ; ++ $ i ; } while ( $ test ) ; } return substr ( $ wbmp , $ i ) ; } | Returns binary frame buffer of the current image . |
10,636 | public function isBinaryBufferEmpty ( $ threshold = 0.01 ) { $ bin = $ this -> getBinaryBuffer ( ) ; if ( strlen ( trim ( $ bin , chr ( 255 ) ) ) / strlen ( $ bin ) < $ threshold || strlen ( trim ( $ bin , chr ( 0 ) ) ) / strlen ( $ bin ) < $ threshold ) { return true ; } return false ; } | Detects if the binary buffer of this image is empty after conversion to two - colors mode . |
10,637 | public function getHistogramData ( $ channels , $ colorMode = Color :: HSL ) { $ colors = array_fill ( 0 , 256 , 0 ) ; for ( $ y = 0 ; $ y < $ this -> height ; ++ $ y ) { for ( $ x = 0 ; $ x < $ this -> width ; ++ $ x ) { $ rgb = imagecolorat ( $ this -> image , $ x , $ y ) ; $ r = ( $ rgb >> 16 ) & 0xff ; $ g = ( $ rg... | Generate histogram data . |
10,638 | public function getHistogram ( $ channels = Channel :: RGB , $ color = 0 , $ backgroundColor = 0xffffff , $ turboMode = false ) { $ colors = $ colors2 = $ this -> getHistogramData ( $ channels , $ turboMode ? null : Color :: HSL ) ; sort ( $ colors2 , SORT_NUMERIC ) ; $ min = $ colors2 [ 0 ] ; $ max = $ colors2 [ 255 ]... | Creates an image histogram . |
10,639 | public function changeHsl ( $ hueAngle = 0 , $ saturationFactor = 1 , $ luminanceFactor = 1 ) { $ hueAngle /= 360 ; $ this -> useShader ( '
$hue += $args[0];
$saturation *= $args[1];
$luminance *= $args[2];
' , array ( $ hueAngle , $ saturationFactor , $ luminanceFactor ) ) ; return $ this ; } | Changes HSL values . |
10,640 | public function useMedian ( $ maskWidth = 3 , $ maskHeight = 3 ) { $ scanLines = array ( ) ; $ maskWidth2 = ( int ) ( $ maskWidth / 2 ) ; $ maskHeight2 = ( int ) ( $ maskHeight / 2 ) ; $ maskMiddle = ( int ) ( ( $ maskWidth * $ maskHeight ) / 2 ) ; $ maxY = $ this -> height - $ maskHeight2 ; $ maxX = $ this -> width - ... | Uses median filter to reduce image noise . |
10,641 | protected function createImageMatrix ( $ size = 0 , & $ ratio ) { $ this -> toBinary ( false ) ; if ( $ size > 0 && ( $ this -> width > $ size || $ this -> height > $ size ) ) { if ( $ this -> width > $ this -> height ) { $ ratio = $ size / $ this -> width ; } else { $ ratio = $ size / $ this -> height ; } $ width = ( ... | Creates the image buffer used by the skew functions . |
10,642 | public function block ( $ name , $ value = null ) { if ( $ value === null ) { return isset ( $ this -> blocks [ $ name ] ) ? $ this -> blocks [ $ name ] : null ; } $ this -> blocks [ $ name ] = $ value ; } | Gets or sets a block . |
10,643 | public function startBlock ( $ name ) { if ( in_array ( $ name , $ this -> openBlocks ) ) { throw new InvalidArgumentException ( sprintf ( 'A block "%s" is already started.' , $ name ) ) ; } $ this -> openBlocks [ ] = $ name ; if ( ! isset ( $ this -> blocks [ $ name ] ) ) { $ this -> blocks [ $ name ] = null ; } ob_st... | Starts a block . |
10,644 | public function endBlock ( ) { if ( ! $ this -> openBlocks ) { throw new RuntimeException ( 'No block started.' ) ; } $ name = array_pop ( $ this -> openBlocks ) ; $ value = ob_get_clean ( ) ; if ( $ this -> blocks [ $ name ] === null ) { $ this -> blocks [ $ name ] = $ value ; } return $ this -> blocks [ $ name ] ; } | Stops a block . |
10,645 | public function getConstant ( $ name , $ object = null ) { if ( $ object !== null ) { $ name = sprintf ( '%s::%s' , get_class ( $ object ) , $ name ) ; } return constant ( $ name ) ; } | Gets a constant from an object . |
10,646 | public function getCharset ( $ string ) { if ( preg_match ( '/<meta .* charset=([^\"]+)".*>/sim' , $ string , $ matches ) ) { $ value = $ matches [ 1 ] ; } else { $ charset = $ this -> guess ( $ string ) ; arsort ( $ charset ) ; $ value = key ( $ charset ) ; } return $ value ; } | Find the most possible character set for given Arabic string in unknown format |
10,647 | public static function valueOf ( $ value ) { if ( $ value instanceof self ) { return $ value ; } if ( is_null ( $ value ) ) { return null ; } $ class = get_called_class ( ) ; if ( ! is_string ( $ value ) ) { throw new \ InvalidArgumentException ( "The given object is neither $class nor string." ) ; } foreach ( self :: ... | Get an instance of this class that the given argument represents . |
10,648 | public function load ( $ library ) { if ( $ this -> _compatibleMode && array_key_exists ( $ library , $ this -> _compatible ) ) { $ library = $ this -> _compatible [ $ library ] ; } $ library = "\\ArUtil\\I18N\\$library" ; $ this -> myFile = $ library ; $ this -> myClass = $ library ; $ class = $ library ; if ( ! isset... | Load selected Arabic library and create an instance of its class |
10,649 | public function setInputCharset ( $ charset ) { $ flag = true ; $ charset = strtolower ( $ charset ) ; $ charsets = array ( 'utf-8' , 'windows-1256' , 'cp1256' , 'iso-8859-6' ) ; if ( in_array ( $ charset , $ charsets ) ) { if ( $ charset == 'windows-1256' ) { $ charset = 'cp1256' ; } $ this -> _inputCharset = $ charse... | Set charset used in class input Arabic strings |
10,650 | public function setOutputCharset ( $ charset ) { $ flag = true ; $ charset = strtolower ( $ charset ) ; $ charsets = array ( 'utf-8' , 'windows-1256' , 'cp1256' , 'iso-8859-6' ) ; if ( in_array ( $ charset , $ charsets ) ) { if ( $ charset == 'windows-1256' ) { $ charset = 'cp1256' ; } $ this -> _outputCharset = $ char... | Set charset used in class output Arabic strings |
10,651 | protected function showMigrations ( Migrator $ migrator ) { $ this -> line ( '<comment>Migrations</comment>' ) ; $ groups = $ migrator -> migrationGroups ( ) ; if ( count ( $ groups ) > 0 ) { $ installed_migrations = $ migrator -> installedMigrationsByDesc ( ) ; foreach ( $ groups as $ group ) { $ installed_versions = ... | Show migration infomation . |
10,652 | protected function showSeeds ( Migrator $ migrator ) { $ this -> line ( '<comment>Seeds</comment>' ) ; $ seeds = $ migrator -> seedNames ( ) ; if ( count ( $ seeds ) > 0 ) { $ default_seed = $ migrator -> defaultSeed ( ) ; foreach ( $ seeds as $ seed ) { $ class = $ migrator -> seedClass ( $ seed ) ; $ status_mark = ' ... | Show seed infomation . |
10,653 | protected function doRefresh ( Migrator $ migrator ) { $ installed_migrations = $ migrator -> installedMigrationsByDesc ( ) ; foreach ( $ installed_migrations as $ group => $ migrations ) { foreach ( $ migrations as $ data ) { $ this -> infoDowngrade ( $ group , $ data -> version , $ data -> class ) ; $ migrator -> doD... | Execute clean and upgrade . |
10,654 | public static function checkString ( $ xml , $ filename = '' ) { $ doc = Utilities :: stringToDOMDocument ( $ xml , $ filename ) ; $ errors = null ; $ preUseInternalErrors = libxml_use_internal_errors ( true ) ; try { if ( ! $ doc -> schemaValidateSource ( static :: getSchema ( ) ) ) { $ errors = Utilities :: explainLi... | Check if an xml code satisfy the schema . |
10,655 | public static function checkFile ( $ filename ) { $ fileContents = ( is_file ( $ filename ) && is_readable ( $ filename ) ) ? @ file_get_contents ( $ filename ) : false ; if ( $ fileContents === false ) { throw new Exception ( 'Failed to load the file ' . $ filename ) ; } return static :: checkString ( $ fileContents ,... | Check if an xml file satisfy the schema . |
10,656 | protected static function getSchema ( ) { static $ cache = null ; if ( ! isset ( $ cache ) ) { $ schemaFile = __DIR__ . '/doctrine-xml-0.5.xsd' ; $ s = ( is_file ( $ schemaFile ) && is_readable ( $ schemaFile ) ) ? @ file_get_contents ( $ schemaFile ) : false ; if ( $ s === false ) { throw new Exception ( 'Failed to lo... | Returns the xml schema . |
10,657 | public function parse ( $ stream , $ filename = null ) { $ this -> stream = $ stream ; $ this -> filename = $ filename ; $ this -> variables = array ( ) ; return $ this -> parseMain ( ) ; } | Parsing method . |
10,658 | public function parseMain ( ) { $ out = '' ; while ( $ token = $ this -> stream -> next ( ) ) { if ( $ token -> test ( T_COMMENT , '/* OUTPUT */' ) ) { $ out .= $ this -> parseOutput ( ) ; } elseif ( $ token -> test ( T_COMMENT , '/* DIRECTIVE */' ) ) { $ out .= $ this -> parseDirective ( ) ; } else { $ out .= $ token ... | Parse main . |
10,659 | public function parseDirective ( ) { $ out = '' ; foreach ( $ this -> engine -> getDirectives ( ) as $ directive ) { if ( $ out = $ directive -> parse ( $ this -> stream , $ this -> stream -> get ( ) ) ) { break ; } } return $ out ; } | Parse directive . |
10,660 | public function parseExpression ( ) { $ out = '' ; $ brackets = array ( ) ; do { if ( $ token = $ this -> stream -> nextIf ( T_STRING ) ) { $ name = $ token -> getValue ( ) ; if ( $ this -> stream -> test ( '(' ) && $ this -> engine -> getFunction ( $ name ) ) { $ out .= sprintf ( "\$this->callFunction('%s', array%s)" ... | Parse expression . |
10,661 | public function parseSubscript ( $ out ) { while ( true ) { if ( $ this -> stream -> nextIf ( '.' ) ) { if ( ! $ this -> stream -> test ( T_STRING ) ) { $ this -> stream -> prev ( ) ; break ; } $ val = $ this -> stream -> next ( ) -> getValue ( ) ; $ out = sprintf ( "\$this->getAttribute(%s, '%s'" , $ out , $ val ) ; i... | Parse subscript . |
10,662 | public function setServices ( array $ services = null ) { ValidationUtility :: ensureNullOrArrayOfType ( '$services' , $ services , __NAMESPACE__ . '\Service' ) ; $ this -> services = $ services ; return $ this ; } | Set the list of services that match the query conditions . |
10,663 | public static function ensureNullOrStringOrInteger ( $ name , $ value ) { if ( is_null ( $ value ) || is_string ( $ value ) || is_integer ( $ value ) ) { return ; } throw new \ InvalidArgumentException ( "'$name' must be null, a string or an integer." ) ; } | Ensure that the given object is null a string instance or an integer instance . |
10,664 | public static function ensureNullOrArrayOfType ( $ name , array & $ array = null , $ type ) { if ( is_null ( $ array ) ) { return ; } foreach ( $ array as $ element ) { if ( ! ( $ element instanceof $ type ) ) { throw new \ InvalidArgumentException ( "'$name' must be null or an array of $type." ) ; } } } | Ensure that the given object is null or an array whose elements are of the specified type . |
10,665 | public function validate ( ) { $ maxAge = $ this -> maxAge ; $ authTime = $ this -> authTime ; $ currentTime = $ this -> currentTime ; if ( empty ( $ maxAge ) ) { return true ; } if ( PHP_INT_SIZE <= 4 || is_integer ( $ maxAge ) === false || is_integer ( $ authTime ) === false ) { return $ this -> validateAsStrings ( $... | Validate that the maximum authentication age has not passed since the last user authentication time . |
10,666 | public static function tagText ( $ str ) { $ text = array ( ) ; $ words = explode ( ' ' , $ str ) ; $ prevWord = '' ; foreach ( $ words as $ word ) { if ( $ word == '' ) { continue ; } if ( self :: isNoun ( $ word , $ prevWord ) ) { $ text [ ] = array ( $ word , 1 ) ; } else { $ text [ ] = array ( $ word , 0 ) ; } $ pr... | Tag all words in a given Arabic string if they are nouns or not |
10,667 | public static function highlightText ( $ str , $ style = null ) { $ html = '' ; $ prevTag = 0 ; $ prevWord = '' ; $ taggedText = self :: tagText ( $ str ) ; foreach ( $ taggedText as $ wordTag ) { list ( $ word , $ tag ) = $ wordTag ; if ( $ prevTag == 1 ) { if ( in_array ( $ word , self :: $ _particlePreNouns ) ) { $ ... | Highlighted all nouns in a given Arabic string |
10,668 | public function getOrderBy ( $ arg ) { $ phrase = explode ( "\"" , $ arg ) ; if ( count ( $ phrase ) > 2 ) { $ arg = '' ; for ( $ i = 0 ; $ i < count ( $ phrase ) ; $ i ++ ) { if ( $ i % 2 == 0 && $ phrase [ $ i ] != '' ) { $ arg .= $ phrase [ $ i ] ; } elseif ( $ i % 2 == 1 && $ phrase [ $ i ] != '' ) { $ wordOrder [ ... | Get more relevant order by section related to the user search keywords |
10,669 | protected function lex ( $ arg ) { $ arg = preg_replace ( $ this -> _lexPatterns , $ this -> _lexReplacements , $ arg ) ; return $ arg ; } | This method will implement various regular expressin rules based on pre - defined Arabic lexical rules |
10,670 | public function allForms ( $ arg , $ array = false ) { $ wordForms = array ( ) ; $ words = explode ( ' ' , $ arg ) ; foreach ( $ words as $ word ) { $ wordForms = array_merge ( $ wordForms , $ this -> allWordForms ( $ word ) ) ; } if ( $ array ) { return $ wordForms ; } $ str = implode ( ' ' , $ wordForms ) ; return $ ... | Get most possible Arabic lexical forms of user search keywords |
10,671 | public function setDescriptions ( array $ descriptions = null ) { ValidationUtility :: ensureNullOrArrayOfType ( '$descriptions' , $ descriptions , __NAMESPACE__ . '\TaggedValue' ) ; $ this -> descriptions = $ descriptions ; return $ this ; } | Set the localized descriptions of this scope . |
10,672 | public function setAttributes ( array $ attributes = null ) { ValidationUtility :: ensureNullOrArrayOfType ( '$attributes' , $ attributes , __NAMESPACE__ . '\Pair' ) ; $ this -> attributes = $ attributes ; return $ this ; } | Set the attributes of this scope . |
10,673 | public function find ( $ id , $ payments = false , $ transactions = false , $ stats = false ) { return $ this -> client -> call ( "contacts/{$id}" , array_filter ( [ 'outstanding_payments' => $ payments , 'past_transactions' => $ transactions , 'stats' => $ stats ] ) , 'GET' ) ; } | Retrieve a contact informations via its own id . |
10,674 | public function setDate ( $ m = 8 , $ d = 2 , $ y = 1975 ) { if ( is_numeric ( $ y ) && $ y > 0 && $ y < 3000 ) { $ this -> year = floor ( $ y ) ; } if ( is_numeric ( $ m ) && $ m >= 1 && $ m <= 12 ) { $ this -> month = floor ( $ m ) ; } if ( is_numeric ( $ d ) && $ d >= 1 && $ d <= 31 ) { $ this -> day = floor ( $ d )... | Setting date of day for Salat calculation |
10,675 | public function setLocation ( $ l1 = 36.20278 , $ l2 = 37.15861 , $ z = 2 , $ e = 0 ) { if ( is_numeric ( $ l1 ) && $ l1 >= - 180 && $ l1 <= 180 ) { $ this -> lat = $ l1 ; } if ( is_numeric ( $ l2 ) && $ l2 >= - 180 && $ l2 <= 180 ) { $ this -> long = $ l2 ; } if ( is_numeric ( $ z ) && $ z >= - 12 && $ z <= 12 ) { $ t... | Setting location information for Salat calculation |
10,676 | public function setConf ( $ sch = 'Shafi' , $ sunriseArc = - 0.833333 , $ ishaArc = - 17.5 , $ fajrArc = - 19.5 , $ view = 'Sunni' ) { $ sch = ucfirst ( $ sch ) ; if ( $ sch == 'Shafi' || $ sch == 'Hanafi' ) { $ this -> school = $ sch ; } if ( is_numeric ( $ sunriseArc ) && $ sunriseArc >= - 180 && $ sunriseArc <= 180 ... | Setting rest of Salat calculation configuration |
10,677 | public function getQibla ( ) { $ K_latitude = 21.423333 ; $ K_longitude = 39.823333 ; $ latitude = $ this -> lat ; $ longitude = $ this -> long ; $ numerator = sin ( deg2rad ( $ K_longitude - $ longitude ) ) ; $ denominator = ( cos ( deg2rad ( $ latitude ) ) * tan ( deg2rad ( $ K_latitude ) ) ) - ( sin ( deg2rad ( $ la... | Determine Qibla direction using basic spherical trigonometric formula |
10,678 | public function setClaims ( array $ claims = null ) { ValidationUtility :: ensureNullOrArrayOfString ( '$claims' , $ claims ) ; $ this -> claims = $ claims ; return $ this ; } | Set the list of claims that the client application requests to be embedded in the userinfo response . |
10,679 | public static function toString ( $ value ) { if ( is_null ( $ value ) || is_string ( $ value ) ) { return $ value ; } if ( is_bool ( $ value ) ) { return ( $ value ? "true" : "false" ) ; } return strval ( $ value ) ; } | Get the string value of the given object . |
10,680 | public static function parseBoolean ( $ value ) { if ( is_null ( $ value ) ) { return false ; } if ( is_bool ( $ value ) ) { return $ value ; } if ( ! is_string ( $ value ) ) { throw new \ InvalidArgumentException ( 'Failed to parse as bool.' ) ; } if ( strcasecmp ( 'true' , $ value ) != 0 ) { return false ; } return t... | Parse the given object as boolean . |
10,681 | public static function parseInteger ( $ value ) { if ( is_null ( $ value ) ) { return 0 ; } if ( is_integer ( $ value ) ) { return $ value ; } if ( ! is_string ( $ value ) ) { throw new \ InvalidArgumentException ( 'Failed to parse as an integer.' ) ; } return intval ( $ value ) ; } | Parse the given object as integer . |
10,682 | public static function & convertArray ( array & $ array = null , $ converter , $ arg = null ) { if ( is_null ( $ array ) ) { $ output = null ; return $ output ; } $ output = array ( ) ; array_walk ( $ array , function ( $ value , $ key ) use ( $ converter , $ arg , & $ output ) { if ( is_null ( $ arg ) ) { $ output [ ]... | Convert elements of an array with a given converter and generate a new array . |
10,683 | public static function convertArrayCopyableToJson ( ArrayCopyable $ object = null , $ options = 0 ) { $ array = self :: convertArrayCopyableToArray ( $ object ) ; if ( is_null ( $ array ) ) { return null ; } return json_encode ( $ array , $ options ) ; } | Convert an ArrayCopyable instance to a JSON string . |
10,684 | public static function convertArrayToArrayCopyable ( array & $ array = null , $ className ) { if ( is_null ( $ array ) ) { return null ; } if ( is_null ( $ className ) || ! is_string ( $ className ) ) { return null ; } $ object = new $ className ( ) ; $ object -> copyFromArray ( $ array ) ; return $ object ; } | Convert an array to an object . |
10,685 | public static function convertJsonToArrayCopyable ( $ json , $ className ) { if ( is_null ( $ json ) || ! is_string ( $ json ) ) { return null ; } $ array = json_decode ( $ json , true , 512 , JSON_BIGINT_AS_STRING ) ; return self :: convertArrayToArrayCopyable ( $ array , $ className ) ; } | Convert a JSON string to an object . |
10,686 | public static function generateToken ( $ secret , $ object ) { try { return ( new TokenGenerator ( $ secret ) ) -> setData ( $ object ) -> create ( ) ; } catch ( TokenException $ e ) { $ e -> getMessage ( ) ; return false ; } } | Generate access token |
10,687 | public function get ( ) { try { $ ch = $ this -> curl ( 'GET' ) ; $ return = curl_exec ( $ ch ) ; curl_close ( $ ch ) ; return json_decode ( $ return , true ) ; } catch ( Exception $ e ) { } return null ; } | Get data from Firebase with a GET request |
10,688 | private function curl ( $ mode ) { $ url = sprintf ( '%s.json' , $ this -> _host ) ; if ( $ this -> _token ) { $ url = sprintf ( '%s?auth=%s' , $ url , $ this -> _token ) ; } $ ch = curl_init ( ) ; curl_setopt ( $ ch , CURLOPT_URL , $ url ) ; curl_setopt ( $ ch , CURLOPT_TIMEOUT , $ this -> _timeout ) ; curl_setopt ( $... | Generate curl object |
10,689 | private function write ( $ data , $ method = 'PUT' ) { $ jsonData = json_encode ( $ data ) ; $ header = array ( 'Content-Type: application/json' , 'Content-Length: ' . strlen ( $ jsonData ) ) ; try { $ ch = $ this -> curl ( $ method ) ; curl_setopt ( $ ch , CURLOPT_HTTPHEADER , $ header ) ; curl_setopt ( $ ch , CURLOPT... | Write data into firebase |
10,690 | protected function isTemplateNameSupported ( string $ templateName ) : bool { $ templateNames = $ this -> getEnvironment ( ) -> getConfig ( ) -> get ( $ this -> templateConfigKey ) ; if ( ! is_array ( $ templateNames ) ) { return false ; } foreach ( $ templateNames as $ supported ) { if ( $ templateName === $ supported... | Check if template name is supported . |
10,691 | public function getAttributes ( string $ sectionId , bool $ inside = false ) : Attributes { $ attributes = new Attributes ( ) ; if ( $ inside ) { $ attributes -> addClass ( 'inside' ) ; } else { $ attributes -> setId ( $ sectionId ) ; } if ( in_array ( $ sectionId , array ( static :: FOOTER , static :: HEADER ) ) ) { $... | Get attributes for a specific section . |
10,692 | private function initialize ( ) : void { if ( ! $ this -> isBootstrapLayout ( ) ) { return ; } switch ( $ this -> layout -> cols ) { case '2cll' : $ this -> leftClass = $ this -> layout -> bs_leftClass ; $ this -> mainClass = $ this -> layout -> bs_mainClass ; break ; case '2clr' : $ this -> rightClass = $ this -> layo... | Initialize the helper . |
10,693 | private function addSchemaAttributes ( string $ sectionId , bool $ inside , Attributes $ attributes ) : void { if ( $ inside ) { return ; } switch ( $ sectionId ) { case static :: MAIN : $ attributes -> setAttribute ( 'itemscope' , true ) ; $ attributes -> setAttribute ( 'itemtype' , 'http://schema.org/WebPageElement' ... | Add the schema attributes . |
10,694 | public function addRoomTemperatureActuatorState ( $ logicalDeviceId , $ pointTemperature , $ mode ) { if ( ( int ) $ pointTemperature < 6 ) { $ pointTemperature = 6 ; } if ( ( int ) $ pointTemperature > 30 ) { $ pointTemperature = 30 ; } if ( ! preg_match ( '#^[0-9]+(\.[05]+)?$#i' , $ pointTemperature ) ) { throw new \... | Sets the temperature and mode for heaters |
10,695 | public function addRollerShutter ( $ logicalDeviceId , $ shutterLevel ) { $ logicalDeviceState = $ this -> actuatorStates -> addChild ( 'LogicalDeviceState' ) ; $ logicalDeviceState -> addAttribute ( 'xmlns:xsi:type' , 'RollerShutterActuatorState' ) ; $ logicalDeviceState -> addAttribute ( 'LID' , $ logicalDeviceId ) ;... | Set the shutter level of shutters |
10,696 | public function getDirective ( $ name ) { if ( ! $ this -> initialized ) { $ this -> initialize ( ) ; } return isset ( $ this -> directives [ $ name ] ) ? $ this -> directives [ $ name ] : null ; } | Gets a directives . |
10,697 | public function addDirective ( DirectiveInterface $ directive ) { if ( $ this -> initialized ) { throw new RuntimeException ( sprintf ( 'Unable to add directive "%s" as they have already been initialized.' , $ directive -> getName ( ) ) ) ; } $ directive -> setEngine ( $ this ) ; $ this -> directives [ $ directive -> g... | Adds a directive . |
10,698 | public function getFunction ( $ name ) { if ( ! $ this -> initialized ) { $ this -> initialize ( ) ; } return isset ( $ this -> functions [ $ name ] ) ? $ this -> functions [ $ name ] : null ; } | Gets a function . |
10,699 | public function addFunction ( $ name , $ function ) { if ( $ this -> initialized ) { throw new RuntimeException ( sprintf ( 'Unable to add function "%s" as they have already been initialized.' , $ name ) ) ; } $ this -> functions [ $ name ] = $ function ; } | Adds a function . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.