Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like QRcode often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use QRcode, and based on these observations, apply Extract Interface, too.
| 1 | <?php  | 
            ||
| 291 | class QRcode { | 
            ||
| 292 | |||
| 293 | /**  | 
            ||
| 294 | * Barcode array to be returned which is readable by TCPDF.  | 
            ||
| 295 | * @protected  | 
            ||
| 296 | */  | 
            ||
| 297 | protected $barcode_array = array();  | 
            ||
| 298 | |||
| 299 | /**  | 
            ||
| 300 | * QR code version. Size of QRcode is defined as version. Version is from 1 to 40. Version 1 is 21*21 matrix. And 4 modules increases whenever 1 version increases. So version 40 is 177*177 matrix.  | 
            ||
| 301 | * @protected  | 
            ||
| 302 | */  | 
            ||
| 303 | protected $version = 0;  | 
            ||
| 304 | |||
| 305 | /**  | 
            ||
| 306 | * Levels of error correction. See definitions for possible values.  | 
            ||
| 307 | * @protected  | 
            ||
| 308 | */  | 
            ||
| 309 | protected $level = QR_ECLEVEL_L;  | 
            ||
| 310 | |||
| 311 | /**  | 
            ||
| 312 | * Encoding mode.  | 
            ||
| 313 | * @protected  | 
            ||
| 314 | */  | 
            ||
| 315 | protected $hint = QR_MODE_8B;  | 
            ||
| 316 | |||
| 317 | /**  | 
            ||
| 318 | * Boolean flag, if true the input string will be converted to uppercase.  | 
            ||
| 319 | * @protected  | 
            ||
| 320 | */  | 
            ||
| 321 | protected $casesensitive = true;  | 
            ||
| 322 | |||
| 323 | /**  | 
            ||
| 324 | * Structured QR code (not supported yet).  | 
            ||
| 325 | * @protected  | 
            ||
| 326 | */  | 
            ||
| 327 | protected $structured = 0;  | 
            ||
| 328 | |||
| 329 | /**  | 
            ||
| 330 | * Mask data.  | 
            ||
| 331 | * @protected  | 
            ||
| 332 | */  | 
            ||
| 333 | protected $data;  | 
            ||
| 334 | |||
| 335 | // FrameFiller  | 
            ||
| 336 | |||
| 337 | /**  | 
            ||
| 338 | * Width.  | 
            ||
| 339 | * @protected  | 
            ||
| 340 | */  | 
            ||
| 341 | protected $width;  | 
            ||
| 342 | |||
| 343 | /**  | 
            ||
| 344 | * Frame.  | 
            ||
| 345 | * @protected  | 
            ||
| 346 | */  | 
            ||
| 347 | protected $frame;  | 
            ||
| 348 | |||
| 349 | /**  | 
            ||
| 350 | * X position of bit.  | 
            ||
| 351 | * @protected  | 
            ||
| 352 | */  | 
            ||
| 353 | protected $x;  | 
            ||
| 354 | |||
| 355 | /**  | 
            ||
| 356 | * Y position of bit.  | 
            ||
| 357 | * @protected  | 
            ||
| 358 | */  | 
            ||
| 359 | protected $y;  | 
            ||
| 360 | |||
| 361 | /**  | 
            ||
| 362 | * Direction.  | 
            ||
| 363 | * @protected  | 
            ||
| 364 | */  | 
            ||
| 365 | protected $dir;  | 
            ||
| 366 | |||
| 367 | /**  | 
            ||
| 368 | * Single bit value.  | 
            ||
| 369 | * @protected  | 
            ||
| 370 | */  | 
            ||
| 371 | protected $bit;  | 
            ||
| 372 | |||
| 373 | // ---- QRrawcode ----  | 
            ||
| 374 | |||
| 375 | /**  | 
            ||
| 376 | * Data code.  | 
            ||
| 377 | * @protected  | 
            ||
| 378 | */  | 
            ||
| 379 | protected $datacode = array();  | 
            ||
| 380 | |||
| 381 | /**  | 
            ||
| 382 | * Error correction code.  | 
            ||
| 383 | * @protected  | 
            ||
| 384 | */  | 
            ||
| 385 | protected $ecccode = array();  | 
            ||
| 386 | |||
| 387 | /**  | 
            ||
| 388 | * Blocks.  | 
            ||
| 389 | * @protected  | 
            ||
| 390 | */  | 
            ||
| 391 | protected $blocks;  | 
            ||
| 392 | |||
| 393 | /**  | 
            ||
| 394 | * Reed-Solomon blocks.  | 
            ||
| 395 | * @protected  | 
            ||
| 396 | */  | 
            ||
| 397 | protected $rsblocks = array(); //of RSblock  | 
            ||
| 398 | |||
| 399 | /**  | 
            ||
| 400 | * Counter.  | 
            ||
| 401 | * @protected  | 
            ||
| 402 | */  | 
            ||
| 403 | protected $count;  | 
            ||
| 404 | |||
| 405 | /**  | 
            ||
| 406 | * Data length.  | 
            ||
| 407 | * @protected  | 
            ||
| 408 | */  | 
            ||
| 409 | protected $dataLength;  | 
            ||
| 410 | |||
| 411 | /**  | 
            ||
| 412 | * Error correction length.  | 
            ||
| 413 | * @protected  | 
            ||
| 414 | */  | 
            ||
| 415 | protected $eccLength;  | 
            ||
| 416 | |||
| 417 | /**  | 
            ||
| 418 | * Value b1.  | 
            ||
| 419 | * @protected  | 
            ||
| 420 | */  | 
            ||
| 421 | protected $b1;  | 
            ||
| 422 | |||
| 423 | // ---- QRmask ----  | 
            ||
| 424 | |||
| 425 | /**  | 
            ||
| 426 | * Run length.  | 
            ||
| 427 | * @protected  | 
            ||
| 428 | */  | 
            ||
| 429 | protected $runLength = array();  | 
            ||
| 430 | |||
| 431 | // ---- QRsplit ----  | 
            ||
| 432 | |||
| 433 | /**  | 
            ||
| 434 | * Input data string.  | 
            ||
| 435 | * @protected  | 
            ||
| 436 | */  | 
            ||
| 437 | protected $dataStr = '';  | 
            ||
| 438 | |||
| 439 | /**  | 
            ||
| 440 | * Input items.  | 
            ||
| 441 | * @protected  | 
            ||
| 442 | */  | 
            ||
| 443 | protected $items;  | 
            ||
| 444 | |||
| 445 | // Reed-Solomon items  | 
            ||
| 446 | |||
| 447 | /**  | 
            ||
| 448 | * Reed-Solomon items.  | 
            ||
| 449 | * @protected  | 
            ||
| 450 | */  | 
            ||
| 451 | protected $rsitems = array();  | 
            ||
| 452 | |||
| 453 | /**  | 
            ||
| 454 | * Array of frames.  | 
            ||
| 455 | * @protected  | 
            ||
| 456 | */  | 
            ||
| 457 | protected $frames = array();  | 
            ||
| 458 | |||
| 459 | /**  | 
            ||
| 460 | * Alphabet-numeric convesion table.  | 
            ||
| 461 | * @protected  | 
            ||
| 462 | */  | 
            ||
| 463 | protected $anTable = array(  | 
            ||
| 464 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //  | 
            ||
| 465 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //  | 
            ||
| 466 | 36, -1, -1, -1, 37, 38, -1, -1, -1, -1, 39, 40, -1, 41, 42, 43, //  | 
            ||
| 467 | 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 44, -1, -1, -1, -1, -1, //  | 
            ||
| 468 | -1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, //  | 
            ||
| 469 | 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, //  | 
            ||
| 470 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, //  | 
            ||
| 471 | -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 //  | 
            ||
| 472 | );  | 
            ||
| 473 | |||
| 474 | /**  | 
            ||
| 475 | * Array Table of the capacity of symbols.  | 
            ||
| 476 | * See Table 1 (pp.13) and Table 12-16 (pp.30-36), JIS X0510:2004.  | 
            ||
| 477 | * @protected  | 
            ||
| 478 | */  | 
            ||
| 479 | protected $capacity = array(  | 
            ||
| 480 | array( 0, 0, 0, array( 0, 0, 0, 0)), //  | 
            ||
| 481 | array( 21, 26, 0, array( 7, 10, 13, 17)), // 1  | 
            ||
| 482 | array( 25, 44, 7, array( 10, 16, 22, 28)), //  | 
            ||
| 483 | array( 29, 70, 7, array( 15, 26, 36, 44)), //  | 
            ||
| 484 | array( 33, 100, 7, array( 20, 36, 52, 64)), //  | 
            ||
| 485 | array( 37, 134, 7, array( 26, 48, 72, 88)), // 5  | 
            ||
| 486 | array( 41, 172, 7, array( 36, 64, 96, 112)), //  | 
            ||
| 487 | array( 45, 196, 0, array( 40, 72, 108, 130)), //  | 
            ||
| 488 | array( 49, 242, 0, array( 48, 88, 132, 156)), //  | 
            ||
| 489 | array( 53, 292, 0, array( 60, 110, 160, 192)), //  | 
            ||
| 490 | array( 57, 346, 0, array( 72, 130, 192, 224)), // 10  | 
            ||
| 491 | array( 61, 404, 0, array( 80, 150, 224, 264)), //  | 
            ||
| 492 | array( 65, 466, 0, array( 96, 176, 260, 308)), //  | 
            ||
| 493 | array( 69, 532, 0, array( 104, 198, 288, 352)), //  | 
            ||
| 494 | array( 73, 581, 3, array( 120, 216, 320, 384)), //  | 
            ||
| 495 | array( 77, 655, 3, array( 132, 240, 360, 432)), // 15  | 
            ||
| 496 | array( 81, 733, 3, array( 144, 280, 408, 480)), //  | 
            ||
| 497 | array( 85, 815, 3, array( 168, 308, 448, 532)), //  | 
            ||
| 498 | array( 89, 901, 3, array( 180, 338, 504, 588)), //  | 
            ||
| 499 | array( 93, 991, 3, array( 196, 364, 546, 650)), //  | 
            ||
| 500 | array( 97, 1085, 3, array( 224, 416, 600, 700)), // 20  | 
            ||
| 501 | array(101, 1156, 4, array( 224, 442, 644, 750)), //  | 
            ||
| 502 | array(105, 1258, 4, array( 252, 476, 690, 816)), //  | 
            ||
| 503 | array(109, 1364, 4, array( 270, 504, 750, 900)), //  | 
            ||
| 504 | array(113, 1474, 4, array( 300, 560, 810, 960)), //  | 
            ||
| 505 | array(117, 1588, 4, array( 312, 588, 870, 1050)), // 25  | 
            ||
| 506 | array(121, 1706, 4, array( 336, 644, 952, 1110)), //  | 
            ||
| 507 | array(125, 1828, 4, array( 360, 700, 1020, 1200)), //  | 
            ||
| 508 | array(129, 1921, 3, array( 390, 728, 1050, 1260)), //  | 
            ||
| 509 | array(133, 2051, 3, array( 420, 784, 1140, 1350)), //  | 
            ||
| 510 | array(137, 2185, 3, array( 450, 812, 1200, 1440)), // 30  | 
            ||
| 511 | array(141, 2323, 3, array( 480, 868, 1290, 1530)), //  | 
            ||
| 512 | array(145, 2465, 3, array( 510, 924, 1350, 1620)), //  | 
            ||
| 513 | array(149, 2611, 3, array( 540, 980, 1440, 1710)), //  | 
            ||
| 514 | array(153, 2761, 3, array( 570, 1036, 1530, 1800)), //  | 
            ||
| 515 | array(157, 2876, 0, array( 570, 1064, 1590, 1890)), // 35  | 
            ||
| 516 | array(161, 3034, 0, array( 600, 1120, 1680, 1980)), //  | 
            ||
| 517 | array(165, 3196, 0, array( 630, 1204, 1770, 2100)), //  | 
            ||
| 518 | array(169, 3362, 0, array( 660, 1260, 1860, 2220)), //  | 
            ||
| 519 | array(173, 3532, 0, array( 720, 1316, 1950, 2310)), //  | 
            ||
| 520 | array(177, 3706, 0, array( 750, 1372, 2040, 2430)) // 40  | 
            ||
| 521 | );  | 
            ||
| 522 | |||
| 523 | /**  | 
            ||
| 524 | * Array Length indicator.  | 
            ||
| 525 | * @protected  | 
            ||
| 526 | */  | 
            ||
| 527 | protected $lengthTableBits = array(  | 
            ||
| 528 | array(10, 12, 14),  | 
            ||
| 529 | array( 9, 11, 13),  | 
            ||
| 530 | array( 8, 16, 16),  | 
            ||
| 531 | array( 8, 10, 12)  | 
            ||
| 532 | );  | 
            ||
| 533 | |||
| 534 | /**  | 
            ||
| 535 | * Array Table of the error correction code (Reed-Solomon block).  | 
            ||
| 536 | * See Table 12-16 (pp.30-36), JIS X0510:2004.  | 
            ||
| 537 | * @protected  | 
            ||
| 538 | */  | 
            ||
| 539 | protected $eccTable = array(  | 
            ||
| 540 | array(array( 0, 0), array( 0, 0), array( 0, 0), array( 0, 0)), //  | 
            ||
| 541 | array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), // 1  | 
            ||
| 542 | array(array( 1, 0), array( 1, 0), array( 1, 0), array( 1, 0)), //  | 
            ||
| 543 | array(array( 1, 0), array( 1, 0), array( 2, 0), array( 2, 0)), //  | 
            ||
| 544 | array(array( 1, 0), array( 2, 0), array( 2, 0), array( 4, 0)), //  | 
            ||
| 545 | array(array( 1, 0), array( 2, 0), array( 2, 2), array( 2, 2)), // 5  | 
            ||
| 546 | array(array( 2, 0), array( 4, 0), array( 4, 0), array( 4, 0)), //  | 
            ||
| 547 | array(array( 2, 0), array( 4, 0), array( 2, 4), array( 4, 1)), //  | 
            ||
| 548 | array(array( 2, 0), array( 2, 2), array( 4, 2), array( 4, 2)), //  | 
            ||
| 549 | array(array( 2, 0), array( 3, 2), array( 4, 4), array( 4, 4)), //  | 
            ||
| 550 | array(array( 2, 2), array( 4, 1), array( 6, 2), array( 6, 2)), // 10  | 
            ||
| 551 | array(array( 4, 0), array( 1, 4), array( 4, 4), array( 3, 8)), //  | 
            ||
| 552 | array(array( 2, 2), array( 6, 2), array( 4, 6), array( 7, 4)), //  | 
            ||
| 553 | array(array( 4, 0), array( 8, 1), array( 8, 4), array(12, 4)), //  | 
            ||
| 554 | array(array( 3, 1), array( 4, 5), array(11, 5), array(11, 5)), //  | 
            ||
| 555 | array(array( 5, 1), array( 5, 5), array( 5, 7), array(11, 7)), // 15  | 
            ||
| 556 | array(array( 5, 1), array( 7, 3), array(15, 2), array( 3, 13)), //  | 
            ||
| 557 | array(array( 1, 5), array(10, 1), array( 1, 15), array( 2, 17)), //  | 
            ||
| 558 | array(array( 5, 1), array( 9, 4), array(17, 1), array( 2, 19)), //  | 
            ||
| 559 | array(array( 3, 4), array( 3, 11), array(17, 4), array( 9, 16)), //  | 
            ||
| 560 | array(array( 3, 5), array( 3, 13), array(15, 5), array(15, 10)), // 20  | 
            ||
| 561 | array(array( 4, 4), array(17, 0), array(17, 6), array(19, 6)), //  | 
            ||
| 562 | array(array( 2, 7), array(17, 0), array( 7, 16), array(34, 0)), //  | 
            ||
| 563 | array(array( 4, 5), array( 4, 14), array(11, 14), array(16, 14)), //  | 
            ||
| 564 | array(array( 6, 4), array( 6, 14), array(11, 16), array(30, 2)), //  | 
            ||
| 565 | array(array( 8, 4), array( 8, 13), array( 7, 22), array(22, 13)), // 25  | 
            ||
| 566 | array(array(10, 2), array(19, 4), array(28, 6), array(33, 4)), //  | 
            ||
| 567 | array(array( 8, 4), array(22, 3), array( 8, 26), array(12, 28)), //  | 
            ||
| 568 | array(array( 3, 10), array( 3, 23), array( 4, 31), array(11, 31)), //  | 
            ||
| 569 | array(array( 7, 7), array(21, 7), array( 1, 37), array(19, 26)), //  | 
            ||
| 570 | array(array( 5, 10), array(19, 10), array(15, 25), array(23, 25)), // 30  | 
            ||
| 571 | array(array(13, 3), array( 2, 29), array(42, 1), array(23, 28)), //  | 
            ||
| 572 | array(array(17, 0), array(10, 23), array(10, 35), array(19, 35)), //  | 
            ||
| 573 | array(array(17, 1), array(14, 21), array(29, 19), array(11, 46)), //  | 
            ||
| 574 | array(array(13, 6), array(14, 23), array(44, 7), array(59, 1)), //  | 
            ||
| 575 | array(array(12, 7), array(12, 26), array(39, 14), array(22, 41)), // 35  | 
            ||
| 576 | array(array( 6, 14), array( 6, 34), array(46, 10), array( 2, 64)), //  | 
            ||
| 577 | array(array(17, 4), array(29, 14), array(49, 10), array(24, 46)), //  | 
            ||
| 578 | array(array( 4, 18), array(13, 32), array(48, 14), array(42, 32)), //  | 
            ||
| 579 | array(array(20, 4), array(40, 7), array(43, 22), array(10, 67)), //  | 
            ||
| 580 | array(array(19, 6), array(18, 31), array(34, 34), array(20, 61)) // 40  | 
            ||
| 581 | );  | 
            ||
