Skip to content

Commit

Permalink
🐛 apparently previous director data is now completely different
Browse files Browse the repository at this point in the history
  • Loading branch information
willpower232 committed Oct 5, 2022
1 parent 4975326 commit ab468af
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/Models/Company.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,11 @@ public function __construct($client, array $companyDetails)
$this->otherAddresses = $companyDetails['report']['contactInformation']['otherAddresses'] ?? [];

$this->currentDirectors = array_map(function ($director) {
return new Company\Director($this, $director, true);
return new Company\Director($this, $director);
}, $companyDetails['report']['directors']['currentDirectors'] ?? []);

$this->previousDirectors = array_map(function ($director) {
return new Company\Director($this, $director, false);
return new Company\PreviousDirector($this, $director);
}, $companyDetails['report']['directors']['previousDirectors'] ?? []);

$this->financialStatements = array_map(function ($statement) {
Expand Down
43 changes: 19 additions & 24 deletions src/Models/Company/Director.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,10 @@ class Director
protected $current;

/**
* Function constructs the Director Class
* @param Company $company Used to store a company data in the Director Class
* @param array $directorDetails Directors Data that needs to be stored in the Director Class
* @param bool $current Boolean used to indicate if the director is a current or previous director
*/
public function __construct(Company $company, array $directorDetails, bool $current)
public function __construct(Company $company, array $directorDetails)
{
$this->company = $company;
$this->directorDetails = $directorDetails;
Expand All @@ -35,50 +33,47 @@ public function __construct(Company $company, array $directorDetails, bool $curr
}
return $position;
}, $this->directorDetails['positions']);
$this->current = $current;
}

/**
* Checks if the director is a current director
* @return boolean Returns if the current variable is true
* @deprecated in favour of checking class
*/
public function isCurrent() : bool
public function isCurrent(): bool
{
return $this->current === true;
return true;
}

/**
* Checks if the director is a previous director
* @return boolean Return if the previous variable is not true
* @deprecated in favour of checking class
*/
public function isPrevious() : bool
public function isPrevious(): bool
{
return $this->current !== true;
return false;
}

/**
*
* @return string Returns the Directors ID
* @return string the ID of the Director
*/
public function getID() : string
public function getID(): string
{
return $this->directorDetails['id'] ?? '';
}

/**
*
* @return string Returns the gender of the Director
* @return string the gender of the Director
*/
public function getGender() : string
public function getGender(): string
{
return $this->directorDetails['gender'] ?? '';
}

/**
*
* @return DateTime | null Returns the Date Of Birth of the Director
* @return DateTime|null the Date Of Birth of the Director
*/
public function getDateOfBirth() : ?\DateTime
public function getDateOfBirth(): ?\DateTime
{
if (isset($this->directorDetails['dateOfBirth'])) {
return $this->directorDetails['dateOfBirth'];
Expand All @@ -89,27 +84,27 @@ public function getDateOfBirth() : ?\DateTime

/**
*
* @return array Returns an array containing the position and the date appointed
* @return array an array containing the position and the date appointed
*/
public function getPositions() : array
public function getPositions(): array
{
return $this->directorDetails['positions'] ?? [];
}

/**
*
* @return string Returns the directors name
* @return string the name of the Director
*/
public function getName() : string
public function getName(): string
{
return $this->directorDetails['name'] ?? '';
}

/**
*
* @return array Returns the directors address in an array
* @return array the directors address in an array
*/
public function getAddress() : array
public function getAddress(): array
{
return $this->directorDetails['address'] ?? [];
}
Expand Down
64 changes: 64 additions & 0 deletions src/Models/Company/PreviousDirector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

namespace SynergiTech\Creditsafe\Models\Company;

use SynergiTech\Creditsafe\Models\Company;

/**
* This class contains all data relating to a Previous Director of a Company
*/
class PreviousDirector
{
protected $company;
protected $directorDetails;

/**
* @param Company $company Used to store a company data in the Director Class
* @param array $directorDetails Directors Data that needs to be stored in the Director Class
*/
public function __construct(Company $company, array $directorDetails)
{
$this->company = $company;
$this->directorDetails = $directorDetails;
}

/**
* @deprecated in favour of checking class
*/
public function isCurrent(): bool
{
return false;
}

/**
* @deprecated in favour of checking class
*/
public function isPrevious(): bool
{
return true;
}

/**
* @return string the ID of the Previous Director
*/
public function getID(): string
{
return $this->directorDetails['id'] ?? '';
}

/**
* @return string the gender of the Previous Director
*/
public function getGender(): string
{
return $this->directorDetails['gender'] ?? '';
}

/**
* @return string the name of the Previous Director
*/
public function getName(): string
{
return $this->directorDetails['name'] ?? '';
}
}

0 comments on commit ab468af

Please sign in to comment.