Skip to content

Commit

Permalink
fix merge conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
spkm committed May 30, 2023
2 parents 5d2fcd6 + 1df44a0 commit 3d1f68c
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 46 deletions.
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,4 @@ If you discover any security related issues, please email spkm@cranleigh.org ins

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.


2 changes: 1 addition & 1 deletion src/Controllers/RewardAndConductRewardController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public function store(string $pupilId, array $attributes): JsonResponse
'TeacherId',
], $attributes);

$response = $this->guzzle->request('POST', $this->endpoint.'/'.$pupilId.'/rewards', [
$response = $this->guzzle->request('POST', $this->endpoint . '/' . $pupilId . '/rewards', [
'headers' => $this->getHeaders(),
'json' => $attributes,
]);
Expand Down
2 changes: 1 addition & 1 deletion src/Controllers/StorageFileController.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ public function download(string $path, string $name)
header('Content-Disposition: ' . $response->getHeader('Content-Disposition')[0]);
header('Content-Length: ' . $response->getHeader('Content-Length')[0]);
echo $response->getBody()->getContents();
exit();
exit;
}
}
28 changes: 6 additions & 22 deletions src/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace spkm\isams;

#[\AllowDynamicProperties]
abstract class Wrapper
{
/**
Expand All @@ -10,30 +11,15 @@ abstract class Wrapper
* @array
*/
protected $hidden = [];

/**
* @var mixed
*/
protected $item;
protected array $attributes = [];

public function __construct($item)
{
$this->item = $item;
$this->setAttributes();
$this->setAttributes($item);
$this->handle();
}

public function __set(string $name, mixed $value)
{
$this->attributes[$name] = $value;
}

public function __get(string $name)
{
return $this->attributes[$name];
}

/**
* Handle the data.
*
Expand All @@ -46,13 +32,11 @@ abstract protected function handle(): void;
*
* @return void
*/
protected function setAttributes(): void
protected function setAttributes(object|array $item): void
{
if (is_array($this->item) || is_object($this->item)) {
foreach ($this->item as $key => $value) {
if (in_array($key, $this->hidden) === false && property_exists($this, $key) === false) {
$this->{$key} = $value;
}
foreach ($item as $key => $value) {
if (in_array($key, $this->hidden) === false && property_exists($this, $key) === false) {
$this->{$key} = $value;
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/AdmissionStatusTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function it_deletes_an_admission_status()

//Find it
$admissionStatuses = (new AdmissionStatusController($this->school))->index();
$toDelete = ($this->findAdmissionStatusByName($newAdmissionStatus, $admissionStatuses->toArray()));
$toDelete = $this->findAdmissionStatusByName($newAdmissionStatus, $admissionStatuses->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -79,7 +79,7 @@ public function it_updates_a_admission_status()

//Find it
$admissionStatuses = (new AdmissionStatusController($this->school))->index();
$toUpdate = ($this->findAdmissionStatusByName($newAdmissionStatus, $admissionStatuses->toArray()));
$toUpdate = $this->findAdmissionStatusByName($newAdmissionStatus, $admissionStatuses->toArray());

//Update it
$renameAdmissionStatus = 'MySpecialAdmissionStatus';
Expand All @@ -88,7 +88,7 @@ public function it_updates_a_admission_status()

//Find it again
$admissionStatuses = (new AdmissionStatusController($this->school))->index();
$toDelete = ($this->findAdmissionStatusByName($renameAdmissionStatus, $admissionStatuses->toArray()));
$toDelete = $this->findAdmissionStatusByName($renameAdmissionStatus, $admissionStatuses->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/EstateBuildingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_updates_a_building()

//Find it
$buildings = (new EstateBuildingController($this->school))->index();
$toUpdate = ($this->findBuildingByName($newBuilding, $buildings->toArray()));
$toUpdate = $this->findBuildingByName($newBuilding, $buildings->toArray());

//Update it
$renameBuilding = 'MySpecialBuilding';
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/PupilBoardingStatusesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function it_deletes_a_boarding_status()
//Find it
$newBoardingStatuses = (new PupilBoardingStatusController($this->school))->index();

$toDelete = ($this->findBoardingStatusByName($newboardingStatus, $newBoardingStatuses->toArray()));
$toDelete = $this->findBoardingStatusByName($newboardingStatus, $newBoardingStatuses->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -81,7 +81,7 @@ public function it_updates_a_boarding_status()

//Find it
$counties = (new PupilBoardingStatusController($this->school))->index();
$toUpdate = ($this->findBoardingStatusByName($newboardingStatus, $counties->toArray()));
$toUpdate = $this->findBoardingStatusByName($newboardingStatus, $counties->toArray());

//Update it
$renameBoardingStatus = 'ImASpecialDayBoy';
Expand All @@ -90,7 +90,7 @@ public function it_updates_a_boarding_status()

//Find it again
$counties = (new PupilBoardingStatusController($this->school))->index();
$toDelete = ($this->findBoardingStatusByName($renameBoardingStatus, $counties->toArray()));
$toDelete = $this->findBoardingStatusByName($renameBoardingStatus, $counties->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/SystemConfigurationCountiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_deletes_a_county()

//Find it
$counties = (new CountyController($this->school))->index();
$toDelete = ($this->findCountyByName($newCounty, $counties->toArray()));
$toDelete = $this->findCountyByName($newCounty, $counties->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -80,7 +80,7 @@ public function it_updates_a_county()

//Find it
$counties = (new CountyController($this->school))->index();
$toUpdate = ($this->findCountyByName($newCounty, $counties->toArray()));
$toUpdate = $this->findCountyByName($newCounty, $counties->toArray());

//Update it
$renameCounty = 'MySpecialCounty';
Expand All @@ -89,7 +89,7 @@ public function it_updates_a_county()

//Find it again
$counties = (new CountyController($this->school))->index();
$toDelete = ($this->findCountyByName($renameCounty, $counties->toArray()));
$toDelete = $this->findCountyByName($renameCounty, $counties->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/SystemConfigurationCountriesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_deletes_a_country()

//Find it
$countries = (new CountryController($this->school))->index();
$toDelete = ($this->findCountryByName($newCountry, $countries->toArray()));
$toDelete = $this->findCountryByName($newCountry, $countries->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -80,7 +80,7 @@ public function it_updates_a_country()

//Find it
$countries = (new CountryController($this->school))->index();
$toUpdate = ($this->findCountryByName($newCountry, $countries->toArray()));
$toUpdate = $this->findCountryByName($newCountry, $countries->toArray());

//Update it
$renameCountry = 'MySpecialCountry';
Expand All @@ -89,7 +89,7 @@ public function it_updates_a_country()

//Find it again
$countries = (new CountryController($this->school))->index();
$toDelete = ($this->findCountryByName($renameCountry, $countries->toArray()));
$toDelete = $this->findCountryByName($renameCountry, $countries->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/SystemConfigurationLanguageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_deletes_a_language()

//Find it
$languages = (new LanguageController($this->school))->index();
$toDelete = ($this->findLanguageByName($newLanguage, $languages->toArray()));
$toDelete = $this->findLanguageByName($newLanguage, $languages->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -80,7 +80,7 @@ public function it_updates_a_language()

//Find it
$languages = (new LanguageController($this->school))->index();
$toUpdate = ($this->findLanguageByName($newLanguage, $languages->toArray()));
$toUpdate = $this->findLanguageByName($newLanguage, $languages->toArray());

//Update it
$renameLanguage = 'MySpecialLanguage';
Expand All @@ -89,7 +89,7 @@ public function it_updates_a_language()

//Find it again
$languages = (new LanguageController($this->school))->index();
$toDelete = ($this->findLanguageByName($renameLanguage, $languages->toArray()));
$toDelete = $this->findLanguageByName($renameLanguage, $languages->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/SystemConfigurationNationalityTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_deletes_a_nationality()

//Find it
$nationalities = (new NationalityController($this->school))->index();
$toDelete = ($this->findNationalityByName($newNationality, $nationalities->toArray()));
$toDelete = $this->findNationalityByName($newNationality, $nationalities->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -80,7 +80,7 @@ public function it_updates_a_nationality()

//Find it
$nationalities = (new NationalityController($this->school))->index();
$toUpdate = ($this->findNationalityByName($newNationality, $nationalities->toArray()));
$toUpdate = $this->findNationalityByName($newNationality, $nationalities->toArray());

//Update it
$renameNationality = 'MySpecialNationality';
Expand All @@ -89,7 +89,7 @@ public function it_updates_a_nationality()

//Find it again
$nationalities = (new NationalityController($this->school))->index();
$toDelete = ($this->findNationalityByName($renameNationality, $nationalities->toArray()));
$toDelete = $this->findNationalityByName($renameNationality, $nationalities->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/SystemConfigurationTitleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function it_deletes_a_title()

//Find it
$titles = (new TitleController($this->school))->index();
$toDelete = ($this->findTitleByName($newTitle, $titles->toArray()));
$toDelete = $this->findTitleByName($newTitle, $titles->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand All @@ -80,7 +80,7 @@ public function it_updates_a_title()

//Find it
$titles = (new TitleController($this->school))->index();
$toUpdate = ($this->findTitleByName($newTitle, $titles->toArray()));
$toUpdate = $this->findTitleByName($newTitle, $titles->toArray());

//Update it
$renameTitle = 'MySpecialTitle';
Expand All @@ -89,7 +89,7 @@ public function it_updates_a_title()

//Find it again
$titles = (new TitleController($this->school))->index();
$toDelete = ($this->findTitleByName($renameTitle, $titles->toArray()));
$toDelete = $this->findTitleByName($renameTitle, $titles->toArray());

//Delete it
foreach ($toDelete as $idToDelete) {
Expand Down

0 comments on commit 3d1f68c

Please sign in to comment.