| @@ 32-52 (lines=21) @@ | ||
| 29 | use Org\Heigl\Hyphenator\Hyphenator; |
|
| 30 | use Org_Heigl\TextStatistics\Text; |
|
| 31 | ||
| 32 | class SyllableCounter implements CalculatorInterface |
|
| 33 | { |
|
| 34 | protected $hyphenator; |
|
| 35 | ||
| 36 | public function __construct(Hyphenator $hyphenator) |
|
| 37 | { |
|
| 38 | $this->hyphenator = $hyphenator; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Do the actual calculation of a statistic |
|
| 43 | * |
|
| 44 | * @param Text $text |
|
| 45 | * |
|
| 46 | * @return mixed |
|
| 47 | */ |
|
| 48 | public function calculate(Text $text) |
|
| 49 | { |
|
| 50 | return count($this->hyphenator->hyphenate($text->getPlainText())); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 32-52 (lines=21) @@ | ||
| 29 | use Org\Heigl\Hyphenator\Hyphenator; |
|
| 30 | use Org_Heigl\TextStatistics\Text; |
|
| 31 | ||
| 32 | class WordsWithNSyllablesCounter implements CalculatorInterface |
|
| 33 | { |
|
| 34 | protected $hyphenator; |
|
| 35 | ||
| 36 | public function __construct(Hyphenator $hyphenator) |
|
| 37 | { |
|
| 38 | $this->hyphenator = $hyphenator; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Do the actual calculation of a statistic |
|
| 43 | * |
|
| 44 | * @param Text $text |
|
| 45 | * |
|
| 46 | * @return mixed |
|
| 47 | */ |
|
| 48 | public function calculate(Text $text) |
|
| 49 | { |
|
| 50 | return count($this->hyphenator->hyphenate($text->getPlainText())); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||
| @@ 32-52 (lines=21) @@ | ||
| 29 | use Org\Heigl\Hyphenator\Hyphenator; |
|
| 30 | use Org_Heigl\TextStatistics\Text; |
|
| 31 | ||
| 32 | class WordsWithNSyllablesOnlyCounter implements CalculatorInterface |
|
| 33 | { |
|
| 34 | protected $hyphenator; |
|
| 35 | ||
| 36 | public function __construct(Hyphenator $hyphenator) |
|
| 37 | { |
|
| 38 | $this->hyphenator = $hyphenator; |
|
| 39 | } |
|
| 40 | ||
| 41 | /** |
|
| 42 | * Do the actual calculation of a statistic |
|
| 43 | * |
|
| 44 | * @param Text $text |
|
| 45 | * |
|
| 46 | * @return mixed |
|
| 47 | */ |
|
| 48 | public function calculate(Text $text) |
|
| 49 | { |
|
| 50 | return count($this->hyphenator->hyphenate($text->getPlainText())); |
|
| 51 | } |
|
| 52 | } |
|
| 53 | ||