{"id":333494,"date":"2022-05-22T21:00:12","date_gmt":"2022-05-22T21:00:12","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=333494"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=333494","title":{"rendered":"<span>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 1C Bitrix<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h3>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c CMS 1C Bitrix \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 &#8212; \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e (\u0434\u0430 \u0438, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043d\u0435\u0437\u0430\u0447\u0435\u043c) \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041d\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438 \u0441\u043b\u0443\u0436\u0431\u0430\u043c\u0438 (\u043f\u043b\u0430\u0442\u0435\u0436\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, API \u0441\u043b\u0443\u0436\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435), \u043b\u0438\u0431\u043e \u0436\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0418 \u0447\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u044a\u0435\u043c \u043a\u043e\u0434\u0430, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043b\u0435\u0436\u0438\u0442 \u0443\u0436\u0435 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435.<br \/>\u042d\u0442\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u043e\u0439 \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0432 CMS \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0448\u0430\u0433\u043e\u0432: <\/p>\n<ol>\n<li>\n<p>\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Composer;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Bitrix \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Composer;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c PHPUnit;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c PHPUnit \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Bitrix.<\/p>\n<\/li>\n<\/ol>\n<h3>Composer<\/h3>\n<details class=\"spoiler\">\n<summary>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 composer \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043f\u043e <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-and-use-composer-on-ubuntu-18-04\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/a>.<\/p>\n<pre><code class=\"bash\">cd ~ curl -sS https:\/\/getcomposer.org\/installer -o composer-setup.php HASH=\u0425\u0435\u0448 \u0444\u0430\u0439\u043b\u0430 php -r \"if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"<\/code><\/pre>\n<p>\u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e &#8212; \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u0438\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0449\u0438\u043a \u0441\u043a\u0430\u0447\u0430\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e:<\/p>\n<pre><code>Installer verified<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435:<\/p>\n<pre><code class=\"bash\">sudo php composer-setup.php --install-dir=\/usr\/local\/bin --filename=composer<\/code><\/pre>\n<p>\u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e \u0432\u0438\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435:<\/p>\n<pre><code class=\"xml\">Output All settings correct for using Composer Downloading...  Composer (version 2.1.9) successfully installed to: \/usr\/local\/bin\/composer Use it: php \/usr\/local\/bin\/composer<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <strong>local<\/strong>. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"bash\">cd local composer init<\/code><\/pre>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c.<br \/>\u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \/local\/composer.json \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"json\">{     \"name\": \"myproject\/website\",     \"type\": \"project\",     \"authors\": [         {             \"name\": \"Andriy Kryvenko\",             \"email\": \"krivenko.a.b@gmail.com\"         }     ] }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0430\u0436\u0435\u043c \u0431\u0438\u0442\u0440\u0438\u043a\u0441\u0443, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 Composer.<br \/>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <strong>\/local\/php_interface\/init.php<\/strong> (\u0441\u043e\u0437\u0434\u0430\u0435\u043c, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442) \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b autoload:<\/p>\n<pre><code class=\"php\">&lt;?php  include_once(__DIR__.'\/..\/vendor\/autoload.php');<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/local\/vendor\/ \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0439. \u0412 \u0444\u0430\u0439\u043b .gitignore \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \/local\/vendor\/*<\/p>\n<h3>PHPUnit<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 PHPUnit. \u041d\u0430 \u043f\u0440\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043e\u043d \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 dev \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433-\u0444\u0430\u0439\u043b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<pre><code class=\"bash\">composer require --dev phpunit\/phpunit ^9.0 .\/vendor\/bin\/phpunit --generate-configuration<\/code><\/pre>\n<p>\u0412 dev-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d phpunit, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d \u0444\u0430\u0439\u043b \/local\/phpunit.xml<br \/>\u041f\u043e\u043c\u0438\u043c\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e PHPUnit, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/packagist.org\/packages\/sempro\/phpunit-pretty-print\" rel=\"noopener noreferrer nofollow\">sempro\/phpunit-pretty-print<\/a>.<\/p>\n<pre><code class=\"bash\">composer require --dev sempro\/phpunit-pretty-print ^1.4<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <strong>\/local\/tests\/bootstrap.php<\/strong><\/p>\n<pre><code class=\"php\">&lt;?php  define(\"NOT_CHECK_PERMISSIONS\", true); define(\"NO_AGENT_CHECK\", true);  $_SERVER[\"DOCUMENT_ROOT\"] = __DIR__ . '\/..\/..';  require($_SERVER[\"DOCUMENT_ROOT\"].\"\/bitrix\/modules\/main\/include\/prolog_before.php\");<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c PHPUnit, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430\u0448 \u0444\u0430\u0439\u043b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0444\u0430\u0439\u043b <strong>\/local\/phpunit.xml<\/strong> \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0433\u043e \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<details class=\"spoiler\">\n<summary>phpunit.xml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?> &lt;phpunit xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"          xsi:noNamespaceSchemaLocation=\"https:\/\/schema.phpunit.de\/9.5\/phpunit.xsd\"          bootstrap=\"tests\/bootstrap.php\"          cacheResultFile=\".phpunit.cache\/test-results\"          colors=\"true\"          printerClass=\"Sempro\\PHPUnitPrettyPrinter\\PrettyPrinterForPhpUnit9\"          executionOrder=\"random\"          forceCoversAnnotation=\"true\"          beStrictAboutCoversAnnotation=\"true\"          beStrictAboutOutputDuringTests=\"true\"          beStrictAboutTodoAnnotatedTests=\"true\"          convertDeprecationsToExceptions=\"true\"          failOnRisky=\"true\"          failOnWarning=\"true\"          verbose=\"true\">      &lt;php>         &lt;ini name=\"memory_limit\" value=\"-1\"\/>         &lt;ini name=\"display_errors\" value=\"true\"\/>     &lt;\/php>      &lt;testsuites>         &lt;testsuite name=\"default\">             &lt;directory suffix=\"Test.php\">tests&lt;\/directory>             &lt;exclude>tests\/Stubs&lt;\/exclude>             &lt;exclude>tests\/Request&lt;\/exclude>             &lt;exclude>tests\/Response&lt;\/exclude>         &lt;\/testsuite>     &lt;\/testsuites>      &lt;coverage cacheDirectory=\".phpunit.cache\/code-coverage\"               processUncoveredFiles=\"true\">         &lt;include>             &lt;directory suffix=\".php\">classes&lt;\/directory>         &lt;\/include>     &lt;\/coverage> &lt;\/phpunit><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/p>\n<details class=\"spoiler\">\n<summary>composer.json<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"json\">{     \"name\": \"myproject\/website\",     \"type\": \"project\",     \"authors\": [         {             \"name\": \"Andriy Kryvenko\",             \"email\": \"krivenko.a.b@gmail.com\"         }     ],     \"require-dev\": {         \"phpunit\/phpunit\": \"^9\",         \"sempro\/phpunit-pretty-print\": \"^1.4\"     },     \"scripts\": {         \"test\": \"phpunit\"     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<pre><code class=\"bash\">composer test<\/code><\/pre>\n<p>\u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b. \u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u0432\u043e\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 local\/classes, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<\/p>\n<pre><code>\/local\/classes\/MyProject\/Product.php \/local\/classes\/MyProject\/Rests.php<\/code><\/pre>\n<p>\u0418 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0440\u0443\u0447\u043d\u0443\u044e &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>\/local\/php_interface\/init.php<\/strong> \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"php\">&lt;?php  spl_autoload_register(function($className) {     $className = str_replace(\"\\\\\", DIRECTORY_SEPARATOR, $className);     include_once $_SERVER['DOCUMENT_ROOT'] . '\/local\/classes\/' . $className . '.php'; });  include_once(__DIR__.'\/..\/vendor\/autoload.php');<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u0441\u0442\u0430<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 (\u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0443\u044e\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e).<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: \u0438\u0437 1\u0421 \u043d\u0430 \u0441\u0430\u0439\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u0440\u043e\u043a\u0430\u0445 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>24 \u0447\u0430\u0441\u0430-7|\u0434\u043e 2 \u0434\u043d\u0435\u0439-14|\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0435 \u0434\u043e 7 \u0448\u0442\u0443\u043a &#8212; \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430 24 \u0447\u0430\u0441\u0430, \u0434\u043e 14 \u0448\u0442\u0443\u043a &#8212; \u0437\u0430 2 \u0434\u043d\u044f, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; \u0437\u0430 15 \u0434\u043d\u0435\u0439.<\/p>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b <strong>Leftover<\/strong> \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>LeftoverTransformer<\/strong>:<\/p>\n<details class=\"spoiler\">\n<summary>Leftover<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites;  class Leftover {     public int $time = 0;      \/**      * \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430.      * \u0415\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0432\u043d\u043e -1.0 - \u0442\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e      *\/     public float $quantity = 0.0;      public function __construct(int $time, float $quantity)     {         $this->time = $time;         $this->quantity = $quantity;     }      public function isAvailable(): bool     {         return ($this->quantity > 0 || $this->quantity == -1.0);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>LeftoverTransformer<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites\\Transform;  use MyProject\\Product\\Requisites\\Leftover;  class LeftoverTransformer {     \/**      * @param string $leftoversString      * @return Leftover[]      * \u0421\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0432\u0438\u0434\u0435      * 24 \u0447\u0430\u0441\u0430-7|\u0434\u043e 2 \u0434\u043d\u0435\u0439-14|\u0434\u043e 7 \u0434\u043d\u0435\u0439-22|\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440      *\/     public static function transform(string $leftoversString): array     {         $leftovers = [];         $intervals = explode('|', $leftoversString);         foreach ($intervals as $v){             $interval = explode('-', $v);             $intervalValues = [];             foreach ($interval as $k => $part) {                 $intervalValues[] = trim($part);             }              if (!empty($intervalValues[0]) &amp;&amp; !empty($intervalValues[1])) {                 $leftovers[] = new Leftover(                     self::getTimeFromString($intervalValues[0]),                     self::getQuantityFromString($intervalValues[1])                 );             }         }          return $leftovers;     }      private static function getTimeFromString(string $timeString): int     {         switch ($timeString) {             case '24 \u0447\u0430\u0441\u0430':                 $time = 1;                 break;             default:                 $parts = explode(' ', $timeString);                 $time = intval($parts[1]);                 break;         }         return $time;     }      private static function getQuantityFromString(string $quantityString): int     {         switch ($quantityString) {             case '\u043d\u0435\u043e\u0433\u0440':                 $quantity = -1;                 break;             default:                 $quantity = intval($quantityString);                 break;         }         return $quantity;     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>LeftoverTest<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites;  use PHPUnit\\Framework\\TestCase;  \/**  * @covers Leftover  *\/ class LeftoverTest extends TestCase {     public function testIsAvailable(): void     {         $leftover = new Leftover(1, 12.0);          $this->assertTrue($leftover->isAvailable());     }        public function testAvailableUnlimited(): void     {         $leftover = new Leftover(1, -1.0);          $this->assertTrue($leftover->isAvailable());     }      public function testUnavailable(): void     {         $leftover = new Leftover(1, 0.0);          $this->assertFalse($leftover->isAvailable());     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>LeftoverTransformerTest<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites\\Transform;  use PHPUnit\\Framework\\TestCase;  \/**  * @covers LeftoverTransformer  *\/ class LeftoverTransformerTest extends TestCase {     public function testEmpty(): void     {         $this->assertEmpty(LeftoverTransformer::transform(''));     }      public function testLeftoversCount(): void     {         $leftoverString = '24 \u0447\u0430\u0441\u0430-7|\u0434\u043e 2 \u0434\u043d\u0435\u0439-14|\u0434\u043e 7 \u0434\u043d\u0435\u0439-22|\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440';         $leftovers = LeftoverTransformer::transform($leftoverString);          $this->assertCount(4, $leftovers);     }      \/**      * @param string $leftoverString      * @param int $expectedTime      * @param float $expectedQuantity      * @return void      * @dataProvider leftoversProvider      *\/     public function testLeftovers(string $leftoverString, int $expectedTime, float $expectedQuantity): void     {         $leftovers = LeftoverTransformer::transform($leftoverString);          $this->assertEquals($expectedTime, $leftovers[0]->time);         $this->assertEquals($expectedQuantity, $leftovers[0]->quantity);     }      public function leftoversProvider(): array     {         return [             '24 \u0447\u0430\u0441\u0430-7' => [                 '24 \u0447\u0430\u0441\u0430-7',                 1, 7.0             ],             '\u0434\u043e 2 \u0434\u043d\u0435\u0439-14' => [                 '\u0434\u043e 2 \u0434\u043d\u0435\u0439-14',                 2, 14.0             ],             '\u0434\u043e 7 \u0434\u043d\u0435\u0439-22' => [                 '\u0434\u043e 7 \u0434\u043d\u0435\u0439-22',                 7, 22.0             ],             '\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440' => [                 '\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440',                 15, -1.0             ]         ];     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u041f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u0441\u0442\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0442\u043e\u0432\u0430\u0440\u0430\u043c\u0438 \u043c\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u043c, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u043e \u043b\u0438 \u043a \u043f\u043e\u043a\u0443\u043f\u043a\u0435 \u0442\u043e \u0438\u043b\u0438 \u0438\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u0438 \u0432 \u043a\u0430\u043a\u043e\u0439 \u0441\u0440\u043e\u043a.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><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\/667160\/\"> https:\/\/habr.com\/ru\/post\/667160\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<h3>\u041f\u0440\u0435\u0434\u0438\u0441\u043b\u043e\u0432\u0438\u0435<\/h3>\n<p>\u0413\u043e\u0432\u043e\u0440\u044f \u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0430\u0439\u0442\u043e\u0432 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c CMS 1C Bitrix \u0432\u043e\u043f\u0440\u043e\u0441 \u043f\u043e\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0435\u0441\u0442\u0430\u043c\u0438 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e. \u0413\u043b\u0430\u0432\u043d\u0430\u044f \u043f\u0440\u0438\u0447\u0438\u043d\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043e\u0431\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u044b\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u043e\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439 &#8212; \u0435\u0433\u043e \u0441\u043b\u043e\u0436\u043d\u043e (\u0434\u0430 \u0438, \u0432 \u043e\u0431\u0449\u0435\u043c-\u0442\u043e, \u043d\u0435\u0437\u0430\u0447\u0435\u043c) \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c.<\/p>\n<p>\u041d\u043e \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442 \u0440\u0430\u0437\u0440\u0430\u0441\u0442\u0430\u0435\u0442\u0441\u044f, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0441\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u043c\u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438 \u0441\u043b\u0443\u0436\u0431\u0430\u043c\u0438 (\u043f\u043b\u0430\u0442\u0435\u0436\u043d\u044b\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, API \u0441\u043b\u0443\u0436\u0431 \u0434\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435), \u043b\u0438\u0431\u043e \u0436\u0435 \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432\u0441\u0435 \u0431\u043e\u043b\u0435\u0435 \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b. \u0418 \u0447\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435, \u0442\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043e\u0431\u044a\u0435\u043c \u043a\u043e\u0434\u0430, \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u0437\u0430 \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043b\u0435\u0436\u0438\u0442 \u0443\u0436\u0435 \u043d\u0430 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0435.<br \/>\u042d\u0442\u043e \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0435\u0434\u043f\u043e\u0441\u044b\u043b\u043a\u043e\u0439 \u0434\u043b\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0432 CMS \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f.<\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0448\u0430\u0433\u043e\u0432: <\/p>\n<ol>\n<li>\n<p>\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c Composer;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 Bitrix \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Composer;<\/p>\n<\/li>\n<li>\n<p>\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c PHPUnit;<\/p>\n<\/li>\n<li>\n<p>\u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c PHPUnit \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 Bitrix.<\/p>\n<\/li>\n<\/ol>\n<h3>Composer<\/h3>\n<details class=\"spoiler\">\n<summary>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0443 composer \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u043c \u043f\u043e <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/how-to-install-and-use-composer-on-ubuntu-18-04\" rel=\"noopener noreferrer nofollow\">\u0438\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0438<\/a>.<\/p>\n<pre><code class=\"bash\">cd ~ curl -sS https:\/\/getcomposer.org\/installer -o composer-setup.php HASH=\u0425\u0435\u0448 \u0444\u0430\u0439\u043b\u0430 php -r \"if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;\"<\/code><\/pre>\n<p>\u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e &#8212; \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u0438 \u0432\u0438\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0447\u0442\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0449\u0438\u043a \u0441\u043a\u0430\u0447\u0430\u043d \u0443\u0441\u043f\u0435\u0448\u043d\u043e:<\/p>\n<pre><code>Installer verified<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435:<\/p>\n<pre><code class=\"bash\">sudo php composer-setup.php --install-dir=\/usr\/local\/bin --filename=composer<\/code><\/pre>\n<p>\u041f\u043e \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044e \u0432\u0438\u0434\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u043e \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435:<\/p>\n<pre><code class=\"xml\">Output All settings correct for using Composer Downloading...  Composer (version 2.1.9) successfully installed to: \/usr\/local\/bin\/composer Use it: php \/usr\/local\/bin\/composer<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0412\u0441\u044e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u044f\u043c\u0438 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0443\u0435\u043c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 <strong>local<\/strong>. \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442:<\/p>\n<pre><code class=\"bash\">cd local composer init<\/code><\/pre>\n<p>\u0423\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u044b\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u043c.<br \/>\u041f\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u044e \u0443 \u043d\u0430\u0441 \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0444\u0430\u0439\u043b \/local\/composer.json \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u0438\u043c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u044b\u043c:<\/p>\n<pre><code class=\"json\">{     \"name\": \"myproject\/website\",     \"type\": \"project\",     \"authors\": [         {             \"name\": \"Andriy Kryvenko\",             \"email\": \"krivenko.a.b@gmail.com\"         }     ] }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043a\u0430\u0436\u0435\u043c \u0431\u0438\u0442\u0440\u0438\u043a\u0441\u0443, \u0447\u0442\u043e \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u043e\u0440\u043e\u043d\u043d\u0438\u0435 \u043f\u0430\u043a\u0435\u0442\u044b, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0447\u0435\u0440\u0435\u0437 Composer.<br \/>\u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0444\u0430\u0439\u043b <strong>\/local\/php_interface\/init.php<\/strong> (\u0441\u043e\u0437\u0434\u0430\u0435\u043c, \u0435\u0441\u043b\u0438 \u043d\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442) \u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0444\u0430\u0439\u043b autoload:<\/p>\n<pre><code class=\"php\">&lt;?php  include_once(__DIR__.'\/..\/vendor\/autoload.php');<\/code><\/pre>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043a\u0430\u0442\u0430\u043b\u043e\u0433 \/local\/vendor\/ \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044f \u0432\u0435\u0440\u0441\u0438\u0439. \u0412 \u0444\u0430\u0439\u043b .gitignore \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \/local\/vendor\/*<\/p>\n<h3>PHPUnit<\/h3>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 PHPUnit. \u041d\u0430 \u043f\u0440\u043e\u0434 \u0441\u0435\u0440\u0432\u0435\u0440\u0435 \u043e\u043d \u043d\u0430\u043c \u043d\u0435 \u043d\u0443\u0436\u0435\u043d, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 dev \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043e\u043d\u0444\u0438\u0433-\u0444\u0430\u0439\u043b. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0432 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435:<\/p>\n<pre><code class=\"bash\">composer require --dev phpunit\/phpunit ^9.0 .\/vendor\/bin\/phpunit --generate-configuration<\/code><\/pre>\n<p>\u0412 dev-\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0431\u044b\u043b \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d phpunit, \u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u043d \u0444\u0430\u0439\u043b \/local\/phpunit.xml<br \/>\u041f\u043e\u043c\u0438\u043c\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e PHPUnit, \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u0438\u044f\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432 \u0442\u0435\u0441\u0442\u043e\u0432 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u043f\u0430\u043a\u0435\u0442 <a href=\"https:\/\/packagist.org\/packages\/sempro\/phpunit-pretty-print\" rel=\"noopener noreferrer nofollow\">sempro\/phpunit-pretty-print<\/a>.<\/p>\n<pre><code class=\"bash\">composer require --dev sempro\/phpunit-pretty-print ^1.4<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043f\u0440\u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u043b\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u044f\u0434\u0440\u0430 \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u0430. \u041d\u0430\u0437\u043e\u0432\u0435\u043c \u0435\u0433\u043e <strong>\/local\/tests\/bootstrap.php<\/strong><\/p>\n<pre><code class=\"php\">&lt;?php  define(\"NOT_CHECK_PERMISSIONS\", true); define(\"NO_AGENT_CHECK\", true);  $_SERVER[\"DOCUMENT_ROOT\"] = __DIR__ . '\/..\/..';  require($_SERVER[\"DOCUMENT_ROOT\"].\"\/bitrix\/modules\/main\/include\/prolog_before.php\");<\/code><\/pre>\n<p>\u041d\u0430\u0441\u0442\u0440\u043e\u0438\u043c PHPUnit, \u0447\u0442\u043e\u0431\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0441\u044f \u043d\u0430\u0448 \u0444\u0430\u0439\u043b \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438 \u043d\u0430\u0448\u0438 \u043a\u043b\u0430\u0441\u0441 \u0434\u0435\u043a\u043e\u0440\u0430\u0446\u0438\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u0432. \u041e\u0442\u043a\u0440\u043e\u0435\u043c \u0444\u0430\u0439\u043b <strong>\/local\/phpunit.xml<\/strong> \u0438 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043c \u0435\u0433\u043e \u043a \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c\u0443 \u0432\u0438\u0434\u0443:<\/p>\n<details class=\"spoiler\">\n<summary>phpunit.xml<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"xml\">&lt;?xml version=\"1.0\" encoding=\"UTF-8\"?> &lt;phpunit xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"          xsi:noNamespaceSchemaLocation=\"https:\/\/schema.phpunit.de\/9.5\/phpunit.xsd\"          bootstrap=\"tests\/bootstrap.php\"          cacheResultFile=\".phpunit.cache\/test-results\"          colors=\"true\"          printerClass=\"Sempro\\PHPUnitPrettyPrinter\\PrettyPrinterForPhpUnit9\"          executionOrder=\"random\"          forceCoversAnnotation=\"true\"          beStrictAboutCoversAnnotation=\"true\"          beStrictAboutOutputDuringTests=\"true\"          beStrictAboutTodoAnnotatedTests=\"true\"          convertDeprecationsToExceptions=\"true\"          failOnRisky=\"true\"          failOnWarning=\"true\"          verbose=\"true\">      &lt;php>         &lt;ini name=\"memory_limit\" value=\"-1\"\/>         &lt;ini name=\"display_errors\" value=\"true\"\/>     &lt;\/php>      &lt;testsuites>         &lt;testsuite name=\"default\">             &lt;directory suffix=\"Test.php\">tests&lt;\/directory>             &lt;exclude>tests\/Stubs&lt;\/exclude>             &lt;exclude>tests\/Request&lt;\/exclude>             &lt;exclude>tests\/Response&lt;\/exclude>         &lt;\/testsuite>     &lt;\/testsuites>      &lt;coverage cacheDirectory=\".phpunit.cache\/code-coverage\"               processUncoveredFiles=\"true\">         &lt;include>             &lt;directory suffix=\".php\">classes&lt;\/directory>         &lt;\/include>     &lt;\/coverage> &lt;\/phpunit><\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u0434\u043e\u0431\u0430\u0432\u0438\u043c \u043a\u043e\u043c\u0430\u043d\u0434\u0443 \u0434\u043b\u044f \u0431\u044b\u0441\u0442\u0440\u043e\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0442\u0435\u0441\u0442\u043e\u0432<\/p>\n<details class=\"spoiler\">\n<summary>composer.json<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"json\">{     \"name\": \"myproject\/website\",     \"type\": \"project\",     \"authors\": [         {             \"name\": \"Andriy Kryvenko\",             \"email\": \"krivenko.a.b@gmail.com\"         }     ],     \"require-dev\": {         \"phpunit\/phpunit\": \"^9\",         \"sempro\/phpunit-pretty-print\": \"^1.4\"     },     \"scripts\": {         \"test\": \"phpunit\"     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b<\/p>\n<pre><code class=\"bash\">composer test<\/code><\/pre>\n<p>\u0431\u0443\u0434\u0443\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0432\u0441\u0435 \u0442\u0435\u0441\u0442\u044b. \u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0437\u0430\u043a\u043e\u043d\u0447\u0435\u043d \u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044e \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<details class=\"spoiler\">\n<summary>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u0442\u044c<\/summary>\n<div class=\"spoiler__content\">\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u0441\u0432\u043e\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u043b\u0443\u0447\u0448\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0442\u044c \u0432 \u043a\u0430\u0442\u0430\u043b\u043e\u0433\u0435 local\/classes, \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u0432\u0438\u0434\u0435:<\/p>\n<pre><code>\/local\/classes\/MyProject\/Product.php \/local\/classes\/MyProject\/Rests.php<\/code><\/pre>\n<p>\u0418 \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0438\u0445 \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u0432\u0440\u0443\u0447\u043d\u0443\u044e &#8212; \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u0435\u043c \u0432 \u0444\u0430\u0439\u043b\u0435 <strong>\/local\/php_interface\/init.php<\/strong> \u0437\u0430\u0433\u0440\u0443\u0437\u0447\u0438\u043a, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e \u043c\u0435\u0440\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438:<\/p>\n<pre><code class=\"php\">&lt;?php  spl_autoload_register(function($className) {     $className = str_replace(\"\\\\\", DIRECTORY_SEPARATOR, $className);     include_once $_SERVER['DOCUMENT_ROOT'] . '\/local\/classes\/' . $className . '.php'; });  include_once(__DIR__.'\/..\/vendor\/autoload.php');<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<h3>\u041f\u0440\u0438\u043c\u0435\u0440 \u0442\u0435\u0441\u0442\u0430<\/h3>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0440\u0435\u0430\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u0435\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0438 \u0442\u0435\u0441\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u044d\u0442\u043e \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u044e\u0442 (\u0447\u0430\u0441\u0442\u044c \u043a\u043e\u0434\u0430, \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0443\u044e\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u043c, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440 \u043d\u0435 \u0432\u043a\u043b\u044e\u0447\u0430\u044e).<\/p>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044f: \u0438\u0437 1\u0421 \u043d\u0430 \u0441\u0430\u0439\u0442 \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0440\u043e\u043a \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b\u0445 \u0441\u0440\u043e\u043a\u0430\u0445 \u043f\u043e\u0441\u0442\u0430\u0432\u043a\u0438 \u0442\u043e\u0432\u0430\u0440\u0430, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<pre><code>24 \u0447\u0430\u0441\u0430-7|\u0434\u043e 2 \u0434\u043d\u0435\u0439-14|\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u043f\u043e\u043a\u0443\u043f\u043a\u0435 \u0434\u043e 7 \u0448\u0442\u0443\u043a &#8212; \u043f\u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0437\u0430 24 \u0447\u0430\u0441\u0430, \u0434\u043e 14 \u0448\u0442\u0443\u043a &#8212; \u0437\u0430 2 \u0434\u043d\u044f, \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 &#8212; \u0437\u0430 15 \u0434\u043d\u0435\u0439.<\/p>\n<p>\u041d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u044b <strong>Leftover<\/strong> \u0434\u043b\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <strong>LeftoverTransformer<\/strong>:<\/p>\n<details class=\"spoiler\">\n<summary>Leftover<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites;  class Leftover {     public int $time = 0;      \/**      * \u0414\u043e\u0441\u0442\u0443\u043f\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u0430.      * \u0415\u0441\u043b\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0440\u0430\u0432\u043d\u043e -1.0 - \u0442\u043e \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u043c, \u0447\u0442\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u043d\u0435\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e      *\/     public float $quantity = 0.0;      public function __construct(int $time, float $quantity)     {         $this->time = $time;         $this->quantity = $quantity;     }      public function isAvailable(): bool     {         return ($this->quantity > 0 || $this->quantity == -1.0);     } }<\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>LeftoverTransformer<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites\\Transform;  use MyProject\\Product\\Requisites\\Leftover;  class LeftoverTransformer {     \/**      * @param string $leftoversString      * @return Leftover[]      * \u0421\u0442\u0440\u043e\u043a\u0443 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432 \u0432\u0438\u0434\u0435      * 24 \u0447\u0430\u0441\u0430-7|\u0434\u043e 2 \u0434\u043d\u0435\u0439-14|\u0434\u043e 7 \u0434\u043d\u0435\u0439-22|\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440      *\/     public static function transform(string $leftoversString): array     {         $leftovers = [];         $intervals = explode('|', $leftoversString);         foreach ($intervals as $v){             $interval = explode('-', $v);             $intervalValues = [];             foreach ($interval as $k => $part) {                 $intervalValues[] = trim($part);             }              if (!empty($intervalValues[0]) &amp;&amp; !empty($intervalValues[1])) {                 $leftovers[] = new Leftover(                     self::getTimeFromString($intervalValues[0]),                     self::getQuantityFromString($intervalValues[1])                 );             }         }          return $leftovers;     }      private static function getTimeFromString(string $timeString): int     {         switch ($timeString) {             case '24 \u0447\u0430\u0441\u0430':                 $time = 1;                 break;             default:                 $parts = explode(' ', $timeString);                 $time = intval($parts[1]);                 break;         }         return $time;     }      private static function getQuantityFromString(string $quantityString): int     {         switch ($quantityString) {             case '\u043d\u0435\u043e\u0433\u0440':                 $quantity = -1;                 break;             default:                 $quantity = intval($quantityString);                 break;         }         return $quantity;     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<p>\u0418 \u043f\u043e\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u044d\u0442\u0438 \u043a\u043b\u0430\u0441\u0441\u044b \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 \u0442\u0435\u0441\u0442\u0430\u043c\u0438:<\/p>\n<details class=\"spoiler\">\n<summary>LeftoverTest<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites;  use PHPUnit\\Framework\\TestCase;  \/**  * @covers Leftover  *\/ class LeftoverTest extends TestCase {     public function testIsAvailable(): void     {         $leftover = new Leftover(1, 12.0);          $this->assertTrue($leftover->isAvailable());     }        public function testAvailableUnlimited(): void     {         $leftover = new Leftover(1, -1.0);          $this->assertTrue($leftover->isAvailable());     }      public function testUnavailable(): void     {         $leftover = new Leftover(1, 0.0);          $this->assertFalse($leftover->isAvailable());     } } <\/code><\/pre>\n<\/p>\n<\/div>\n<\/details>\n<details class=\"spoiler\">\n<summary>LeftoverTransformerTest<\/summary>\n<div class=\"spoiler__content\">\n<pre><code class=\"php\">&lt;?php  namespace MyProject\\Product\\Requisites\\Transform;  use PHPUnit\\Framework\\TestCase;  \/**  * @covers LeftoverTransformer  *\/ class LeftoverTransformerTest extends TestCase {     public function testEmpty(): void     {         $this->assertEmpty(LeftoverTransformer::transform(''));     }      public function testLeftoversCount(): void     {         $leftoverString = '24 \u0447\u0430\u0441\u0430-7|\u0434\u043e 2 \u0434\u043d\u0435\u0439-14|\u0434\u043e 7 \u0434\u043d\u0435\u0439-22|\u0434\u043e 15 \u0434\u043d\u0435\u0439-\u043d\u0435\u043e\u0433\u0440';        <\/code><\/pre>\n<\/div>\n<\/details>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-333494","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333494","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=333494"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/333494\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=333494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=333494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=333494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}