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.

RepresentationErrorException::hasErrors()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace prgTW\BaseCRM\Exception;
4
5
use GuzzleHttp\Exception\ClientException;
6
use prgTW\BaseCRM\Error\Error;
7
8
class RepresentationErrorException extends ClientException
9
{
10
	/**
11
	 * @param string $field
0 ignored issues
show
Documentation introduced by
Should the type for parameter $field not be string|null?

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...
12
	 *
13
	 * @return array|Error[]
14
	 */
15
	public function getErrors($field = null)
16
	{
17
		$decoded = $this->getResponse()->json();
18
19
		$errors = [];
20
		foreach ($decoded['errors'] as $resourceName => $errorsData)
21
		{
22
			foreach ($errorsData as $errorData)
23
			{
24
				$errorData = $errorData['error'];
25
				if (null !== $field && $errorData['field'] !== $field)
26
				{
27
					continue;
28
				}
29
				$errors[] = new Error($errorData['code'], $errorData['field'], $errorData['description']);
30
			}
31
		}
32
33
		return $errors;
34
	}
35
36
	/**
37
	 * @param string $field
0 ignored issues
show
Documentation introduced by
Should the type for parameter $field not be string|null?

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...
38
	 *
39
	 * @return bool
40
	 */
41
	public function hasErrors($field = null)
42
	{
43
		$errors = $this->getErrors($field);
44
45
		return 0 !== count($errors);
46
	}
47
}
48