| 582 | |||
| 583 | /**  | 
            ||
| 584 | * Array Positions of alignment patterns.  | 
            ||
| 585 | * This array includes only the second and the third position of the alignment patterns. Rest of them can be calculated from the distance between them.  | 
            ||
| 586 | * See Table 1 in Appendix E (pp.71) of JIS X0510:2004.  | 
            ||
| 587 | * @protected  | 
            ||
| 588 | */  | 
            ||
| 589 | protected $alignmentPattern = array(  | 
            ||
| 590 | array( 0, 0),  | 
            ||
| 591 | array( 0, 0), array(18, 0), array(22, 0), array(26, 0), array(30, 0), // 1- 5  | 
            ||
| 592 | array(34, 0), array(22, 38), array(24, 42), array(26, 46), array(28, 50), // 6-10  | 
            ||
| 593 | array(30, 54), array(32, 58), array(34, 62), array(26, 46), array(26, 48), // 11-15  | 
            ||
| 594 | array(26, 50), array(30, 54), array(30, 56), array(30, 58), array(34, 62), // 16-20  | 
            ||
| 595 | array(28, 50), array(26, 50), array(30, 54), array(28, 54), array(32, 58), // 21-25  | 
            ||
| 596 | array(30, 58), array(34, 62), array(26, 50), array(30, 54), array(26, 52), // 26-30  | 
            ||
| 597 | array(30, 56), array(34, 60), array(30, 58), array(34, 62), array(30, 54), // 31-35  | 
            ||
| 598 | array(24, 50), array(28, 54), array(32, 58), array(26, 54), array(30, 58) // 35-40  | 
            ||
| 599 | );  | 
            ||
