GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Deals   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 58.54 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getEndpoint() 0 4 1
A all() 9 9 2
A create() 15 15 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 prgTW\BaseCRM\Service;
4
5
use prgTW\BaseCRM\Resource\DetachedResource;
6
use prgTW\BaseCRM\Resource\Page;
7
use prgTW\BaseCRM\Resource\PaginatedListResource;
8
use prgTW\BaseCRM\Service\Enum\DealStage;
9
10
class Deals extends PaginatedListResource
11
{
12
	/** {@inheritdoc} */
13
	protected function getEndpoint()
14
	{
15
		return self::ENDPOINT_SALES;
16
	}
17
18
	/**
19
	 * @param int       $page
20
	 * @param DealStage $stage defaults to DealStage::INCOMING
0 ignored issues
show
Documentation introduced by
Should the type for parameter $stage not be null|DealStage?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
21
	 *
22
	 * @return Page
0 ignored issues
show
Documentation introduced by
Should the return type not be \prgTW\BaseCRM\Resource\ResourceCollection?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
23
	 */
24 View Code Duplication
	public function all($page = 1, DealStage $stage = null)
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...
25
	{
26
		$stage = $stage ? : DealStage::INCOMING();
27
		$query = [
28
			'stage' => $stage->getValue(),
29
		];
30
31
		return parent::getPage($page, $query);
0 ignored issues
show
Comprehensibility Bug introduced by
It seems like you call parent on a different method (getPage() instead of all()). Are you sure this is correct? If so, you might want to change this to $this->getPage().

This check looks for a call to a parent method whose name is different than the method from which it is called.

Consider the following code:

class Daddy
{
    protected function getFirstName()
    {
        return "Eidur";
    }

    protected function getSurName()
    {
        return "Gudjohnsen";
    }
}

class Son
{
    public function getFirstName()
    {
        return parent::getSurname();
    }
}

The getFirstName() method in the Son calls the wrong method in the parent class.

Loading history...
32
	}
33
34
	/** {@inheritdoc} */
35 View Code Duplication
	public function create(DetachedResource $resource, array $fieldNames = [], $useKey = true)
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
		$fieldNames = array_intersect($fieldNames, [
38
			'name',
39
			'entity_id',
40
			'scope',
41
			'hot',
42
			'deal_tags',
43
			'contact_ids',
44
			'source_id',
45
			'stage',
46
		]);
47
48
		return parent::create($resource, $fieldNames, $useKey);
49
	}
50
}
51