Skip to content

Commit 51ac98f

Browse files
author
Nito
committed
Code reformat
1 parent 7c9e1aa commit 51ac98f

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

src/LanguageSubset.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,17 +52,17 @@ public function dynamicLangSubset($langs)
5252
// langSubset($langs,$save=true) Will previously remove the excluded languages form the ngrams database; for a single detection might be slower than dynamicLangSubset(), but for multiple strings will be faster. if $save option is true (default), the new ngrams subset will be stored, and next loaded for the same language subset, increasing startup speed.
5353
public function langSubset($langs, $save = true, $safe = false)
5454
{
55-
if ( ! $langs) {
55+
if (!$langs) {
5656
if ($this->loadedSubset) {
57-
$this->ngrams = $this->defaultNgrams;
57+
$this->ngrams = $this->defaultNgrams;
5858
$this->loadedSubset = false;
5959
}
6060

6161
return true;
6262
}
6363

6464
$langs_array = $this->dynamicLangSubset($langs);
65-
if ( ! $langs_array) {
65+
if (!$langs_array) {
6666
return 'No languages found';
6767
}
6868
$this->subset = false; // We use dynamicLangSubset() to filter languages, but set dynamic subset to false
@@ -72,7 +72,7 @@ public function langSubset($langs, $save = true, $safe = false)
7272
}
7373

7474
$new_subset = hash('sha1', implode(',', $langs_array));
75-
$file_name = __DIR__.'/ngrams/ngrams.'.$new_subset.'.php';
75+
$file_name = __DIR__ . '/ngrams/ngrams.' . $new_subset . '.php';
7676

7777
if ($this->loadedSubset !== $new_subset) {
7878
$this->loadedSubset = $new_subset;
@@ -88,21 +88,21 @@ public function langSubset($langs, $save = true, $safe = false)
8888

8989
foreach ($this->ngrams as $ngram => $langsID) {
9090
foreach ($langsID as $id => $value) {
91-
if ( ! in_array($id, $langs_array)) {
91+
if (!in_array($id, $langs_array)) {
9292
unset($this->ngrams[$ngram][$id]);
9393
}
9494
}
95-
if ( ! $this->ngrams[$ngram]) {
95+
if (!$this->ngrams[$ngram]) {
9696
unset($this->ngrams[$ngram]);
9797
}
9898
}
9999
}
100100

101101
if ($save) {
102-
if ( ! file_exists($file_name)) { // in case $this->loadedSubset !== $new_subset, and was previously saved
102+
if (!file_exists($file_name)) { // in case $this->loadedSubset !== $new_subset, and was previously saved
103103
file_put_contents($file_name,
104-
'<?php'."\r\n".'// Do not edit unless you ensure you are using UTF-8 encoding'."\r\n"
105-
.'$this->ngrams='.$this->ngram_export($this->ngrams, $safe).';'
104+
'<?php' . "\r\n" . '// Do not edit unless you ensure you are using UTF-8 encoding' . "\r\n"
105+
. '$this->ngrams=' . $this->ngram_export($this->ngrams, $safe) . ';'
106106
);
107107
}
108108

@@ -115,7 +115,7 @@ public function langSubset($langs, $save = true, $safe = false)
115115
protected function filterLangSubset($results)
116116
{
117117
foreach ($results as $key => $value) {
118-
if ( ! in_array($key, $this->subset)) {
118+
if (!in_array($key, $this->subset)) {
119119
unset($results[$key]);
120120
}
121121
}
@@ -128,11 +128,11 @@ protected function ngram_export($var, $safe = false)
128128
if (is_array($var)) {
129129
$toImplode = array();
130130
foreach ($var as $key => $value) {
131-
$toImplode[] = ($safe === true ? '"\\x'.substr(chunk_split(bin2hex($key), 2, '\\x'), 0, -2).'"'
132-
: var_export($key, true)).'=>'.$this->ngram_export($value);
131+
$toImplode[] = ($safe === true ? '"\\x' . substr(chunk_split(bin2hex($key), 2, '\\x'), 0, -2) . '"'
132+
: var_export($key, true)) . '=>' . $this->ngram_export($value);
133133
}
134134

135-
return '['.implode(',', $toImplode).']';
135+
return '[' . implode(',', $toImplode) . ']';
136136
} else {
137137
return var_export($var, true);
138138
}

0 commit comments

Comments
 (0)