Passed
Push — master ( b101db...a45b24 )
by Robbie
05:17
created

getArchiveFieldClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace SilverStripe\VersionedAdmin\Tests\ArchiveAdminTest;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\ORM\DataObject;
7
use SilverStripe\Versioned\Versioned;
8
use SilverStripe\VersionedAdmin\ArchiveViewProvider;
9
10
class ViewProviderVersionedObject extends DataObject implements ArchiveViewProvider
11
{
12
    private static $table_name = 'Test_ViewProviderVersionedObject';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
13
14
    private static $extensions = [
0 ignored issues
show
introduced by
The private property $extensions is not used, and could be removed.
Loading history...
15
        Versioned::class,
16
    ];
17
18
    public function getArchiveFieldClass()
19
    {
20
        return ViewProviderVersionedObject::class;
0 ignored issues
show
Bug Best Practice introduced by
The expression return SilverStripe\Vers...rVersionedObject::class returns the type string which is incompatible with the return type mandated by SilverStripe\VersionedAd...:getArchiveFieldClass() of array.

In the issue above, the returned value is violating the contract defined by the mentioned interface.

Let's take a look at an example:

interface HasName {
    /** @return string */
    public function getName();
}

class Name {
    public $name;
}

class User implements HasName {
    /** @return string|Name */
    public function getName() {
        return new Name('foo'); // This is a violation of the ``HasName`` interface
                                // which only allows a string value to be returned.
    }
}
Loading history...
21
    }
22
    public function getArchiveField()
23
    {
24
        return null;
25
    }
26
    public function isArchiveFieldEnabled()
27
    {
28
        return true;
29
    }
30
}
31