Method search
has 33 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function search(): array
{
if (!$this->isActive()) {
return [];
}
Function search
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring. Open
public function search(): array
{
if (!$this->isActive()) {
return [];
}
- Read upRead up
Cognitive Complexity
Cognitive Complexity is a measure of how difficult a unit of code is to intuitively understand. Unlike Cyclomatic Complexity, which determines how difficult your code will be to test, Cognitive Complexity tells you how difficult your code will be to read and comprehend.
A method's cognitive complexity is based on a few simple rules:
- Code is not considered more complex when it uses shorthand that the language provides for collapsing multiple statements into one
- Code is considered more complex for each "break in the linear flow of the code"
- Code is considered more complex when "flow breaking structures are nested"
Further reading
Missing class import via use statement (line '133', column '22'). Open
if ($client = new \SoapClient($this->url, \App\RequestHttp::getSoapOptions())) {
- Read upRead up
- Exclude checks
MissingImport
Since: 2.7.0
Importing all external classes in a file through use statements makes them clearly visible.
Example
function make() {
return new \stdClass();
}
Source http://phpmd.org/rules/cleancode.html#MissingImport
Avoid using static access to class '\App\Fields\Country' in method 'getFields'. Open
if (!$this->request->isEmpty($value, true) && ($code = \App\Fields\Country::getCountryCode($this->request->getByType($value, 'Text')))) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\RequestHttp' in method 'search'. Open
if ($client = new \SoapClient($this->url, \App\RequestHttp::getSoapOptions())) {
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid using static access to class '\App\Log' in method 'search'. Open
\App\Log::warning($e->faultstring, 'RecordCollectors');
- Read upRead up
- Exclude checks
StaticAccess
Since: 1.4.0
Static access causes unexchangeable dependencies to other classes and leads to hard to test code. Avoid using static access at all costs and instead inject dependencies through the constructor. The only case when static access is acceptable is when used for factory methods.
Example
class Foo
{
public function bar()
{
Bar::baz();
}
}
Source https://phpmd.org/rules/cleancode.html#staticaccess
Avoid assigning values to variables in if clauses and the like (line '133', column '8'). Open
public function search(): array
{
if (!$this->isActive()) {
return [];
}
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
Avoid assigning values to variables in if clauses and the like (line '112', column '51'). Open
public function getFields(): array
{
$fieldsModels = parent::getFields();
foreach (['addresslevel1a', 'addresslevel1b', 'addresslevel1c'] as $value) {
if (!$this->request->isEmpty($value, true) && ($code = \App\Fields\Country::getCountryCode($this->request->getByType($value, 'Text')))) {
- Read upRead up
- Exclude checks
IfStatementAssignment
Since: 2.7.0
Assignments in if clauses and the like are considered a code smell. Assignments in PHP return the right operand as their result. In many cases, this is an expected behavior, but can lead to many difficult to spot bugs, especially when the right operand could result in zero, null or an empty string and the like.
Example
class Foo
{
public function bar($flag)
{
if ($foo = 'bar') { // possible typo
// ...
}
if ($baz = 0) { // always false
// ...
}
}
}
Source http://phpmd.org/rules/cleancode.html#ifstatementassignment
syntax error, unexpected 'bool' (T_STRING), expecting function (T_FUNCTION) or const (T_CONST)
Open
protected bool $paid = false;
- Exclude checks
Avoid variables with short names like $r. Configured minimum length is 3. Open
$r = $client->checkVatApprox([
- Read upRead up
- Exclude checks
ShortVariable
Since: 0.2
Detects when a field, local, or parameter has a very short name.
Example
class Something {
private $q = 15; // VIOLATION - Field
public static function main( array $as ) { // VIOLATION - Formal
$r = 20 + $this->q; // VIOLATION - Local
for (int $i = 0; $i < 10; $i++) { // Not a Violation (inside FOR)
$r += $this->q;
}
}
}
Source https://phpmd.org/rules/naming.html#shortvariable
Spaces must be used to indent lines; tabs are not allowed Open
public $label = 'LBL_VIES';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $docUrl = 'https://ec.europa.eu/taxation_customs/vies/technicalInformation.html';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'DK' => 'Denmark',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LT' => 'Lithuania',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'SE' => 'Sweden',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'typeofdata' => 'V~M',
- Exclude checks
Line exceeds 120 characters; contains 149 characters Open
if (!$this->request->isEmpty($value, true) && ($code = \App\Fields\Country::getCountryCode($this->request->getByType($value, 'Text')))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'CZ' => 'Czech Republic',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'RO' => 'Romania',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'SK' => 'Slovakia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'CY' => 'Cyprus',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'DE' => 'Germany',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'GB' => 'United Kingdom',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'IE' => 'Ireland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
break;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $displayType = 'Summary';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'AT' => 'Austria',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $modulesFieldsMap = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
{
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'picklistModule' => 'Other.Country',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PT' => 'Portugal',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach (['addresslevel1a', 'addresslevel1b', 'addresslevel1c'] as $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->request->isEmpty($value, true) && ($code = \App\Fields\Country::getCountryCode($this->request->getByType($value, 'Text')))) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $description = 'LBL_VIES_DESC';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'EE' => 'Estonia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LV' => 'Latvia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'MT' => 'Malta',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'NL' => 'Netherlands',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected bool $paid = false;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function search(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $icon = 'yfi yfi-vies';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'labelModule' => '_Base',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BE' => 'Belgium',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FR' => 'France',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'typeofdata' => 'V~M',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Accounts' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getFields(): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$vatNumber) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Vies server address. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'PL' => 'Poland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Vendors' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $url = 'https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'Country',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'ES' => 'Spain',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LU' => 'Luxembourg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $fieldsModels;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsModels['countryCode']->set('fieldvalue', $code);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public $allowedModules = ['Accounts', 'Leads', 'Vendors', 'Competition'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BG' => 'Bulgaria',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'HU' => 'Hungary',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'IT' => 'Italy',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'label' => 'Vat ID',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => 'vat_id',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'HR' => 'Croatia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Competition' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
protected $fields = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'countryCode' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'FI' => 'Finland',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'labelModule' => '_Base',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
],
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$vatNumber = str_replace([' ', ',', '.', '-'], '', $this->request->getByType('vatNumber', 'Text'));
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'uitype' => 16,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'picklistValues' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'EL' => 'Greece',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'SI' => 'Slovenia',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** {@inheritdoc} */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Leads' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fieldsModels = parent::getFields();
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (!$this->isActive()) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'countryCode' => $countryCode,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['fields'] = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Address details' => $r->traderAddress,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($client = new \SoapClient($this->url, \App\RequestHttp::getSoapOptions())) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($r->valid) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$countryCode = $this->request->getByType('countryCode', 'Standard');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'requesterCountryCode' => $countryCode,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Country' => $r->countryCode,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::warning($e->faultstring, 'RecordCollectors');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_REQUEST_DATE' => $r->requestDate,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\SoapFault $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $response;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_REQUEST_ID' => $r->requestIdentifier
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'vatNumber' => $vatNumber,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'requesterVatNumber' => $vatNumber
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'Vat ID' => $r->countryCode . $r->vatNumber,
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['error'] = $e->faultstring;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$r = $client->checkVatApprox([
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LBL_COMPANY_NAME' => $r->traderName,
- Exclude checks