Completed
Push — master ( 2ad0de...2fd600 )
by Levan
03:06
created

LanguageDetectionTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 36
Duplicated Lines 66.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 24
loc 36
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 4 1
A testSingleWord() 8 8 1
A testSingleSentence() 8 8 1
A testMultipleSentence() 8 8 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Stichoza\GoogleTranslate\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Stichoza\GoogleTranslate\GoogleTranslate;
7
8
class LanguageDetectionTest extends TestCase
9
{
10
    public $tr;
11
12
    public function setUp()
13
    {
14
        $this->tr = new GoogleTranslate();
15
    }
16
17 View Code Duplication
    public function testSingleWord()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        $this->tr->translate('გამარჯობა');
20
        $this->assertEquals($this->tr->getLastDetectedSource(), 'ka');
21
22
        $this->tr->translate('Cześć');
23
        $this->assertEquals($this->tr->getLastDetectedSource(), 'pl');
24
    }
25
26 View Code Duplication
    public function testSingleSentence()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
    {
28
        $this->tr->translate('იყო არაბეთს როსტევან');
29
        $this->assertEquals($this->tr->getLastDetectedSource(), 'ka');
30
31
        $this->tr->translate('Путин хуйло');
32
        $this->assertEquals($this->tr->getLastDetectedSource(), 'ru');
33
    }
34
35 View Code Duplication
    public function testMultipleSentence()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
36
    {
37
        $this->tr->translate('ჩემი ხატია სამშობლო. სახატე - მთელი ქვეყანა. განათებული მთა-ბარი.');
38
        $this->assertEquals($this->tr->getLastDetectedSource(), 'ka');
39
40
        $this->tr->translate('Ще не вмерла Україна, И слава, и воля! Ще намъ, браття-молодці, Усміхнеться доля!');
41
        $this->assertEquals($this->tr->getLastDetectedSource(), 'uk');
42
    }
43
}
44