{"id":295294,"date":"2019-11-27T15:00:34","date_gmt":"2019-11-27T15:00:34","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=295294"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=295294","title":{"rendered":"\u0413\u043e\u043b\u043b\u0438\u0432\u0443\u0434\u0441\u043a\u0438\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f (IoC)"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/477700\/\">\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c Inversion of Control \/ \u0418\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f (IoC), \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c \u0435\u0449\u0435 \u0413\u043e\u043b\u043b\u0438\u0432\u0443\u0434\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c. \u041f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043a <a href=\"https:\/\/dou.ua\/lenta\/articles\/liskov-substitution-principle\/\">\u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0411\u0430\u0440\u0431\u0430\u0440\u044b \u041b\u0438\u0441\u043a\u043e\u0432\u043e (LSP)<\/a> \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043d\u0435\u0441\u0443 \u0441\u0432\u043e\u044e \u043b\u0435\u043f\u0442\u0443 \u0432 \u0441\u0432\u044f\u0449\u0435\u043d\u043d\u0443\u044e \u0432\u043e\u0439\u043d\u0443 private vs protected.<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u044f \u0445\u043e\u0447\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0441\u043b\u043e\u0432 \u043e \u0441\u0435\u0431\u0435. \u041f\u043e \u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u044f \u0438\u043d\u0436\u0435\u043d\u0435\u0440-\u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442, \u0432 \u0438\u043d\u0434\u0443\u0441\u0442\u0440\u0438\u0438 IT \u0440\u0430\u0431\u043e\u0442\u0430\u044e \u0443\u0436\u0435 \u0431\u043e\u043b\u0435\u0435 10 \u043b\u0435\u0442 \u0438 \u0432 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0435 \u0432\u0440\u0435\u043c\u044f \u0443\u0432\u043b\u0435\u043a\u0430\u044e\u0441\u044c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0435\u0439. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0431\u044b\u043b\u0438 \u0443\u0434\u0430\u0447\u043d\u044b\u043c\u0438. \u0420\u0430\u043d\u0435\u0435 \u044f \u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0430\u0441\u044c \u043d\u0430 \u0434\u0440\u0443\u0433\u043e\u043c \u0440\u0435\u0441\u0443\u0440\u0441\u0435, \u043a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u043c \u043d\u0430 \u0442\u0435\u0440\u0440\u0438\u0442\u043e\u0440\u0438\u0438 \u0420\u043e\u0441\u0441\u0438\u0438 (\u043f\u0440\u0438\u0432\u0435\u0442 \u0420\u043e\u0441\u043a\u043e\u043c\u043d\u0430\u0434\u0437\u043e\u0440\u0443). \u0415\u0441\u043b\u0438 \u043a\u0442\u043e-\u0442\u043e \u0437\u0430\u0445\u043e\u0447\u0435\u0442 \u0441 \u043d\u0438\u043c\u0438 \u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u044c\u0441\u044f \u2014 \u0432\u044b \u0437\u043d\u0430\u0435\u0442\u0435 \u0447\u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c.<\/p>\n<p>  \u0412\u0441\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u043a\u043e\u0434\u0430, \u043a\u0430\u043a \u043e\u0431\u044b\u0447\u043d\u043e, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u044b \u0432 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0441\u0435\u0432\u0434\u043e\u043a\u043e\u0434\u043e\u043c, \u0441\u0442\u0438\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u043c \u043f\u043e\u0434 \u201c\u043d\u0435\u043d\u0430\u0432\u0438\u0441\u0442\u043d\u044b\u0439 php\u201d.<\/p>\n<h3>\u0418\u0441\u0445\u043e\u0434\u043d\u0430\u044f \u0437\u0430\u0434\u0430\u0447\u0430<\/h3>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0438 \u043f\u043e\u043d\u044f\u0442\u043d\u0435\u0435, \u0441\u0440\u0430\u0437\u0443 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443. \u0418\u0437 \u043e\u0442\u0434\u0435\u043b\u0430 \u043f\u0440\u043e\u0434\u0430\u0436 \u043f\u043e\u0441\u0442\u0443\u043f\u0438\u043b\u0430 \u0445\u043e\u0442\u0435\u043b\u043a\u0430 \u0432\u0438\u0434\u0435\u0442\u044c \u043c\u0435\u0442\u0440\u0438\u043a\u0438: \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0435\u043d\u0435\u0433 \u043c\u044b \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u043c \u0435\u0436\u0435\u043c\u0435\u0441\u044f\u0447\u043d\u043e, \u0435\u0436\u0435\u0434\u043d\u0435\u0432\u043d\u043e, \u0435\u0436\u0435\u0447\u0430\u0441\u043d\u043e.<\/p>\n<p>  \u041c\u044b \u0440\u0435\u0448\u0430\u0435\u043c \u044d\u0442\u0443 \u0437\u0430\u0434\u0430\u0447\u0443 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0442\u0440\u0435\u0445 \u043a\u043e\u043c\u0430\u043d\u0434, \u043f\u0435\u0440\u0438\u043e\u0434\u0438\u0447\u0435\u0441\u043a\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c\u044b\u0445 \u043f\u043e \u0440\u0430\u0441\u043f\u0438\u0441\u0430\u043d\u0438\u044e:<\/p>\n<ul>\n<li>MonthlyReportCommand<\/li>\n<li>DailyReportCommand<\/li>\n<li>HourlyPerortCommand<\/li>\n<\/ul>\n<p>  \u041d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u044f\u0442\u0441\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b:<\/p>\n<pre><code class=\"php\">interface ReportCommandInterface {     public function createReport(): Money; }  interface MoneyRepositoryInterface {     \/** @return Money[] *\/     public function getMoney(Period $period): array; }  interface MetricRepositoryInterface {     public function saveMoneyMetric(Period $period, Money $amount, string $metricType); } <\/code><\/pre>\n<p>  \u041f\u0438\u0448\u0435\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0440\u0435\u043f\u043e\u0440\u0442\u043e\u0432 (\u043f\u043e\u0441\u043b\u0435\u0434\u043d\u044f\u044f \u043e\u043f\u0443\u0449\u0435\u043d\u0430, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0443\u043f\u0440\u0430\u0436\u043d\u0435\u043d\u0438\u044f \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0445\u043e\u0440\u043e\u0448\u0435\u043d\u044c\u043a\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0438 \u043f\u043e\u0442\u0440\u0435\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0435\u0435 \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e):<\/p>\n<pre><code class=\"php\">class MonthlyReportCommand implements ReportCommandInterface {     \/\/lets assume constructor is already here      public function createReport(): Money {         $period = new Period(new DateTime('first day of previous month'), new DateTime('last day of previous month'));         $moneyRecords = $this-&gt;moneyRepository-&gt;getMoney($period);         $amount = $this-&gt;calculateMoneySumm($moneyRecords);         $this-&gt;metricRepository-&gt;saveMoneyMetric($period, $amount, 'monthly income');     }      \/** @param Money[] $moneyRecords *\/     private function calculateMoneySumm(array $moneyRecords): Money {         \/\/here calculates sum of money records     } }  class DailyReportCommand implements ReportCommandInterface {     \/\/lets assume constructor is already here      public function createReport(): Money {         $period = new Period(new DateTime('yesterday'), new DateTime('today'));         $moneyRecords = $this-&gt;moneyRepository-&gt;getMoney($period);         $amount = $this-&gt;calculateMoneySumm($moneyRecords);         $this-&gt;metricRepository-&gt;saveMoneyMetric($period, $amount, 'daily income');     }      \/** @param Money[] $moneyRecords *\/     private function calculateMoneySumm(array $moneyRecords): Money {         \/\/here calculates sum of money records     } }  class HourlyReportCommand ... {     \/\/the same as previous two but hourly } <\/code><\/pre>\n<p>  \u0418 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u043a\u043e\u0434 \u043c\u0435\u0442\u043e\u0434\u0430 calculateMoneySumm() \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0432\u043e \u0432\u0441\u0435\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445. \u041f\u0435\u0440\u0432\u043e\u0435, \u0447\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442 \u0432 \u0433\u043e\u043b\u043e\u0432\u0443 \u2014 \u044d\u0442\u043e \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0434\u0443\u0431\u043b\u0438\u0440\u0443\u044e\u0449\u0438\u0439\u0441\u044f \u043a\u043e\u0434 \u0432 \u043e\u0431\u0449\u0438\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441. \u0412\u043e\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ru\/ho\/qx\/ruhoqxhgpjaax1wznwsvvvptgbk.png\" alt=\"image\"\/><\/p>\n<pre><code class=\"php\">abstract class AbstractReportCommand {     protected function calculateMoneySumm(array $moneyRecords): Money {         \/\/here calculates sum of money records     } }  class MonthlyReportCommand extends AbstractReportCommand implements ReportCommandInterface {     public function createReport(): Money {         \/\/realization is here, calls calculateMoneySumm($moneyRecords)     } }  class DailyReportCommand extends AbstractReportCommand implements ReportCommandInterface {     \/\/the same as previous two but daily }  class HourlyReportCommand ... {     \/\/the same as previous two but hourly } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 calculateMoneySumm() \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0447\u0430\u0441\u0442\u044c\u044e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u043e\u0432 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430. \u041c\u044b \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e, \u0442.\u043a. \u043e\u043d \u043d\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432\u044b\u0437\u0432\u0430\u043d \u043f\u043e\u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u043a\u043b\u0438\u0435\u043d\u0442\u0430\u043c\u0438 \u2014 \u043c\u044b \u043d\u0435 \u0434\u043b\u044f \u0442\u043e\u0433\u043e \u0435\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u0443\u0435\u043c. \u041c\u044b \u043e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 protected, \u0442.\u043a. \u043f\u043b\u0430\u043d\u0438\u0440\u0443\u0435\u043c \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u0445 \u2014 \u0432\u043e\u0442 \u043d\u0430\u0448\u0430 \u0446\u0435\u043b\u044c. \u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u0445\u043e\u0436 \u043d\u0430 \u043d\u0435\u0447\u0442\u043e \u0432\u0440\u043e\u0434\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u2014 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043a\u0430\u043a\u0438\u0435-\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b (\u0434\u043b\u044f php-\u0437\u043d\u0430\u0442\u043e\u043a\u043e\u0432: \u0442.\u0435. \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043a\u0430\u043a Trait).<\/p>\n<h3>\u0421\u0435\u043a\u0440\u0435\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432<\/h3>\n<p>  \u041d\u0430\u0441\u0442\u0430\u043b\u043e \u0432\u0440\u0435\u043c\u044f \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043e\u0442\u0432\u043b\u0435\u0447\u044c\u0441\u044f \u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0438 \u0432\u0441\u043f\u043e\u043c\u043d\u0438\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<p>  <i>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u044b, \u0432 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044f \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u043d\u044b\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u043c \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f.<\/i><\/p>\n<p>  \u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f (\u043b\u0430\u0442. abstractio \u2014 \u043e\u0442\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435) \u2014 \u044d\u0442\u043e \u043e\u0442\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0442 \u0434\u0435\u0442\u0430\u043b\u0435\u0439 \u0438 \u043e\u0431\u043e\u0431\u0449\u0435\u043d\u0438\u0435. \u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043a\u043b\u0430\u0441\u0441 AbstractReportCommand \u043e\u0431\u043e\u0431\u0449\u0430\u0435\u0442 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0440\u0435\u043f\u043e\u0440\u0442\u043e\u0432 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u0441\u0447\u0435\u0442 \u0434\u0435\u043d\u0435\u0433. \u041d\u043e \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0430\u0448\u0443 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u0435\u0435, \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0432\u0448\u0438\u0441\u044c \u0413\u043e\u043b\u043b\u0438\u0432\u0443\u0434\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0437\u0432\u0443\u0447\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<p>  <i>\u201c\u041d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0441, \u043c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0432\u0430\u0441 \u0441\u0430\u043c\u0438\u201d<\/i><\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0443\u0432\u0438\u0434\u0435\u0442\u044c, \u043a\u0430\u043a \u044d\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u0432 AbstractReportCommand \u043e\u0431\u0449\u0438\u0439 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432:<\/p>\n<p>  <img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/_z\/ag\/nt\/_zagntuyn9d0vous7xjooatxlmw.png\" alt=\"image\"\/><\/p>\n<pre><code class=\"php\">abstract class AbstractReportCommand implements ReportCommandInterface {     \/** @var MoneyRepositoryInterface *\/     private $moneyRepository;     \/** @var MetricRepositoryInterface *\/     private $metricRepository;      \/\/lets assume constructor is already here      public function createReport(): Money {         $period = $this-&gt;getPeriod();         $metricType = $this-&gt;getMetricType();          $moneyRecords = $this-&gt;moneyRepository-&gt;getMoney($period);         $amount = $this-&gt;calculateMoneySumm($moneyRecords);          $this-&gt;metricRepository-&gt;saveMoneyMetric($period, $amount, $metricType);     }      abstract protected function getPeriod(): Period;     abstract protected function getMetricType(): string;      private function calculateMoneySumm(array $moneyRecords): Money {         \/\/here calculates sum of money records     } }  class MonthlyReportCommand extends AbstractReportCommand {     protected function getPeriod(): Period  {         return new Period(new DateTime('first day of previous month'), new DateTime('last day of previous month'));     }      protected function getMetricType(): string {         return 'monthly income';     } }  class DailyReportCommand extends AbstractReportCommand {     protected function getPeriod(): Period  {         return new Period(new DateTime('yesterday'), new DateTime('today'));     }      protected function getMetricType(): string {         return 'daily income';     } }  class HourlyReportCommand ... {     \/\/the same as previous two but hourly } <\/code><\/pre>\n<p>  \u0427\u0442\u043e \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u0411\u043e\u043b\u0435\u0435 \u043d\u0438 \u043e\u0434\u0438\u043d \u0438\u0437 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u043e\u0432 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043d\u0435 \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u043e\u0431\u0449\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c (\u043d\u0435 \u0432\u044b\u0437\u044b\u0432\u0430\u0439\u0442\u0435 \u043d\u0430\u0441). \u0412\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e, \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0437\u0430\u0434\u0430\u0435\u0442 \u0441\u0432\u043e\u0438\u043c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430\u043c \u043e\u0431\u0449\u0443\u044e \u0441\u0445\u0435\u043c\u0443 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u0442 \u043d\u0438\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043d\u044b\u0435 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043f\u043e\u043b\u044c\u0437\u0443\u044f\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430\u043c\u0438 (\u043c\u044b \u0432\u044b\u0437\u043e\u0432\u0435\u043c \u0432\u0430\u0441 \u0441\u0430\u043c\u0438).<\/p>\n<h3>\u0410 \u043a\u0430\u043a \u0436\u0435 \u043e\u0431\u0435\u0449\u0430\u043d\u043d\u044b\u0435 IoC, LSP, private vs protected?<\/h3>\n<p>  \u0422\u0430\u043a \u043f\u0440\u0438 \u0447\u0435\u043c \u0442\u0443\u0442 \u0418\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f? \u041e\u0442\u043a\u0443\u0434\u0430 \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435? \u041e\u0447\u0435\u043d\u044c \u043f\u0440\u043e\u0441\u0442\u043e: \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043c\u044b \u0437\u0430\u0434\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0445 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f\u0445, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u044f \u0442\u0435\u043c, \u0447\u0442\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u043d\u043e. \u0410 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c, \u043c\u044b \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u043b\u0438 \u044d\u0442\u0443 \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u043e\u0431\u0449\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e. \u0422\u0435\u043f\u0435\u0440\u044c \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0442\u0435\u043c, \u0447\u0442\u043e \u0438 \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u0432\u0430\u043d\u043e, \u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0441\u0442\u043e \u043f\u043e\u0434\u0447\u0438\u043d\u044f\u044e\u0442\u0441\u044f \u044d\u0442\u043e\u043c\u0443. \u0422.\u0435 \u043c\u044b \u0438\u043d\u0432\u0435\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435.<\/p>\n<p>  \u0427\u0442\u043e\u0431\u044b \u0437\u0430\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0442\u0430\u043a\u043e\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0438 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u0441 <a href=\"https:\/\/dou.ua\/lenta\/articles\/liskov-substitution-principle\/\">\u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0411\u0430\u0440\u0431\u0430\u0440\u044b \u041b\u0438\u0441\u043a\u043e\u0432 (LSP)<\/a>, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u043c\u0435\u0442\u043e\u0434 createReport() \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f final \u0432 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430. \u0412\u0435\u0434\u044c \u0432\u0441\u0435\u043c \u0438\u0437\u0432\u0435\u0441\u0442\u043d\u043e, \u0447\u0442\u043e LSP \u0438\u043c\u0435\u0435\u0442 \u043f\u0440\u044f\u043c\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u043a \u043d\u0430\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044e.<\/p>\n<pre><code class=\"php\">abstract class AbstractReportCommand implements ReportCommandInterface {     final public function createReport(): Money {         \/\/bla-bla realization     }     ... } <\/code><\/pre>\n<p>  \u0422\u043e\u0433\u0434\u0430 \u0432\u0441\u0435 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 AbstractReportCommand \u0441\u0442\u0430\u043d\u043e\u0432\u044f\u0442\u0441\u044f \u0436\u0435\u0441\u0442\u043a\u043e \u043f\u043e\u0434\u0447\u0438\u043d\u0435\u043d\u044b \u0435\u0434\u0438\u043d\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u0435, \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c. \u0416\u0435\u043b\u0435\u0437\u043d\u0430\u044f \u0434\u0438\u0441\u0446\u0438\u043f\u043b\u0438\u043d\u0430, \u043f\u043e\u0440\u044f\u0434\u043e\u043a, \u0441\u0432\u0435\u0442\u043b\u043e\u0435 \u0431\u0443\u0434\u0443\u0449\u0435\u0435.<\/p>\n<p>  \u041f\u043e \u0442\u043e\u0439 \u0436\u0435 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e private \u043f\u0435\u0440\u0435\u0434 protected. \u0412\u0441\u0435, \u0447\u0442\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a \u043e\u0431\u0449\u0438\u043c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0437\u0430\u0448\u0438\u0442\u043e \u0432 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u043c \u043a\u043b\u0430\u0441\u0441\u0435 \u0438 \u043d\u0435\u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043a \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u2014 private. \u0412\u0441\u0435, \u0447\u0442\u043e \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043e\/\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0432 \u0447\u0430\u0441\u0442\u043d\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u2014 abstract protected. \u041b\u044e\u0431\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0434\u043b\u044f \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u0445 \u0446\u0435\u043b\u0435\u0439. \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u043a\u0430\u043a\u0443\u044e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0437\u0430\u0434\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0443 \u2014 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u0432\u044b \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435, \u0437\u0430\u0447\u0435\u043c \u0432\u044b \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435. \u0422\u0430\u043a\u043e\u0439 \u0434\u0438\u0437\u0430\u0439\u043d \u0441\u0442\u043e\u0438\u0442 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>  \u041a\u043e\u043d\u0441\u0442\u0440\u0443\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432\u0441\u0435\u0433\u0434\u0430 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438\u0442\u0435\u043b\u044c\u043d\u0435\u0435 \u0441 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435\u043c \u0418\u043d\u0432\u0435\u0440\u0441\u0438\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u0442.\u043a. \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0438\u0434\u0435\u0435\u0439 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u0438 \u043d\u0430 \u043f\u043e\u043b\u043d\u0443\u044e \u043a\u0430\u0442\u0443\u0448\u043a\u0443. \u041d\u043e \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u0432 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043e\u043f\u0440\u0430\u0432\u0434\u0430\u043d\u043e.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0448\u0438\u0440\u0435, \u0442\u043e \u043d\u0430\u0448\u0435 \u043c\u0435\u0441\u0442\u0435\u0447\u043a\u043e\u0432\u043e\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0413\u043e\u043b\u043b\u0438\u0432\u0443\u0434\u0441\u043a\u043e\u0433\u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430 \u0438 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430-\u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043a\u0438 \u043f\u0440\u0435\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u0432 \u0441\u043f\u043e\u0440: \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a (IoC \u043f\u043e-\u0432\u0437\u0440\u043e\u0441\u043b\u043e\u043c\u0443) vs \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430. \u041d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0434\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u0437 \u043d\u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u2014 \u043a\u0430\u0436\u0434\u044b\u0439 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0439 \u0446\u0435\u043b\u044c\u044e. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u0430\u0436\u043d\u043e\u0435 \u2014 \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440. <\/p>\n<p>  \u0421\u043f\u0430\u0441\u0438\u0431\u043e \u0432\u0441\u0435\u043c, \u043a\u0442\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u043b \u043e\u0442 \u043d\u0430\u0447\u0430\u043b\u0430 \u0434\u043e \u043a\u043e\u043d\u0446\u0430 \u2014 \u0432\u044b \u043c\u043e\u0438 \u043b\u044e\u0431\u0438\u043c\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438.<\/p><\/div>\n<p>               <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d() } } }t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>      <br \/> \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\/477700\/\"> https:\/\/habr.com\/ru\/post\/477700\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/477700\/\">\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u043f\u043e\u0441\u0442\u0430\u0440\u0430\u044e\u0441\u044c \u0440\u0430\u0441\u0441\u043a\u0430\u0437\u0430\u0442\u044c \u043e \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c Inversion of Control \/ \u0418\u043d\u0432\u0435\u0440\u0441\u0438\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f (IoC), \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u043e\u043c \u0435\u0449\u0435 \u0413\u043e\u043b\u043b\u0438\u0432\u0443\u0434\u0441\u043a\u0438\u043c \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u043e\u043c. \u041f\u043e\u043a\u0430\u0436\u0443, \u043a\u0430\u043a\u043e\u0435 \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u0435 \u044d\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u043a <a href=\"https:\/\/dou.ua\/lenta\/articles\/liskov-substitution-principle\/\">\u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0443 \u043f\u043e\u0434\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 \u0411\u0430\u0440\u0431\u0430\u0440\u044b \u041b\u0438\u0441\u043a\u043e\u0432\u043e (LSP)<\/a> \u0430 \u0442\u0430\u043a\u0436\u0435 \u0432\u043d\u0435\u0441\u0443 \u0441\u0432\u043e\u044e \u043b\u0435\u043f\u0442\u0443 \u0432 \u0441\u0432\u044f\u0449\u0435\u043d\u043d\u0443\u044e \u0432\u043e\u0439\u043d\u0443 private vs protected.  <\/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-295294","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295294","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=295294"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/295294\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=295294"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=295294"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=295294"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}