{"id":307208,"date":"2020-07-20T15:00:45","date_gmt":"2020-07-20T15:00:45","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=307208"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2020-07-20T15:00:45","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=307208","title":{"rendered":"\u0412\u044b \u0443\u0432\u0435\u0440\u0435\u043d\u044b, \u0447\u0442\u043e \u043f\u0438\u0448\u0435\u0442\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434?"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/511744\/\">\n<p>\u041c\u044b, PHP-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0433\u043e\u0440\u0434\u044b \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0438\u0448\u0435\u043c \u043d\u0430 \u041e\u041e\u041f-\u044f\u0437\u044b\u043a\u0435 (\u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c PHP \u043d\u0430 C#, Java \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u041e\u041e\u041f-\u044f\u0437\u044b\u043a). \u041a\u0430\u0436\u0434\u0430\u044f \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u041e\u041e\u041f. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e SOLID \u0438\u043b\u0438 \u0442\u0440\u0435\u0445 &quot;\u043a\u0438\u0442\u043e\u0432&quot; \u041e\u041e\u041f. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u0434\u0435\u043b\u0430 \u2014 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c\u0438. \u041e\u041e\u041f \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b ORM-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b(\u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u2014 \u043d\u0435\u0432\u0430\u0436\u043d\u043e), \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043e\u043d\u043e \u043f\u0440\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 <strong>\u0432\u043b\u0430\u0434\u0435\u044e\u0442<\/strong> \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0445 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u043e\u0434\u0443. \u041e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u2014 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0437\u0430\u0434\u0430\u043d \u0432 \u043e\u0434\u043d\u043e\u043c \u0447\u0430\u0442\u0435: &quot;\u041a\u0430\u043a \u044f \u043c\u043e\u0433\u0443 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434?&quot;<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<pre><code class=\"php\">private function getWorkingTimeIntervals(CarbonPeriod $businessDaysPeriod, array $timeRanges): array {     $workingTimeIntervals = [];     foreach ($businessDaysPeriod as $date) {         foreach ($timeRanges as $time) {             $workingTimeIntervals[] = [                 'start' =&gt; Carbon::create($date-&gt;format('Y-m-d') . ' ' . $time['start']),                 'end' =&gt; Carbon::create($date-&gt;format('Y-m-d') . ' ' . $time['end'])             ];         }     }      return $workingTimeIntervals; }  \/**  * \u0423\u0434\u0430\u043b\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0438\u0437 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f  *  * @param array $workingTimeIntervals  * @param array $events  * @return array  *\/ private function removeEventsFromWorkingTime(array $workingTimeIntervals, array $events): array {     foreach ($workingTimeIntervals as $n =&gt; &amp;$interval) {         foreach ($events as $event) {             $period = CarbonPeriod::create($interval['start'], $interval['end']);             if ($period-&gt;overlaps($event['start_date'], $event['end_date'])) {                 if ($interval['start'] &lt;= $event['start_date'] &amp;&amp; $interval['end'] &lt;= $event['end_date']) {                     $interval['end'] = $event['start_date'];                 } elseif ($interval['start'] &gt;= $event['start_date'] &amp;&amp; $interval['end'] &gt;= $event['end_date']) {                     $interval['start'] = $event['end_date'];                 } elseif ($interval['start'] &lt;= $event['start_date'] &amp;&amp; $interval['end'] &gt;= $event['end_date']) {                     $interval['start'] = $event['start_date'];                     $interval['end'] = $event['end_date'];                 } else {                     unset($workingTimeIntervals[$n]);                 }             }         }     }      return $workingTimeIntervals; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e\u0442 \u043a\u043e\u0434 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430\u043c\u0438. \u041c\u0435\u0442\u043e\u0434 \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u043e\u0434\u043d\u0438\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432(\u0441\u043e\u0431\u044b\u0442\u0438\u0439) \u0438\u0437 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0434\u0440\u0443\u0433\u0438\u0445(\u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f), \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0432 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u0438. \u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u0432\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430 \u0437\u0434\u0435\u0441\u044c \u0432\u0435\u0440\u0442\u0438\u0442\u0441\u044f \u0432\u043e\u043a\u0440\u0443\u0433 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u0437 \u0434\u0432\u0443\u0445 \u0434\u0430\u0442. \u0418 \u0441\u0442\u0438\u043b\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0451\u043d\u043d\u044b\u0439 \u2014 \u043d\u0435\u043a\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445(\u0437\u0434\u0435\u0441\u044c \u043c\u0430\u0441\u0441\u0438\u0432) \u0438 \u043d\u0435\u043a\u0438\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0439 \u043a\u043e\u0434, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441 \u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u044f \u043a\u043e\u0434 \u0442\u0430\u043a, \u043b\u0435\u0433\u043a\u043e \u0434\u0443\u0431\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u0441\u0445\u043e\u0436\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u043c\u0435\u0441\u0442\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u0441\u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u0434, \u0441 \u043d\u0438\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439, \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043d\u0430\u0447\u0438\u043d\u0430\u044f \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044e \u043d\u0430\u043b\u0438\u0447\u0438\u0435 unit-\u0442\u0435\u0441\u0442\u043e\u0432 \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430. \u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u0431\u043e\u043b\u0435\u0437\u043d\u0435\u043d\u043d\u044b\u043c. \u041a\u043e\u0434 \u0438\u0437 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438\u0445 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0438 \u0435\u0433\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043d\u0435 \u0434\u0430\u0451\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0431\u044b\u0441\u0442\u0440\u043e \u0438\u0445 \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c (\u043c\u0435\u0442\u043e\u0434\u044b \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u044b\u0435). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0431\u0443\u0434\u0435\u043c \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043f\u043e\u0441\u043b\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class Interval {     \/\/ \u0422\u0438\u043f\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044f \u0438\u0437 PHP 7.4     public DateTimeImmutable $start;     public DateTimeImmutable $end; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <strong>DateTimeImmutable<\/strong> \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u043a\u0430\u043a \u0431\u043e\u043b\u0435\u0435 \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u0430\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u0442\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0432\u043e\u0435 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u0435 \u043a \u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u2014 \u043d\u0430\u0447\u0430\u043b\u044c\u043d\u0430\u044f \u0434\u0430\u0442\u0430 \u043d\u0435 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u0439.<br \/>  \u041d\u0430\u043c\u043d\u043e\u0433\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u043a\u043e\u0433\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442, \u043d\u0435 \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0438\u0439 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u043c, \u0434\u0430\u0436\u0435 \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u2014 \u043b\u0443\u0447\u0448\u0435\u0435 \u043c\u0435\u0441\u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0439 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u042f \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u043d\u0430\u0447\u0438\u043d\u0430\u044e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0447\u0435\u0440\u0435\u0437 unit-\u0442\u0435\u0441\u0442\u044b. \u041f\u043e\u0437\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443. \u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043e\u0431\u044b\u0447\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0430:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class Interval {     public DateTimeImmutable $start;     public DateTimeImmutable $end;      public function __construct(DateTimeImmutable $start, DateTimeImmutable $end)     {         $this-&gt;start = $start;         $this-&gt;end = $end;     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c PHPUnit-\u0442\u0435\u0441\u0442\u044b \u0434\u043b\u044f \u043d\u0430\u0448\u0435\u0433\u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">use App\\Interval; use PHPUnit\\Framework\\TestCase;  class IntervalTest extends TestCase {     private DateTimeImmutable $today;     private DateTimeImmutable $yesterday;     private DateTimeImmutable $tomorrow;      protected function setUp(): void     {         $this-&gt;today = new DateTimeImmutable();         $this-&gt;yesterday = $this-&gt;today-&gt;add(\\DateInterval::createFromDateString(&quot;-1 day&quot;));         $this-&gt;tomorrow = $this-&gt;today-&gt;add(\\DateInterval::createFromDateString(&quot;1 day&quot;));          parent::setUp();     }      public function testValidDates()     {         $interval = new Interval($this-&gt;yesterday, $this-&gt;today);          $this-&gt;assertEquals($this-&gt;yesterday, $interval-&gt;start);         $this-&gt;assertEquals($this-&gt;today, $interval-&gt;end);     }      public function testInvalidDates()     {         $this-&gt;expectException(\\InvalidArgumentException::class);          new Interval($this-&gt;today, $this-&gt;yesterday);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u044a\u0435\u043a\u0442\u044b \u0434\u0430\u0442 \u0434\u043b\u044f \u0441\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u0435\u0433\u043e, \u0432\u0447\u0435\u0440\u0430\u0448\u043d\u0435\u0433\u043e \u0438 \u0437\u0430\u0432\u0442\u0440\u0430\u0448\u043d\u0435\u0433\u043e \u0434\u043d\u044f \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u0441\u0442\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442, <code>testValidDates<\/code>, \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043e\u0431\u044b\u0447\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430. \u0412\u0442\u043e\u0440\u043e\u0439, <code>testInvalidDates<\/code>, \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0435\u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u0442 \u044d\u043a\u0441\u0435\u043f\u0448\u0435\u043d. \u041f\u0435\u0440\u0432\u044b\u0439 \u0442\u0435\u0441\u0442 \u043f\u0440\u043e\u0439\u0434\u0435\u0442 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u0432\u0430\u043b\u0438\u0442\u0441\u044f \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">Failed asserting that exception of type &quot;InvalidArgumentException&quot; is thrown.<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u044d\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class Interval {     public DateTimeImmutable $start;     public DateTimeImmutable $end;      public function __construct(DateTimeImmutable $start, DateTimeImmutable $end)     {         if ($start &gt; $end) {             throw new \\InvalidArgumentException(&quot;Invalid date interval&quot;);         }          $this-&gt;start = $start;         $this-&gt;end = $end;     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043e\u0431\u0430 \u0442\u0435\u0441\u0442\u044b \u0431\u0443\u0434\u0443\u0442 \u0437\u0435\u043b\u0435\u043d\u044b\u043c\u0438. \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0441\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0441\u0438\u0441\u0442\u0435\u043c\u0435 \u0442\u0438\u043f\u043e\u0432 \u0432 PHP, \u043c\u044b \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u043d\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c null \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0441\u043e\u043a\u0440\u0430\u0449\u0430\u0435\u0442 \u043e\u0431\u044a\u0435\u043c \u0442\u0435\u0441\u0442\u043e\u0432. \u041e\u0434\u043d\u0430\u043a\u043e, \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437, \u043a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043f\u0438\u0448\u0435\u0442 \u0442\u0435\u0441\u0442\u044b \u043e\u043d \u043e\u0431\u044f\u0437\u0430\u043d \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0440\u0430\u0435\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043a\u0440\u0430\u0435\u0432\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u043b\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 <strong>Interval<\/strong> \u0431\u0443\u0434\u0443\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u0434\u0430\u0442\u044b \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u043e\u0435 \u0438\u043b\u0438 \u043d\u0435\u0442? \u0412\u043e\u0442 \u043a\u0430\u043a unit-\u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0434\u0438\u0437\u0430\u0439\u043d. \u041e\u043d\u0438 \u0437\u0430\u0434\u0430\u044e\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u0435\u0449\u0435 \u0434\u043e \u0442\u043e\u0433\u043e, \u043a\u0430\u043a \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0439 \u043a\u043e\u0434. \u0414\u043e \u0442\u043e\u0433\u043e \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u0430\u043c \u0437\u0430\u0434\u0430\u0441\u0442 \u0438\u0445 \u0441\u0435\u0431\u0435. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0448\u0438\u043c, \u0447\u0442\u043e \u043f\u0443\u0441\u0442\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b, \u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 <code>isEmpty<\/code> \u043a \u044d\u0442\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443.<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class Interval {     public DateTimeImmutable $start;     public DateTimeImmutable $end;      public function __construct(DateTimeImmutable $start, DateTimeImmutable $end)     {         if ($start &gt; $end) {             throw new \\InvalidArgumentException(&quot;Invalid date interval&quot;);         }          $this-&gt;start = $start;         $this-&gt;end = $end;     }      public function isEmpty(): bool     {         return $this-&gt;start-&gt;getTimestamp() == $this-&gt;end-&gt;getTimestamp();     } }  class IntervalTest extends TestCase {     \/\/...      public function testNonEmpty()     {         $interval = new Interval($this-&gt;yesterday, $this-&gt;today);          $this-&gt;assertFalse($interval-&gt;isEmpty());     }      public function testEmpty()     {         $interval = new Interval($this-&gt;today, $this-&gt;today);          $this-&gt;assertTrue($interval-&gt;isEmpty());     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0434\u043b\u044f \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u0434\u0430\u0442. \u041e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d \u0432\u043c\u0435\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 <code>['start'=&gt;,'end'=&gt;]<\/code>, \u043d\u043e \u0431\u043e\u043b\u044c\u0448\u043e\u0433\u043e \u0441\u043c\u044b\u0441\u043b\u0430 \u0432 \u044d\u0442\u043e\u043c \u043d\u0435\u0442. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u043c <strong>\u0437\u043d\u0430\u043d\u0438\u044f<\/strong> \u043e\u0431 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u0434\u0430\u0442 \u0432 \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442! \u041d\u0430\u0447\u0430\u043b\u044c\u043d\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u0431\u044b\u043b\u043e \u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0445 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u0437\u0430\u043d\u044f\u0442\u044b\u0445 \u0441\u043b\u043e\u0442\u043e\u0432. \u041f\u0435\u0440\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u043b \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u044b, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0435\u043d\u044c 08:00 - 12:00 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0435\u043d\u044c 13:00 - 17:00 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c 08:00 - 12:00 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c 13:00 - 17:00 ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u0412\u0442\u043e\u0440\u043e\u0439 \u043c\u0435\u0442\u043e\u0434 \u0443\u0434\u0430\u043b\u044f\u043b \u0437\u0430\u043d\u044f\u0442\u044b\u0435 \u0441\u043b\u043e\u0442\u044b \u0438\u0437 \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044f \u043b\u0438\u0448\u044c \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u044b\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"plaintext\">\u0417\u0430\u043d\u044f\u0442\u044b\u0435 \u0441\u043b\u043e\u0442\u044b: \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0435\u043d\u044c 08:00 - 09:00 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0435\u043d\u044c 16:00 - 17:00 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c 13:00 - 17:00  \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442: \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0435\u043d\u044c 09:00 - 12:00 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0434\u0435\u043d\u044c 13:00 - 16:00 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0434\u0435\u043d\u044c 08:00 - 12:00 ...<\/code><\/pre>\n<p>  <\/p>\n<p>\u042f \u0445\u043e\u0447\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u043a\u043b\u0430\u0441\u0441 <strong>Interval<\/strong>:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">$period = CarbonPeriod::create($interval['start'], $interval['end']); if ($period-&gt;overlaps($event['start_date'], $event['end_date'])) {     if ($interval['start'] &lt;= $event['start_date'] &amp;&amp; $interval['end'] &lt;= $event['end_date']) {         $interval['end'] = $event['start_date'];     } elseif ($interval['start'] &gt;= $event['start_date'] &amp;&amp; $interval['end'] &gt;= $event['end_date']) {         $interval['start'] = $event['end_date'];     } elseif ($interval['start'] &lt;= $event['start_date'] &amp;&amp; $interval['end'] &gt;= $event['end_date']) {         $interval['start'] = $event['start_date'];         $interval['end'] = $event['end_date'];     } else {         unset($workingTimeIntervals[$n]);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043a\u043b\u0430\u0441\u0441\u0430 <strong>Interval<\/strong>: <code>remove(Interval $other)<\/code> \u0431\u0443\u0434\u0435\u0442 \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442, \u0443\u0434\u0430\u043b\u044f\u044f \u0438\u0437 \u043d\u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b. \u041a\u043e\u0434 \u0441\u0442\u0430\u043d\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0447\u0438\u0449\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">private function getWorkingTimeIntervals(CarbonPeriod $businessDaysPeriod, array $timeRanges): array {     $workingTimeIntervals = [];     foreach ($businessDaysPeriod as $date) {         foreach ($timeRanges as $time) {             $workingTimeIntervals[] = new Interval(                 Carbon::create($date-&gt;format('Y-m-d') . ' ' . $time['start']),                 Carbon::create($date-&gt;format('Y-m-d') . ' ' . $time['end'])             );         }     }      return $workingTimeIntervals; }  \/**  * @param Interval[] $workingTimeIntervals  * @param Interval[] $events  * @return Interval[]  *\/ private function removeEventsFromWorkingTime($workingTimeIntervals, $events): array {     foreach ($workingTimeIntervals as $n =&gt; $interval) {         foreach ($events as $event) {             $interval-&gt;remove($event);              if ($interval-&gt;isEmpty()) {                 unset($workingTimeIntervals[$n]);             }         }     }      return $workingTimeIntervals; }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e. \u0412\u0440\u0435\u043c\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u043c\u0435\u0442\u043e\u0434. \u0418 \u043d\u0430\u0447\u043d\u0451\u043c, \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0441 \u0442\u0435\u0441\u0442\u043e\u0432! \u041a\u043e\u0433\u0434\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441 \u0442\u0435\u0441\u0442\u043e\u0432, \u043e\u043d \u043e\u0431\u044f\u0437\u0430\u043d \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u043e \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f\u0445 \u043a \u043a\u043b\u0430\u0441\u0441\u0443 \u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c \u0438 \u043f\u043e\u0434\u0443\u043c\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u043e. \u042d\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e. \u041f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u0432 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043b\u0443\u0447\u0430\u0438.<\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0451\u043d, \u0435\u0441\u043b\u0438 <code>$other<\/code> \u043d\u0435 \u043a\u0430\u0441\u0430\u0435\u0442\u0441\u044f \u0435\u0433\u043e.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/070\/c5b\/7ed\/070c5b7ed859f2157326730a037a165f.png\"><\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class IntervalRemoveTest extends TestCase {     private DateTimeImmutable $minus10Days;     private DateTimeImmutable $today;     private DateTimeImmutable $yesterday;     private DateTimeImmutable $tomorrow;     private DateTimeImmutable $plus10Days;      protected function setUp(): void     {         $this-&gt;today = new DateTimeImmutable();         $this-&gt;yesterday = $this-&gt;today-&gt;sub(\\DateInterval::createFromDateString(&quot;1 day&quot;));         $this-&gt;tomorrow = $this-&gt;today-&gt;add(\\DateInterval::createFromDateString(&quot;1 day&quot;));          $this-&gt;minus10Days = $this-&gt;today-&gt;sub(\\DateInterval::createFromDateString(&quot;10 day&quot;));         $this-&gt;plus10Days = $this-&gt;today-&gt;add(\\DateInterval::createFromDateString(&quot;10 day&quot;));          parent::setUp();     }      public function testDifferent()     {         $interval = new Interval($this-&gt;minus10Days, $this-&gt;yesterday);          $interval-&gt;remove(new Interval($this-&gt;tomorrow, $this-&gt;plus10Days));          $this-&gt;assertEquals($this-&gt;minus10Days, $interval-&gt;start);         $this-&gt;assertEquals($this-&gt;yesterday, $interval-&gt;end);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0418\u043d\u0442\u0435\u0440\u0432\u0430\u043b, \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043f\u043e\u043a\u0440\u044b\u0442\u044b\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c, \u0434\u043e\u043b\u0436\u0435\u043d \u0441\u0442\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c.<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/779\/0c3\/a4b\/7790c3a4b86637a793a2ac5901128c71.png\"><\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class IntervalRemoveTest extends TestCase {     public function testFullyCovered()     {         $interval = new Interval($this-&gt;yesterday, $this-&gt;tomorrow);          $interval-&gt;remove(new Interval($this-&gt;minus10Days, $this-&gt;plus10Days));          $this-&gt;assertTrue($interval-&gt;isEmpty());     }      public function testFullyCoveredWithCommonStart()     {         $interval = new Interval($this-&gt;yesterday, $this-&gt;tomorrow);          $interval-&gt;remove(new Interval($this-&gt;yesterday, $this-&gt;plus10Days));          $this-&gt;assertTrue($interval-&gt;isEmpty());     }      \/\/ and testFullyCoveredWithCommonEnd() }<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439, \u043a\u043e\u0433\u0434\u0430 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0442\u0435\u043a\u0443\u0449\u0438\u0439:<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/4ec\/9b4\/741\/4ec9b474174788d0078c4085f8d40c76.png\"><\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u043e \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e?<\/p>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/getpro\/habr\/post_images\/484\/8f1\/022\/4848f1022804e614a7f393bd3a66488a.png\"><\/p>\n<p>  <\/p>\n<p>\u042d\u043c\u043c\u043c\u043c?! \u041d\u0430\u0448 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u043b\u0441\u044f \u043d\u0430 \u0434\u0432\u0430! \u0412\u0435\u0441\u044c \u0434\u0438\u0437\u0430\u0439\u043d \u043d\u0430\u0448\u0435\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 <code>remove<\/code> \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u043c! \u041a\u0441\u0442\u0430\u0442\u0438, \u0438 \u0438\u0437\u043d\u0430\u0447\u0430\u043b\u044c\u043d\u044b\u0439 \u043a\u043e\u0434 \u0442\u043e\u0436\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u044d\u0442\u043e\u043c \u043c\u0435\u0441\u0442\u0435:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">} elseif ($interval['start'] &lt;= $event['start_date'] &amp;&amp; $interval['end'] &gt;= $event['end_date']) {         $interval['start'] = $event['start_date'];         $interval['end'] = $event['end_date'];<\/code><\/pre>\n<p>  <\/p>\n<p>\u041d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0430 \u043e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u043f\u043e\u0437\u0436\u0435 \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u0435\u0441\u043b\u0438 \u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f\u043c\u0438 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u0434\u0430\u0436\u0435 \u043d\u0435 \u043d\u0430\u0447\u0430\u043b\u0438 \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0430\u043c \u043a\u043e\u0434, \u043d\u043e \u0443\u0436\u0435 \u043d\u0430\u0448\u043b\u0438 \u0431\u043e\u043b\u044c\u0448\u0443\u044e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435. \u0414\u0430, \u044d\u0442\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440 \u0432\u0435\u0441\u044c\u043c\u0430 \u043f\u0440\u043e\u0441\u0442 \u0438 \u043c\u043d\u043e\u0433\u0438\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043d\u0430\u0448\u043b\u0438 \u0431\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u0438 \u0431\u0435\u0437 \u0442\u0435\u0441\u0442\u043e\u0432, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u043d\u0430\u0439\u0442\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443 \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u0443\u043c\u043e\u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f\u043c\u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u0440\u043e\u0441\u0442\u043e. \u0412\u043e\u0442 \u043f\u043e\u0447\u0435\u043c\u0443 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u043b\u0435\u0437\u043d\u044b. \u041e\u043d\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043e\u0434, \u0447\u0430\u0441\u0442\u043e \u0438\u0437\u0431\u0435\u0433\u0430\u044f \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u044b\u0445 \u043f\u0440\u043e\u0441\u0447\u0435\u0442\u043e\u0432 \u0432 \u0434\u0438\u0437\u0430\u0439\u043d\u0435. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u0433\u043e\u0432\u043e\u0440\u044f\u0442, \u0447\u0442\u043e \u043d\u0435 \u043b\u044e\u0431\u044f\u0442 \u043f\u0438\u0441\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u044b, \u043f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e \u0441 \u043d\u0438\u043c\u0438 \u043a\u043e\u0434 \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043c\u0435\u0434\u043b\u0435\u043d\u043d\u0435\u0439. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0442\u0435\u0441\u0442\u043e\u0432, \u0432\u0440\u043e\u0434\u0435 \u0442\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u0432\u043d\u0430\u0447\u0430\u043b\u0435, \u044d\u0442\u043e \u0432\u0435\u0440\u043d\u043e. \u041d\u043e \u0434\u043b\u044f \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0439 \u043f\u043e\u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u043a\u043e\u0434 \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u0447\u0430\u0441\u0442\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0431\u044b\u0432\u0430\u0435\u0442 \u0431\u044b\u0441\u0442\u0440\u0435\u0435, \u0447\u0435\u043c \u0431\u0435\u0437 \u043d\u0438\u0445! \u0422\u0435\u0441\u0442\u044b \u0437\u0430\u0434\u0430\u044e\u0442 \u0445\u043e\u0440\u043e\u0448\u0438\u0435 \u0438 \u0432\u0435\u0441\u044c\u043c\u0430 \u0442\u043e\u0447\u043d\u044b\u0435 \u0432\u043e\u043f\u0440\u043e\u0441\u044b \u043f\u0440\u043e \u0434\u0438\u0437\u0430\u0439\u043d \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a <strong>\u043e\u0431\u044f\u0437\u0430\u043d<\/strong> \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0445\u043e\u0440\u043e\u0448\u0438\u0439 \u0434\u0438\u0437\u0430\u0439\u043d.<\/p>\n<p>  <\/p>\n<p>\u041e\u0434\u043d\u0438\u043c \u0438\u0437 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0440\u0435\u0448\u0435\u043d\u0438\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 <strong>IntervalCollection<\/strong>, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0449\u0435\u0433\u043e \u0441\u043e\u0431\u043e\u0439 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u0432 \u0438 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430\u0434 \u043d\u0438\u043c\u0438:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class Interval {     public DateTimeImmutable $start;     public DateTimeImmutable $end;      public function __construct(DateTimeImmutable $start,                                  DateTimeImmutable $end)     {         if ($start &gt; $end) {             throw new \\InvalidArgumentException(                                 &quot;Invalid date interval&quot;);         }          $this-&gt;start = $start;         $this-&gt;end = $end;     }      public function isEmpty(): bool     {         return $this-&gt;start === $this-&gt;end;     }      \/**      * @param Interval $other      * @return Interval[]      *\/     public function remove(Interval $other)     {         if ($this-&gt;start &gt;= $other-&gt;end                  || $this-&gt;end &lt;= $other-&gt;start) return [$this];          if ($this-&gt;start &gt;= $other-&gt;start                  &amp;&amp; $this-&gt;end &lt;= $other-&gt;end) return [];          if ($this-&gt;start &lt; $other-&gt;start                  &amp;&amp; $this-&gt;end &gt; $other-&gt;end) return [             new Interval($this-&gt;start, $other-&gt;start),             new Interval($other-&gt;end, $this-&gt;end),         ];          if ($this-&gt;start === $other-&gt;start) {             return [new Interval($other-&gt;end, $this-&gt;end)];         }          return [new Interval($this-&gt;start, $other-&gt;start)];     } }  \/** @mixin Interval[] *\/ class IntervalCollection extends \\ArrayIterator {     public function diff(IntervalCollection $other)             : IntervalCollection     {         \/** @var Interval[] $items *\/         $items = $this-&gt;getArrayCopy();         foreach ($other as $interval) {             $newItems = [];             foreach ($items as $ourInterval) {                 array_push($newItems,                  ...$ourInterval-&gt;remove($interval));             }             $items = $newItems;         }          return new self($items);     } }<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a\u043b\u0430\u0441\u0441 <strong>IntervalCollection<\/strong> \u2014 \u044d\u0442\u043e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0430\u0446\u0438\u0438 \u043b\u043e\u0433\u0438\u043a\u0438 \u0440\u044f\u0434\u043e\u043c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043e\u043d\u0430 \u043e\u043f\u0435\u0440\u0438\u0440\u0443\u0435\u0442. \u041d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u043c\u0430\u0441\u0441\u0438\u0432 \u0441 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438 <strong>Interval<\/strong>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438, \u0430 \u0446\u0435\u043b\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0441 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u043c \u0438\u043c\u0435\u043d\u0435\u043c \u0438 \u043f\u043e\u043a\u0440\u044b\u0442\u044b\u0439 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0437\u0434\u0435\u0441\u044c \u2014 <a href=\"https:\/\/github.com\/adelf\/intervals-example\" rel=\"nofollow\">https:\/\/github.com\/adelf\/intervals-example<\/a>. \u0422\u0435\u043a\u0443\u0449\u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043e\u043f\u0442\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0435 \u0441 \u0442\u043e\u0447\u043a\u0438 \u0437\u0440\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u043b\u043e\u0433\u0438\u043a\u0430 \u0435\u0433\u043e \u0441\u043f\u0440\u044f\u0442\u0430\u043d\u0430 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>IntervalCollection::diff<\/code> \u0438 \u0445\u043e\u0440\u043e\u0448\u043e \u043f\u043e\u043a\u0440\u044b\u0442\u0430 \u0442\u0435\u0441\u0442\u0430\u043c\u0438. \u0415\u0441\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043e\u043d \u0441\u043c\u043e\u0436\u0435\u0442 \u044d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0431\u0435\u0437 \u0432\u0441\u044f\u043a\u043e\u0433\u043e \u0441\u0442\u0440\u0430\u0445\u0430. \u041b\u044e\u0431\u0443\u044e \u043e\u0448\u0438\u0431\u043a\u0443 \u0432 \u043b\u043e\u0433\u0438\u043a\u0435 \u0442\u0435\u0441\u0442\u044b \u043f\u043e\u0439\u043c\u0430\u044e\u0442 \u043d\u0435\u043c\u0435\u0434\u043b\u0435\u043d\u043d\u043e. \u042d\u0442\u043e \u0432\u0442\u043e\u0440\u043e\u0435 \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e unit-\u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0430\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e-\u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0435\u043c\u0443 \u0432\u043b\u0430\u0434\u0435\u044e\u0442 \u0441\u0432\u043e\u0438\u043c\u0438 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c coupling (\u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0441\u0442\u044c \u0438\u043b\u0438 \u0437\u0430\u0446\u0435\u043f\u043b\u0435\u043d\u0438\u0435), \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e \u0432 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445. \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u044d\u0442\u0430\u043f\u043e\u043c \u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0435\u0440\u0435\u0434\u0435\u043b\u043a\u0430 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u043e\u0432 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043f\u043e\u043b\u0435\u0439 \u043d\u0430 private:<\/p>\n<p>  <\/p>\n<pre><code class=\"php\">class Interval {     private DateTimeImmutable $start;     private DateTimeImmutable $end;      \/\/ methods }<\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0432 \u0441\u0442\u0438\u043b\u0435 <code>print()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u043d\u0430\u043c \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e\u0431 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0435 \u0432 \u043d\u0443\u0436\u043d\u043e\u043c \u0444\u043e\u0440\u043c\u0430\u0442\u0435, \u043d\u043e \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0437\u0430\u043a\u0440\u043e\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430 \u0438\u0437\u0432\u043d\u0435. \u041d\u043e \u044d\u0442\u043e \u0443\u0436\u0435 \u0442\u043e\u0447\u043d\u043e \u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0438.<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/511744\/\"> https:\/\/habr.com\/ru\/post\/511744\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/511744\/\">\n<p>\u041c\u044b, PHP-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438, \u0433\u043e\u0440\u0434\u044b \u0442\u0435\u043c, \u0447\u0442\u043e \u043f\u0438\u0448\u0435\u043c \u043d\u0430 \u041e\u041e\u041f-\u044f\u0437\u044b\u043a\u0435 (\u043c\u043e\u0436\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0437\u0434\u0435\u0441\u044c \u0437\u0430\u043c\u0435\u043d\u0438\u0442\u044c PHP \u043d\u0430 C#, Java \u0438\u043b\u0438 \u0434\u0440\u0443\u0433\u043e\u0439 \u041e\u041e\u041f-\u044f\u0437\u044b\u043a). \u041a\u0430\u0436\u0434\u0430\u044f \u0432\u0430\u043a\u0430\u043d\u0441\u0438\u044f \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e \u0437\u043d\u0430\u043d\u0438\u0435 \u041e\u041e\u041f. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043e\u0431\u0435\u0441\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u0438 \u0441\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u044e\u0442 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u0440\u043e SOLID \u0438\u043b\u0438 \u0442\u0440\u0435\u0445 &quot;\u043a\u0438\u0442\u043e\u0432&quot; \u041e\u041e\u041f. \u041d\u043e \u043a\u043e\u0433\u0434\u0430 \u0434\u0435\u043b\u043e \u0434\u043e\u0445\u043e\u0434\u0438\u0442 \u0434\u043e \u0434\u0435\u043b\u0430 \u2014 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b, \u043d\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u043d\u044b\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c\u0438. \u041e\u041e\u041f \u043f\u0440\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e, \u043e\u0431\u044b\u0447\u043d\u043e \u0432 \u043a\u043e\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u044b\u0447\u043d\u043e\u0435 \u0432\u0435\u0431-\u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u2014 \u044d\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u044b ORM-\u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0441\u0442\u0440\u043e\u043a\u0438 \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u044b(\u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u2014 \u043d\u0435\u0432\u0430\u0436\u043d\u043e), \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u044d\u0442\u0438\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438. \u041e\u0431\u044a\u0435\u043a\u0442\u043d\u043e-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u2014 \u043e\u043d\u043e \u043f\u0440\u043e \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 <strong>\u0432\u043b\u0430\u0434\u0435\u044e\u0442<\/strong> \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u043d\u043d\u044b\u043c\u0438, \u0430 \u043d\u0435 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0445 \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0434\u0440\u0443\u0433\u043e\u043c\u0443 \u043a\u043e\u0434\u0443. \u041e\u0442\u043b\u0438\u0447\u043d\u0430\u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u044d\u0442\u043e\u0433\u043e \u2014 \u0432\u043e\u043f\u0440\u043e\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0437\u0430\u0434\u0430\u043d \u0432 \u043e\u0434\u043d\u043e\u043c \u0447\u0430\u0442\u0435: &quot;\u041a\u0430\u043a \u044f \u043c\u043e\u0433\u0443 \u0443\u043b\u0443\u0447\u0448\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043e\u0434?&quot;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-307208","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307208","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=307208"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/307208\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=307208"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=307208"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=307208"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}