Skip to content

Repository files navigation

Vacation days calculation

Determine the number of vacation days for each of its employees for a given year. The script should take the year of interest as its only input argument and output the name of each employee along with the respective number of vacation days for the given year.

Requirements

  • Each employee has a minimum of 26 vacation days
  • A special contract can overwrite the minimum amount of vacation days
  • Employees with an age >= 30 years get one additional vacation day every 5 years of employment
  • Contracts may start on the 1st or 15th of the month

Prerequisites

composer
php (>=8.2)
Docker (Optional for Containerized Development)

Note

The application will not work if register_argc_argv is disabled.

Installation and Run the script

  • All the code required to get started
  • Need write permission to following directory ./var/logs
  • Install the script
$ cd /path/to/base/directory
$ composer install --no-dev
  • Run the script and sample output
$ php index.php 2025
Hans Müller: 26
Angelika Fringe: 26
Peter Klever: 27
Marina Helter: 26
Sepp Meier: 26
$ php index.php 2021
Hans Müller: 27
Angelika Fringe: 27
Peter Klever: 28
Marina Helter: 26
Sepp Meier: 26
$ php index.php 2017
Hans Müller: 26
Angelika Fringe: 26
Peter Klever: 27
Marina Helter: Not applicable
Sepp Meier: 2.16

Running the tests

  • Follow Install instructions. Adapt phpunit.xml.dist PHP Constant according to your setup environment.
$ cd /path/to/base/directory
$ composer update
$ ./vendor/bin/phpunit tests

Test-cases, test unit and integration tests.

Run the script in a Docker container

  • Build the Docker Image
$ docker build --no-cache -t vacation_days .
  • Run the Container and script
$ docker run -it --rm vacation_days
$ php index.php <year>
$ ./vendor/bin/phpunit tests

About

Calculate each employee's vacation days for the year built with PHP and clean code.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages