Skip to content

Commit

Permalink
fix errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mimmi20 committed Feb 11, 2022
1 parent 3e74526 commit 1940849
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .php-cs-fixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* This file is part of the mimmi20/contact package.
*
* Copyright (c) 2020-2021, Thomas Mueller <[email protected]>
* Copyright (c) 2022, Thomas Mueller <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
Expand Down
34 changes: 21 additions & 13 deletions src/Contact.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
<?php
/**
* This file is part of the mimmi20/contact package.
*
* Copyright (c) 2022, Thomas Mueller <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

namespace Mimmi20\Contact;

use DateTimeInterface;

class Contact implements ContactInterface
final class Contact implements ContactInterface
{
private ?int $contactId = null;

Expand Down Expand Up @@ -153,8 +161,8 @@ public function setProfession(?string $value): void
}

/**
* @return string[]|null[]
* @phpstan-return array{contactId: string|null, salutation: string|null, firstname: string|null, familyname: string|null, street: string|null, housenumber: string|null, city: string|null, birthdate: string|null, phonenumber: string|null, email: string|null, profession: string|null}
* @return int[]|null[]|string[]
* @phpstan-return array{contactId: int|null, salutation: string|null, firstname: string|null, familyname: string|null, street: string|null, housenumber: string|null, city: string|null, birthdate: string|null, phonenumber: string|null, email: string|null, profession: string|null}
*/
public function toArray(): array
{
Expand All @@ -165,18 +173,18 @@ public function toArray(): array
}

return [
'contactId' => $this->getContactId(),
'salutation' => $this->getSalutation(),
'firstname' => $this->getFirstname(),
'familyname' => $this->getFamilyname(),
'street' => $this->getStreet(),
'contactId' => $this->getContactId(),
'salutation' => $this->getSalutation(),
'firstname' => $this->getFirstname(),
'familyname' => $this->getFamilyname(),
'street' => $this->getStreet(),
'housenumber' => $this->getHousenumber(),
'postalcode' => $this->getPostalcode(),
'city' => $this->getCity(),
'birthdate' => $birthdate,
'postalcode' => $this->getPostalcode(),
'city' => $this->getCity(),
'birthdate' => $birthdate,
'phonenumber' => $this->getPhonenumber(),
'email' => $this->getEmail(),
'profession' => $this->getProfession(),
'email' => $this->getEmail(),
'profession' => $this->getProfession(),
];
}
}
12 changes: 10 additions & 2 deletions src/ContactInterface.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* This file is part of the mimmi20/contact package.
*
* Copyright (c) 2022, Thomas Mueller <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

Expand Down Expand Up @@ -57,8 +65,8 @@ public function getProfession(): ?string;
public function setProfession(?string $value): void;

/**
* @return string[]|null[]
* @phpstan-return array{contactId: string|null, salutation: string|null, firstname: string|null, familyname: string|null, street: string|null, housenumber: string|null, city: string|null, birthdate: string|null, phonenumber: string|null, email: string|null, profession: string|null}
* @return int[]|null[]|string[]
* @phpstan-return array{contactId: int|null, salutation: string|null, firstname: string|null, familyname: string|null, street: string|null, housenumber: string|null, city: string|null, birthdate: string|null, phonenumber: string|null, email: string|null, profession: string|null}
*/
public function toArray(): array;
}
30 changes: 19 additions & 11 deletions tests/ContactTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
<?php
/**
* This file is part of the mimmi20/contact package.
*
* Copyright (c) 2022, Thomas Mueller <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types = 1);

Expand All @@ -8,7 +16,7 @@
use Exception;
use PHPUnit\Framework\TestCase;

class ContactTest extends TestCase
final class ContactTest extends TestCase
{
private Contact $object;

Expand Down Expand Up @@ -172,18 +180,18 @@ public function testToArray(): void
$this->object->setProfession($profession);

$expected = [
'contactId' => $id,
'salutation' => $salutation,
'firstname' => $firstname,
'familyname' => $familyname,
'street' => $street,
'contactId' => $id,
'salutation' => $salutation,
'firstname' => $firstname,
'familyname' => $familyname,
'street' => $street,
'housenumber' => $housenumber,
'postalcode' => $postalcode,
'city' => $city,
'birthdate' => $birthdate->format('Y-m-d'),
'postalcode' => $postalcode,
'city' => $city,
'birthdate' => $birthdate->format('Y-m-d'),
'phonenumber' => $phonenumber,
'email' => $email,
'profession' => $profession,
'email' => $email,
'profession' => $profession,
];

self::assertSame($expected, $this->object->toArray());
Expand Down

0 comments on commit 1940849

Please sign in to comment.