Skip to content

Commit b63efad

Browse files
authored
Merge pull request #3 from bdumitrua/1.x
Добавление поля "isProject" в сущность Day
2 parents 5106da9 + e04e6d1 commit b63efad

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ $calendarForDay = $calendar->getPeriodForDay(new DateTime('2024-01-01'));
5050
- `type` - тип дня(праздничный, рабочий, выходной и тд);
5151
- `weekDay` - день недели;
5252
- `workingHours` - количество рабочих часов.
53+
- `isProject` - находится ли этот день в проекте закона и еще не утвержден.
5354

5455
Свойство `statistic` отображает ряд статистических данных для задаваемого периода:
5556
- `calendarDays` – количество календарных дней в периоде;
@@ -117,6 +118,7 @@ Shahruslan\ProductionCalendar\Entity\Period Object
117118
[value] => вс
118119
)
119120
[workingHours] => 0
121+
[isProject] => 0
120122
)
121123
[1] => Shahruslan\ProductionCalendar\Entity\Day Object
122124
(
@@ -137,6 +139,7 @@ Shahruslan\ProductionCalendar\Entity\Period Object
137139
[value] => пн
138140
)
139141
[workingHours] => 0
142+
[isProject] => 0
140143
)
141144
[2] => Shahruslan\ProductionCalendar\Entity\Day Object
142145
(
@@ -157,6 +160,7 @@ Shahruslan\ProductionCalendar\Entity\Period Object
157160
[value] => вт
158161
)
159162
[workingHours] => 8
163+
[isProject] => 0
160164
)
161165
)
162166
[statistic] => Shahruslan\ProductionCalendar\Entity\Statistic Object

src/Entity/Day.php

+1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,6 @@ public function __construct(
1818
public readonly DayType $type,
1919
public readonly WeekDay $weekDay,
2020
public readonly int $workingHours,
21+
public readonly bool $isProject,
2122
) {}
2223
}

src/Factory/Factory.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,11 @@ public static function createPeriod(object $data): Period
2323
$dateEnd = new DateTimeImmutable($data->dt_end);
2424

2525
$days = array_map(static function ($day) {
26-
$data = new DateTimeImmutable($day->date);
26+
$date = new DateTimeImmutable($day->date);
2727
$type = DayType::from($day->type_text);
2828
$week = WeekDay::from($day->week_day);
29-
return new Day($data, $type, $week, $day->working_hours);
29+
$isProject = (bool) ($day->is_project ?? false);
30+
return new Day($date, $type, $week, $day->working_hours, $isProject);
3031
}, $data->days);
3132

3233
$statistic = new Statistic(

0 commit comments

Comments
 (0)