Code Duplication    Length = 23-26 lines in 5 locations

src/Calculator/AverageSentenceLengthCalculator.php 1 location

@@ 31-54 (lines=24) @@
28
29
use Org_Heigl\TextStatistics\Text;
30
31
class AverageSentenceLengthCalculator implements CalculatorInterface
32
{
33
    protected $wordCounter;
34
35
    protected $sentenceCounter;
36
37
    public function __construct(WordCounter $wordCounter, SentenceCounter $sentenceCounter)
38
    {
39
        $this->wordCounter = $wordCounter;
40
        $this->sentenceCounter = $sentenceCounter;
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->wordCounter->calculate($text) / $this->sentenceCounter->calculate($text);
53
    }
54
}
55

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-57 (lines=26) @@
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(
39
        WordsWithNSyllablesOnlyCounter $wordsWithNSyllablesOnlyCounter,
40
        WordCounter $wordCounter
41
    ) {
42
        $this->wordsWithNSyllablesOnlyCounter = $wordsWithNSyllablesOnlyCounter;
43
        $this->wordCounter = $wordCounter;
44
    }
45
46
    /**
47
     * Do the actual calculation of a statistic
48
     *
49
     * @param Text $text
50
     *
51
     * @return mixed
52
     */
53
    public function calculate(Text $text)
54
    {
55
        return $this->wordsWithNSyllablesOnlyCounter->calculate($text) / $this->wordCounter->calculate($text) * 100;
56
    }
57
}
58

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