Completed
Push — master ( 7e5e34...10763a )
by Nelson
02:30
created

ObjectTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 34
loc 34
rs 10
wmc 2
lcom 1
cbo 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A testConstructorWithBadArguments() 22 22 2

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
 * PHP: Nelson Martell Library file
4
 *
5
 * Content:
6
 * - Test case for: [NelsonMartell] Object (alias for StrictObject)
7
 *
8
 * Copyright © 2016-2017 Nelson Martell (http://nelson6e65.github.io)
9
 *
10
 * Licensed under The MIT License (MIT)
11
 * For full copyright and license information, please see the LICENSE
12
 * Redistributions of files must retain the above copyright notice.
13
 *
14
 * @copyright 2016-2017 Nelson Martell
15
 * @link      http://nelson6e65.github.io/php_nml/
16
 * @since     v0.6.0
17
 * @license   http://www.opensource.org/licenses/mit-license.php The MIT License (MIT)
18
 * */
19
20
namespace NelsonMartell\Test\TestCaseLt71;
21
22
use NelsonMartell as NML;
23
use NelsonMartell\Extensions\Text;
24
use NelsonMartell\Test\DataProviders\ObjectTestProvider;
25
use NelsonMartell\Object;
26
use PHPUnit\Framework\TestCase;
27
use \InvalidArgumentException;
28
use \Exception;
29
30
/**
31
 *
32
 * @author Nelson Martell <[email protected]>
33
 * @internal
34
 * @group Criticals
35
 * @requires PHP < 7.2.0
36
 *
37
 * */
38 View Code Duplication
class ObjectTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class 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...
39
{
40
    use ObjectTestProvider;
41
42
    /**
43
     * Overrides default tests, due to this class constructor do not throws argument exceptions.
44
     * So, using any type should be pass.
45
     *
46
     * @testdox Do not throws error on creating new instances, due to all arguments passed are ignored
47
     * @group Criticals
48
     */
49
    public function testConstructorWithBadArguments()
50
    {
51
        $actual = null;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
52
        $message = Text::format(
53
            '$object = new {class}();',
54
            [
55
                'class' => Object::class,
56
            ]
57
        );
58
59
        try {
60
            $actual = new Object();
61
        } catch (Exception $e) {
62
            $actual = $e;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
63
            $message .= Text::format(
64
                ' // # Constructor should not throws exceptions. Error: {0}',
65
                $this->exporter->export($e->getMessage())
66
            );
67
        }
68
69
        $this->assertInstanceOf(Object::class, $actual, $message);
70
    }
71
}
72