idx
int64
0
60.3k
question
stringlengths
99
4.85k
target
stringlengths
5
718
800
public function getBootstrapFile ( ) { if ( isset ( $ this -> raw -> bootstrap ) ) { $ path = $ this -> raw -> bootstrap ; if ( false === Path :: isAbsolute ( $ path ) ) { $ path = Path :: canonical ( $ this -> getBasePath ( ) . DIRECTORY_SEPARATOR . $ path ) ; } return $ path ; } return null ; }
Returns the bootstrap file path .
801
public function getCompactors ( ) { $ compactors = array ( ) ; if ( isset ( $ this -> raw -> compactors ) ) { foreach ( ( array ) $ this -> raw -> compactors as $ class ) { if ( false === class_exists ( $ class ) ) { throw new InvalidArgumentException ( sprintf ( 'The compactor class "%s" does not exist.' , $ class ) )...
Returns the list of file contents compactors .
802
public function getCompressionAlgorithm ( ) { if ( isset ( $ this -> raw -> compression ) ) { if ( is_string ( $ this -> raw -> compression ) ) { if ( false === defined ( 'Phar::' . $ this -> raw -> compression ) ) { throw new InvalidArgumentException ( sprintf ( 'The compression algorithm "%s" is not supported.' , $ t...
Returns the Phar compression algorithm .
803
public function getDirectories ( ) { if ( isset ( $ this -> raw -> directories ) ) { $ directories = ( array ) $ this -> raw -> directories ; $ base = $ this -> getBasePath ( ) ; array_walk ( $ directories , function ( & $ directory ) use ( $ base ) { $ directory = $ base . DIRECTORY_SEPARATOR . rtrim ( Path :: canonic...
Returns the list of relative directory paths .
804
public function getDirectoriesIterator ( ) { if ( array ( ) !== ( $ directories = $ this -> getDirectories ( ) ) ) { return Finder :: create ( ) -> files ( ) -> filter ( $ this -> getBlacklistFilter ( ) ) -> ignoreVCS ( true ) -> in ( $ directories ) ; } return null ; }
Returns the iterator for the directory paths .
805
public function getFileMode ( ) { if ( isset ( $ this -> raw -> chmod ) ) { return intval ( $ this -> raw -> chmod , 8 ) ; } return null ; }
Returns the file mode in octal form .
806
public function getFiles ( ) { if ( isset ( $ this -> raw -> files ) ) { $ base = $ this -> getBasePath ( ) ; $ files = array ( ) ; foreach ( ( array ) $ this -> raw -> files as $ file ) { $ file = new SplFileInfo ( $ path = $ base . DIRECTORY_SEPARATOR . Path :: canonical ( $ file ) ) ; if ( false === $ file -> isFile...
Returns the list of relative file paths .
807
public function getFinders ( ) { if ( isset ( $ this -> raw -> finder ) ) { return $ this -> processFinders ( $ this -> raw -> finder ) ; } return array ( ) ; }
Returns the list of configured Finder instances .
808
public function getGitVersion ( ) { try { return $ this -> getGitTag ( ) ; } catch ( RuntimeException $ exception ) { try { return $ this -> getGitHash ( true ) ; } catch ( RuntimeException $ exception ) { throw new RuntimeException ( sprintf ( 'The tag or commit hash could not be retrieved from "%s": %s' , dirname ( $...
Returns the Git tag name or short commit hash .
809
public function getMainScriptContents ( ) { if ( null !== ( $ path = $ this -> getMainScriptPath ( ) ) ) { $ path = $ this -> getBasePath ( ) . DIRECTORY_SEPARATOR . $ path ; if ( false === ( $ contents = @ file_get_contents ( $ path ) ) ) { $ errors = error_get_last ( ) ; if ( $ errors === null ) { $ errors = array ( ...
Returns the processed contents of the main script file .
810
public function getMainScriptPath ( ) { if ( isset ( $ this -> raw -> main ) ) { return Path :: canonical ( $ this -> raw -> main ) ; } return null ; }
Returns the main script file path .
811
public function getMap ( ) { if ( isset ( $ this -> raw -> map ) ) { $ map = array ( ) ; foreach ( ( array ) $ this -> raw -> map as $ item ) { $ processed = array ( ) ; foreach ( $ item as $ match => $ replace ) { $ processed [ Path :: canonical ( $ match ) ] = Path :: canonical ( $ replace ) ; } if ( isset ( $ proces...
Returns the internal file path mapping .
812
public function getMapper ( ) { $ map = $ this -> getMap ( ) ; return function ( $ path ) use ( $ map ) { foreach ( $ map as $ item ) { foreach ( $ item as $ match => $ replace ) { if ( empty ( $ match ) ) { return $ replace . $ path ; } elseif ( 0 === strpos ( $ path , $ match ) ) { return preg_replace ( '/^' . preg_q...
Returns a mapping callable for the configured map .
813
public function getMetadata ( ) { if ( isset ( $ this -> raw -> metadata ) ) { if ( is_object ( $ this -> raw -> metadata ) ) { return ( array ) $ this -> raw -> metadata ; } return $ this -> raw -> metadata ; } return null ; }
Returns the Phar metadata .
814
public function getOutputPath ( ) { $ base = getcwd ( ) . DIRECTORY_SEPARATOR ; if ( isset ( $ this -> raw -> output ) ) { $ path = $ this -> raw -> output ; if ( false === Path :: isAbsolute ( $ path ) ) { $ path = Path :: canonical ( $ base . $ path ) ; } } else { $ path = $ base . 'default.phar' ; } if ( false !== s...
Returns the output file path .
815
public function getPrivateKeyPassphrase ( ) { if ( isset ( $ this -> raw -> { 'key-pass' } ) && is_string ( $ this -> raw -> { 'key-pass' } ) ) { return $ this -> raw -> { 'key-pass' } ; } return null ; }
Returns the private key passphrase .
816
public function getProcessedReplacements ( ) { $ values = $ this -> getReplacements ( ) ; if ( null !== ( $ git = $ this -> getGitHashPlaceholder ( ) ) ) { $ values [ $ git ] = $ this -> getGitHash ( ) ; } if ( null !== ( $ git = $ this -> getGitShortHashPlaceholder ( ) ) ) { $ values [ $ git ] = $ this -> getGitHash (...
Returns the processed list of replacement placeholders and their values .
817
public function getShebang ( ) { if ( isset ( $ this -> raw -> shebang ) ) { if ( ( '' === $ this -> raw -> shebang ) || ( false === $ this -> raw -> shebang ) ) { return '' ; } $ shebang = trim ( $ this -> raw -> shebang ) ; if ( '#!' !== substr ( $ shebang , 0 , 2 ) ) { throw new InvalidArgumentException ( sprintf ( ...
Returns the shebang line .
818
public function getSigningAlgorithm ( ) { if ( isset ( $ this -> raw -> algorithm ) ) { if ( is_string ( $ this -> raw -> algorithm ) ) { if ( false === defined ( 'Phar::' . $ this -> raw -> algorithm ) ) { throw new InvalidArgumentException ( sprintf ( 'The signing algorithm "%s" is not supported.' , $ this -> raw -> ...
Returns the Phar signing algorithm .
819
public function getStubBannerFromFile ( ) { if ( null !== ( $ path = $ this -> getStubBannerPath ( ) ) ) { $ path = $ this -> getBasePath ( ) . DIRECTORY_SEPARATOR . $ path ; if ( false === ( $ contents = @ file_get_contents ( $ path ) ) ) { $ errors = error_get_last ( ) ; if ( $ errors === null ) { $ errors = array ( ...
Returns the stub banner comment from the file .
820
public function getStubPath ( ) { if ( isset ( $ this -> raw -> stub ) && is_string ( $ this -> raw -> stub ) ) { return $ this -> raw -> stub ; } return null ; }
Returns the Phar stub file path .
821
public function isStubGenerated ( ) { if ( isset ( $ this -> raw -> stub ) && ( true === $ this -> raw -> stub ) ) { return true ; } return false ; }
Checks if the Phar stub should be generated .
822
public function loadBootstrap ( ) { if ( null !== ( $ file = $ this -> getBootstrapFile ( ) ) ) { if ( false === file_exists ( $ file ) ) { throw new InvalidArgumentException ( sprintf ( 'The bootstrap path "%s" is not a file or does not exist.' , $ file ) ) ; } include $ file ; } }
Loads the configured bootstrap file if available .
823
private function processFinders ( array $ config ) { $ finders = array ( ) ; $ filter = $ this -> getBlacklistFilter ( ) ; foreach ( $ config as $ methods ) { $ finder = Finder :: create ( ) -> files ( ) -> filter ( $ filter ) -> ignoreVCS ( true ) ; if ( isset ( $ methods -> in ) ) { $ base = $ this -> getBasePath ( )...
Processes the Finders configuration list .
824
private function runGitCommand ( $ command ) { $ path = dirname ( $ this -> file ) ; $ process = new Process ( $ command , $ path ) ; if ( 0 === $ process -> run ( ) ) { return trim ( $ process -> getOutput ( ) ) ; } throw new RuntimeException ( sprintf ( 'The tag or commit hash could not be retrieved from "%s": %s' , ...
Runs a Git command on the repository .
825
private function add ( Traversable $ iterator = null , $ message = null , $ binary = false ) { static $ count = 0 ; if ( $ iterator ) { if ( $ message ) { $ this -> putln ( '?' , $ message ) ; } $ box = $ binary ? $ this -> box -> getPhar ( ) : $ this -> box ; $ baseRegex = $ this -> config -> getBasePathRegex ( ) ; $ ...
Adds files using an iterator .
826
public function push ( $ key , $ value = null ) { $ pushItem = new DataLayer ( ) ; $ pushItem -> set ( $ key , $ value ) ; $ this -> pushDataLayer -> push ( $ pushItem ) ; }
Add data to be pushed to the data layer .
827
protected function isDefaultEanLabelEnabled ( ) { $ label = $ this -> getLabel ( ) ; $ font = $ this -> font ; return $ label !== null && $ label !== '' && $ font !== null && $ this -> defaultLabel !== null ; }
Checks if the default ean label is enabled .
828
private static function getExtendedVersion ( $ char ) { $ o = ord ( $ char ) ; if ( $ o === 0 ) { return '%U' ; } elseif ( $ o >= 1 && $ o <= 26 ) { return '$' . chr ( $ o + 64 ) ; } elseif ( ( $ o >= 33 && $ o <= 44 ) || $ o === 47 || $ o === 48 ) { return '/' . chr ( $ o + 32 ) ; } elseif ( $ o >= 97 && $ o <= 122 ) ...
Returns the extended reprensentation of the character .
829
public function setThickness ( $ thickness ) { $ thickness = intval ( $ thickness ) ; if ( $ thickness <= 0 ) { throw new CINArgumentException ( 'The thickness must be larger than 0.' , 'thickness' ) ; } $ this -> thickness = $ thickness ; }
Sets the thickness .
830
public function setPosition ( $ position ) { $ position = intval ( $ position ) ; if ( $ position !== self :: POSITION_TOP && $ position !== self :: POSITION_RIGHT && $ position !== self :: POSITION_BOTTOM && $ position !== self :: POSITION_LEFT ) { throw new CINArgumentException ( 'The text position must be one of a v...
Sets the text position for drawing .
831
public function setAlignment ( $ alignment ) { $ alignment = intval ( $ alignment ) ; if ( $ alignment !== self :: ALIGN_LEFT && $ alignment !== self :: ALIGN_TOP && $ alignment !== self :: ALIGN_CENTER && $ alignment !== self :: ALIGN_RIGHT && $ alignment !== self :: ALIGN_BOTTOM ) { throw new CINArgumentException ( '...
Sets the text alignment for drawing .
832
public function setRotationAngle ( $ rotationAngle ) { $ this -> rotationAngle = intval ( $ rotationAngle ) ; $ this -> font -> setRotationAngle ( $ this -> rotationAngle ) ; }
Sets the rotation angle in degree .
833
public function setBackgroundColor ( $ backgroundColor ) { $ this -> backgroundColor = $ backgroundColor ; $ this -> font -> setBackgroundColor ( $ this -> backgroundColor ) ; }
Sets the background color in case of rotation .
834
private function setStartFromText ( $ text ) { if ( $ this -> starting_text === null ) { if ( is_array ( $ text ) ) { if ( is_array ( $ text [ 0 ] ) ) { $ this -> starting_text = $ this -> METHOD [ $ text [ 0 ] [ 0 ] ] ; return ; } else { if ( is_string ( $ text [ 0 ] ) ) { $ text = $ text [ 0 ] ; } else { $ this -> st...
Specifies the starting_text table if none has been specified earlier .
835
private function setParseA ( $ text , & $ currentMode ) { $ tmp = preg_quote ( $ this -> keysA , '/' ) ; if ( $ this -> tilde ) { $ tmp .= '~' ; } $ match = array ( ) ; if ( preg_match ( '/[^' . $ tmp . ']/' , $ text , $ match ) === 1 ) { throw new CINParseException ( 'code128' , 'The text "' . $ text . '" can\'t be pa...
Parses the text and returns the appropriate sequence for the Table A .
836
private function setParseB ( $ text , & $ currentMode ) { $ tmp = preg_quote ( $ this -> keysB , '/' ) ; $ match = array ( ) ; if ( preg_match ( '/[^' . $ tmp . ']/' , $ text , $ match ) === 1 ) { throw new CINParseException ( 'code128' , 'The text "' . $ text . '" can\'t be parsed with the Table B. The character "' . ...
Parses the text and returns the appropriate sequence for the Table B .
837
private function setParseC ( $ text , & $ currentMode ) { $ tmp = preg_quote ( $ this -> keysC , '/' ) ; if ( $ this -> tilde ) { $ tmp .= '~F' ; } $ match = array ( ) ; if ( preg_match ( '/[^' . $ tmp . ']/' , $ text , $ match ) === 1 ) { throw new CINParseException ( 'code128' , 'The text "' . $ text . '" can\'t be p...
Parses the text and returns the appropriate sequence for the Table C .
838
private function encodeChar ( & $ data , $ encoding , $ seq , $ text , & $ i , & $ counter , & $ indcheck ) { if ( isset ( $ seq [ $ i + 1 ] ) && $ seq [ $ i + 1 ] === 'F' ) { if ( $ text [ $ counter + 1 ] === 'F' ) { $ number = $ text [ $ counter + 2 ] ; $ fnc = $ this -> fnc [ $ encoding ] [ $ number - 1 ] ; $ indche...
Encodes characters base on its encoding and sequence
839
public function draw ( ) { ob_start ( ) ; imagepng ( $ this -> im ) ; $ bin = ob_get_contents ( ) ; ob_end_clean ( ) ; $ this -> setInternalProperties ( $ bin ) ; if ( empty ( $ this -> filename ) ) { echo $ bin ; } else { file_put_contents ( $ this -> filename , $ bin ) ; } }
Draws the PNG on the screen or in a file .
840
public function allocate ( & $ im ) { $ allocated = imagecolorallocate ( $ im , $ this -> r , $ this -> g , $ this -> b ) ; if ( $ this -> transparent ) { return imagecolortransparent ( $ im , $ allocated ) ; } else { return $ allocated ; } }
Returns the int value for PHP color .
841
public function drawException ( $ exception ) { $ this -> w = 1 ; $ this -> h = 1 ; $ this -> init ( ) ; $ w = imagesx ( $ this -> im ) ; $ h = imagesy ( $ this -> im ) ; $ text = 'Error: ' . $ exception -> getMessage ( ) ; $ width = imagefontwidth ( 2 ) * strlen ( $ text ) ; $ height = imagefontheight ( 2 ) ; if ( $ w...
Writes the Error on the picture .
842
private function init ( ) { if ( $ this -> im === null ) { $ this -> im = imagecreatetruecolor ( $ this -> w , $ this -> h ) or die ( 'Can\'t Initialize the GD Libraty' ) ; imagefilledrectangle ( $ this -> im , 0 , 0 , $ this -> w - 1 , $ this -> h - 1 , $ this -> color -> allocate ( $ this -> im ) ) ; } }
Init Image and color background .
843
protected function checkCharsAllowed ( ) { $ c = strlen ( $ this -> text ) ; if ( $ c === 10 ) { if ( array_search ( $ this -> text [ 9 ] , $ this -> keys ) === false && $ this -> text [ 9 ] !== 'X' ) { throw new CINParseException ( 'isbn' , 'The character \'' . $ this -> text [ 9 ] . '\' is not allowed.' ) ; } $ this ...
Check chars allowed .
844
private function createISBNText ( ) { $ isbn = '' ; if ( ! empty ( $ this -> text ) ) { $ c = strlen ( $ this -> text ) ; if ( $ c === 12 || $ c === 13 ) { $ lastCharacter = '' ; if ( $ c === 13 ) { $ lastCharacter = $ this -> text [ 12 ] ; $ this -> text = substr ( $ this -> text , 0 , 12 ) ; } $ checksum = $ this -> ...
Creates the ISBN text .
845
public function setTrackingCode ( $ barcodeIdentifier , $ serviceTypeIdentifier , $ mailerIdentifier , $ serialNumber ) { $ barcodeIdentifier = ( string ) ( int ) $ barcodeIdentifier ; $ serviceTypeIdentifier = ( int ) $ serviceTypeIdentifier ; $ mailerIdentifier = ( int ) $ mailerIdentifier ; $ serialNumber = ( string...
Sets the tracking code .
846
private static function conversionRoutingCode ( $ zipcode ) { $ number = $ zipcode ; switch ( strlen ( $ zipcode ) ) { case 11 : $ number = bcadd ( $ number , '1000000000' , 0 ) ; case 9 : $ number = bcadd ( $ number , '100000' , 0 ) ; case 5 : $ number = bcadd ( $ number , '1' , 0 ) ; default : return $ number ; } }
Converts the routing code zipcode .
847
private static function conversionTrackingCode ( $ number , $ barcodeIdentifier , $ serviceTypeIdentifier , $ mailerIdentifier , $ serialNumber ) { $ number = bcmul ( $ number , 10 , 0 ) ; $ number = bcadd ( $ number , $ barcodeIdentifier [ 0 ] , 0 ) ; $ number = bcmul ( $ number , 5 , 0 ) ; $ number = bcadd ( $ number...
Converts the tracking code number .
848
public function setStructureAppend ( $ n , $ m , $ parity , $ original_data ) { $ this -> structure_append_n = $ n ; $ this -> structure_append_m = $ m ; $ this -> structure_append_parity = $ parity ; $ this -> structure_append_original_data = $ original_data ; return $ this ; }
Set structure append .
849
public function setErrorCorrection ( $ error_correction ) { if ( ! is_numeric ( $ error_correction ) ) { $ level_constant = 'CodeItNow\BarcodeBundle\Utils\QrCode::LEVEL_' . strtoupper ( $ error_correction ) ; $ error_correction = constant ( $ level_constant ) ; } if ( in_array ( $ error_correction , $ this -> error_cor...
Set QR Code error correction level .
850
public function getDataUri ( ) { if ( empty ( $ this -> image ) ) { $ this -> create ( ) ; } ob_start ( ) ; call_user_func ( 'image' . $ this -> image_type , $ this -> image ) ; $ contents = ob_get_clean ( ) ; return 'data:image/' . $ this -> image_type . ';base64,' . base64_encode ( $ contents ) ; }
Return the data URI .
851
public function setScale ( $ scale ) { $ scale = intval ( $ scale ) ; if ( $ scale <= 0 ) { throw new CINArgumentException ( 'The scale must be larger than 0.' , 'scale' ) ; } $ this -> scale = $ scale ; }
Sets the scale of the barcode in pixel . If the scale is lower than 1 an exception is raised .
852
public function setOffsetX ( $ offsetX ) { $ offsetX = intval ( $ offsetX ) ; if ( $ offsetX < 0 ) { throw new CINArgumentException ( 'The offset X must be 0 or larger.' , 'offsetX' ) ; } $ this -> offsetX = $ offsetX ; }
Sets the X offset .
853
public function setOffsetY ( $ offsetY ) { $ offsetY = intval ( $ offsetY ) ; if ( $ offsetY < 0 ) { throw new CINArgumentException ( 'The offset Y must be 0 or larger.' , 'offsetY' ) ; } $ this -> offsetY = $ offsetY ; }
Sets the Y offset .
854
public function addLabel ( CINLabel $ label ) { $ label -> setBackgroundColor ( $ this -> colorBg ) ; $ label -> setForegroundColor ( $ this -> colorFg ) ; $ this -> labels [ ] = $ label ; }
Adds the label to the drawing .
855
public function removeLabel ( CINLabel $ label ) { $ remove = - 1 ; $ c = count ( $ this -> labels ) ; for ( $ i = 0 ; $ i < $ c ; $ i ++ ) { if ( $ this -> labels [ $ i ] === $ label ) { $ remove = $ i ; break ; } } if ( $ remove > - 1 ) { array_splice ( $ this -> labels , $ remove , 1 ) ; } }
Removes the label from the drawing .
856
protected function drawPixel ( $ im , $ x , $ y , $ color = self :: COLOR_FG ) { $ xR = ( $ x + $ this -> offsetX ) * $ this -> scale + $ this -> pushLabel [ 0 ] ; $ yR = ( $ y + $ this -> offsetY ) * $ this -> scale + $ this -> pushLabel [ 1 ] ; imagefilledrectangle ( $ im , $ xR , $ yR , $ xR + $ this -> scale - 1 , ...
Draws 1 pixel on the resource at a specific position with a determined color .
857
protected function drawFilledRectangle ( $ im , $ x1 , $ y1 , $ x2 , $ y2 , $ color = self :: COLOR_FG ) { if ( $ x1 > $ x2 ) { $ x1 ^= $ x2 ^= $ x1 ^= $ x2 ; } if ( $ y1 > $ y2 ) { $ y1 ^= $ y2 ^= $ y1 ^= $ y2 ; } imagefilledrectangle ( $ im , ( $ x1 + $ this -> offsetX ) * $ this -> scale + $ this -> pushLabel [ 0 ] ...
Draws a filled rectangle on the resource at a specific position with a determined color .
858
protected function getColor ( $ im , $ color ) { if ( $ color === self :: COLOR_BG ) { return $ this -> colorBg -> allocate ( $ im ) ; } else { return $ this -> colorFg -> allocate ( $ im ) ; } }
Allocates the color based on the integer .
859
private function findPosition ( $ size1 , $ size2 , $ alignment ) { $ rsize1 = max ( $ size1 , $ size2 ) ; $ rsize2 = min ( $ size1 , $ size2 ) ; if ( $ alignment === self :: ALIGN_LEFT ) { return 0 ; } elseif ( $ alignment === self :: ALIGN_CENTER ) { return $ rsize1 / 2 - $ rsize2 / 2 ; } else { return $ rsize1 - $ r...
Finds the position where the barcode should be aligned .
860
private function changeBars ( $ in ) { if ( $ this -> ratio > 1 ) { $ c = strlen ( $ in ) ; for ( $ i = 0 ; $ i < $ c ; $ i ++ ) { $ in [ $ i ] = $ in [ $ i ] === '1' ? $ this -> ratio : $ in [ $ i ] ; } } return $ in ; }
Changes the size of the bars based on the ratio
861
private function _getCode ( ) { $ code = null ; $ text = $ this -> text ; $ textColor = new CINColor ( $ this -> foregroundColor ) ; $ backgroudColor = new CINColor ( $ this -> backgroundColor ) ; $ fontPath = isset ( $ this -> font ) ? $ this -> font : $ this -> _getDefaultFont ( ) ; $ font = new CINFontFile ( $ fontP...
Get barcode object to create image
862
private function _render ( ) { $ textColor = new CINColor ( $ this -> foregroundColor ) ; $ backgroudColor = new CINColor ( $ this -> backgroundColor ) ; $ drawing = new CINDrawing ( $ this -> filename , $ backgroudColor ) ; $ drawException = null ; if ( isset ( $ this -> format ) and ! in_array ( strtoupper ( $ this -...
Render barcode as base64 encoded
863
private function _getFormat ( ) { $ format = '' ; switch ( strtoupper ( $ this -> format ) ) { case 'PNG' : $ format = CINDrawing :: IMG_FORMAT_PNG ; break ; case 'JPEG' : $ format = CINDrawing :: IMG_FORMAT_JPEG ; break ; case 'GIF' : $ format = CINDrawing :: IMG_FORMAT_GIF ; break ; case 'WBMP' : $ format = CINDrawin...
Barcode image format
864
public function draw ( ) { ob_start ( ) ; imagejpeg ( $ this -> im , null , $ this -> quality ) ; $ bin = ob_get_contents ( ) ; ob_end_clean ( ) ; $ this -> setInternalProperties ( $ bin ) ; if ( empty ( $ this -> filename ) ) { echo $ bin ; } else { file_put_contents ( $ this -> filename , $ bin ) ; } }
Draws the JPG on the screen or in a file .
865
protected function drawBars ( $ im ) { $ this -> calculateChecksum ( ) ; $ temp_text = $ this -> text . $ this -> keys [ $ this -> checksumValue ] ; $ this -> drawChar ( $ im , '000' , true ) ; $ this -> drawChar ( $ im , $ this -> findCode ( $ temp_text [ 1 ] ) , false ) ; for ( $ i = 0 ; $ i < 5 ; $ i ++ ) { $ this -...
Draws the bars
866
public function setChecksum ( $ checksum ) { $ checksum = intval ( $ checksum ) ; if ( $ checksum < 0 && $ checksum > 2 ) { throw new CINArgumentException ( 'The checksum must be between 0 and 2 included.' , 'checksum' ) ; } $ this -> checksum = $ checksum ; }
Sets how many checksums we display . 0 to 2 .
867
public function parse ( $ text ) { $ parsedText = $ this -> parseGs1128 ( $ text ) ; if ( $ this -> customLabelText !== false and CINBarcode1D :: AUTO_LABEL != $ this -> customLabelText ) { parent :: setLabel ( $ this -> customLabelText ) ; } parent :: parse ( $ parsedText ) ; }
Parses Text .
868
private function formatGs1128 ( ) { $ formatedText = '~F1' ; $ formatedLabel = '' ; $ c = count ( $ this -> identifiersId ) ; for ( $ i = 0 ; $ i < $ c ; $ i ++ ) { if ( $ i > 0 ) { $ formatedLabel .= ' ' ; } if ( $ this -> identifiersId [ $ i ] !== null ) { $ formatedLabel .= '(' . $ this -> identifiersId [ $ i ] . ')...
Formats data for gs1 - 128 .
869
private function parseGs1128 ( $ text ) { if ( is_array ( $ text ) ) { $ formatArray = array ( ) ; foreach ( $ text as $ content ) { if ( is_array ( $ content ) ) { if ( count ( $ content ) === 2 ) { if ( is_array ( $ content [ self :: ID ] ) || is_array ( $ content [ self :: CONTENT ] ) ) { throw new CINParseException...
Parses the text to gs1 - 128 .
870
private function idExists ( $ id , & $ yAlreadySet , & $ realNameId ) { $ yFound = isset ( $ id [ 3 ] ) && $ id [ 3 ] === 'y' ; $ idVarAdded = substr ( $ id , 0 , - 1 ) . 'y' ; if ( isset ( $ this -> identifiersAi [ $ id ] ) ) { if ( $ yFound ) { $ yAlreadySet = false ; } $ realNameId = $ id ; return true ; } elseif ( ...
Checks if an id exists .
871
private function findIdFormated ( $ id , & $ yAlreadySet , & $ realNameId ) { $ pos = strpos ( $ id , ')' ) ; if ( $ pos === false ) { throw new CINParseException ( 'gs1128' , 'Identifiers must have no more than 4 characters.' ) ; } else { if ( $ pos < 3 ) { throw new CINParseException ( 'gs1128' , 'Identifiers must ha...
Finds ID with formated content .
872
private function findIdNotFormated ( $ id , & $ yAlreadySet , & $ realNameId ) { $ tofind = $ id ; while ( strlen ( $ tofind ) >= 2 ) { if ( $ this -> idExists ( $ tofind , $ yAlreadySet , $ realNameId ) ) { return $ tofind ; } else { $ tofind = substr ( $ tofind , 0 , - 1 ) ; } } if ( $ this -> allowsUnknownIdentifier...
Finds ID with non - formated content .
873
private function checkConformity ( & $ content , $ id , $ realNameId ) { switch ( $ this -> identifiersAi [ $ realNameId ] [ self :: KIND_OF_DATA ] ) { case self :: NUMERIC : $ content = str_replace ( ',' , '.' , $ content ) ; if ( ! preg_match ( "/^[0-9.]+$/" , $ content ) ) { throw new CINParseException ( 'gs1128' , ...
Checks confirmity of the content .
874
private function checkChecksum ( & $ content , $ id , $ realNameId , & $ checksumAdded ) { if ( $ this -> identifiersAi [ $ realNameId ] [ self :: CHECKSUM ] ) { $ nbCharContent = strlen ( $ content ) ; $ minlengthContent = $ this -> identifiersAi [ $ realNameId ] [ self :: MINLENGTH ] ; if ( $ nbCharContent === ( $ mi...
Verifies the checksum .
875
private function checkVars ( & $ content , & $ id , $ yAlreadySet , & $ decimalPointRemoved ) { $ nbCharContent = strlen ( $ content ) ; if ( $ yAlreadySet ) { if ( strpos ( $ content , '.' ) !== false ) { throw new CINParseException ( 'gs1128' , 'If you do not use any "y" variable, you have to insert a whole number.' ...
Checks vars y .
876
private static function calculateChecksumMod10 ( $ content ) { $ odd = true ; $ checksumValue = 0 ; $ c = strlen ( $ content ) ; for ( $ i = $ c ; $ i > 0 ; $ i -- ) { if ( $ odd === true ) { $ multiplier = 3 ; $ odd = false ; } else { $ multiplier = 1 ; $ odd = true ; } $ checksumValue += ( $ content [ $ i - 1 ] * $ m...
Checksum Mod10 .
877
protected function validateConfig ( $ key , $ algo , $ maxAge , $ leeway ) { if ( empty ( $ key ) ) { throw new JWTException ( 'Signing key cannot be empty' , static :: ERROR_KEY_EMPTY ) ; } if ( ! isset ( $ this -> algos [ $ algo ] ) ) { throw new JWTException ( 'Unsupported algo ' . $ algo , static :: ERROR_ALGO_UNSU...
Throw up if input parameters invalid .
878
protected function validateHeader ( array $ header ) { if ( empty ( $ header [ 'alg' ] ) ) { throw new JWTException ( 'Invalid token: Missing header algo' , static :: ERROR_ALGO_MISSING ) ; } if ( empty ( $ this -> algos [ $ header [ 'alg' ] ] ) ) { throw new JWTException ( 'Invalid token: Unsupported header algo' , st...
Throw up if header invalid .
879
protected function validateKid ( array $ header ) { if ( ! isset ( $ header [ 'kid' ] ) ) { return ; } if ( empty ( $ this -> keys [ $ header [ 'kid' ] ] ) ) { throw new JWTException ( 'Invalid token: Unknown key ID' , static :: ERROR_KID_UNKNOWN ) ; } $ this -> key = $ this -> keys [ $ header [ 'kid' ] ] ; }
Throw up if kid exists and invalid .
880
protected function validateTimestamps ( array $ payload ) { $ timestamp = $ this -> timestamp ? : \ time ( ) ; $ checks = [ [ 'exp' , $ this -> leeway , static :: ERROR_TOKEN_EXPIRED , 'Expired' ] , [ 'iat' , $ this -> maxAge - $ this -> leeway , static :: ERROR_TOKEN_EXPIRED , 'Expired' ] , [ 'nbf' , $ this -> maxAge ...
Throw up if timestamp claims like iat exp nbf are invalid .
881
protected function validateKey ( ) { if ( \ is_string ( $ key = $ this -> key ) ) { if ( \ substr ( $ key , 0 , 7 ) !== 'file://' ) { $ key = 'file://' . $ key ; } $ this -> key = \ openssl_get_privatekey ( $ key , $ this -> passphrase ? : '' ) ; } if ( ! \ is_resource ( $ this -> key ) ) { throw new JWTException ( 'In...
Throw up if key is not resource or file path to private key .
882
public function encode ( array $ payload , array $ header = [ ] ) { $ header = [ 'typ' => 'JWT' , 'alg' => $ this -> algo ] + $ header ; $ this -> validateKid ( $ header ) ; if ( ! isset ( $ payload [ 'iat' ] ) && ! isset ( $ payload [ 'exp' ] ) ) { $ payload [ 'exp' ] = ( $ this -> timestamp ? : \ time ( ) ) + $ this ...
Encode payload as JWT token .
883
public function decode ( $ token ) { if ( \ substr_count ( $ token , '.' ) < 2 ) { throw new JWTException ( 'Invalid token: Incomplete segments' , static :: ERROR_TOKEN_INVALID ) ; } $ token = \ explode ( '.' , $ token , 3 ) ; $ this -> validateHeader ( ( array ) $ this -> urlSafeDecode ( $ token [ 0 ] ) ) ; if ( ! $ t...
Decode JWT token and return original payload .
884
protected function sign ( $ input ) { if ( \ substr ( $ this -> algo , 0 , 2 ) === 'HS' ) { return \ hash_hmac ( $ this -> algos [ $ this -> algo ] , $ input , $ this -> key , true ) ; } $ this -> validateKey ( ) ; \ openssl_sign ( $ input , $ signature , $ this -> key , $ this -> algos [ $ this -> algo ] ) ; return $ ...
Sign the input with configured key and return the signature .
885
protected function verify ( $ input , $ signature ) { $ algo = $ this -> algos [ $ this -> algo ] ; if ( \ substr ( $ this -> algo , 0 , 2 ) === 'HS' ) { return \ hash_equals ( $ this -> urlSafeEncode ( \ hash_hmac ( $ algo , $ input , $ this -> key , true ) ) , $ signature ) ; } $ this -> validateKey ( ) ; $ pubKey = ...
Verify the signature of given input .
886
protected function urlSafeEncode ( $ data ) { if ( \ is_array ( $ data ) ) { $ data = \ json_encode ( $ data , \ JSON_UNESCAPED_SLASHES ) ; $ this -> validateLastJson ( ) ; } return \ rtrim ( \ strtr ( \ base64_encode ( $ data ) , '+/' , '-_' ) , '=' ) ; }
URL safe base64 encode .
887
protected function urlSafeDecode ( $ data , $ asJson = true ) { if ( ! $ asJson ) { return \ base64_decode ( \ strtr ( $ data , '-_' , '+/' ) ) ; } $ data = \ json_decode ( \ base64_decode ( \ strtr ( $ data , '-_' , '+/' ) ) ) ; $ this -> validateLastJson ( ) ; return $ data ; }
URL safe base64 decode .
888
public function preValidate ( ) : bool { $ this -> errors = [ ] ; if ( ! \ is_array ( $ this -> parsedfile ) ) { $ this -> errors [ ] = 'Incorrect format parsed file' ; return false ; } $ r = $ this -> readUNHmessageNumber ( ) ; if ( ! $ r && isset ( $ this -> errors [ 0 ] ) && $ this -> errors [ 0 ] == 'Segment "UNH" ...
Do initial validation
889
public static function splitMultiMessage ( string $ ediMessage ) : array { $ splicedMessages = [ ] ; $ message = [ ] ; $ unb = false ; foreach ( self :: unwrap ( $ ediMessage ) as $ segment ) { if ( \ strpos ( $ segment , 'UNB' ) === 0 ) { $ unb = $ segment ; continue ; } if ( \ strpos ( $ segment , 'UNH' ) === 0 ) { i...
Split multi messages to separate messages
890
public function readEdiDataValueReq ( $ filter , int $ l1 , $ l2 = false ) : string { return $ this -> readEdiDataValue ( $ filter , $ l1 , $ l2 , true ) ; }
read required value . if no found registered error
891
public function readEdiSegmentDTM ( $ PeriodQualifier ) { $ date = $ this -> readEdiDataValue ( [ 'DTM' , [ '1.0' => $ PeriodQualifier ] ] , 1 , 1 ) ; $ format = $ this -> readEdiDataValue ( [ 'DTM' , [ '1.0' => $ PeriodQualifier ] ] , 1 , 2 ) ; if ( empty ( $ date ) ) { return $ date ; } switch ( $ format ) { case 203...
read date from DTM segment period qualifier - codelist 2005
892
public function readUNBDateTimeOfPreparation ( ) { $ date = $ this -> readEdiDataValue ( 'UNB' , 4 , 0 ) ; if ( ! empty ( $ date ) ) { $ time = $ this -> readEdiDataValue ( 'UNB' , 4 , 1 ) ; $ datetime = \ preg_replace ( '#(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)#' , '20$1-$2-$3 $4:$5:00' , $ date . $ time ) ; return $ datetime ...
get message preparation time
893
public function readTDTtransportIdentification ( $ transportStageQualifier ) : string { $ transportIdentification = $ this -> readEdiDataValue ( [ 'TDT' , [ '1' => $ transportStageQualifier ] ] , 8 , 0 ) ; if ( ! empty ( $ transportIdentification ) ) { return $ transportIdentification ; } return $ this -> readEdiDataVa...
read transport identification number
894
public function readGroups ( string $ before , string $ start , string $ end , string $ after ) { $ groups = [ ] ; $ group = [ ] ; $ position = 'before_search' ; foreach ( $ this -> parsedfile as $ edi_row ) { if ( $ position == 'before_search' && $ edi_row [ 0 ] == $ before ) { $ position = 'before_is' ; continue ; } ...
Get groups from message .
895
public function groupsExtract ( string $ start = 'LIN' , array $ barrier = [ 'UNS' ] ) : array { $ groups = [ ] ; $ group = [ ] ; $ position = 'before_search' ; foreach ( $ this -> getParsedFile ( ) as $ edi_row ) { $ segment = $ edi_row [ 0 ] ; if ( $ position == 'group_is' && ( $ segment == $ start || \ in_array ( $ ...
Get groups from message when last segment is unknown but you know the barrier useful for invoices by default .
896
public function parse ( array & $ file2 ) : array { $ i = 0 ; foreach ( $ file2 as & $ line ) { ++ $ i ; $ line = str_replace ( [ "\x00" , "\r" , "\n" ] , '' , $ line ) ; $ lineTrim = \ trim ( $ line ) ; $ line = \ preg_replace ( $ this -> stripChars , '' , $ lineTrim ) ; $ line_bytes = \ strlen ( $ line ) ; if ( $ lin...
Parse edi array
897
public function analyseUNA ( string $ line ) { $ line = \ substr ( $ line , 0 , 6 ) ; if ( isset ( $ line [ 0 ] ) ) { $ this -> sepComp = \ preg_quote ( $ line [ 0 ] , self :: $ DELIMITER ) ; $ this -> sepUnescapedComp = $ line [ 0 ] ; if ( isset ( $ line [ 1 ] ) ) { $ this -> sepData = \ preg_quote ( $ line [ 1 ] , se...
Read UNA s characters definition
898
public function analyseUNB ( $ encoding ) { if ( \ is_array ( $ encoding ) ) { $ encoding = $ encoding [ 0 ] ; } $ this -> encoding = $ encoding ; if ( isset ( self :: $ encodingToStripChars [ $ encoding ] ) ) { $ this -> setStripRegex ( self :: $ encodingToStripChars [ $ encoding ] ) ; } $ this -> unbChecked = true ; ...
UNB line analysis
899
public function analyseUNH ( array $ line ) { if ( \ count ( $ line ) < 3 ) { return ; } $ lineElement = $ line [ 2 ] ; if ( ! \ is_array ( $ lineElement ) ) { $ this -> messageFormat = $ lineElement ; return ; } $ this -> messageFormat = $ lineElement [ 0 ] ; $ this -> messageDirectory = $ lineElement [ 2 ] ; }
Identify message type