Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion phpstan-bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
define('GF_BAG_FILE', 'plugin.php');
define('GF_BAG_SLUG', 'owc-gravityforms-bag-address');
define('GF_BAG_ROOT_PATH', './');
define('GF_BAG_VERSION', '1.1.3');
define('GF_BAG_VERSION', '1.1.6');
4 changes: 2 additions & 2 deletions plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Description: Add a BAG address field to GravityForms.
* Author: Yard | Digital Agency
* Author URI: https://www.yard.nl
* Version: 1.1.5
* Version: 1.1.6
* License: GPL3.0
* License URI: https://www.gnu.org/licenses/gpl-3.0.txt
* Text Domain: owc-gravityforms-bag-address
Expand All @@ -23,7 +23,7 @@
define('GF_BAG_SLUG', 'owc-gravityforms-bag-address');
define('GF_BAG_LANGUAGE_DOMAIN', GF_BAG_SLUG);
define('GF_BAG_ROOT_PATH', __DIR__);
define('GF_BAG_VERSION', '1.1.5');
define('GF_BAG_VERSION', '1.1.6');

/**
* Manual loaded file: the autoloader.
Expand Down
53 changes: 27 additions & 26 deletions src/BAG/GravityForms/BAGAddress/BAGLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,35 @@ public static function make(): self
* @return string
*/
private function parseURLvariables(): string
{
$params = [
'postcode' => $this->zip,
'type' => 'adres'
];

if (empty($this->homeNumberAddition)) {
$params = array_merge($params, [
'huis_nlt' => $this->homeNumber,
]);
} else {
$params = array_merge($params, [
'huisnummer' => $this->homeNumber,
'huisletter' => $this->homeNumberAddition,
]);
}
{
$arg_and = ['type:adres'];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mierenneuken maar snake_case vs camelCase 🐜

$arg_or = [];

$filteredParameters = array_filter(
$params,
function ($item) {
return !empty($item);
}
);
if (!empty($this->zip)) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De class properties zijn niet typed helaas maar de postcode dient altijd een string te zijn.
Een empty() check kan duiden op een code smell. Niet relevant voor deze PR maar denk dat we deze plugin later nog eens moeten checken in zijn geheel. Ik schrijf hem even op voor later.

$arg_and[] = "postcode:{$this->zip}";
}

$query = http_build_query($filteredParameters, null, '%20and%20');
$query = str_replace('=', ':', $query);
return sprintf('%s%s', $this->url, $query);
}
if (!empty($this->homeNumber)) {
$arg_and[] = "huisnummer:{$this->homeNumber}";
}

if (!empty($this->homeNumberAddition)) {
$addition = strtoupper($this->homeNumberAddition);

$arg_or[] = [
"huisnummertoevoeging:{$addition}",
"huisletter:{$addition}",
];
}

$arg_or = array_map(function ($group) {
return '( ' . implode(' or ', $group) . ' )';
}, $arg_or);

$query = implode(' and ', array_merge($arg_and, $arg_or));

return $this->url . urlencode($query);
}

/**
* Actually execute the remote request.
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
define('GF_BAG_LANGUAGE_DOMAIN', GF_BAG_SLUG);
define('GF_BAG_DIR', basename(__DIR__));
define('GF_BAG_ROOT_PATH', __DIR__);
define('GF_BAG_VERSION', '1.1.3');
define('GF_BAG_VERSION', '1.1.6');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ik zou de versie niet bijwerken in deze PR. Mocht iemand in de tussentijd een andere versie releasen dan ontstaat daar weer een conflict.


/**
* Bootstrap WordPress Mock.
Expand Down