| 600 | |||
| 601 | /**  | 
            ||
| 602 | * Array Version information pattern (BCH coded).  | 
            ||
| 603 | * See Table 1 in Appendix D (pp.68) of JIS X0510:2004.  | 
            ||
| 604 | * size: [QRSPEC_VERSION_MAX - 6]  | 
            ||
| 605 | * @protected  | 
            ||
| 606 | */  | 
            ||
| 607 | protected $versionPattern = array(  | 
            ||
| 608 | 0x07c94, 0x085bc, 0x09a99, 0x0a4d3, 0x0bbf6, 0x0c762, 0x0d847, 0x0e60d, //  | 
            ||
| 609 | 0x0f928, 0x10b78, 0x1145d, 0x12a17, 0x13532, 0x149a6, 0x15683, 0x168c9, //  | 
            ||
| 610 | 0x177ec, 0x18ec4, 0x191e1, 0x1afab, 0x1b08e, 0x1cc1a, 0x1d33f, 0x1ed75, //  | 
            ||
| 611 | 0x1f250, 0x209d5, 0x216f0, 0x228ba, 0x2379f, 0x24b0b, 0x2542e, 0x26a64, //  | 
            ||
| 612 | 0x27541, 0x28c69  | 
            ||
| 613 | );  | 
            ||
| 614 | |||
| 615 | /**  | 
            ||
| 616 | * Array Format information  | 
            ||
| 617 | * @protected  | 
            ||
| 618 | */  | 
            ||
| 619 | protected $formatInfo = array(  | 
            ||
| 620 | array(0x77c4, 0x72f3, 0x7daa, 0x789d, 0x662f, 0x6318, 0x6c41, 0x6976), //  | 
            ||
| 621 | array(0x5412, 0x5125, 0x5e7c, 0x5b4b, 0x45f9, 0x40ce, 0x4f97, 0x4aa0), //  | 
            ||
| 622 | array(0x355f, 0x3068, 0x3f31, 0x3a06, 0x24b4, 0x2183, 0x2eda, 0x2bed), //  | 
            ||
| 623 | array(0x1689, 0x13be, 0x1ce7, 0x19d0, 0x0762, 0x0255, 0x0d0c, 0x083b) //  | 
            ||
| 624 | );  | 
            ||
| 625 | |||
| 626 | |||
| 627 | // -------------------------------------------------  | 
            ||
| 628 | // -------------------------------------------------  | 
            ||
| 629 | |||
| 630 | |||
| 631 | /**  | 
            ||
| 632 | * This is the class constructor.  | 
            ||
| 633 | * Creates a QRcode object  | 
            ||
| 634 | * @param $code (string) code to represent using QRcode  | 
            ||
| 635 | * @param $eclevel (string) error level: <ul><li>L : About 7% or less errors can be corrected.</li><li>M : About 15% or less errors can be corrected.</li><li>Q : About 25% or less errors can be corrected.</li><li>H : About 30% or less errors can be corrected.</li></ul>  | 
            ||
| 636 | * @public  | 
            ||
| 637 | * @since 1.0.000  | 
            ||
| 638 | */  | 
            ||
