Code Duplication    Length = 27-29 lines in 4 locations

src/Calculator/FleschKincaidGradeLevelCalculator.php 1 location

@@ 39-67 (lines=29) @@
36
 * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
37
 * @package Org_Heigl\TextStatistics\Calculator
38
 */
39
class FleschKincaidGradeLevelCalculator implements CalculatorInterface
40
{
41
    protected $averageSentenceLengthCalculator;
42
43
    protected $averageSyllablesPerWordCalculator;
44
45
    public function __construct(
46
        AverageSentenceLengthCalculator $averageSentenceLengthCalculator,
47
        AverageSyllablesPerWordCalculator $averageSyllablesPerWordCalculator
48
    ) {
49
        $this->averageSentenceLengthCalculator = $averageSentenceLengthCalculator;
50
        $this->averageSyllablesPerWordCalculator = $averageSyllablesPerWordCalculator;
51
    }
52
    /**
53
     * Do the actual calculation of a statistic
54
     *
55
     * @param Text $text
56
     *
57
     * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
58
     * @return int
59
     */
60
    public function calculate(Text $text)
61
    {
62
        return (0.39 * $this->averageSentenceLengthCalculator->calculate($text)) +
63
               (11.8 * $this->averageSyllablesPerWordCalculator->calculate($text)) -
64
               15.59
65
            ;
66
    }
67
}
68

src/Calculator/FleschReadingEaseCalculator.php 1 location

@@ 39-65 (lines=27) @@
36
 * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
37
 * @package Org_Heigl\TextStatistics\Calculator
38
 */
39
class FleschReadingEaseCalculator implements CalculatorInterface
40
{
41
    protected $averageSentenceLengthCalculator;
42
43
    protected $averageSyllablesPerWordCalculator;
44
45
    public function __construct(
46
        AverageSentenceLengthCalculator $averageSentenceLengthCalculator,
47
        AverageSyllablesPerWordCalculator $averageSyllablesPerWordCalculator
48
    ) {
49
        $this->averageSentenceLengthCalculator = $averageSentenceLengthCalculator;
50
        $this->averageSyllablesPerWordCalculator = $averageSyllablesPerWordCalculator;
51
    }
52
    /**
53
     * Do the actual calculation of a statistic
54
     *
55
     * @param Text $text
56
     *
57
     * @return mixed
58
     */
59
    public function calculate(Text $text)
60
    {
61
        return 206.835 -
62
               (1.015 * $this->averageSentenceLengthCalculator->calculate($text)) -
63
               (84.6 * $this->averageSyllablesPerWordCalculator->calculate($text));
64
    }
65
}
66

src/Calculator/WienerSachtextFormel3Calculator.php 1 location

@@ 39-67 (lines=29) @@
36
 * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
37
 * @package Org_Heigl\TextStatistics\Calculator
38
 */
39
class WienerSachtextFormel3Calculator implements CalculatorInterface
40
{
41
    protected $percentWordsWithMoreThanThreeSyllables;
42
43
    protected $averageSentenceLenght;
44
45
    public function __construct(
46
        WordsWithNSyllablesPercentCalculator $percentWordsWithMoreThanThreeSyllables,
47
        AverageSentenceLengthCalculator $averageSentenceLenght
48
    ) {
49
        $this->percentWordsWithMoreThanThreeSyllables = $percentWordsWithMoreThanThreeSyllables;
50
        $this->averageSentenceLenght = $averageSentenceLenght;
51
    }
52
53
    /**
54
     * Do the actual calculation of a statistic
55
     *
56
     * @param Text $text
57
     *
58
     * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
59
     * @return mixed
60
     */
61
    public function calculate(Text $text)
62
    {
63
        return 0.2963 * $this->percentWordsWithMoreThanThreeSyllables->calculate($text)
64
             + 0.1905 * $this->averageSentenceLenght->calculate($text)
65
             - 1.1144;
66
    }
67
}
68

src/Calculator/WienerSachtextFormel4Calculator.php 1 location

@@ 39-67 (lines=29) @@
36
 * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
37
 * @package Org_Heigl\TextStatistics\Calculator
38
 */
39
class WienerSachtextFormel4Calculator implements CalculatorInterface
40
{
41
    protected $percentWordsWithMoreThanThreeSyllables;
42
43
    protected $averageSentenceLenght;
44
45
    public function __construct(
46
        WordsWithNSyllablesPercentCalculator $percentWordsWithMoreThanThreeSyllables,
47
        AverageSentenceLengthCalculator $averageSentenceLenght
48
    ) {
49
        $this->percentWordsWithMoreThanThreeSyllables = $percentWordsWithMoreThanThreeSyllables;
50
        $this->averageSentenceLenght = $averageSentenceLenght;
51
    }
52
53
    /**
54
     * Do the actual calculation of a statistic
55
     *
56
     * @param Text $text
57
     *
58
     * @see https://de.wikipedia.org/wiki/Lesbarkeitsindex
59
     * @return mixed
60
     */
61
    public function calculate(Text $text)
62
    {
63
        return 0.2963 * $this->percentWordsWithMoreThanThreeSyllables->calculate($text)
64
             + 0.1905 * $this->averageSentenceLenght->calculate($text)
65
             - 1.1144;
66
    }
67
}
68