Code Duplication    Length = 23-24 lines in 4 locations

src/Calculator/AverageSyllablesPerWordCalculator.php 1 location

@@ 31-54 (lines=24) @@
28
29
use Org_Heigl\TextStatistics\Text;
30
31
class AverageSyllablesPerWordCalculator implements CalculatorInterface
32
{
33
    protected $syllableCounter;
34
35
    protected $wordCounter;
36
37
    public function __construct(SyllableCounter $syllableCounter, WordCounter $wordCounter)
38
    {
39
        $this->syllableCounter = $syllableCounter;
40
        $this->wordCounter = $wordCounter;
41
    }
42
43
    /**
44
     * Do the actual calculation of a statistic
45
     *
46
     * @param Text $text
47
     *
48
     * @return mixed
49
     */
50
    public function calculate(Text $text)
51
    {
52
        return $this->syllableCounter->calculate($text) / $this->wordCounter->calculate($text);
53
    }
54
}
55

src/Calculator/WordsWithNCharsPercentCalculator.php 1 location

@@ 31-53 (lines=23) @@
28
29
use Org_Heigl\TextStatistics\Text;
30
31
class WordsWithNCharsPercentCalculator implements CalculatorInterface
32
{
33
    protected $wordsWithNCharsCounter;
34
    protected $wordCounter;
35
36
    public function __construct(WordsWithNCharsCounter $wordsWithNCharsCounter, WordCounter $wordCounter)
37
    {
38
        $this->wordsWithNCharsCounter = $wordsWithNCharsCounter;
39
        $this->wordCounter = $wordCounter;
40
    }
41
42
    /**
43
     * Do the actual calculation of a statistic
44
     *
45
     * @param Text $text
46
     *
47
     * @return mixed
48
     */
49
    public function calculate(Text $text)
50
    {
51
        return $this->wordsWithNCharsCounter->calculate($text) / $this->wordCounter->calculate($text) * 100;
52
    }
53
}
54

src/Calculator/WordsWithNSyllablesOnlyPercentCalculator.php 1 location

@@ 32-55 (lines=24) @@
29
use Org\Heigl\Hyphenator\Hyphenator;
30
use Org_Heigl\TextStatistics\Text;
31
32
class WordsWithNSyllablesOnlyPercentCalculator implements CalculatorInterface
33
{
34
    protected $wordsWithNSyllablesOnlyCounter;
35
36
    protected $wordCounter;
37
38
    public function __construct(WordsWithNSyllablesOnlyCounter $wordsWithNSyllablesOnlyCounter, WordCounter $wordCounter)
39
    {
40
        $this->wordsWithNSyllablesOnlyCounter = $wordsWithNSyllablesOnlyCounter;
41
        $this->wordCounter = $wordCounter;
42
    }
43
44
    /**
45
     * Do the actual calculation of a statistic
46
     *
47
     * @param Text $text
48
     *
49
     * @return mixed
50
     */
51
    public function calculate(Text $text)
52
    {
53
        return $this->wordsWithNSyllablesOnlyCounter->calculate($text) / $this->wordCounter->calculate($text) * 100;
54
    }
55
}
56

src/Calculator/WordsWithNSyllablesPercentCalculator.php 1 location

@@ 32-54 (lines=23) @@
29
use Org\Heigl\Hyphenator\Hyphenator;
30
use Org_Heigl\TextStatistics\Text;
31
32
class WordsWithNSyllablesPercentCalculator implements CalculatorInterface
33
{
34
    protected $wordsWithNSyllablesCounter;
35
    protected $wordCounter;
36
37
    public function __construct(WordsWithNSyllablesCounter $wordsWithNSyllablesCounter, WordCounter $wordCounter)
38
    {
39
        $this->wordsWithNSyllablesCounter = $wordsWithNSyllablesCounter;
40
        $this->wordCounter = $wordCounter;
41
    }
42
43
    /**
44
     * Do the actual calculation of a statistic
45
     *
46
     * @param Text $text
47
     *
48
     * @return mixed
49
     */
50
    public function calculate(Text $text)
51
    {
52
        return $this->wordsWithNSyllablesCounter->calculate($text) / $this->wordCounter->calculate($text) * 100;
53
    }
54
}
55