Skip to content

Commit

Permalink
Adds some wrapping around
Browse files Browse the repository at this point in the history
  • Loading branch information
heiglandreas committed Mar 21, 2017
1 parent 62a039b commit 73f9c57
Show file tree
Hide file tree
Showing 11 changed files with 40 additions and 13 deletions.
6 changes: 4 additions & 2 deletions src/Calculator/WordsWithNSyllablesOnlyPercentCalculator.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ class WordsWithNSyllablesOnlyPercentCalculator implements CalculatorInterface

protected $wordCounter;

public function __construct(WordsWithNSyllablesOnlyCounter $wordsWithNSyllablesOnlyCounter, WordCounter $wordCounter)
{
public function __construct(
WordsWithNSyllablesOnlyCounter $wordsWithNSyllablesOnlyCounter,
WordCounter $wordCounter
) {
$this->wordsWithNSyllablesOnlyCounter = $wordsWithNSyllablesOnlyCounter;
$this->wordCounter = $wordCounter;
}
Expand Down
10 changes: 8 additions & 2 deletions src/Service/WienerSachtextFormel1CalculatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@ class WienerSachtextFormel1CalculatorFactory
public static function getCalculator()
{
return new WienerSachtextFormel1Calculator(
new WordsWithNSyllablesPercentCalculator(WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3), WordCounterFactory::getCalculator()),
new WordsWithNSyllablesPercentCalculator(
WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3),
WordCounterFactory::getCalculator()
),
new AverageSentenceLengthCalculator(WordCounterFactory::getCalculator(), new SentenceCounter()),
new WordsWithNCharsPercentCalculator(new WordsWithNCharsCounter(6), WordCounterFactory::getCalculator()),
new WordsWithNSyllablesOnlyPercentCalculator(WordsWithNSyllablesOnlyCounterFactory::getCalculator('de_DE', 1), WordCounterFactory::getCalculator())
new WordsWithNSyllablesOnlyPercentCalculator(
WordsWithNSyllablesOnlyCounterFactory::getCalculator('de_DE', 1),
WordCounterFactory::getCalculator()
)
);
}
}
5 changes: 4 additions & 1 deletion src/Service/WienerSachtextFormel2CalculatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ class WienerSachtextFormel2CalculatorFactory
public static function getCalculator()
{
return new WienerSachtextFormel2Calculator(
new WordsWithNSyllablesPercentCalculator(WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3), WordCounterFactory::getCalculator()),
new WordsWithNSyllablesPercentCalculator(
WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3),
WordCounterFactory::getCalculator()
),
new AverageSentenceLengthCalculator(WordCounterFactory::getCalculator(), new SentenceCounter()),
new WordsWithNCharsPercentCalculator(new WordsWithNCharsCounter(6), WordCounterFactory::getCalculator())
);
Expand Down
5 changes: 4 additions & 1 deletion src/Service/WienerSachtextFormel3CalculatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class WienerSachtextFormel3CalculatorFactory
public static function getCalculator()
{
return new WienerSachtextFormel3Calculator(
new WordsWithNSyllablesPercentCalculator(WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3), new WordCounter()),
new WordsWithNSyllablesPercentCalculator(
WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3),
new WordCounter()
),
new AverageSentenceLengthCalculator(new WordCounter(), new SentenceCounter())
);
}
Expand Down
5 changes: 4 additions & 1 deletion src/Service/WienerSachtextFormel4CalculatorFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ class WienerSachtextFormel4CalculatorFactory
public static function getCalculator()
{
return new WienerSachtextFormel4Calculator(
new WordsWithNSyllablesPercentCalculator(WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3), new WordCounter()),
new WordsWithNSyllablesPercentCalculator(
WordsWithNSyllablesCounterFactory::getCalculator('de_DE', 3),
new WordCounter()
),
new AverageSentenceLengthCalculator(new WordCounter(), new SentenceCounter())
);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Util/SyllableFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function run(t\TokenRegistry $tokens)
*
* @return mixed
*/
protected function _concatenate(t\TokenRegistry $tokens)
protected function _concatenate(t\TokenRegistry $tokens) // @codingStandardsIgnoreLine
{
$syllables = [];
foreach ($tokens as $token) {
Expand Down
2 changes: 1 addition & 1 deletion src/Util/WordsWithNSyllablesFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function run(t\TokenRegistry $tokens)
*
* @return mixed
*/
protected function _concatenate(t\TokenRegistry $tokens)
protected function _concatenate(t\TokenRegistry $tokens) // @codingStandardsIgnoreLine
{
$wordsWithNSyllables = [];
foreach ($tokens as $token) {
Expand Down
2 changes: 1 addition & 1 deletion src/Util/WordsWithNSyllablesOnlyFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public function run(t\TokenRegistry $tokens)
*
* @return mixed
*/
protected function _concatenate(t\TokenRegistry $tokens)
protected function _concatenate(t\TokenRegistry $tokens) // @codingStandardsIgnoreLine
{
$wordsWithNSyllables = [];
foreach ($tokens as $token) {
Expand Down
6 changes: 5 additions & 1 deletion tests/Calculator/CharacterWithoutWhitespaceCounterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ class CharacterWithoutWhitespaceCounterTest extends \PHPUnit_Framework_TestCase
{
public function testThatCountingcharactersWorksWithoutWhitespace()
{
$text = new Text('Dieser text' . "\t" . 'enthält die ein oder andere Silbe des Donaudampfschifffahrtskapitäns');
$text = new Text(
'Dieser text' .
"\t" .
'enthält die ein oder andere Silbe des Donaudampfschifffahrtskapitäns'
);

$calculator = new CharacterWithoutWhitespaceCounter();

Expand Down
5 changes: 4 additions & 1 deletion tests/Calculator/FleschReadingEaseCalculatorGermanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public function testThatReadingEaseIsCalculatedProperly()

$text = new Text('Dieser text enthält die ein oder andere Silbe des Donaudampfschifffahrtskapitäns');

$fleshReadingEaseCalculator = new FleschReadingEaseCalculatorGerman($averageSentenceLengthCalculator, $averageSyllablesPerWordCalculator);
$fleshReadingEaseCalculator = new FleschReadingEaseCalculatorGerman(
$averageSentenceLengthCalculator,
$averageSyllablesPerWordCalculator
);

$this->assertEquals(87, (int) $fleshReadingEaseCalculator->calculate($text));
}
Expand Down
5 changes: 4 additions & 1 deletion tests/Calculator/FleschReadingEaseCalculatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public function testThatReadingEaseIsCalculatedProperly()

$text = new Text('Dieser text enthält die ein oder andere Silbe des Donaudampfschifffahrtskapitäns');

$fleshReadingEaseCalculator = new FleschReadingEaseCalculator($averageSentenceLengthCalculator, $averageSyllablesPerWordCalculator);
$fleshReadingEaseCalculator = new FleschReadingEaseCalculator(
$averageSentenceLengthCalculator,
$averageSyllablesPerWordCalculator
);

$this->assertEquals(74, (int) $fleshReadingEaseCalculator->calculate($text));
}
Expand Down

0 comments on commit 73f9c57

Please sign in to comment.