diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index 7acf742..904f610 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -6,12 +6,9 @@ For details, take a look at the following workflow configuration files: - [`workflows/continuous-integration.yaml`](workflows/continuous-integration.yaml) - [`workflows/lock-closed-issues.yaml`](workflows/lock-closed-issues.yaml) -- [`workflows/stale.yaml`](workflows/stale.yaml) ## Coding Standards -We are using [`ergebnis/composer-normalize`](https://github.com/ergebnis/composer-normalize) to normalize `composer.json`. - We are using [`friendsofphp/php-cs-fixer`](https://github.com/FriendsOfPHP/PHP-CS-Fixer) and [`squizlabs/php_codesniffer`](https://github.com/squizlabs/PHP_CodeSniffer) to enforce coding standards in PHP files. Run diff --git a/.github/dependabot.yml b/.github/dependabot.yml index 59c591c..4d8e40b 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -6,7 +6,8 @@ updates: - package-ecosystem: "composer" directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "monday" time: "04:00" timezone: "Europe/Berlin" open-pull-requests-limit: 10 @@ -16,7 +17,7 @@ updates: - "mimmi20" labels: - "dependencies" - versioning-strategy: "widen" + versioning-strategy: "increase" commit-message: include: "scope" prefix: "composer" @@ -31,7 +32,8 @@ updates: - package-ecosystem: "github-actions" directory: "/" schedule: - interval: "daily" + interval: "weekly" + day: "monday" time: "04:00" timezone: "Europe/Berlin" open-pull-requests-limit: 10 diff --git a/.github/labels.yml b/.github/labels.yml index 1e6d550..d9aa1a0 100644 --- a/.github/labels.yml +++ b/.github/labels.yml @@ -54,7 +54,7 @@ name: "documentation" description: "Improvements or additions to documentation" -# other Labels to mimmi20/template +# other Labels to mimmi20/contact #- color: 5319e7 # name: "new useragents" # description: "" diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index 6d720ef..dd04500 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -32,7 +32,7 @@ categories: - title: '**🧹 Maintenance:**' labels: - 'maintenance' - # other Labels to mimmi20/template + # other Labels to mimmi20/contact #- title: '**📦 new Useragents:**' # labels: # - 'new useragents' diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index 364e4a3..3c46e47 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -7,7 +7,7 @@ on: name: "Continuous Integration" env: - PHP_EXTENSIONS: "json, opcache, mbstring" + PHP_EXTENSIONS: "json, opcache" PHP_INI_VALUES: "opcache.enable=1, opcache.fast_shutdown=0, zend.assertions=1, assert.exception=On, intl.default_locale=de, intl.use_exceptions=1, zend.exception_ignore_args=0" COMPOSER_OPTIONS: "--optimize-autoloader --prefer-dist --prefer-stable -v" TOOLS: "composer:v2" @@ -155,7 +155,7 @@ jobs: composer-options: "${{ env.COMPOSER_OPTIONS }}" - name: "Check dependencies with composer" - run: "composer outdated --direct --strict" + run: "composer outdated --direct" php-cs-fixer: name: "Check Coding Standards with PHP-CS-Fixer" @@ -408,13 +408,17 @@ jobs: matrix: operating-system: + - "ubuntu-18.04" - "ubuntu-20.04" php-version: - "7.4" + - "8.0" + - "8.1" dependencies: - "highest" + - "lowest" coverage-drivers: - "xdebug" @@ -455,7 +459,7 @@ jobs: verbose: false - name: "Run mutation tests with infection/infection" - run: "infection -s --min-covered-msi=84 --min-msi=84 --coverage=.build/coverage --logger-github" + run: "infection -s --min-covered-msi=93 --min-msi=90 --coverage=.build/coverage --logger-github" roave-backwards-compatibility-check: name: "Check for Backward Compatibility breaks" diff --git a/.php-cs-fixer.php b/.php-cs-fixer.php index 62a135e..afd1d23 100644 --- a/.php-cs-fixer.php +++ b/.php-cs-fixer.php @@ -1,6 +1,6 @@ * @@ -11,9 +11,9 @@ declare(strict_types = 1); $header = <<<'EOF' - This file is part of the mimmi20/template package. + This file is part of the mimmi20/contact package. - Copyright (c) 2020-2021, Thomas Mueller + Copyright (c) 2022, Thomas Mueller For the full copyright and license information, please view the LICENSE file that was distributed with this source code. diff --git a/README.md b/README.md index b5f715d..7e57907 100644 --- a/README.md +++ b/README.md @@ -1,29 +1,27 @@ -# template +# contact -[![Latest Stable Version](https://poser.pugx.org/mimmi20/template/v/stable?format=flat-square)](https://packagist.org/packages/mimmi20/template) -[![Latest Unstable Version](https://poser.pugx.org/mimmi20/template/v/unstable?format=flat-square)](https://packagist.org/packages/mimmi20/template) -[![License](https://poser.pugx.org/mimmi20/template/license?format=flat-square)](https://packagist.org/packages/mimmi20/template) +[![Latest Stable Version](https://poser.pugx.org/mimmi20/contact/v/stable?format=flat-square)](https://packagist.org/packages/mimmi20/contact) +[![Latest Unstable Version](https://poser.pugx.org/mimmi20/contact/v/unstable?format=flat-square)](https://packagist.org/packages/mimmi20/contact) +[![License](https://poser.pugx.org/mimmi20/contact/license?format=flat-square)](https://packagist.org/packages/mimmi20/contact) ## Code Status -[![codecov](https://codecov.io/gh/mimmi20/template/branch/master/graph/badge.svg)](https://codecov.io/gh/mimmi20/template) -[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/mimmi20/template.svg)](http://isitmaintained.com/project/mimmi20/template "Average time to resolve an issue") -[![Percentage of issues still open](http://isitmaintained.com/badge/open/mimmi20/template.svg)](http://isitmaintained.com/project/mimmi20/template "Percentage of issues still open") +[![codecov](https://codecov.io/gh/mimmi20/contact/branch/master/graph/badge.svg)](https://codecov.io/gh/mimmi20/contact) +[![Average time to resolve an issue](http://isitmaintained.com/badge/resolution/mimmi20/contact.svg)](http://isitmaintained.com/project/mimmi20/contact "Average time to resolve an issue") +[![Percentage of issues still open](http://isitmaintained.com/badge/open/mimmi20/contact.svg)](http://isitmaintained.com/project/mimmi20/contact "Percentage of issues still open") -## Installation +## Requirements + +This library requires PHP 7.4+. -:bulb: This is a great place for showing how to install the package, see below: +## Installation Run ``` -$ composer require mimmi20/template +$ composer require mimmi20/contact ``` -## Usage - -:bulb: This is a great place for showing a few usage examples! - ## License This package is licensed using the MIT License. diff --git a/composer.json b/composer.json index 82d9656..157fb4a 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { - "name": "mimmi20/template", - "description": "Provides a GitHub repository template for a PHP library, using GitHub actions.", + "name": "mimmi20/contact", + "description": "A small contact class to use in other projects", "license": "MIT", "type": "library", "authors": [ @@ -8,24 +8,39 @@ "name": "Thomas Müller", "homepage": "https://github.com/mimmi20", "role": "Developer" + }, + { + "name": "Contributors", + "homepage": "https://github.com/mimmi20/contact/graphs/contributors" } ], - "homepage": "https://github.com/mimmi20/template", + "homepage": "https://github.com/mimmi20/contact", "support": { - "issues": "https://github.com/mimmi20/template/issues", - "source": "https://github.com/mimmi20/template" + "issues": "https://github.com/mimmi20/contact/issues", + "source": "https://github.com/mimmi20/contact" }, "require": { - "php": "^7.4.3 || ^8.0.0", - "ext-mbstring": "*" + "php": "^7.4.3 || ^8.0.0" }, "require-dev": { - "mimmi20/coding-standard": "^2.6.2", + "mimmi20/coding-standard": "^2.6.3", "phpstan/extension-installer": "^1.1.0", - "phpstan/phpstan": "^1.4.2", + "phpstan/phpstan": "^1.4.6", "phpstan/phpstan-deprecation-rules": "^1.0.0", "phpstan/phpstan-phpunit": "^1.0.0", - "phpunit/phpunit": "^9.5.12" + "phpunit/phpunit": "^9.5.13" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "autoload": { + "psr-4": { + "Mimmi20\\Contact\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Mimmi20\\Contact\\": "tests/" + } }, "config": { "preferred-install": "dist", diff --git a/phpcs.xml b/phpcs.xml index a58f9d6..242439c 100644 --- a/phpcs.xml +++ b/phpcs.xml @@ -1,9 +1,9 @@ - - browser-detector + contact diff --git a/phpmd.ruleset.xml b/phpmd.ruleset.xml index fc18ff9..af7e2eb 100644 --- a/phpmd.ruleset.xml +++ b/phpmd.ruleset.xml @@ -1,10 +1,10 @@ - - The coding standard. + contact diff --git a/phpunit.xml b/phpunit.xml index 5fc05c4..76c9102 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -33,7 +33,7 @@ - + tests/ diff --git a/src/.gitkeep b/src/.gitkeep deleted file mode 100644 index e69de29..0000000 diff --git a/src/Contact.php b/src/Contact.php new file mode 100644 index 0000000..8777bd1 --- /dev/null +++ b/src/Contact.php @@ -0,0 +1,182 @@ +contactId; + } + + public function setContactId(?int $value): void + { + $this->contactId = $value; + } + + public function getSalutation(): ?string + { + return $this->salutation; + } + + public function setSalutation(?string $value): void + { + $this->salutation = $value; + } + + public function getFirstname(): ?string + { + return $this->firstname; + } + + public function setFirstname(?string $value): void + { + $this->firstname = $value; + } + + public function getFamilyname(): ?string + { + return $this->familyname; + } + + public function setFamilyname(?string $value): void + { + $this->familyname = $value; + } + + public function getStreet(): ?string + { + return $this->street; + } + + public function setStreet(?string $value): void + { + $this->street = $value; + } + + public function getHousenumber(): ?string + { + return $this->housenumber; + } + + public function setHousenumber(?string $value): void + { + $this->housenumber = $value; + } + + public function getPostalcode(): ?string + { + return $this->postalcode; + } + + public function setPostalcode(?string $value): void + { + $this->postalcode = $value; + } + + public function getCity(): ?string + { + return $this->city; + } + + public function setCity(?string $value): void + { + $this->city = $value; + } + + public function getBirthdate(): ?DateTimeInterface + { + return $this->birthdate; + } + + public function setBirthdate(?DateTimeInterface $value): void + { + $this->birthdate = $value; + } + + public function getPhonenumber(): ?string + { + return $this->phonenumber; + } + + public function setPhonenumber(?string $value): void + { + $this->phonenumber = $value; + } + + public function getEmail(): ?string + { + return $this->email; + } + + public function setEmail(?string $value): void + { + $this->email = $value; + } + + public function getProfession(): ?string + { + return $this->profession; + } + + public function setProfession(?string $value): void + { + $this->profession = $value; + } + + /** + * @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} + */ + public function toArray(): array + { + $birthdate = $this->getBirthdate(); + + if (null !== $birthdate) { + $birthdate = $birthdate->format('Y-m-d'); + } + + return [ + '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, + 'phonenumber' => $this->getPhonenumber(), + 'email' => $this->getEmail(), + 'profession' => $this->getProfession(), + ]; + } +} diff --git a/src/ContactInterface.php b/src/ContactInterface.php new file mode 100644 index 0000000..d85a147 --- /dev/null +++ b/src/ContactInterface.php @@ -0,0 +1,64 @@ +object = new Contact(); + } + + public function testSetGetContactId(): void + { + self::assertNull($this->object->getContactId()); + + $id = 1; + + $this->object->setContactId($id); + self::assertSame($id, $this->object->getContactId()); + } + + public function testSetGetSalutation(): void + { + self::assertNull($this->object->getSalutation()); + + $salutation = 'xyz'; + + $this->object->setSalutation($salutation); + self::assertSame($salutation, $this->object->getSalutation()); + } + + public function testSetGetFirstname(): void + { + self::assertNull($this->object->getFirstname()); + + $firstname = 'testvorname'; + + $this->object->setFirstname($firstname); + self::assertSame($firstname, $this->object->getFirstname()); + } + + public function testSetGetFamilyname(): void + { + self::assertNull($this->object->getFamilyname()); + + $familyname = 'testnachname'; + + $this->object->setFamilyname($familyname); + self::assertSame($familyname, $this->object->getFamilyname()); + } + + public function testSetGetStreet(): void + { + self::assertNull($this->object->getStreet()); + + $street = 'teststrasse'; + + $this->object->setStreet($street); + self::assertSame($street, $this->object->getStreet()); + } + + public function testSetGetHousenumber(): void + { + self::assertNull($this->object->getHousenumber()); + + $housenumber = '1a'; + + $this->object->setHousenumber($housenumber); + self::assertSame($housenumber, $this->object->getHousenumber()); + } + + public function testSetGetPostalcode(): void + { + self::assertNull($this->object->getPostalcode()); + + $postalcode = '01234'; + + $this->object->setPostalcode($postalcode); + self::assertSame($postalcode, $this->object->getPostalcode()); + } + + public function testSetGetCity(): void + { + self::assertNull($this->object->getCity()); + + $city = 'testStadt'; + + $this->object->setCity($city); + self::assertSame($city, $this->object->getCity()); + } + + /** + * @throws Exception + */ + public function testSetGetBirthdate(): void + { + self::assertNull($this->object->getBirthdate()); + + $birthdate = new DateTimeImmutable(); + + $this->object->setBirthdate($birthdate); + self::assertSame($birthdate, $this->object->getBirthdate()); + } + + public function testSetGetEmail(): void + { + self::assertNull($this->object->getEmail()); + + $email = 'test@test.de'; + + $this->object->setEmail($email); + self::assertSame($email, $this->object->getEmail()); + } + + public function testSetGetPhonenumber(): void + { + self::assertNull($this->object->getPhonenumber()); + + $phonenumber = '+49 1234 56789'; + + $this->object->setPhonenumber($phonenumber); + self::assertSame($phonenumber, $this->object->getPhonenumber()); + } + + public function testSetGetProfession(): void + { + self::assertNull($this->object->getProfession()); + + $profession = 'Tester'; + + $this->object->setProfession($profession); + self::assertSame($profession, $this->object->getProfession()); + } + + /** + * @throws Exception + */ + public function testToArray(): void + { + $id = 1; + $salutation = 'xyz'; + $firstname = 'testvorname'; + $familyname = 'testnachname'; + $street = 'teststrasse'; + $housenumber = '1a'; + $postalcode = '01234'; + $city = 'testStadt'; + $birthdate = new DateTimeImmutable(); + $email = 'test@test.de'; + $phonenumber = '+49 1234 56789'; + $profession = 'Tester'; + + $this->object->setContactId($id); + $this->object->setSalutation($salutation); + $this->object->setFirstname($firstname); + $this->object->setFamilyname($familyname); + $this->object->setStreet($street); + $this->object->setHousenumber($housenumber); + $this->object->setPostalcode($postalcode); + $this->object->setCity($city); + $this->object->setBirthdate($birthdate); + $this->object->setEmail($email); + $this->object->setPhonenumber($phonenumber); + $this->object->setProfession($profession); + + $expected = [ + 'contactId' => $id, + 'salutation' => $salutation, + 'firstname' => $firstname, + 'familyname' => $familyname, + 'street' => $street, + 'housenumber' => $housenumber, + 'postalcode' => $postalcode, + 'city' => $city, + 'birthdate' => $birthdate->format('Y-m-d'), + 'phonenumber' => $phonenumber, + 'email' => $email, + 'profession' => $profession, + ]; + + self::assertSame($expected, $this->object->toArray()); + } +}