| 639 | 	public function __construct($code, $eclevel = 'L') { | 
            ||
| 674 | |||
| 675 | /**  | 
            ||
| 676 | * Returns a barcode array which is readable by TCPDF  | 
            ||
| 677 | * @return array barcode array readable by TCPDF;  | 
            ||
| 678 | * @public  | 
            ||
| 679 | */  | 
            ||
| 680 | 	public function getBarcodeArray() { | 
            ||
| 683 | |||
| 684 | /**  | 
            ||
| 685 | * Convert the frame in binary form  | 
            ||
| 686 | * @param $frame (array) array to binarize  | 
            ||
| 687 | * @return array frame in binary form  | 
            ||
| 688 | */  | 
            ||
| 689 | 	protected function binarize($frame) { | 
            ||
| 699 | |||
| 700 | /**  | 
            ||
| 701 | * Encode the input string to QR code  | 
            ||
| 702 | * @param $string (string) input string to encode  | 
            ||
| 703 | */  | 
            ||
| 704 | 	protected function encodeString($string) { | 
            ||
| 715 | |||
| 716 | /**  | 
            ||
| 717 | * Encode mask  | 
            ||
| 718 | * @param $mask (int) masking mode  | 
            ||
| 719 | */  | 
            ||
| 720 | 	protected function encodeMask($mask) { | 
            ||
| 775 | |||
| 776 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 777 | |||
| 778 | // FrameFiller  | 
            ||
| 779 | |||
| 780 | /**  | 
            ||
| 781 | * Set frame value at specified position  | 
            ||
| 782 | * @param $at (array) x,y position  | 
            ||
| 783 | * @param $val (int) value of the character to set  | 
            ||
| 784 | */  | 
            ||
| 785 | 	protected function setFrameAt($at, $val) { | 
            ||
| 788 | |||
| 789 | /**  | 
            ||
| 790 | * Get frame value at specified position  | 
            ||
| 791 | * @param $at (array) x,y position  | 
            ||
| 792 | * @return value at specified position  | 
            ||
| 793 | */  | 
            ||
| 794 | 	protected function getFrameAt($at) { | 
            ||
| 797 | |||
| 798 | /**  | 
            ||
| 799 | * Return the next frame position  | 
            ||
| 800 | * @return array of x,y coordinates  | 
            ||
| 801 | */  | 
            ||
| 802 | 	protected function getNextPosition() { | 
            ||
| 848 | |||
| 849 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 850 | |||
| 851 | // QRrawcode  | 
            ||
| 852 | |||
| 853 | /**  | 
            ||
| 854 | * Initialize code.  | 
            ||
| 855 | * @param $spec (array) array of ECC specification  | 
            ||
| 856 | * @return 0 in case of success, -1 in case of error  | 
            ||
| 
                                                                                                    
                        
                         | 
                |||
| 857 | */  | 
            ||
| 858 | 	protected function init($spec) { | 
            ||
| 904 | |||
| 905 | /**  | 
            ||
| 906 | * Return Reed-Solomon block code.  | 
            ||
| 907 | * @return array rsblocks  | 
            ||
| 908 | */  | 
            ||
| 909 | 	protected function getCode() { | 
            ||
| 927 | |||
| 928 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 929 | |||
| 930 | // QRmask  | 
            ||
| 931 | |||
| 932 | /**  | 
            ||
| 933 | * Write Format Information on frame and returns the number of black bits  | 
            ||
| 934 | * @param $width (int) frame width  | 
            ||
| 935 | * @param $frame (array) frame  | 
            ||
| 936 | * @param $mask (array) masking mode  | 
            ||
| 937 | * @param $level (int) error correction level  | 
            ||
| 938 | * @return int blacks  | 
            ||
| 939 | */  | 
            ||
| 940 | 	 protected function writeFormatInformation($width, &$frame, $mask, $level) { | 
            ||
| 975 | |||
| 976 | /**  | 
            ||
| 977 | * mask0  | 
            ||
| 978 | * @param $x (int) X position  | 
            ||
| 979 | * @param $y (int) Y position  | 
            ||
| 980 | * @return int mask  | 
            ||
| 981 | */  | 
            ||
| 982 | 	 protected function mask0($x, $y) { | 
            ||
| 985 | |||
| 986 | /**  | 
            ||
| 987 | * mask1  | 
            ||
| 988 | * @param $x (int) X position  | 
            ||
| 989 | * @param $y (int) Y position  | 
            ||
| 990 | * @return int mask  | 
            ||
| 991 | */  | 
            ||
| 992 | 	 protected function mask1($x, $y) { | 
            ||
| 995 | |||
| 996 | /**  | 
            ||
| 997 | * mask2  | 
            ||
| 998 | * @param $x (int) X position  | 
            ||
| 999 | * @param $y (int) Y position  | 
            ||
| 1000 | * @return int mask  | 
            ||
| 1001 | */  | 
            ||
| 1002 | 	 protected function mask2($x, $y) { | 
            ||
| 1005 | |||
| 1006 | /**  | 
            ||
| 1007 | * mask3  | 
            ||
| 1008 | * @param $x (int) X position  | 
            ||
| 1009 | * @param $y (int) Y position  | 
            ||
| 1010 | * @return int mask  | 
            ||
| 1011 | */  | 
            ||
| 1012 | 	 protected function mask3($x, $y) { | 
            ||
| 1015 | |||
| 1016 | /**  | 
            ||
| 1017 | * mask4  | 
            ||
| 1018 | * @param $x (int) X position  | 
            ||
| 1019 | * @param $y (int) Y position  | 
            ||
| 1020 | * @return int mask  | 
            ||
| 1021 | */  | 
            ||
| 1022 | 	 protected function mask4($x, $y) { | 
            ||
| 1025 | |||
| 1026 | /**  | 
            ||
| 1027 | * mask5  | 
            ||
| 1028 | * @param $x (int) X position  | 
            ||
| 1029 | * @param $y (int) Y position  | 
            ||
| 1030 | * @return int mask  | 
            ||
| 1031 | */  | 
            ||
| 1032 | 	 protected function mask5($x, $y) { | 
            ||
| 1035 | |||
| 1036 | /**  | 
            ||
| 1037 | * mask6  | 
            ||
| 1038 | * @param $x (int) X position  | 
            ||
| 1039 | * @param $y (int) Y position  | 
            ||
| 1040 | * @return int mask  | 
            ||
| 1041 | */  | 
            ||
| 1042 | 	 protected function mask6($x, $y) { | 
            ||
| 1045 | |||
| 1046 | /**  | 
            ||
| 1047 | * mask7  | 
            ||
| 1048 | * @param $x (int) X position  | 
            ||
| 1049 | * @param $y (int) Y position  | 
            ||
| 1050 | * @return int mask  | 
            ||
| 1051 | */  | 
            ||
| 1052 | 	 protected function mask7($x, $y) { | 
            ||
| 1055 | |||
| 1056 | /**  | 
            ||
| 1057 | * Return bitmask  | 
            ||
| 1058 | * @param $maskNo (int) mask number  | 
            ||
| 1059 | * @param $width (int) width  | 
            ||
| 1060 | * @param $frame (array) frame  | 
            ||
| 1061 | * @return array bitmask  | 
            ||
| 1062 | */  | 
            ||
| 1063 | 	protected function generateMaskNo($maskNo, $width, $frame) { | 
            ||
| 1077 | |||
| 1078 | /**  | 
            ||
| 1079 | * makeMaskNo  | 
            ||
| 1080 | * @param $maskNo (int)  | 
            ||
| 1081 | * @param $width (int)  | 
            ||
| 1082 | * @param $s (int)  | 
            ||
| 1083 | * @param $d (int)  | 
            ||
| 1084 | * @param $maskGenOnly (boolean)  | 
            ||
| 1085 | * @return int b  | 
            ||
| 1086 | */  | 
            ||
| 1087 | 	 protected function makeMaskNo($maskNo, $width, $s, &$d, $maskGenOnly=false) { | 
            ||
| 1105 | |||
| 1106 | /**  | 
            ||
| 1107 | * makeMask  | 
            ||
| 1108 | * @param $width (int)  | 
            ||
| 1109 | * @param $frame (array)  | 
            ||
| 1110 | * @param $maskNo (int)  | 
            ||
| 1111 | * @param $level (int)  | 
            ||
| 1112 | * @return array mask  | 
            ||
| 1113 | */  | 
            ||
| 1114 | 	 protected function makeMask($width, $frame, $maskNo, $level) { | 
            ||
| 1120 | |||
| 1121 | /**  | 
            ||
| 1122 | * calcN1N3  | 
            ||
| 1123 | * @param $length (int)  | 
            ||
| 1124 | * @return int demerit  | 
            ||
| 1125 | */  | 
            ||
| 1126 | 	 protected function calcN1N3($length) { | 
            ||
| 1150 | |||
| 1151 | /**  | 
            ||
| 1152 | * evaluateSymbol  | 
            ||
| 1153 | * @param $width (int)  | 
            ||
| 1154 | * @param $frame (array)  | 
            ||
| 1155 | * @return int demerit  | 
            ||
| 1156 | */  | 
            ||
| 1157 | 	 protected function evaluateSymbol($width, $frame) { | 
            ||
| 1211 | |||
| 1212 | /**  | 
            ||
| 1213 | * mask  | 
            ||
| 1214 | * @param $width (int)  | 
            ||
| 1215 | * @param $frame (array)  | 
            ||
| 1216 | * @param $level (int)  | 
            ||
| 1217 | * @return array best mask  | 
            ||
| 1218 | */  | 
            ||
| 1219 | 	 protected function mask($width, $frame, $level) { | 
            ||
| 1250 | |||
| 1251 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 1252 | |||
| 1253 | // QRsplit  | 
            ||
| 1254 | |||
| 1255 | /**  | 
            ||
| 1256 | * Return true if the character at specified position is a number  | 
            ||
| 1257 | * @param $str (string) string  | 
            ||
| 1258 | * @param $pos (int) characted position  | 
            ||
| 1259 | * @return boolean true of false  | 
            ||
| 1260 | */  | 
            ||
| 1261 | 	 protected function isdigitat($str, $pos) { | 
            ||
| 1267 | |||
| 1268 | /**  | 
            ||
| 1269 | * Return true if the character at specified position is an alphanumeric character  | 
            ||
| 1270 | * @param $str (string) string  | 
            ||
| 1271 | * @param $pos (int) characted position  | 
            ||
| 1272 | * @return boolean true of false  | 
            ||
| 1273 | */  | 
            ||
| 1274 | 	 protected function isalnumat($str, $pos) { | 
            ||
| 1280 | |||
| 1281 | /**  | 
            ||
| 1282 | * identifyMode  | 
            ||
| 1283 | * @param $pos (int)  | 
            ||
| 1284 | * @return int mode  | 
            ||
| 1285 | */  | 
            ||
| 1286 | 	 protected function identifyMode($pos) { | 
            ||
| 1306 | |||
| 1307 | /**  | 
            ||
| 1308 | * eatNum  | 
            ||
| 1309 | * @return int run  | 
            ||
| 1310 | */  | 
            ||
| 1311 | 	 protected function eatNum() { | 
            ||
| 1338 | |||
| 1339 | /**  | 
            ||
| 1340 | * eatAn  | 
            ||
| 1341 | * @return int run  | 
            ||
| 1342 | */  | 
            ||
| 1343 | 	 protected function eatAn() { | 
            ||
| 1377 | |||
| 1378 | /**  | 
            ||
| 1379 | * eatKanji  | 
            ||
| 1380 | * @return int run  | 
            ||
| 1381 | */  | 
            ||
| 1382 | 	 protected function eatKanji() { | 
            ||
| 1390 | |||
| 1391 | /**  | 
            ||
| 1392 | * eat8  | 
            ||
| 1393 | * @return int run  | 
            ||
| 1394 | */  | 
            ||
| 1395 | 	 protected function eat8() { | 
            ||
| 1439 | |||
| 1440 | /**  | 
            ||
| 1441 | * splitString  | 
            ||
| 1442 | * @return (int)  | 
            ||
| 1443 | */  | 
            ||
| 1444 | 	 protected function splitString() { | 
            ||
| 1479 | |||
| 1480 | /**  | 
            ||
| 1481 | * toUpper  | 
            ||
| 1482 | */  | 
            ||
| 1483 | 	 protected function toUpper() { | 
            ||
| 1499 | |||
| 1500 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 1501 | |||
| 1502 | // QRinputItem  | 
            ||
| 1503 | |||
| 1504 | /**  | 
            ||
| 1505 | * newInputItem  | 
            ||
| 1506 | * @param $mode (int)  | 
            ||
| 1507 | * @param $size (int)  | 
            ||
| 1508 | * @param $data (array)  | 
            ||
| 1509 | * @param $bstream (array)  | 
            ||
| 1510 | * @return array input item  | 
            ||
| 1511 | */  | 
            ||
| 1512 | 	 protected function newInputItem($mode, $size, $data, $bstream=null) { | 
            ||
| 1527 | |||
| 1528 | /**  | 
            ||
| 1529 | * encodeModeNum  | 
            ||
| 1530 | * @param $inputitem (array)  | 
            ||
| 1531 | * @param $version (int)  | 
            ||
| 1532 | * @return array input item  | 
            ||
| 1533 | */  | 
            ||
| 1534 | 	 protected function encodeModeNum($inputitem, $version) { | 
            ||
| 1556 | |||
| 1557 | /**  | 
            ||
| 1558 | * encodeModeAn  | 
            ||
| 1559 | * @param $inputitem (array)  | 
            ||
| 1560 | * @param $version (int)  | 
            ||
| 1561 | * @return array input item  | 
            ||
| 1562 | */  | 
            ||
| 1563 | 	 protected function encodeModeAn($inputitem, $version) { | 
            ||
| 1579 | |||
| 1580 | /**  | 
            ||
| 1581 | * encodeMode8  | 
            ||
| 1582 | * @param $inputitem (array)  | 
            ||
| 1583 | * @param $version (int)  | 
            ||
| 1584 | * @return array input item  | 
            ||
| 1585 | */  | 
            ||
| 1586 | 	 protected function encodeMode8($inputitem, $version) { | 
            ||
| 1595 | |||
| 1596 | /**  | 
            ||
| 1597 | * encodeModeKanji  | 
            ||
| 1598 | * @param $inputitem (array)  | 
            ||
| 1599 | * @param $version (int)  | 
            ||
| 1600 | * @return array input item  | 
            ||
| 1601 | */  | 
            ||
| 1602 | 	 protected function encodeModeKanji($inputitem, $version) { | 
            ||
| 1619 | |||
| 1620 | /**  | 
            ||
| 1621 | * encodeModeStructure  | 
            ||
| 1622 | * @param $inputitem (array)  | 
            ||
| 1623 | * @return array input item  | 
            ||
| 1624 | */  | 
            ||
| 1625 | 	 protected function encodeModeStructure($inputitem) { | 
            ||
| 1633 | |||
| 1634 | /**  | 
            ||
| 1635 | * encodeBitStream  | 
            ||
| 1636 | * @param $inputitem (array)  | 
            ||
| 1637 | * @param $version (int)  | 
            ||
| 1638 | * @return array input item  | 
            ||
| 1639 | */  | 
            ||
| 1640 | 	 protected function encodeBitStream($inputitem, $version) { | 
            ||
| 1680 | |||
| 1681 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 1682 | |||
| 1683 | // QRinput  | 
            ||
| 1684 | |||
| 1685 | /**  | 
            ||
| 1686 | * Append data to an input object.  | 
            ||
| 1687 | * The data is copied and appended to the input object.  | 
            ||
| 1688 | * @param $items (arrray) input items  | 
            ||
| 1689 | * @param $mode (int) encoding mode.  | 
            ||
| 1690 | * @param $size (int) size of data (byte).  | 
            ||
| 1691 | * @param $data (array) array of input data.  | 
            ||
| 1692 | * @return items  | 
            ||
| 1693 | *  | 
            ||
| 1694 | */  | 
            ||
| 1695 | 	protected function appendNewInputItem($items, $mode, $size, $data) { | 
            ||
| 1702 | |||
| 1703 | /**  | 
            ||
| 1704 | * insertStructuredAppendHeader  | 
            ||
| 1705 | * @param $items (array)  | 
            ||
| 1706 | * @param $size (int)  | 
            ||
| 1707 | * @param $index (int)  | 
            ||
| 1708 | * @param $parity (int)  | 
            ||
| 1709 | * @return array items  | 
            ||
| 1710 | */  | 
            ||
| 1711 | 	 protected function insertStructuredAppendHeader($items, $size, $index, $parity) { | 
            ||
| 1723 | |||
| 1724 | /**  | 
            ||
| 1725 | * calcParity  | 
            ||
| 1726 | * @param $items (array)  | 
            ||
| 1727 | * @return int parity  | 
            ||
| 1728 | */  | 
            ||
| 1729 | 	 protected function calcParity($items) { | 
            ||
| 1740 | |||
| 1741 | /**  | 
            ||
| 1742 | * checkModeNum  | 
            ||
| 1743 | * @param $size (int)  | 
            ||
| 1744 | * @param $data (array)  | 
            ||
| 1745 | * @return boolean true or false  | 
            ||
| 1746 | */  | 
            ||
| 1747 | 	 protected function checkModeNum($size, $data) { | 
            ||
| 1755 | |||
| 1756 | /**  | 
            ||
| 1757 | * Look up the alphabet-numeric convesion table (see JIS X0510:2004, pp.19).  | 
            ||
| 1758 | * @param $c (int) character value  | 
            ||
| 1759 | * @return value  | 
            ||
| 1760 | */  | 
            ||
| 1761 | 	protected function lookAnTable($c) { | 
            ||
| 1764 | |||
| 1765 | /**  | 
            ||
| 1766 | * checkModeAn  | 
            ||
| 1767 | * @param $size (int)  | 
            ||
| 1768 | * @param $data (array)  | 
            ||
| 1769 | * @return boolean true or false  | 
            ||
| 1770 | */  | 
            ||
| 1771 | 	 protected function checkModeAn($size, $data) { | 
            ||
| 1779 | |||
| 1780 | /**  | 
            ||
| 1781 | * estimateBitsModeNum  | 
            ||
| 1782 | * @param $size (int)  | 
            ||
| 1783 | * @return int number of bits  | 
            ||
| 1784 | */  | 
            ||
| 1785 | 	 protected function estimateBitsModeNum($size) { | 
            ||
| 1800 | |||
| 1801 | /**  | 
            ||
| 1802 | * estimateBitsModeAn  | 
            ||
| 1803 | * @param $size (int)  | 
            ||
| 1804 | * @return int number of bits  | 
            ||
| 1805 | */  | 
            ||
| 1806 | 	 protected function estimateBitsModeAn($size) { | 
            ||
| 1813 | |||
| 1814 | /**  | 
            ||
| 1815 | * estimateBitsMode8  | 
            ||
| 1816 | * @param $size (int)  | 
            ||
| 1817 | * @return int number of bits  | 
            ||
| 1818 | */  | 
            ||
| 1819 | 	 protected function estimateBitsMode8($size) { | 
            ||
| 1822 | |||
| 1823 | /**  | 
            ||
| 1824 | * estimateBitsModeKanji  | 
            ||
| 1825 | * @param $size (int)  | 
            ||
| 1826 | * @return int number of bits  | 
            ||
| 1827 | */  | 
            ||
| 1828 | 	 protected function estimateBitsModeKanji($size) { | 
            ||
| 1831 | |||
| 1832 | /**  | 
            ||
| 1833 | * checkModeKanji  | 
            ||
| 1834 | * @param $size (int)  | 
            ||
| 1835 | * @param $data (array)  | 
            ||
| 1836 | * @return boolean true or false  | 
            ||
| 1837 | */  | 
            ||
| 1838 | 	 protected function checkModeKanji($size, $data) { | 
            ||
| 1850 | |||
| 1851 | /**  | 
            ||
| 1852 | * Validate the input data.  | 
            ||
| 1853 | * @param $mode (int) encoding mode.  | 
            ||
| 1854 | * @param $size (int) size of data (byte).  | 
            ||
| 1855 | * @param $data (array) data to validate  | 
            ||
| 1856 | * @return boolean true in case of valid data, false otherwise  | 
            ||
| 1857 | */  | 
            ||
| 1858 | 	protected function check($mode, $size, $data) { | 
            ||
| 1884 | |||
| 1885 | /**  | 
            ||
| 1886 | * estimateBitStreamSize  | 
            ||
| 1887 | * @param $items (array)  | 
            ||
| 1888 | * @param $version (int)  | 
            ||
| 1889 | * @return int bits  | 
            ||
| 1890 | */  | 
            ||
| 1891 | 	 protected function estimateBitStreamSize($items, $version) { | 
            ||
| 1928 | |||
| 1929 | /**  | 
            ||
| 1930 | * estimateVersion  | 
            ||
| 1931 | * @param $items (array)  | 
            ||
| 1932 | * @return int version  | 
            ||
| 1933 | */  | 
            ||
| 1934 | 	 protected function estimateVersion($items) { | 
            ||
| 1947 | |||
| 1948 | /**  | 
            ||
| 1949 | * lengthOfCode  | 
            ||
| 1950 | * @param $mode (int)  | 
            ||
| 1951 | * @param $version (int)  | 
            ||
| 1952 | * @param $bits (int)  | 
            ||
| 1953 | * @return int size  | 
            ||
| 1954 | */  | 
            ||
| 1955 | 	 protected function lengthOfCode($mode, $version, $bits) { | 
            ||
| 2004 | |||
| 2005 | /**  | 
            ||
| 2006 | * createBitStream  | 
            ||
| 2007 | * @param $items (array)  | 
            ||
| 2008 | * @return array of items and total bits  | 
            ||
| 2009 | */  | 
            ||
| 2010 | 	 protected function createBitStream($items) { | 
            ||
| 2019 | |||
| 2020 | /**  | 
            ||
| 2021 | * convertData  | 
            ||
| 2022 | * @param $items (array)  | 
            ||
| 2023 | * @return array items  | 
            ||
| 2024 | */  | 
            ||
| 2025 | 	 protected function convertData($items) { | 
            ||
| 2048 | |||
| 2049 | /**  | 
            ||
| 2050 | * Append Padding Bit to bitstream  | 
            ||
| 2051 | * @param $bstream (array)  | 
            ||
| 2052 | * @return array bitstream  | 
            ||
| 2053 | */  | 
            ||
| 2054 | 	 protected function appendPaddingBit($bstream) { | 
            ||
| 2081 | |||
| 2082 | /**  | 
            ||
| 2083 | * mergeBitStream  | 
            ||
| 2084 | * @param $items (array) items  | 
            ||
| 2085 | * @return array bitstream  | 
            ||
| 2086 | */  | 
            ||
| 2087 | 	 protected function mergeBitStream($items) { | 
            ||
| 2098 | |||
| 2099 | /**  | 
            ||
| 2100 | * Returns a stream of bits.  | 
            ||
| 2101 | * @param $items (int)  | 
            ||
| 2102 | * @return array padded merged byte stream  | 
            ||
| 2103 | */  | 
            ||
| 2104 | 	protected function getBitStream($items) { | 
            ||
| 2108 | |||
| 2109 | /**  | 
            ||
| 2110 | * Pack all bit streams padding bits into a byte array.  | 
            ||
| 2111 | * @param $items (int)  | 
            ||
| 2112 | * @return array padded merged byte stream  | 
            ||
| 2113 | */  | 
            ||
| 2114 | 	protected function getByteStream($items) { | 
            ||
| 2118 | |||
| 2119 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 2120 | |||
| 2121 | // QRbitstream  | 
            ||
| 2122 | |||
| 2123 | /**  | 
            ||
| 2124 | * Return an array with zeros  | 
            ||
| 2125 | * @param $setLength (int) array size  | 
            ||
| 2126 | * @return array  | 
            ||
| 2127 | */  | 
            ||
| 2128 | 	 protected function allocate($setLength) { | 
            ||
| 2131 | |||
| 2132 | /**  | 
            ||
| 2133 | * Return new bitstream from number  | 
            ||
| 2134 | * @param $bits (int) number of bits  | 
            ||
| 2135 | * @param $num (int) number  | 
            ||
| 2136 | * @return array bitstream  | 
            ||
| 2137 | */  | 
            ||
| 2138 | 	 protected function newFromNum($bits, $num) { | 
            ||
| 2151 | |||
| 2152 | /**  | 
            ||
| 2153 | * Return new bitstream from bytes  | 
            ||
| 2154 | * @param $size (int) size  | 
            ||
| 2155 | * @param $data (array) bytes  | 
            ||
| 2156 | * @return array bitstream  | 
            ||
| 2157 | */  | 
            ||
| 2158 | 	 protected function newFromBytes($size, $data) { | 
            ||
| 2175 | |||
| 2176 | /**  | 
            ||
| 2177 | * Append one bitstream to another  | 
            ||
| 2178 | * @param $bitstream (array) original bitstream  | 
            ||
| 2179 | * @param $append (array) bitstream to append  | 
            ||
| 2180 | * @return array bitstream  | 
            ||
| 2181 | */  | 
            ||
| 2182 | 	 protected function appendBitstream($bitstream, $append) { | 
            ||
| 2191 | |||
| 2192 | /**  | 
            ||
| 2193 | * Append one bitstream created from number to another  | 
            ||
| 2194 | * @param $bitstream (array) original bitstream  | 
            ||
| 2195 | * @param $bits (int) number of bits  | 
            ||
| 2196 | * @param $num (int) number  | 
            ||
| 2197 | * @return array bitstream  | 
            ||
| 2198 | */  | 
            ||
| 2199 | 	 protected function appendNum($bitstream, $bits, $num) { | 
            ||
| 2206 | |||
| 2207 | /**  | 
            ||
| 2208 | * Append one bitstream created from bytes to another  | 
            ||
| 2209 | * @param $bitstream (array) original bitstream  | 
            ||
| 2210 | * @param $size (int) size  | 
            ||
| 2211 | * @param $data (array) bytes  | 
            ||
| 2212 | * @return array bitstream  | 
            ||
| 2213 | */  | 
            ||
| 2214 | 	 protected function appendBytes($bitstream, $size, $data) { | 
            ||
| 2221 | |||
| 2222 | /**  | 
            ||
| 2223 | * Convert bitstream to bytes  | 
            ||
| 2224 | * @param $bstream (array) original bitstream  | 
            ||
| 2225 | * @return array of bytes  | 
            ||
| 2226 | */  | 
            ||
| 2227 | 	 protected function bitstreamToByte($bstream) { | 
            ||
| 2258 | |||
| 2259 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 2260 | |||
| 2261 | // QRspec  | 
            ||
| 2262 | |||
| 2263 | /**  | 
            ||
| 2264 | * Replace a value on the array at the specified position  | 
            ||
| 2265 | * @param $srctab (array)  | 
            ||
| 2266 | * @param $x (int) X position  | 
            ||
| 2267 | * @param $y (int) Y position  | 
            ||
| 2268 | * @param $repl (string) value to replace  | 
            ||
| 2269 | * @param $replLen (int) length of the repl string  | 
            ||
| 2270 | * @return array srctab  | 
            ||
| 2271 | */  | 
            ||
| 2272 | 	 protected function qrstrset($srctab, $x, $y, $repl, $replLen=false) { | 
            ||
| 2276 | |||
| 2277 | /**  | 
            ||
| 2278 | * Return maximum data code length (bytes) for the version.  | 
            ||
| 2279 | * @param $version (int) version  | 
            ||
| 2280 | * @param $level (int) error correction level  | 
            ||
| 2281 | * @return int maximum size (bytes)  | 
            ||
| 2282 | */  | 
            ||
| 2283 | 	protected function getDataLength($version, $level) { | 
            ||
| 2286 | |||
| 2287 | /**  | 
            ||
| 2288 | * Return maximum error correction code length (bytes) for the version.  | 
            ||
| 2289 | * @param $version (int) version  | 
            ||
| 2290 | * @param $level (int) error correction level  | 
            ||
| 2291 | * @return int ECC size (bytes)  | 
            ||
| 2292 | */  | 
            ||
| 2293 | 	protected function getECCLength($version, $level){ | 
            ||
| 2296 | |||
| 2297 | /**  | 
            ||
| 2298 | * Return the width of the symbol for the version.  | 
            ||
| 2299 | * @param $version (int) version  | 
            ||
| 2300 | * @return int width  | 
            ||
| 2301 | */  | 
            ||
| 2302 | 	protected function getWidth($version) { | 
            ||
| 2305 | |||
| 2306 | /**  | 
            ||
| 2307 | * Return the numer of remainder bits.  | 
            ||
| 2308 | * @param $version (int) version  | 
            ||
| 2309 | * @return int number of remainder bits  | 
            ||
| 2310 | */  | 
            ||
| 2311 | 	protected function getRemainder($version) { | 
            ||
| 2314 | |||
| 2315 | /**  | 
            ||
| 2316 | * Return a version number that satisfies the input code length.  | 
            ||
| 2317 | * @param $size (int) input code length (bytes)  | 
            ||
| 2318 | * @param $level (int) error correction level  | 
            ||
| 2319 | * @return int version number  | 
            ||
| 2320 | */  | 
            ||
| 2321 | 	protected function getMinimumVersion($size, $level) { | 
            ||
| 2331 | |||
| 2332 | /**  | 
            ||
| 2333 | * Return the size of length indicator for the mode and version.  | 
            ||
| 2334 | * @param $mode (int) encoding mode  | 
            ||
| 2335 | * @param $version (int) version  | 
            ||
| 2336 | * @return int the size of the appropriate length indicator (bits).  | 
            ||
| 2337 | */  | 
            ||
| 2338 | 	protected function lengthIndicator($mode, $version) { | 
            ||
| 2351 | |||
| 2352 | /**  | 
            ||
| 2353 | * Return the maximum length for the mode and version.  | 
            ||
| 2354 | * @param $mode (int) encoding mode  | 
            ||
| 2355 | * @param $version (int) version  | 
            ||
| 2356 | * @return int the maximum length (bytes)  | 
            ||
| 2357 | */  | 
            ||
| 2358 | 	protected function maximumWords($mode, $version) { | 
            ||
| 2376 | |||
| 2377 | /**  | 
            ||
| 2378 | * Return an array of ECC specification.  | 
            ||
| 2379 | * @param $version (int) version  | 
            ||
| 2380 | * @param $level (int) error correction level  | 
            ||
| 2381 | 	 * @param $spec (array) an array of ECC specification contains as following: {# of type1 blocks, # of data code, # of ecc code, # of type2 blocks, # of data code} | 
            ||
| 2382 | * @return array spec  | 
            ||
| 2383 | */  | 
            ||
| 2384 | 	protected function getEccSpec($version, $level, $spec) { | 
            ||
| 2407 | |||
| 2408 | /**  | 
            ||
| 2409 | * Put an alignment marker.  | 
            ||
| 2410 | * @param $frame (array) frame  | 
            ||
| 2411 | * @param $ox (int) X center coordinate of the pattern  | 
            ||
| 2412 | * @param $oy (int) Y center coordinate of the pattern  | 
            ||
| 2413 | * @return array frame  | 
            ||
| 2414 | */  | 
            ||
| 2415 | 	protected function putAlignmentMarker($frame, $ox, $oy) { | 
            ||
| 2430 | |||
| 2431 | /**  | 
            ||
| 2432 | * Put an alignment pattern.  | 
            ||
| 2433 | * @param $version (int) version  | 
            ||
| 2434 | * @param $frame (array) frame  | 
            ||
| 2435 | * @param $width (int) width  | 
            ||
| 2436 | * @return array frame  | 
            ||
| 2437 | */  | 
            ||
| 2438 | 	 protected function putAlignmentPattern($version, $frame, $width) { | 
            ||
| 2472 | |||
| 2473 | /**  | 
            ||
| 2474 | * Return BCH encoded version information pattern that is used for the symbol of version 7 or greater. Use lower 18 bits.  | 
            ||
| 2475 | * @param $version (int) version  | 
            ||
| 2476 | * @return BCH encoded version information pattern  | 
            ||
| 2477 | */  | 
            ||
| 2478 | 	protected function getVersionPattern($version) { | 
            ||
| 2484 | |||
| 2485 | /**  | 
            ||
| 2486 | * Return BCH encoded format information pattern.  | 
            ||
| 2487 | * @param $mask (array)  | 
            ||
| 2488 | * @param $level (int) error correction level  | 
            ||
| 2489 | * @return BCH encoded format information pattern  | 
            ||
| 2490 | */  | 
            ||
| 2491 | 	protected function getFormatInfo($mask, $level) { | 
            ||
| 2500 | |||
| 2501 | /**  | 
            ||
| 2502 | * Put a finder pattern.  | 
            ||
| 2503 | * @param $frame (array) frame  | 
            ||
| 2504 | * @param $ox (int) X center coordinate of the pattern  | 
            ||
| 2505 | * @param $oy (int) Y center coordinate of the pattern  | 
            ||
| 2506 | * @return array frame  | 
            ||
| 2507 | */  | 
            ||
| 2508 | 	protected function putFinderPattern($frame, $ox, $oy) { | 
            ||
| 2523 | |||
| 2524 | /**  | 
            ||
| 2525 | * Return a copy of initialized frame.  | 
            ||
| 2526 | * @param $version (int) version  | 
            ||
| 2527 | * @return Array of unsigned char.  | 
            ||
| 2528 | */  | 
            ||
| 2529 | 	protected function createFrame($version) { | 
            ||
| 2588 | |||
| 2589 | /**  | 
            ||
| 2590 | * Set new frame for the specified version.  | 
            ||
| 2591 | * @param $version (int) version  | 
            ||
| 2592 | * @return Array of unsigned char.  | 
            ||
| 2593 | */  | 
            ||
| 2594 | 	protected function newFrame($version) { | 
            ||
| 2606 | |||
| 2607 | /**  | 
            ||
| 2608 | * Return block number 0  | 
            ||
| 2609 | * @param $spec (array)  | 
            ||
| 2610 | * @return int value  | 
            ||
| 2611 | */  | 
            ||
| 2612 | 	 protected function rsBlockNum($spec) { | 
            ||
| 2615 | |||
| 2616 | /**  | 
            ||
| 2617 | * Return block number 1  | 
            ||
| 2618 | * @param $spec (array)  | 
            ||
| 2619 | * @return int value  | 
            ||
| 2620 | */  | 
            ||
| 2621 | 	 protected function rsBlockNum1($spec) { | 
            ||
| 2624 | |||
| 2625 | /**  | 
            ||
| 2626 | * Return data codes 1  | 
            ||
| 2627 | * @param $spec (array)  | 
            ||
| 2628 | * @return int value  | 
            ||
| 2629 | */  | 
            ||
| 2630 | 	 protected function rsDataCodes1($spec) { | 
            ||
| 2633 | |||
| 2634 | /**  | 
            ||
| 2635 | * Return ecc codes 1  | 
            ||
| 2636 | * @param $spec (array)  | 
            ||
| 2637 | * @return int value  | 
            ||
| 2638 | */  | 
            ||
| 2639 | 	 protected function rsEccCodes1($spec) { | 
            ||
| 2642 | |||
| 2643 | /**  | 
            ||
| 2644 | * Return block number 2  | 
            ||
| 2645 | * @param $spec (array)  | 
            ||
| 2646 | * @return int value  | 
            ||
| 2647 | */  | 
            ||
| 2648 | 	 protected function rsBlockNum2($spec) { | 
            ||
| 2651 | |||
| 2652 | /**  | 
            ||
| 2653 | * Return data codes 2  | 
            ||
| 2654 | * @param $spec (array)  | 
            ||
| 2655 | * @return int value  | 
            ||
| 2656 | */  | 
            ||
| 2657 | 	 protected function rsDataCodes2($spec) { | 
            ||
| 2660 | |||
| 2661 | /**  | 
            ||
| 2662 | * Return ecc codes 2  | 
            ||
| 2663 | * @param $spec (array)  | 
            ||
| 2664 | * @return int value  | 
            ||
| 2665 | */  | 
            ||
| 2666 | 	 protected function rsEccCodes2($spec) { | 
            ||
| 2669 | |||
| 2670 | /**  | 
            ||
| 2671 | * Return data length  | 
            ||
| 2672 | * @param $spec (array)  | 
            ||
| 2673 | * @return int value  | 
            ||
| 2674 | */  | 
            ||
| 2675 | 	 protected function rsDataLength($spec) { | 
            ||
| 2678 | |||
| 2679 | /**  | 
            ||
| 2680 | * Return ecc length  | 
            ||
| 2681 | * @param $spec (array)  | 
            ||
| 2682 | * @return int value  | 
            ||
| 2683 | */  | 
            ||
| 2684 | 	 protected function rsEccLength($spec) { | 
            ||
| 2687 | |||
| 2688 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 2689 | |||
| 2690 | // QRrs  | 
            ||
| 2691 | |||
| 2692 | /**  | 
            ||
| 2693 | * Initialize a Reed-Solomon codec and add it to existing rsitems  | 
            ||
| 2694 | * @param $symsize (int) symbol size, bits  | 
            ||
| 2695 | * @param $gfpoly (int) Field generator polynomial coefficients  | 
            ||
| 2696 | * @param $fcr (int) first root of RS code generator polynomial, index form  | 
            ||
| 2697 | * @param $prim (int) primitive element to generate polynomial roots  | 
            ||
| 2698 | * @param $nroots (int) RS code generator polynomial degree (number of roots)  | 
            ||
| 2699 | * @param $pad (int) padding bytes at front of shortened block  | 
            ||
| 2700 | * @return array Array of RS values:<ul><li>mm = Bits per symbol;</li><li>nn = Symbols per block;</li><li>alpha_to = log lookup table array;</li><li>index_of = Antilog lookup table array;</li><li>genpoly = Generator polynomial array;</li><li>nroots = Number of generator;</li><li>roots = number of parity symbols;</li><li>fcr = First consecutive root, index form;</li><li>prim = Primitive element, index form;</li><li>iprim = prim-th root of 1, index form;</li><li>pad = Padding bytes in shortened block;</li><li>gfpoly</ul>.  | 
            ||
| 2701 | */  | 
            ||
| 2702 | 	 protected function init_rs($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) { | 
            ||
| 2714 | |||
| 2715 | // - - - - - - - - - - - - - - - - - - - - - - - - -  | 
            ||
| 2716 | |||
| 2717 | // QRrsItem  | 
            ||
| 2718 | |||
| 2719 | /**  | 
            ||
| 2720 | * modnn  | 
            ||
| 2721 | * @param $rs (array) RS values  | 
            ||
| 2722 | * @param $x (int) X position  | 
            ||
| 2723 | * @return int X osition  | 
            ||
| 2724 | */  | 
            ||
| 2725 | 	 protected function modnn($rs, $x) { | 
            ||
| 2732 | |||
| 2733 | /**  | 
            ||
| 2734 | * Initialize a Reed-Solomon codec and returns an array of values.  | 
            ||
| 2735 | * @param $symsize (int) symbol size, bits  | 
            ||
| 2736 | * @param $gfpoly (int) Field generator polynomial coefficients  | 
            ||
| 2737 | * @param $fcr (int) first root of RS code generator polynomial, index form  | 
            ||
| 2738 | * @param $prim (int) primitive element to generate polynomial roots  | 
            ||
| 2739 | * @param $nroots (int) RS code generator polynomial degree (number of roots)  | 
            ||
| 2740 | * @param $pad (int) padding bytes at front of shortened block  | 
            ||
| 2741 | * @return array Array of RS values:<ul><li>mm = Bits per symbol;</li><li>nn = Symbols per block;</li><li>alpha_to = log lookup table array;</li><li>index_of = Antilog lookup table array;</li><li>genpoly = Generator polynomial array;</li><li>nroots = Number of generator;</li><li>roots = number of parity symbols;</li><li>fcr = First consecutive root, index form;</li><li>prim = Primitive element, index form;</li><li>iprim = prim-th root of 1, index form;</li><li>pad = Padding bytes in shortened block;</li><li>gfpoly</ul>.  | 
            ||
| 2742 | */  | 
            ||
| 2743 | 	protected function init_rs_char($symsize, $gfpoly, $fcr, $prim, $nroots, $pad) { | 
            ||
| 2819 | |||
| 2820 | /**  | 
            ||
| 2821 | * Encode a Reed-Solomon codec and returns the parity array  | 
            ||
| 2822 | * @param $rs (array) RS values  | 
            ||
| 2823 | * @param $data (array) data  | 
            ||
| 2824 | * @param $parity (array) parity  | 
            ||
| 2825 | * @return parity array  | 
            ||
| 2826 | */  | 
            ||
| 2827 | 	 protected function encode_rs_char($rs, $data, $parity) { | 
            ||
| 2861 | |||
| 2862 | } // end QRcode class  | 
            ||
| 2863 | |||
| 2867 | 
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.