Function getAdvanceData
has a Cognitive Complexity of 19 (exceeds 5 allowed). Consider refactoring. Open
public function getAdvanceData(array &$response): void
{
if (isset($response['Typ'], $response['SilosID']) && ($reportName = $this->getReportName($response['Typ'], $response['SilosID']))) {
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
if (empty($responseFromGus)) {
- 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
Method getAdvanceData
has 59 lines of code (exceeds 25 allowed). Consider refactoring. Open
public function getAdvanceData(array &$response): void
{
if (isset($response['Typ'], $response['SilosID']) && ($reportName = $this->getReportName($response['Typ'], $response['SilosID']))) {
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
if (empty($responseFromGus)) {
Method __doRequest
has 5 arguments (exceeds 4 allowed). Consider refactoring. Open
public function __doRequest($req, $location, $action, $version = SOAP_1_2, $oneWay = null): string
The method getAdvanceData() has a Cyclomatic Complexity of 10. The configured cyclomatic complexity threshold is 10. Open
public function getAdvanceData(array &$response): void
{
if (isset($response['Typ'], $response['SilosID']) && ($reportName = $this->getReportName($response['Typ'], $response['SilosID']))) {
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
if (empty($responseFromGus)) {
- Read upRead up
- Exclude checks
CyclomaticComplexity
Since: 0.1
Complexity is determined by the number of decision points in a method plus one for the method entry. The decision points are 'if', 'while', 'for', and 'case labels'. Generally, 1-4 is low complexity, 5-7 indicates moderate complexity, 8-10 is high complexity, and 11+ is very high complexity.
Example
// Cyclomatic Complexity = 11
class Foo {
1 public function example() {
2 if ($a == $b) {
3 if ($a1 == $b1) {
fiddle();
4 } elseif ($a2 == $b2) {
fiddle();
} else {
fiddle();
}
5 } elseif ($c == $d) {
6 while ($c == $d) {
fiddle();
}
7 } elseif ($e == $f) {
8 for ($n = 0; $n < $h; $n++) {
fiddle();
}
} else {
switch ($z) {
9 case 1:
fiddle();
break;
10 case 2:
fiddle();
break;
11 case 3:
fiddle();
break;
default:
fiddle();
break;
}
}
}
}
Source https://phpmd.org/rules/codesize.html#cyclomaticcomplexity
Refactor this function to reduce its Cognitive Complexity from 21 to the 15 allowed. Open
public function getAdvanceData(array &$response): void
- Read upRead up
- Exclude checks
Cognitive Complexity is a measure of how hard the control flow of a function is to understand. Functions with high Cognitive Complexity will be difficult to maintain.
See
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$this->__setSoapHeaders($header);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$this->__setSoapHeaders($header);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Wyloguj'), 0);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Zaloguj'), 0);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$this->__setSoapHeaders($header);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction($type), true);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Avoid using undefined variables such as '$header' which will lead to PHP notices. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], true);
- Read upRead up
- Exclude checks
UndefinedVariable
Since: 2.8.0
Detects when a variable is used that has not been defined before.
Example
class Foo
{
private function bar()
{
// $message is undefined
echo $message;
}
}
Source https://phpmd.org/rules/cleancode.html#undefinedvariable
Missing class import via use statement (line '159', column '20'). Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- 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
Missing class import via use statement (line '204', column '19'). Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], true);
- 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
Missing class import via use statement (line '177', column '22'). Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- 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
Missing class import via use statement (line '203', column '19'). Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction($type), true);
- 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
Missing class import via use statement (line '176', column '22'). Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Wyloguj'), 0);
- 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
Missing class import via use statement (line '158', column '20'). Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Zaloguj'), 0);
- 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\RequestHttp' in method 'getInstance'. Open
$options = \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 'endSession'. Open
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
- 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 '243', column '57'). Open
public function getAdvanceData(array &$response): void
{
if (isset($response['Typ'], $response['SilosID']) && ($reportName = $this->getReportName($response['Typ'], $response['SilosID']))) {
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
if (empty($responseFromGus)) {
- 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 using static access to class '\App\Json' in method 'getInstance'. Open
$cacheKey = \App\Json::encode($params);
- 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\Purifier' in method 'parseResponse'. Open
$fields[$val[2]] = \App\Purifier::decodeHtml($val[3]);
- 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
The method getAdvanceData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$additional[] = "{$value[$prefixName . 'pkdKod']} - {$name}";
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
The method getAdvanceData uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
$response = [];
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Define a constant instead of duplicating this literal "BIR11OsFizycznaPkd" 4 times. Open
'BIR11OsFizycznaDzialalnoscCeidg' => 'BIR11OsFizycznaPkd',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Regon" 4 times. Open
$response = $this->getData('DaneSzukajPodmioty', ['pParametryWyszukiwania' => ['Nip' => $vatId, 'Krs' => $ncr, 'Regon' => $taxNumber]]);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "UTF-8" 3 times. Open
$response['PodstawowaFormaPrawnaNazwa'] = mb_convert_case($responseFromGus[$prefixName . 'podstawowaFormaPrawna_Nazwa'] ?? '', MB_CASE_TITLE, 'UTF-8');
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "BIR11OsPrawna" 4 times. Open
'P' => 'BIR11OsPrawna',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "BIR11OsFizycznaDzialalnoscPozostala" 3 times. Open
'3' => 'BIR11OsFizycznaDzialalnoscPozostala',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "BIR11JednLokalnaOsPrawnej" 3 times. Open
'LP' => 'BIR11JednLokalnaOsPrawnej',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "fiz_adSiedzNumerNieruchomosci" 4 times. Open
'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108' => 'fiz_adSiedzNumerNieruchomosci',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "BIR11OsFizycznaDzialalnoscSkreslonaDo20141108" 4 times. Open
'4' => 'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "pRegon" 3 times. Open
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "BIR11OsFizycznaDzialalnoscCeidg" 3 times. Open
'1' => 'BIR11OsFizycznaDzialalnoscCeidg',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "Action" 3 times. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Zaloguj'), 0);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "addressToService" 5 times. Open
'addressToService' => 'https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "BIR11OsFizycznaDzialalnoscRolnicza" 3 times. Open
'2' => 'BIR11OsFizycznaDzialalnoscRolnicza',
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Define a constant instead of duplicating this literal "pNazwaRaportu" 3 times. Open
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
- Read upRead up
- Exclude checks
Duplicated string literals make the process of refactoring error-prone, since you must be sure to update all occurrences.
On the other hand, constants can be referenced from many places, but only need to be updated in a single place.
Noncompliant Code Example
With the default threshold of 3:
function run() { prepare('action1'); // Non-Compliant - 'action1' is duplicated 3 times execute('action1'); release('action1'); }
Compliant Solution
ACTION_1 = 'action1'; function run() { prepare(ACTION_1); execute(ACTION_1); release(ACTION_1); }
Exceptions
To prevent generating some false-positives, literals having less than 5 characters are excluded.
Call with 2 arg(s) to \App\RecordCollectors\Helper\GusClient::__construct()
which only takes 0 arg(s) defined at /code/app/RecordCollectors/Helper/GusClient.php:22
Open
$instance = new self(self::CONFIG['addressToWsdl'], $options);
- Exclude checks
When fetching an array index from a value of type array{1:'BIR11OsFizycznaDzialalnoscCeidg',2:'BIR11OsFizycznaDzialalnoscRolnicza',3:'BIR11OsFizycznaDzialalnoscPozostala',4:'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108'},
found an array index of type string,
but expected the index to be of type int
Open
$name = self::REPORT_NAME[$type][$silosId];
- Exclude checks
Variable $header
was undeclared, but array fields are being added to it. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Wyloguj'), 0);
- Exclude checks
Argument 4 (mustunderstand)
is 0
but \SoapHeader::__construct()
takes bool
Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- Exclude checks
Reference to undeclared property \App\RecordCollectors\Helper\GusClient->register
Open
$this->register = true;
- Exclude checks
Variable $header
was undeclared, but array fields are being added to it. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Zaloguj'), 0);
- Exclude checks
Argument 4 (mustunderstand)
is 0
but \SoapHeader::__construct()
takes bool
Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- Exclude checks
Call to method error
from undeclared class \App\Log
Open
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
- Exclude checks
Argument 4 (mustunderstand)
is 0
but \SoapHeader::__construct()
takes bool
Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Wyloguj'), 0);
- Exclude checks
Variable $header
was undeclared, but array fields are being added to it. Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction($type), true);
- Exclude checks
Argument 4 (mustunderstand)
is 0
but \SoapHeader::__construct()
takes bool
Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Zaloguj'), 0);
- Exclude checks
Reference to undeclared property \App\RecordCollectors\Helper\GusClient->register
Open
if (empty($this->register)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'3' => 'BIR11OsFizycznaDzialalnoscPozostala',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsPrawna' => 'praw_adSiedzNumerNieruchomosci',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var self[] Namespace for header. */
- 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
'LF' => 'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addressToWsdl' => 'https://wyszukiwarkaregon.stat.gov.pl/wsBIR/wsdl/UslugaBIRzewnPubl-ver11-prod.wsdl',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $streamContext;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'1' => 'BIR11OsFizycznaDzialalnoscCeidg',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Mapping field from report to number local field in record. */
- 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
const PKD_REPORTS = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const HEADER_NAMESPACE = 'http://www.w3.org/2005/08/addressing';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const REPORT_TO_NUMBER_LOCAL = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsPrawna' => 'praw_',
- 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
'BIR11OsFizycznaDzialalnoscRolnicza' => 'BIR11OsFizycznaPkd',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $params;
- 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
const REPORT_NAME = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'F' => [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'2' => 'BIR11OsFizycznaDzialalnoscRolnicza',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'P' => 'BIR11OsPrawna',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11JednLokalnaOsPrawnej' => 'BIR11JednLokalnaOsPrawnejPkd',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Params. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get instance.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsFizycznaDzialalnoscPozostala' => 'fiz_adSiedzNumerNieruchomosci',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108' => 'BIR11OsFizycznaPkd',
- 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
/** @var string Client session. */
- 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
'BIR11OsFizycznaDzialalnoscCeidg' => 'fiz_adSiedzNumerNieruchomosci',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsFizycznaDzialalnoscCeidg' => 'BIR11OsFizycznaPkd',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var array Report names for entity. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'addressToService' => 'https://wyszukiwarkaregon.stat.gov.pl/wsBIR/UslugaBIRzewnPubl.svc',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static $cache = [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsFizycznaDzialalnoscRolnicza' => 'fiz_adSiedzNumerNieruchomosci',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] PKD report map. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const CONFIG = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private $sessionId;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Client connection details. */
- 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
* @return self
- Exclude checks
Line exceeds 120 characters; contains 182 characters Open
* The file is part of the paid functionality. Using the file is allowed only after purchasing a subscription. File modification allowed only with the consent of the system producer.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'4' => 'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'LP' => 'BIR11JednLokalnaOsPrawnej',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string[] Variable for mapping report names to value prefix. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
const REPORT_PREFIX = [
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $params
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11JednLokalnaOsPrawnej' => 'lokpraw_',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var string Namespace for header. */
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'apiKey' => 'd2df36a7394c432e88ea',
- 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
'BIR11OsFizycznaDzialalnoscSkreslonaDo20141108' => 'fiz_adSiedzNumerNieruchomosci',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsPrawna' => 'BIR11OsPrawnaPkd',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
'BIR11OsFizycznaDzialalnoscPozostala' => 'BIR11OsFizycznaPkd',
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
/** @var resource Stream context. */
- 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
$options['stream_context'] = $context;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $action
- 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
* End session - logout.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function endSession()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__setSoapHeaders();
- 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
if (isset($response['Typ'], $response['SilosID']) && ($reportName = $this->getReportName($response['Typ'], $response['SilosID']))) {
- Exclude checks
Line exceeds 120 characters; contains 140 characters Open
if (isset($response['Typ'], $response['SilosID']) && ($reportName = $this->getReportName($response['Typ'], $response['SilosID']))) {
- 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
if (empty($this->sessionId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->sessionId = $result->ZalogujResult;
- 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
try {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->Wyloguj(['pIdentyfikatorSesji' => $this->sessionId]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getAdvanceData(array &$response): void
- 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
* @param string $response
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return void
- 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
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction($type), true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public static function getInstance(array $params = []): self
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance->params = $params;
- 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
$response = parent::__doRequest($req, self::CONFIG['addressToService'], $action, $version);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $totalFields;
- 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
throw $e;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $ncr
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($response as &$info) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$cache[$cacheKey];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$context = stream_context_create([]);
- 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
* Start session - login.
- 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
if (!$vatId && !$taxNumber && !$ncr) {
- Exclude checks
Line exceeds 120 characters; contains 145 characters Open
$response = $this->getData('DaneSzukajPodmioty', ['pParametryWyszukiwania' => ['Nip' => $vatId, 'Krs' => $ncr, 'Regon' => $taxNumber]]);
- 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
$instance->streamContext = $context;
- 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
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Zaloguj'), 0);
- 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
* @param array $params
- 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
$options['soap_version'] = SOAP_1_2;
- 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
$totalFields[] = $fields;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields[$val[2]] = \App\Purifier::decodeHtml($val[3]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__setSoapHeaders($header);
- 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
* Get data from API.
- 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
return [];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$options = \App\RequestHttp::getSoapOptions();
- 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
$this->__setSoapHeaders($header);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'To', self::CONFIG['addressToService'], true);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $vatId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param array $response
- 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 string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getAddressToAction(string $action): string
- 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 'http://CIS/BIR/PUBL/2014/07/IUslugaBIRzewnPubl/' . $action;
- 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
Line exceeds 120 characters; contains 123 characters Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Wyloguj'), 0);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function getData(string $type, array $params): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__setSoapHeaders($header);
- 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
public function search(?string $vatId, ?string $ncr = null, ?string $taxNumber = null): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$options['encoding'] = 'utf-8';
- 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
$totalFields = $fields = [];
- 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
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return $this->parseResponse($result->{"{$type}Result"});
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset(self::$cache[$cacheKey])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
return self::$cache[$cacheKey] = $instance;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$header[] = new \SoapHeader(self::HEADER_NAMESPACE, 'Action', $this->getAddressToAction('Wyloguj'), 0);
- 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
$result = $this->{$type}($params);
- 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
$this->getAdvanceData($info);
- Exclude checks
Line exceeds 120 characters; contains 138 characters Open
$responseFromGus = $this->getData('DanePobierzPelnyRaport', ['pRegon' => $response['Regon'], 'pNazwaRaportu' => $reportName]);
- 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
public function __doRequest($req, $location, $action, $version = SOAP_1_2, $oneWay = null): string
- 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
preg_match('/<s:Envelope.*<\\/s:Envelope>/s', $response, $matches);
- 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 array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function parseResponse(string $response): array
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$totalFields[] = $fields;
- 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
* Search entity.
- 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 $matches[0];
- 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
* Parsing response.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($matches as $val) {
- 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
if (empty($this->register)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} catch (\Throwable $e) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->startSession();
- 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
* Get data for record fields from gus reports.
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$fields = [];
- 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
$result = $this->Zaloguj(['pKluczUzytkownika' => self::CONFIG['apiKey']]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($this->sessionId)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->endSession();
- 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
*
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* Get address to action.
- 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
if (isset($fields[$val[2]])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
public function startSession()
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
register_shutdown_function(function () {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
\App\Log::error($e->getMessage() . PHP_EOL . $e->__toString());
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
stream_context_set_option($this->streamContext, ['http' => ['header' => 'sid: ' . $this->sessionId]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->__setSoapHeaders();
- 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 void
- 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
$cacheKey = \App\Json::encode($params);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$instance = new self(self::CONFIG['addressToWsdl'], $options);
- 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
preg_match_all('/(<([\\w]+)[^>]*>)(.*?)(<\\/\\2>)/', $response, $matches, PREG_SET_ORDER);
- 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 void
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$this->register = true;
- 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
}
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string|null $taxNumber
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return array
- 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 = $this->getData('DaneSzukajPodmioty', ['pParametryWyszukiwania' => ['Nip' => $vatId, 'Krs' => $ncr, 'Regon' => $taxNumber]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['NumerBudynku'] = $responseFromGus[self::REPORT_TO_NUMBER_LOCAL[$reportName]] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataZawieszeniaDzialalnosci'] = $responseFromGus[$prefixName . 'dataZawieszeniaDzialalnosci'] ?? '';
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$result = $this->DanePobierzPelnyRaport(['pRegon' => $response['Regon'], 'pNazwaRaportu' => self::PKD_REPORTS[$reportName]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ($value[$prefixName . 'pkdPrzewazajace']) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$additional[] = "{$value[$prefixName . 'pkdKod']} - {$name}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} elseif (isset(self::REPORT_NAME[$type])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$prefixName = self::REPORT_PREFIX[$reportName] ?? 'fiz_';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responseFromGusFiz = $this->parseResponse($resultFiz->DanePobierzPelnyRaportResult);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['SzczegolnaFormaPrawnaNazwa'] = mb_convert_case($responseFromGus[$prefixName . 'szczegolnaFormaPrawna_Nazwa'] ?? '', MB_CASE_TITLE, 'UTF-8');
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
$response['SzczegolnaFormaPrawna'] = "{$response['SzczegolnaFormaPrawnaKod']} - {$response['SzczegolnaFormaPrawnaNazwa']}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (\in_array('pkd', $this->params)) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
} else {
- 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
$responseFromGusFiz = reset($responseFromGusFiz);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['NumerFaksu'] = $responseFromGus[$prefixName . 'numerFaksu'] ?? '';
- Exclude checks
Line exceeds 120 characters; contains 130 characters Open
$response['AdresStronyInternetowej'] = mb_strtolower($responseFromGus[$prefixName . 'adresStronyinternetowej'] ?? '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataWpisuDoRejestruEwidencji'] = $responseFromGus[$prefixName . 'dataWpisuDoRejestruEwidencji'] ?? '';
- Exclude checks
Line exceeds 120 characters; contains 125 characters Open
$response['DataWpisuDoRejestruEwidencji'] = $responseFromGus[$prefixName . 'dataWpisuDoRejestruEwidencji'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (empty($responseFromGus)) {
- Exclude checks
Line exceeds 120 characters; contains 141 characters Open
$resultFiz = $this->DanePobierzPelnyRaport(['pRegon' => $response['Regon'], 'pNazwaRaportu' => 'BIR11OsFizycznaDaneOgolne']);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataZakonczeniaDzialalnosci'] = $responseFromGus[$prefixName . 'dataZakonczeniaDzialalnosci'] ?? '';
- 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;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['PodstawowaFormaPrawnaKod'] = $responseFromGus[$prefixName . 'podstawowaFormaPrawna_Symbol'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataWznowieniaDzialalnosci'] = $responseFromGus[$prefixName . 'dataWznowieniaDzialalnosci'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$responseFromGus = array_merge($responseFromGus, $responseFromGusFiz);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['PKDPodstawowyNazwa'] = $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::REPORT_NAME[$type];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['Kraj'] = 'POLSKA' === $response['Kraj'] ? 'Poland' : $response['Kraj'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['PodstawowaFormaPrawna'] = "{$response['PodstawowaFormaPrawnaKod']} - {$response['PodstawowaFormaPrawnaNazwa']}";
- 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
return $name;
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['FormaFinansowania'] = $responseFromGus[$prefixName . 'formaFinansowania_Nazwa'] ?? '';
- 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
Line exceeds 120 characters; contains 121 characters Open
$response['PodstawowaFormaPrawnaKod'] = $responseFromGus[$prefixName . 'podstawowaFormaPrawna_Symbol'] ?? '';
- 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
$additional = [];
- 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
} else {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $type
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @return string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['NumerTelefonu'] = $responseFromGus[$prefixName . 'numerTelefonu'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['PodstawowaFormaPrawnaNazwa'] = mb_convert_case($responseFromGus[$prefixName . 'podstawowaFormaPrawna_Nazwa'] ?? '', MB_CASE_TITLE, 'UTF-8');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataSkresleniazRegon'] = $responseFromGus[$prefixName . 'dataSkresleniazRegon'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if (isset($responseFromGus[$prefixName . 'nip'])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['Nip'] = $responseFromGus[$prefixName . 'nip'];
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['PKDPozostale'] = implode(' ## ', $additional);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('F' === $type && isset(self::REPORT_NAME[$type][$silosId])) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = self::REPORT_NAME[$type][$silosId];
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
$response['PodstawowaFormaPrawnaNazwa'] = mb_convert_case($responseFromGus[$prefixName . 'podstawowaFormaPrawna_Nazwa'] ?? '', MB_CASE_TITLE, 'UTF-8');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataRozpoczeciaDzialalnosci'] = $responseFromGus[$prefixName . 'dataRozpoczeciaDzialalnosci'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['FormaWlasnosci'] = $responseFromGus[$prefixName . 'formaWlasnosci_Nazwa'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataPowstania'] = $responseFromGus[$prefixName . 'dataPowstania'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataWpisuDoREGON'] = $responseFromGus[$prefixName . 'dataWpisuDoREGON'] ?? '';
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$response['DataZawieszeniaDzialalnosci'] = $responseFromGus[$prefixName . 'dataZawieszeniaDzialalnosci'] ?? '';
- 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
* Undocumented function.
- Exclude checks
Line exceeds 120 characters; contains 163 characters Open
$response['SzczegolnaFormaPrawnaNazwa'] = mb_convert_case($responseFromGus[$prefixName . 'szczegolnaFormaPrawna_Nazwa'] ?? '', MB_CASE_TITLE, 'UTF-8');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['SzczegolnaFormaPrawnaKod'] = $responseFromGus[$prefixName . 'szczegolnaFormaPrawna_Symbol'] ?? '';
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$response['SzczegolnaFormaPrawnaKod'] = $responseFromGus[$prefixName . 'szczegolnaFormaPrawna_Symbol'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$result = $this->DanePobierzPelnyRaport(['pRegon' => $response['Regon'], 'pNazwaRaportu' => self::PKD_REPORTS[$reportName]]);
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$resultFiz = $this->DanePobierzPelnyRaport(['pRegon' => $response['Regon'], 'pNazwaRaportu' => 'BIR11OsFizycznaDaneOgolne']);
- Exclude checks
Line exceeds 120 characters; contains 135 characters Open
$response['PodstawowaFormaPrawna'] = "{$response['PodstawowaFormaPrawnaKod']} - {$response['PodstawowaFormaPrawnaNazwa']}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['DataZaistnieniaZmiany'] = $responseFromGus[$prefixName . 'dataZaistnieniaZmiany'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
foreach ($this->parseResponse($result->DanePobierzPelnyRaportResult) as $value) {
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['PKDPodstawowyKod'] = $value[$prefixName . 'pkdKod'];
- 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
$responseFromGus = reset($responseFromGus);
- 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['AdresEmail'] = mb_strtolower($responseFromGus[$prefixName . 'adresEmail'] ?? '');
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$response['DataRozpoczeciaDzialalnosci'] = $responseFromGus[$prefixName . 'dataRozpoczeciaDzialalnosci'] ?? '';
- Exclude checks
Line exceeds 120 characters; contains 121 characters Open
$response['DataWznowieniaDzialalnosci'] = $responseFromGus[$prefixName . 'dataWznowieniaDzialalnosci'] ?? '';
- 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
*/
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
private function getReportName(string $type, string $silosId): string
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['NumerLokalu'] = $responseFromGus[$prefixName . 'adSiedzNumerLokalu'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['Krs'] = $responseFromGus[$prefixName . 'numerWrejestrzeEwidencji'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['Kraj'] = $responseFromGus[$prefixName . 'adSiedzKraj_Nazwa'] ?? '';
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['AdresStronyInternetowej'] = mb_strtolower($responseFromGus[$prefixName . 'adresStronyinternetowej'] ?? '');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$response['SzczegolnaFormaPrawna'] = "{$response['SzczegolnaFormaPrawnaKod']} - {$response['SzczegolnaFormaPrawnaNazwa']}";
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
$name = mb_convert_case($value[$prefixName . 'pkdNazwa'] ?? '', MB_CASE_TITLE, 'UTF-8');
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
* @param string $silosId
- Exclude checks
Spaces must be used to indent lines; tabs are not allowed Open
if ('fiz_' === $prefixName) {
- Exclude checks
Line exceeds 120 characters; contains 123 characters Open
$response['DataZakonczeniaDzialalnosci'] = $responseFromGus[$prefixName . 'dataZakonczeniaDzialalnosci'] ?? '';
- 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
The method __doRequest is not named in camelCase. Open
public function __doRequest($req, $location, $action, $version = SOAP_1_2, $oneWay = null): string
{
$response = parent::__doRequest($req, self::CONFIG['addressToService'], $action, $version);
preg_match('/<s:Envelope.*<\\/s:Envelope>/s', $response, $matches);
return $matches[0];
- Read upRead up
- Exclude checks
CamelCaseMethodName
Since: 0.2
It is considered best practice to use the camelCase notation to name methods.
Example
class ClassName {
public function get_name() {
}
}