Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
2 / 2
CRAP
100.00% covered (success)
100.00%
1 / 1
ProjectStage
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
2 / 2
2
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 isCompleted
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3declare(strict_types=1);
4
5/** @license For full copyright and license information, please see the LICENSE.md file. */
6
7namespace App\Modules\Projects\Domain\Model;
8
9defined('AMMONLY_APP') || exit('Direct script access is forbidden.');
10
11/**
12 * Domain entity representing a Project Stage or Milestone in WBS hierarchy.
13 *
14 * @package App\Modules\Projects\Domain\Model
15 */
16final readonly class ProjectStage
17{
18    /**
19     * @param int         $id             Unique identifier of the stage.
20     * @param string      $name           Stage or phase title.
21     * @param int         $projectId      Identifier of the parent project.
22     * @param string      $endDate        Deadline or scheduled end date.
23     * @param int|null    $parentId       Optional parent stage identifier for sub-stages.
24     * @param string      $type           Stage classification.
25     * @param string      $status         Current execution status.
26     * @param string      $priority       Priority level.
27     * @param string|null $startDate      Planned start date.
28     * @param string|null $actualEndDate  Actual completion date.
29     * @param float       $progress       Completion percentage (0.00 to 100.00).
30     * @param float       $estimatedHours Total estimated hours for the stage.
31     * @param float       $actualHours    Total logged work hours.
32     * @param bool        $isMilestone    Whether this stage represents a zero-duration milestone.
33     * @param int         $sortOrder      Sorting position within the schedule.
34     */
35    public function __construct(
36        public int $id,
37        public string $name,
38        public int $projectId,
39        public string $endDate,
40        public ?int $parentId = null,
41        public string $type = 'development',
42        public string $status = 'planned',
43        public string $priority = 'normal',
44        public ?string $startDate = null,
45        public ?string $actualEndDate = null,
46        public float $progress = 0.0,
47        public float $estimatedHours = 0.0,
48        public float $actualHours = 0.0,
49        public bool $isMilestone = false,
50        public int $sortOrder = 10,
51    ) {
52    }
53
54    /**
55     * Checks whether the stage is finished.
56     *
57     * @return bool True if completed, false otherwise.
58     */
59    public function isCompleted(): bool
60    {
61        return $this->status === 'completed';
62    }
63}