Completed
Push — develop ( fc6531...baf107 )
by Jaap
16:51 queued 06:54
created

DeepExample   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A doSomethingJson() 0 4 1
A doSomething() 0 5 1
1
<?php
2
/**
3
 * This file is part of phpDocumentor.
4
 *
5
 *  For the full copyright and license information, please view the LICENSE
6
 *  file that was distributed with this source code.
7
 *
8
 *  @copyright 2010-2017 Mike van Riel<[email protected]>
9
 *  @license   http://www.opensource.org/licenses/mit-license.php MIT
10
 *  @link      http://phpdoc.org
11
 */
12
13
interface ExampleInterface
0 ignored issues
show
Coding Style Compatibility introduced by
Each interface must be in a namespace of at least one level (a top-level vendor name)

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
14
{
15
    /**
16
     * Do something with $object and return that it worked
17
     *
18
     * @param \stdClass $object The object
19
     * @return bool
20
     */
21
    public function doSomething(\stdClass $object);
22
}
23
24
class Example implements ExampleInterface
0 ignored issues
show
Coding Style Compatibility introduced by
Each interface must be in a file by itself

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
25
{
26
    /** {@inheritdoc} */
27
    public function doSomething(\stdClass $object)
28
    {
29
        // what ever
30
        return true;
31
    }
32
}
33
34
interface DeepExampleInterface extends ExampleInterface
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
Each interface must be in a namespace of at least one level (a top-level vendor name)

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
35
{
36
    /**
37
     * Convert $json to object and doSomething
38
     *
39
     * @param string $json
40
     * @return bool
41
     */
42
    public function doSomethingJson($json);
43
}
44
45
class DeepExample extends Example implements DeepExampleInterface
0 ignored issues
show
Coding Style Compatibility introduced by
Each interface must be in a file by itself

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
46
{
47
    /** {@inheritdoc} */
48
    public function doSomethingJson($json)
49
    {
50
        return $this->doSomething(json_encode($json));
0 ignored issues
show
Documentation introduced by
json_encode($json) is of type string, but the function expects a object<stdClass>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
51
    }
52
53
    /** {@inheritdoc} */
54
    public function doSomething(\stdClass $object)
55
    {
56
        // do something really special
57
        return true;
58
    }
59
}
60