Skip to content

Commit

Permalink
feat(Branch): Implement v4 attributes by doc, Fixes #30
Browse files Browse the repository at this point in the history
  • Loading branch information
Salamek committed Mar 7, 2023
1 parent 35c81dd commit 15b7d66
Show file tree
Hide file tree
Showing 3 changed files with 106 additions and 5 deletions.
33 changes: 33 additions & 0 deletions src/Entity/BranchStatus.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php

declare(strict_types=1);

namespace Salamek\Zasilkovna\Entity;

final class BranchStatus
{
private int $statusId;

private string $description;

/**
* @param array $status
*/
public function __construct(array $status)
{
$this->statusId = (int) $photos['statusId'] ?? -1;
$this->description = $photos['description'] ?? '';
}


public function getStatusId(): int
{
return $this->statusId;
}


public function getDescription(): string
{
return $this->description;
}
}
48 changes: 47 additions & 1 deletion src/Entity/IBranch.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,57 @@ public function __construct(array $data);

public function getName(): string;

public function getLabelRouting(): string;
public function getPlace(): string;

public function getStreet(): string;

public function getCity(): string;

public function getZip(): string;

public function getCountry(): string;

public function getCurrency(): string;

public function getDirections(): string;

public function getDirectionsCar(): string;

public function getDirectionsPublic(): string;

public function isWheelchairAccessible(): bool;

public function isCreditCardPayment(): bool;

public function getLatitude(): float;

public function getLongitude(): float;

public function getDistanceFrom(float $latitude, float $longitude): float;

public function getUrl(): string;

public function isDressingRoom(): bool;

public function isClaimAssistant(): bool;

public function isPacketConsignment(): bool;

public function getMaxWeight(): int;

public function getRegion(): string;

public function getDistrict(): string;

public function getLabelRouting(): string;

public function getLabelName(): string;

public function getPhotos(): array;

public function getOpeningHours(): BranchOpeningHours;

public function getStatus(): BranchStatus;

public function isDisplayFrontend(): bool;
}
30 changes: 26 additions & 4 deletions src/Entity/ZasilkovnaBranch.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ final class ZasilkovnaBranch implements IBranch

private string $name;

private string $nameStreet;

private string $place;

private string $street;
Expand All @@ -26,6 +24,10 @@ final class ZasilkovnaBranch implements IBranch

private string $currency;

private BranchStatus $status;

private bool $displayFrontend;

private ?string $directions;

private ?string $directionsCar;
Expand All @@ -34,6 +36,8 @@ final class ZasilkovnaBranch implements IBranch

private bool $wheelchairAccessible;

private bool $creditCardPayment;

private float $latitude;

private float $longitude;
Expand Down Expand Up @@ -69,17 +73,19 @@ public function __construct(array $data)
{
$this->id = (int) $data['id'];
$this->name = $data['name'];
$this->nameStreet = $data['nameStreet'];
$this->place = $data['place'];
$this->street = $data['street'];
$this->city = $data['city'];
$this->zip = $data['zip'];
$this->country = $data['country'];
$this->currency = $data['currency'];
$this->status = new BranchStatus((array) ($data['status'] ?? []));
$this->displayFrontend = $data['displayFrontend'] === '1';
$this->directions = Tool::convertToString($data['directions'] ?? null);
$this->directionsCar = Tool::convertToString($data['directionsCar'] ?? null);
$this->directionsPublic = Tool::convertToString($data['directionsPublic'] ?? null);
$this->wheelchairAccessible = $data['wheelchairAccessible'] !== 'no';
$this->creditCardPayment = $data['creditCardPayment'] !== 'no';
$this->latitude = (float) $data['latitude'];
$this->longitude = (float) $data['longitude'];
$this->url = $data['url'];
Expand Down Expand Up @@ -115,7 +121,8 @@ public function getName(): string

public function getNameStreet(): string
{
return $this->nameStreet;
trigger_error('Method ' . __METHOD__ . ' is deprecated, use getName() instead!', E_USER_DEPRECATED);
return $this->getName();
}


Expand Down Expand Up @@ -178,6 +185,11 @@ public function isWheelchairAccessible(): bool
return $this->wheelchairAccessible;
}

public function isCreditCardPayment(): bool
{
return $this->creditCardPayment;
}


public function getLatitude(): float
{
Expand Down Expand Up @@ -276,4 +288,14 @@ public function getOpeningHours(): BranchOpeningHours
{
return $this->openingHours;
}

public function getStatus(): BranchStatus
{
return $this->status;
}

public function isDisplayFrontend(): bool
{
return $this->displayFrontend;
}
}

0 comments on commit 15b7d66

Please sign in to comment.