Method update
has 91 lines of code (exceeds 25 allowed). Consider refactoring.
function update($user_id, $order = null)
{
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
if (!empty($vindi_customer_id)) {
$vindiUser = $this->routes->findCustomerById($vindi_customer_id);
Function update
has a Cognitive Complexity of 25 (exceeds 5 allowed). Consider refactoring.
function update($user_id, $order = null)
{
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
if (!empty($vindi_customer_id)) {
$vindiUser = $this->routes->findCustomerById($vindi_customer_id);
The class CustomerController has an overall complexity of 57 which is very high. The configured complexity threshold is 50.
class CustomerController
{
/**
* @var VindiSettings
Method create
has 61 lines of code (exceeds 25 allowed). Consider refactoring.
function create($user_id, $order = null)
{
$customer = new WC_Customer($user_id);
Function create
has a Cognitive Complexity of 15 (exceeds 5 allowed). Consider refactoring.
function create($user_id, $order = null)
{
$customer = new WC_Customer($user_id);
The method create() has an NPath complexity of 589824. The configured NPath complexity threshold is 200.
function create($user_id, $order = null)
{
$customer = new WC_Customer($user_id);
The method update() has an NPath complexity of 38928384. The configured NPath complexity threshold is 200.
function update($user_id, $order = null)
{
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
if (!empty($vindi_customer_id)) {
$vindiUser = $this->routes->findCustomerById($vindi_customer_id);
The method update() has a Cyclomatic Complexity of 30. The configured cyclomatic complexity threshold is 10.
function update($user_id, $order = null)
{
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
if (!empty($vindi_customer_id)) {
$vindiUser = $this->routes->findCustomerById($vindi_customer_id);
The method create() has a Cyclomatic Complexity of 23. The configured cyclomatic complexity threshold is 10.
function create($user_id, $order = null)
{
$customer = new WC_Customer($user_id);
The method create uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them.
} else {
$cpf_or_cnpj = $order->get_meta('_billing_cpf');
$notes = '';
The property $vindi_settings is not named in camelCase.
class CustomerController
{
/**
* @var VindiSettings
Visibility must be declared on method "__construct"
function __construct(VindiSettings $vindi_settings)
Visibility must be declared on method "create"
function create($user_id, $order = null)
Visibility must be declared on method "update"
function update($user_id, $order = null)
Blank line found at start of control structure
if (empty($vindi_customer_id)) {
Visibility must be declared on method "delete"
function delete($user_id)
Blank line found at start of control structure
if (!$vindiUser) {
Line exceeds 120 characters; contains 125 characters
'neighborhood' => ($customer->get_meta('billing_neighborhood')) ? $customer->get_meta('billing_neighborhood') : '',
Line exceeds 120 characters; contains 125 characters
'neighborhood' => ($customer->get_meta('billing_neighborhood')) ? $customer->get_meta('billing_neighborhood') : '',
Line indented incorrectly; expected at least 8 spaces, found 4
add_action('woocommerce_save_account_details', array($this, 'update'), 10, 1);
Line indented incorrectly; expected 8 spaces, found 4
if ($customer->get_billing_phone()) {
Multi-line function call not indented correctly; expected 8 spaces but found 6
array(
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 8 spaces, found 4
$notes = null;
Line indented incorrectly; expected at least 16 spaces, found 8
$cpf_or_cnpj = $order->get_meta('_billing_cnpj');
Line indented incorrectly; expected at least 12 spaces, found 6
$phones[] = array(
Line indented incorrectly; expected 4 spaces, found 2
function create($user_id, $order = null)
Line indented incorrectly; expected at least 12 spaces, found 6
$metadata = array();
Line indented incorrectly; expected at least 16 spaces, found 8
$name = $order->get_billing_company();
Line indented incorrectly; expected at least 16 spaces, found 8
$notes = sprintf('Nome: %s %s', $order->get_billing_first_name(), $order->get_billing_last_name());
Line indented incorrectly; expected at least 8 spaces, found 4
$createdUser = $this->routes->createCustomer(
Line indented incorrectly; expected 4 spaces, found 2
private $vindi_settings;
Line indented incorrectly; expected at least 8 spaces, found 4
$this->vindi_settings = $vindi_settings;
Line indented incorrectly; expected 8 spaces, found 4
if ($customer->get_meta('billing_cellphone')) {
Line indented incorrectly; expected 16 spaces, found 8
if ($this->vindi_settings->send_nfe_information()) {
Line indented incorrectly; expected at least 20 spaces, found 10
$metadata['carteira_de_identidade'] = $order->get_meta('_billing_rg');
Line indented incorrectly; expected at least 8 spaces, found 4
add_action('user_register', array($this, 'create'), 10, 1);
Line indented incorrectly; expected at least 8 spaces, found 4
$customer = new WC_Customer($user_id);
Line indented incorrectly; expected at least 12 spaces, found 8
'number' => preg_replace('/\D+/', '', '55' . $customer->get_billing_phone())
Line indented incorrectly; expected 4 spaces, found 2
private $routes;
Line indented incorrectly; expected at least 8 spaces, found 4
add_action('woocommerce_customer_save_address', array($this, 'update'), 10, 1);
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
$user = $customer->get_data();
Line indented incorrectly; expected 12 spaces, found 6
} else {
Line indented incorrectly; expected at least 10 spaces, found 4
);
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
$name = (!$user['first_name']) ? $user['display_name'] : $user['first_name'] . ' ' . $user['last_name'];
Line indented incorrectly; expected 12 spaces, found 6
if ('2' === $order->get_meta('_billing_persontype')) {
Line indented incorrectly; expected 16 spaces, found 8
}
Multi-line function call not indented correctly; expected 8 spaces but found 6
)
Line indented incorrectly; expected at least 8 spaces, found 4
$cpf_or_cnpj = null;
Line indented incorrectly; expected at least 12 spaces, found 6
$phones[] = array(
Line indented incorrectly; expected at least 16 spaces, found 6
);
Line indented incorrectly; expected 8 spaces, found 4
if ($order && method_exists($order, 'needs_payment')) {
Line indented incorrectly; expected at least 16 spaces, found 8
$cpf_or_cnpj = $order->get_meta('_billing_cpf');
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 4
add_action('delete_user', array($this, 'delete'), 10, 1);
Line indented incorrectly; expected at least 8 spaces, found 4
$phones = [];
Line indented incorrectly; expected at least 12 spaces, found 8
'number' => preg_replace('/\D+/', '', '55' . $customer->get_meta('billing_cellphone'))
Line indented incorrectly; expected 16 spaces, found 8
if ($this->vindi_settings->send_nfe_information()) {
Line indented incorrectly; expected at least 20 spaces, found 10
$metadata['inscricao_estadual'] = $order->get_meta('_billing_ie');
Line indented incorrectly; expected at least 8 spaces, found 6
array(
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 12 spaces, found 6
return $this->create($user_id);
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 4
if (empty($vindi_customer_id)) {
Line indented incorrectly; expected 4 spaces, found 2
function __construct(VindiSettings $vindi_settings)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 12 spaces, found 8
'phone_type' => 'landline',
Line indented incorrectly; expected at least 16 spaces, found 8
$notes = '';
Line indented incorrectly; expected at least 14 spaces, found 12
update_user_meta($user_id, 'vindi_customer_id', $createdUser['id']);
Line indented incorrectly; expected at least 12 spaces, found 4
return $createdUser;
Line indented incorrectly; expected at least 8 spaces, found 4
$cpf_or_cnpj = null;
Line indented incorrectly; expected at least 10 spaces, found 4
);
Line indented incorrectly; expected at least 16 spaces, found 6
);
Line indented incorrectly; expected 8 spaces, found 4
if ($customer->get_billing_phone()) {
Line indented incorrectly; expected at least 4 spaces, found 2
{
Multi-line function call not indented correctly; expected 8 spaces but found 6
$vindi_customer_id
Line indented incorrectly; expected at least 8 spaces, found 6
$vindi_customer_id
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 4 spaces, found 2
function update($user_id, $order = null)
Line indented incorrectly; expected at least 12 spaces, found 6
$vindi_phones[$phone['phone_type']] = $phone['id'];
Line indented incorrectly; expected at least 12 spaces, found 8
'number' => preg_replace('/\D+/', '', '55' . $customer->get_meta('billing_cellphone'))
Line indented incorrectly; expected at least 8 spaces, found 6
$vindi_customer_id,
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 10 spaces, found 4
);
Line indented incorrectly; expected at least 8 spaces, found 4
$metadata = null;
Line indented incorrectly; expected at least 12 spaces, found 8
'phone_type' => 'mobile',
Line indented incorrectly; expected at least 16 spaces, found 6
);
Line indented incorrectly; expected 16 spaces, found 8
}
Line indented incorrectly; expected 12 spaces, found 10
}
Line indented incorrectly; expected at least 8 spaces, found 4
$notes = null;
Line indented incorrectly; expected 8 spaces, found 4
if ($order && method_exists($order, 'needs_payment')) {
Line indented incorrectly; expected 16 spaces, found 8
}
Line indented incorrectly; expected at least 16 spaces, found 8
$this->vindi_settings->logger->log(sprintf('Order rg -> %s', $order->get_meta('_billing_rg')));
Line indented incorrectly; expected at least 8 spaces, found 4
$this->routes = $vindi_settings->routes;
Line indented incorrectly; expected 12 spaces, found 6
}
Line indented incorrectly; expected at least 8 spaces, found 6
)
Line indented incorrectly; expected 8 spaces, found 4
foreach ($vindiUser['phones'] as $phone) {
Line indented incorrectly; expected at least 12 spaces, found 6
$landline = array(
Line indented incorrectly; expected at least 8 spaces, found 6
)
Line indented incorrectly; expected at least 10 spaces, found 4
return $deletedUser;
Line indented incorrectly; expected 8 spaces, found 4
if (empty($vindi_customer_id)) {
Line indented incorrectly; expected at least 8 spaces, found 4
$name = (!$user['first_name']) ? $user['display_name'] : $user['first_name'] . ' ' . $user['last_name'];
Line indented incorrectly; expected 16 spaces, found 8
}
Line indented incorrectly; expected at least 8 spaces, found 4
$updatedUser = $this->routes->updateCustomer(
Line indented incorrectly; expected at least 10 spaces, found 4
return $updatedUser;
Line indented incorrectly; expected at least 12 spaces, found 6
return;
Line indented incorrectly; expected at least 12 spaces, found 6
return;
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 12 spaces, found 6
$mobile = array(
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 20 spaces, found 10
$metadata['inscricao_estadual'] = $order->get_meta('_billing_ie');
Line indented incorrectly; expected at least 20 spaces, found 10
$metadata['carteira_de_identidade'] = $order->get_meta('_billing_rg');
Line indented incorrectly; expected at least 8 spaces, found 4
$vindiUser = $this->routes->findCustomerById($vindi_customer_id);
Line indented incorrectly; expected at least 8 spaces, found 4
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
Line indented incorrectly; expected 8 spaces, found 4
if (!$vindiUser) {
Line indented incorrectly; expected at least 8 spaces, found 4
$customer = new WC_Customer($user_id);
Line indented incorrectly; expected at least 8 spaces, found 4
$phones = $vindi_phones = [];
Line indented incorrectly; expected at least 12 spaces, found 8
'phone_type' => 'mobile',
Line indented incorrectly; expected 16 spaces, found 8
if ($this->vindi_settings->send_nfe_information()) {
Multi-line function call not indented correctly; expected 8 spaces but found 6
$vindi_customer_id,
Multi-line function call not indented correctly; expected 8 spaces but found 6
array(
Line indented incorrectly; expected 4 spaces, found 2
function delete($user_id)
Line indented incorrectly; expected 4 spaces, found 2
}
Line indented incorrectly; expected at least 8 spaces, found 4
$user = $customer->get_data();
Line indented incorrectly; expected at least 8 spaces, found 4
$metadata = null;
Line indented incorrectly; expected at least 16 spaces, found 8
$name = $order->get_billing_company();
Line indented incorrectly; expected at least 16 spaces, found 8
$this->vindi_settings->logger->log(sprintf('Order cpf -> %s', $cpf_or_cnpj));
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 12 spaces, found 8
'number' => preg_replace('/\D+/', '', '55' . $customer->get_billing_phone())
Line indented incorrectly; expected at least 16 spaces, found 8
$this->vindi_settings->logger->log(sprintf('Customer cpf -> %s', $customer->get_meta('billing_cpf')));
Line indented incorrectly; expected at least 16 spaces, found 8
$notes = '';
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 8 spaces, found 6
array(
Line indented incorrectly; expected 12 spaces, found 6
}
Line indented incorrectly; expected at least 8 spaces, found 4
$deletedUser = $this->routes->deleteCustomer(
Line indented incorrectly; expected 8 spaces, found 4
if (empty($vindi_customer_id)) {
Line indented incorrectly; expected 8 spaces, found 4
if ($customer->get_meta('billing_cellphone')) {
Line indented incorrectly; expected at least 16 spaces, found 8
$cpf_or_cnpj = $order->get_meta('_billing_cnpj');
Line indented incorrectly; expected at least 16 spaces, found 8
$notes = sprintf('Nome: %s %s', $order->get_billing_first_name(), $order->get_billing_last_name());
Line indented incorrectly; expected 16 spaces, found 8
if ($this->vindi_settings->send_nfe_information()) {
Line indented incorrectly; expected 8 spaces, found 4
if (!$vindiUser) {
Line indented incorrectly; expected at least 12 spaces, found 10
$vindiUser = $this->routes->findCustomerById($vindi_customer_id);
Line indented incorrectly; expected at least 12 spaces, found 6
return $this->create($user_id, $order);
Line indented incorrectly; expected at least 16 spaces, found 6
$phones[] = $mobile;
Line indented incorrectly; expected at least 16 spaces, found 6
);
Line indented incorrectly; expected at least 16 spaces, found 8
$cpf_or_cnpj = $order->get_meta('_billing_cpf');
Multi-line function call not indented correctly; expected 8 spaces but found 6
)
Line indented incorrectly; expected at least 4 spaces, found 2
{
Line indented incorrectly; expected at least 12 spaces, found 8
'phone_type' => 'landline',
Line indented incorrectly; expected at least 16 spaces, found 6
$phones[] = $landline;
Line indented incorrectly; expected 8 spaces, found 4
}
Line indented incorrectly; expected at least 12 spaces, found 6
$metadata = array();
Line indented incorrectly; expected 12 spaces, found 6
if ('2' === $order->get_meta('_billing_persontype')) {
Line indented incorrectly; expected at least 8 spaces, found 4
$vindi_customer_id = get_user_meta($user_id, 'vindi_customer_id', true);
There are no issues that match your filters.