src/Calculator/CachingSyllableCounter.php 1 location
|
@@ 31-48 (lines=18) @@
|
28 |
|
|
29 |
|
use Org_Heigl\TextStatistics\Text; |
30 |
|
|
31 |
|
class CachingSyllableCounter extends SyllableCounter |
32 |
|
{ |
33 |
|
protected static $cache = []; |
34 |
|
|
35 |
|
public function calculate(Text $text) |
36 |
|
{ |
37 |
|
$text = $text->getPlainText(); |
38 |
|
$hash = sha1($text); |
39 |
|
|
40 |
|
if (! isset( static::$cache[$hash])) { |
41 |
|
$result = parent::calculate($text); |
42 |
|
static::$cache[$hash] = $result; |
43 |
|
} |
44 |
|
|
45 |
|
return static::$cache[$hash]; |
46 |
|
} |
47 |
|
|
48 |
|
} |
49 |
|
|
src/Calculator/CachingWordCounter.php 1 location
|
@@ 31-48 (lines=18) @@
|
28 |
|
|
29 |
|
use Org_Heigl\TextStatistics\Text; |
30 |
|
|
31 |
|
class CachingWordCounter extends WordCounter |
32 |
|
{ |
33 |
|
protected static $cache = []; |
34 |
|
|
35 |
|
public function calculate(Text $text) |
36 |
|
{ |
37 |
|
$text = $text->getPlainText(); |
38 |
|
$hash = sha1($text); |
39 |
|
|
40 |
|
if (! isset( static::$cache[$hash])) { |
41 |
|
$result = parent::calculate($text); |
42 |
|
static::$cache[$hash] = $result; |
43 |
|
} |
44 |
|
|
45 |
|
return static::$cache[$hash]; |
46 |
|
} |
47 |
|
|
48 |
|
} |
49 |
|
|
src/Calculator/CachingWordMaxSyllablesCounter.php 1 location
|
@@ 31-48 (lines=18) @@
|
28 |
|
|
29 |
|
use Org_Heigl\TextStatistics\Text; |
30 |
|
|
31 |
|
class CachingWordMaxSyllablesCounter extends WordMaxSyllablesCounter |
32 |
|
{ |
33 |
|
protected static $cache = []; |
34 |
|
|
35 |
|
public function calculate(Text $text) |
36 |
|
{ |
37 |
|
$text = $text->getPlainText(); |
38 |
|
$hash = sha1($text); |
39 |
|
|
40 |
|
if (! isset( static::$cache[$hash])) { |
41 |
|
$result = parent::calculate($text); |
42 |
|
static::$cache[$hash] = $result; |
43 |
|
} |
44 |
|
|
45 |
|
return static::$cache[$hash]; |
46 |
|
} |
47 |
|
|
48 |
|
} |
49 |
|
|
src/Calculator/CachingWordsWithNCharsCounter.php 1 location
|
@@ 31-48 (lines=18) @@
|
28 |
|
|
29 |
|
use Org_Heigl\TextStatistics\Text; |
30 |
|
|
31 |
|
class CachingWordsWithNCharsCounter extends WordsWithNCharsCounter |
32 |
|
{ |
33 |
|
protected static $cache = []; |
34 |
|
|
35 |
|
public function calculate(Text $text) |
36 |
|
{ |
37 |
|
$text = $text->getPlainText(); |
38 |
|
$hash = sha1($text); |
39 |
|
|
40 |
|
if (! isset( static::$cache[$hash])) { |
41 |
|
$result = parent::calculate($text); |
42 |
|
static::$cache[$hash] = $result; |
43 |
|
} |
44 |
|
|
45 |
|
return static::$cache[$hash]; |
46 |
|
} |
47 |
|
|
48 |
|
} |
49 |
|
|
src/Calculator/CachingWordsWithNSyllablesCounter.php 1 location
|
@@ 31-48 (lines=18) @@
|
28 |
|
|
29 |
|
use Org_Heigl\TextStatistics\Text; |
30 |
|
|
31 |
|
class CachingWordsWithNSyllablesCounter extends WordsWithNSyllablesCounter |
32 |
|
{ |
33 |
|
protected static $cache = []; |
34 |
|
|
35 |
|
public function calculate(Text $text) |
36 |
|
{ |
37 |
|
$text = $text->getPlainText(); |
38 |
|
$hash = sha1($text); |
39 |
|
|
40 |
|
if (! isset( static::$cache[$hash])) { |
41 |
|
$result = parent::calculate($text); |
42 |
|
static::$cache[$hash] = $result; |
43 |
|
} |
44 |
|
|
45 |
|
return static::$cache[$hash]; |
46 |
|
} |
47 |
|
|
48 |
|
} |
49 |
|
|
src/Calculator/CachingWordsWithNSyllablesOnlyCounter.php 1 location
|
@@ 31-48 (lines=18) @@
|
28 |
|
|
29 |
|
use Org_Heigl\TextStatistics\Text; |
30 |
|
|
31 |
|
class CachingWordsWithNSyllablesOnlyCounter extends WordsWithNSyllablesOnlyCounter |
32 |
|
{ |
33 |
|
protected static $cache = []; |
34 |
|
|
35 |
|
public function calculate(Text $text) |
36 |
|
{ |
37 |
|
$text = $text->getPlainText(); |
38 |
|
$hash = sha1($text); |
39 |
|
|
40 |
|
if (! isset( static::$cache[$hash])) { |
41 |
|
$result = parent::calculate($text); |
42 |
|
static::$cache[$hash] = $result; |
43 |
|
} |
44 |
|
|
45 |
|
return static::$cache[$hash]; |
46 |
|
} |
47 |
|
|
48 |
|
} |
49 |
|
|