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...
17
{
18
/**
19
* @var \Bitbucket\API\Repositories\Src
20
*/
21
private $client;
22
23
/**
24
* Constructor.
25
*/
26
public function __construct()
27
{
28
$this->client = new \Bitbucket\API\Repositories\Src();
29
//$this->client ->setCredentials( new Bitbucket\API\Authentication\Basic($bb_user, $bb_pass) );
60% of this comment could be valid code. Did you maybe forget this after debugging?
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have
checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that
someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.
Loading history...
30
}
31
32
/**
33
* Get the file contents.
34
*
35
*
36
* @param Project $project
37
* @param string $file
38
*
39
* @return array
40
*/
41
public function getFileContents(Project $project, string $file): array
42
{
43
$response = $this->client->raw(
44
$project->getVendorName(),
45
$project->getPackageName(),
46
$project->getBranch(),
47
$file
48
);
49
50
return $this->parseJson($response->getContent());
51
}
52
53
/**
54
* Parse JSON data.
55
*
56
* @param string $data
57
*
58
* @return mixed
59
*/
60
private function parseJson($data)
61
{
62
$parsedData = json_decode($data, true);
63
if ($parsedData === false) {
64
throw new \RuntimeException('Unable to parse json file');
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.