diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..4ee1f20 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,43 @@ +name: build + +on: + push: + branches: + - 'main' + pull_request: + branches: + - 'main' + +jobs: + test: + name: "Test (PHP ${{ matrix.php-versions }}, Neos ${{ matrix.neos-versions }})" + + strategy: + fail-fast: false + matrix: + php-versions: [ '8.2', '8.4' ] + neos-versions: [ '8.3', '8.4' ] + + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + path: ${{ env.FLOW_FOLDER }} + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: mbstring, xml, json, zlib, iconv, intl, pdo_sqlite + ini-values: date.timezone="Africa/Tunis", opcache.fast_shutdown=0, apc.enable_cli=on + + - name: Set Neos Version + run: composer require neos/neos ^${{ matrix.neos-versions }} --no-progress --no-interaction + + - name: Lint + run: composer lint + + - name: Stan + run: composer analyse diff --git a/.gitignore b/.gitignore index 12dc185..018952d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,10 @@ **/node_modules/** node_modules **/lib/ -.yarn \ No newline at end of file +.yarn + +composer.lock +Packages +vendor +bin +Build diff --git a/Classes/Domain/StartDateIsMissing.php b/Classes/Domain/StartDateIsMissing.php index 43655f2..b6101a0 100644 --- a/Classes/Domain/StartDateIsMissing.php +++ b/Classes/Domain/StartDateIsMissing.php @@ -8,7 +8,8 @@ final class StartDateIsMissing extends \InvalidArgumentException { public static function butWasRequired(string $attemptedValue): self { - return new self('Start date is missing in value ' . $attemptedValue + return new self( + 'Start date is missing in value ' . $attemptedValue . ', must contain a DTSTART: line', 1746602782 ); diff --git a/Classes/Infrastructure/CalendarIsMissing.php b/Classes/Infrastructure/CalendarIsMissing.php index 96181b9..2eec24e 100644 --- a/Classes/Infrastructure/CalendarIsMissing.php +++ b/Classes/Infrastructure/CalendarIsMissing.php @@ -10,7 +10,8 @@ final class CalendarIsMissing extends \RuntimeException { public static function butWasRequired(NodeAggregateIdentifier $eventId): self { - return new self('Failed to resolve calendar ID for event ' + return new self( + 'Failed to resolve calendar ID for event ' . $eventId . ', one of its ancestors must be a calendar', 1745919357 ); diff --git a/Classes/Infrastructure/LocationIsMissing.php b/Classes/Infrastructure/LocationIsMissing.php index e02dd02..2140c58 100644 --- a/Classes/Infrastructure/LocationIsMissing.php +++ b/Classes/Infrastructure/LocationIsMissing.php @@ -10,7 +10,8 @@ final class LocationIsMissing extends \RuntimeException { public static function butWasRequired(NodeAggregateIdentifier $eventId): self { - return new self('Failed to resolve location time zone for event ' + return new self( + 'Failed to resolve location time zone for event ' . $eventId . ', one of its ancestors must be a location', 1746795172 ); diff --git a/README.md b/README.md new file mode 100644 index 0000000..e96da78 --- /dev/null +++ b/README.md @@ -0,0 +1,41 @@ +# Sitegeist.GroundhogDay + +> NodeTypes and PHP Tools for Events including recurrence rules +> based on RFC 5545 - iCalendar + +The package will calculate all future occurences for the next Year based on the contained nodeType mixins. +The PHP class `Sitegeist\GroundhogDay\Domain\EventOccurrenceRepository` can be used to fetch events +based on calendar, location and time-period. + +## Authors & Sponsors + +* Bernhard Schmitt - schmitt@sitegeist.de + +_The development and the public-releases of this package is generously sponsored by our employer http://www.sitegeist.de._ + +## Installation + +Sitegeist.GroundhogDay is available via packagist: +```shell +composer require sitegeist/groundhogday +``` + +## Usage + +### NodeTypes + +- Sitegeist.GroundhogDay:Mixin.Calendar +- Sitegeist.GroundhogDay:Mixin.Event +- Sitegeist.GroundhogDay:Mixin.Location + +# to be written + +## Contributions + +We will gladly accept contributions. Please send us pull requests. + +In lieu of a formal styleguide, take care to maintain the existing coding style. Please make sure to contribute [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) compliant sources. + +## License + +See [LICENSE.md](./LICENSE.md) diff --git a/Tests/Unit/Domain/EventOccurrenceSpecificationTest.php b/Tests/Unit/Domain/EventOccurrenceSpecificationTest.php index 029d59b..8aa0dda 100644 --- a/Tests/Unit/Domain/EventOccurrenceSpecificationTest.php +++ b/Tests/Unit/Domain/EventOccurrenceSpecificationTest.php @@ -28,7 +28,7 @@ public function testFromArray(array $array, EventOccurrenceSpecification $expect } /** - * @return iterable, expectedSpecification: EventOccurrenceSpecification}> + * @return iterable, expectedSpecification: EventOccurrenceSpecification}> */ public static function arrayProvider(): iterable { @@ -115,6 +115,9 @@ public function testResolveDates( ); } + /** + * @return iterable + */ public static function resolvedDatesProvider(): iterable { yield 'only startDate, no afterDate' => [ @@ -349,6 +352,10 @@ public static function resolvedDatesProvider(): iterable private static function createDateTime(string $date): \DateTimeImmutable { - return \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date, new \DateTimeZone('UTC')); + $date = \DateTimeImmutable::createFromFormat('Y-m-d H:i:s', $date, new \DateTimeZone('UTC')); + if ($date instanceof \DateTimeImmutable) { + return $date; + } + throw new \Exception('invalid date string: "' . $date . '"'); } } diff --git a/composer.json b/composer.json index 032532f..0ed9914 100644 --- a/composer.json +++ b/composer.json @@ -18,14 +18,15 @@ }, "require-dev": { "phpunit/phpunit": "^9.5", - "phpstan/phpstan": "^2.1", + "phpstan/phpstan": "^1.12", "neos/buildessentials": "^8.3", "mikey179/vfsstream": "^1.6", "squizlabs/php_codesniffer": "^3.6" }, "scripts": { + "fix": "bin/phpcbf --standard=PSR12 --extensions=php --exclude=Generic.Files.LineLength Classes/ Tests/", "lint": "bin/phpcs --standard=PSR12 --extensions=php --exclude=Generic.Files.LineLength Classes/ Tests/", - "analyse": "bin/phpstan analyse --level 9 Tests/Unit Classes", + "analyse": "bin/phpstan analyse --level 8 Tests/Unit Classes", "test:unit": "bin/phpunit -c phpunit.xml --enforce-time-limit --coverage-html Build/Reports/coverage Tests", "test:functional": [ "FLOW_CONTEXT=Testing bin/phpunit --colors --stop-on-failure -c Build/BuildEssentials/PhpUnit/FunctionalTests.xml Tests/Functional"