source-class-Com.Tecnick.Unicode.Bidi.StepI

It appears that you are using AdBlocking software. The cost of running this website is covered by advertisements. If you like it please feel free to a small amount of money to secure the future of this website.
 1: <?php
 2: /**
 3:  * StepI.php
 4:  *
 5:  * @since       2011-05-23
 6:  * @category    Library
 7:  * @package     Unicode
 8:  * @author      Nicola Asuni <info@tecnick.com>
 9:  * @copyright   2011-2015 Nicola Asuni - Tecnick.com LTD
10:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
11:  * @link        https://github.com/tecnickcom/tc-lib-unicode
12:  *
13:  * This file is part of tc-lib-unicode software library.
14:  */
15: 
16: namespace Com\Tecnick\Unicode\Bidi;
17: 
18: /**
19:  * Com\Tecnick\Unicode\Bidi\StepI
20:  *
21:  * @since       2015-07-13
22:  * @category    Library
23:  * @package     Unicode
24:  * @author      Nicola Asuni <info@tecnick.com>
25:  * @copyright   2011-2015 Nicola Asuni - Tecnick.com LTD
26:  * @license     http://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE.TXT)
27:  * @link        https://github.com/tecnickcom/tc-lib-unicode
28:  */
29: class StepI extends \Com\Tecnick\Unicode\Bidi\StepBase
30: {
31:     /**
32:      * Process I steps
33:      */
34:     protected function process()
35:     {
36:         $this->seq['maxlevel'] = 0;
37:         $this->processStep('processI');
38:     }
39: 
40:     /**
41:      * I1. For all characters with an even (left-to-right) embedding level, those of type R go up one level and those
42:      *     of type AN or EN go up two levels.
43:      * I2. For all characters with an odd (right-to-left) embedding level, those of type L, EN or AN go up one level.
44:      *
45:      * @param int $idx Current character position
46:      */
47:     protected function processI($idx)
48:     {
49:         $odd = ($this->seq['item'][$idx]['level'] % 2);
50:         if ($odd) {
51:             if (($this->seq['item'][$idx]['type'] == 'L')
52:                 || ($this->seq['item'][$idx]['type'] == 'EN')
53:                 || ($this->seq['item'][$idx]['type'] == 'AN')
54:             ) {
55:                 $this->seq['item'][$idx]['level'] += 1;
56:             }
57:         } else {
58:             if ($this->seq['item'][$idx]['type'] == 'R') {
59:                 $this->seq['item'][$idx]['level'] += 1;
60:             } elseif (($this->seq['item'][$idx]['type'] == 'AN')
61:                 || ($this->seq['item'][$idx]['type'] == 'EN')
62:             ) {
63:                 $this->seq['item'][$idx]['level'] += 2;
64:             }
65:         }
66:         // update the maximum level
67:         $this->seq['maxlevel'] = max($this->seq['maxlevel'], $this->seq['item'][$idx]['level']);
68:     }
69: }
70: 
 

© 2004-2017 – Nicola Asuni - Tecnick.com - All rights reserved.
about - disclaimer - privacy