@@ -11,9 +11,9 @@ class File implements Source
11
11
private static $ minHyphens = null ;
12
12
private $ path = null ;
13
13
private $ language = null ;
14
- private $ loaded = false ;
14
+ private $ loaded ;
15
15
private $ patterns = null ;
16
- private $ max_pattern_length = null ;
16
+ private $ maxPatternLength = null ;
17
17
private $ hyphenations = null ;
18
18
19
19
public function __construct ($ language , $ path )
@@ -38,7 +38,7 @@ public function setLanguage($language)
38
38
public function getMinHyphens ()
39
39
{
40
40
if (!self ::$ minHyphens ) {
41
- self ::$ minHyphens = json_decode (file_get_contents ("{ $ this ->path } /min.json " ), true );
41
+ self ::$ minHyphens = json_decode (file_get_contents ("$ this ->path /min.json " ), true );
42
42
}
43
43
44
44
return isset (self ::$ minHyphens [$ this ->language ]) ? self ::$ minHyphens [$ this ->language ] : null ;
@@ -48,18 +48,18 @@ private function loadLanguage()
48
48
{
49
49
if (!$ this ->loaded ) {
50
50
$ this ->patterns = [];
51
- $ this ->max_pattern_length = 0 ;
51
+ $ this ->maxPatternLength = 0 ;
52
52
$ this ->hyphenations = [];
53
53
54
54
// parser state
55
55
$ command = false ;
56
56
$ braces = false ;
57
57
58
58
// parse .tex file
59
- foreach (file ("{ $ this ->path } /hyph- { $ this ->language } .tex " ) as $ line ) {
59
+ foreach (file ("$ this ->path /hyph- $ this ->language .tex " ) as $ line ) {
60
60
$ offset = 0 ;
61
- $ strlen_line = mb_strlen ($ line );
62
- while ($ offset < $ strlen_line ) {
61
+ $ strlenLine = mb_strlen ($ line );
62
+ while ($ offset < $ strlenLine ) {
63
63
$ char = $ line [$ offset ];
64
64
65
65
// %comment
@@ -74,7 +74,7 @@ private function loadLanguage()
74
74
continue ; // next token
75
75
}
76
76
77
- // {
77
+ // opening brace
78
78
if ($ char === '{ ' ) {
79
79
$ braces = true ;
80
80
$ offset ++;
@@ -89,43 +89,43 @@ private function loadLanguage()
89
89
$ numbers = '' ;
90
90
$ pattern = '' ;
91
91
$ strlen = 0 ;
92
- $ expect_number = true ;
92
+ $ expectNumber = true ;
93
93
foreach (preg_split ('/(?<!^)(?!$)/u ' , $ m [0 ]) as $ char ) {
94
94
if (is_numeric ($ char )) {
95
95
$ numbers .= $ char ;
96
- $ expect_number = false ;
96
+ $ expectNumber = false ;
97
97
} else {
98
- if ($ expect_number ) {
98
+ if ($ expectNumber ) {
99
99
$ numbers .= '0 ' ;
100
100
}
101
101
$ pattern .= $ char ;
102
102
$ strlen ++;
103
- $ expect_number = true ;
103
+ $ expectNumber = true ;
104
104
}
105
105
$ offset ++;
106
106
}
107
- if ($ expect_number ) {
107
+ if ($ expectNumber ) {
108
108
$ numbers .= '0 ' ;
109
109
}
110
110
111
111
$ this ->patterns [$ pattern ] = $ numbers ;
112
- if ($ strlen > $ this ->max_pattern_length ) {
113
- $ this ->max_pattern_length = $ strlen ;
112
+ if ($ strlen > $ this ->maxPatternLength ) {
113
+ $ this ->maxPatternLength = $ strlen ;
114
114
}
115
115
}
116
116
continue 3 ; // next token
117
117
118
118
case 'hyphenation ' :
119
119
if (preg_match ('~^\S+~u ' , substr ($ line , $ offset ), $ m ) === 1 ) {
120
- $ hyphenation = preg_replace ( ' ~\-~ ' , '' , $ m [0 ]);
120
+ $ hyphenation = str_replace ( ' - ' , '' , $ m [0 ]);
121
121
$ this ->hyphenations [$ hyphenation ] = $ m [0 ];
122
122
$ offset += strlen ($ m [0 ]);
123
123
}
124
124
continue 3 ; // next token
125
125
}
126
126
}
127
127
128
- // }
128
+ // closing brace
129
129
if ($ char === '} ' ) {
130
130
$ braces = false ;
131
131
$ command = false ;
@@ -153,7 +153,7 @@ public function getMaxPattern()
153
153
{
154
154
$ this ->loadLanguage ();
155
155
156
- return $ this ->max_pattern_length ;
156
+ return $ this ->maxPatternLength ;
157
157
}
158
158
159
159
public function getPatterns ()
0 commit comments