{"id":334637,"date":"2022-06-17T15:00:38","date_gmt":"2022-06-17T15:00:38","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=334637"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=334637","title":{"rendered":"<span>\u0414\u0435\u043c\u043e Symfony \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0432\u0430\u043b\u044e\u0442<\/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<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435.<br \/>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0434\u043e\u0432\u0435\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 Symfony &#8212; \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0432\u0430\u043b\u044e\u0442 \u0441 \u043f\u0440\u044f\u043c\u043e\u0439 \u0438 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043a\u0430\u043d\u043e\u043d\u0430\u043c Symfony: DI, autowiring, \u0442\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0433\u0438\u0431\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0432\u0441\u0451. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c &#171;\u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0441\u0442\u0430\u043c&#187;.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <a href=\"https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo<\/a><\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 &#171;\u043e\u0431\u043c\u0435\u043d \u0432\u0430\u043b\u044e\u0442\u044b&#187; \u043f\u043e \u043f\u0440\u044f\u043c\u044b\u043c \u043a\u0443\u0440\u0441\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, USD -> EUR), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 &#171;\u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435&#187; \u0432\u0430\u043b\u044e\u0442\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, BTC -> EUR). \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0444\u0435\u0439\u043a\u043e\u0432\u044b\u0435 \u043a\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041a\u0443\u0440\u0441\u044b \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0441 \u0441\u0430\u0439\u0442\u043e\u0432 <a href=\"http:\/\/ecb.europa.eu\" rel=\"noopener noreferrer nofollow\">ecb.europa.eu<\/a> (\u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0438\u0440\u043e\u0432\u044b\u0435 \u0432\u0430\u043b\u044e\u0442\u044b \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a EUR) \u0438 <a href=\"http:\/\/coindesk.com\" rel=\"noopener noreferrer nofollow\">coindesk.com<\/a> (BTC \u043a USD). \u0422\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u0445 \u043e\u0442\u0441\u044e\u0434\u0430 <a href=\"http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html\" rel=\"noopener noreferrer nofollow\">http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html<\/a>. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0411\u0414 SQLite.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 PHP \u0438\u043b\u0438 \u0432 Docker.<br \/>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a PHP: \u0432\u0435\u0440\u0441\u0438\u044f <em>8.1<\/em>, \u043c\u043e\u0434\u0443\u043b\u0438 <em>bcmath<\/em>, <em>ctype<\/em>, <em>iconv<\/em>, <em>intl<\/em>, <em>pdo_sqlite<\/em>, <em>simplexml<\/em>, <em>sqlite3<\/em>.<\/p>\n<p>\u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u043c\u0430\u043b\u043e \u043e\u043f\u044b\u0442\u0430 \u0441 Symfony, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 Laravel, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SQLite \u043d\u0430\u043b\u043e\u0436\u0438\u043b\u043e \u0441\u0432\u043e\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f (\u0438\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0445 decimal \u0438 numeric \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0438 INSERT IGNORE \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c &#171;\u0437\u0430\u0448\u0438\u0442\u044c&#187; \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f 16,8). \u0415\u0449\u0451 \u0431\u044b\u043b \u0441\u0431\u043e\u0439 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u043a\u0443\u0440\u0441\u043e\u0432 \u0415\u0426\u0411, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u0442 \u043a\u0443\u0440\u0441\u043e\u0432, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u044b\u0439 \u0434\u0435\u043d\u044c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430.<\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<h4>\u041a\u043e\u043c\u0430\u043d\u0434\u044b<\/h4>\n<p>\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: &#171;<em>currency:update<\/em>&#187; &#8212; \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442 \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 (<code>\\App\\Command\\CurrencyExchangeCommand<\/code>) \u0438 &#171;<em>currency:exchange<\/em>&#187; &#8212; \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043c\u0435\u043d (<code>\\App\\Command\\CurrencyUpdateCommand)<\/code>.<\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0438\u0445 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043b\u043e\u0432\u044f\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0432\u044b\u0432\u043e\u0434\u044f\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 exit status.<\/p>\n<p>\u0412\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u043c \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u043a\u0443\u0440\u0441\u043e\u0432 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0442\u0435\u0433\u043e\u043c &#171;<em>app.rates_provider&#187;<\/em> \u0432 config\/services.yaml \u0438 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0442\u0435\u0433\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 <code>\\App\\Services\\RatesUpdater<\/code>. \u041e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434.<\/p>\n<pre><code class=\"php\">App\\Providers\\CoinDeskRatesProvider:     tags: [ 'app.rates_provider' ]  App\\Providers\\EcbRatesProvider:     tags: [ 'app.rates_provider' ]  App\\Services\\RatesUpdater:     arguments:         - !tagged_iterator app.rates_provider<\/code><\/pre>\n<pre><code class=\"php\">class RatesUpdater {     public function __construct(private readonly iterable $ratesProviders, ...)     {     } ... }<\/code><\/pre>\n<h4>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0432\u0430\u043b\u044e\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <abbr title=\"Data Transfer Object\" type=\"abbr\">DTO<\/abbr>: <code>\\App\\Dto\\Exchange<\/code> \u0438 <code>\\App\\Dto\\Rate<\/code> \u0441\u043e\u043e\u0442\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041d\u0430 DTO \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0432\u0430\u043b\u044e\u0442 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f &#171;<em>AmountRequirements<\/em>&#187; &#8212; \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0438 &#171;<em>ExchangeCurrencyRequirements<\/em>&#187; &#8212; \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0432\u0430\u043b\u044e\u0442\u0435.<br \/> \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u043d\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>\\App\\Entity\\Pair<\/code> \u0438 <code>\\App\\Entity\\Rate<\/code>.<\/p>\n<p>\u0412\u0441\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b &#8212; \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u044e. \u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 <code>src\/Validator\/<\/code>. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 &#8212; \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 (Compound) \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 &#8212; &#171;<em>\u041d\u0435 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430<\/em>&#171;, &#171;<em>\u0422\u0438\u043f Numeric<\/em>&#187; \u0438 &#171;<em>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/em>&#171;.<\/p>\n<pre><code class=\"php\">class AmountRequirements extends Compound {     protected function getConstraints(array $options): array     {         return [             new Assert\\NotBlank(),             new Assert\\Type(type: 'numeric', message: 'The value {{ value }} is not a valid {{ type }}'),             new Assert\\Positive(),         ];     } }<\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0430\u043b\u044e\u0442\u044b <code>\\App\\Validator\\PairCurrencyExistValidator<\/code>. \u041e\u043d \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u044e \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0445 \u043f\u0430\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432 \u0411\u0414 <code>SELECT COUNT(1) FROM pair WHERE base = &lt;\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043a\u0435\u0440 \u0432\u0430\u043b\u044e\u0442\u044b><\/code>. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0447\u0435\u0440\u0435\u0437 Doctrine Query Builder.<\/p>\n<h4>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442<\/h4>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: <code>\\App\\Services\\RatesUpdater<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442 \u0438 \u043f\u043e-\u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 (\u0447\u0435\u0440\u0435\u0437 <em>__invoke<\/em>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430). \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>\\App\\Providers\\RatesProvider<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 DTO <code>\\App\\Dto\\Rate<\/code>.<\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 &#171;\u0445\u043e\u0434\u0438\u0442&#187; \u0437\u0430 \u043a\u0443\u0440\u0441\u0430\u043c\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 <em>.env<\/em> \u0430\u0434\u0440\u0435\u0441\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0435\u0434\u0440\u0451\u043d \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u044b. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432, \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043f\u0430\u0440\u0441\u0438\u0442 \u0438\u0445 \u0438\u0437 Json \u0438\u043b\u0438 XML \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0438\u0445 \u0432 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u041f\u0430\u0440\u0441\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 <em>src\/Parsers\/<\/em>.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>\\App\\Providers\\FakeRatesProvider<\/code> \u0441 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <em>fetch<\/em> \u0438 \u043f\u0430\u0440\u043e\u0439 \u0437\u0430\u0448\u0438\u0442\u044b\u0445 \u0432 \u043d\u0435\u0433\u043e \u043a\u0443\u0440\u0441\u043e\u0432.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 DTO \u043a\u0443\u0440\u0441\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0411\u0414 \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0442\u043e\u0440 <code>\\App\\Services\\RatesTriangulator<\/code>. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0432\u0430\u043b\u044e\u0442\u044b (\u0442.\u043d. \u043a\u0440\u043e\u0441\u0441-\u043a\u0443\u0440\u0441\u044b) \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>\\App\\Entity\\Pair<\/code>. <br \/>\u0422\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u0445 <a href=\"http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html\" rel=\"noopener noreferrer nofollow\">http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html<\/a> \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438\u0437 \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0443\u044e \u043f\u0430\u0440\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, \u043d\u0435\u0436\u0435\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0443\u0440\u0441\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a, \u0442\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u0438\u043b\u0438 \u0442\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0442\u043e\u0440 \u043a\u0438\u0434\u0430\u044e\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e PHP \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u0439, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0411\u0414, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u0443\u0440\u0441\u044b \u0432\u0430\u043b\u044e\u0442<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo.git cd symfony-exchange-demo composer install --no-dev --no-interaction php bin\/console doctrine:database:create php bin\/console doctrine:migrations:migrate --no-interaction php bin\/console currency:update<\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e<br \/><code>php bin\/console currency:exchange &lt;amount> &lt;from> &lt;to><\/code><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<br \/><code>php bin\/console currency:exchange 2 EUR BTC<br \/><\/code>\u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e<br \/><code>[OK] 2 EUR is 0.00005254 BTC<\/code><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Docker<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo.git cd symfony-exchange-demo docker compose up --build<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f \u043a\u0443\u0440\u0441\u044b \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p>\u0420\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e<br \/><code>docker compose run symfony-exchange-demo currency:exchange &lt;amount> &lt;from> &lt;to><\/code><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<br \/><code>docker compose run symfony-exchange-demo currency:exchange 2 EUR BTC<\/code><\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043a\u0430\u043a \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c PHP.<\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u0430\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430. \u0412 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u043e\u043a\u0430\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p><code>\\App\\Tests\\Command\\CurrencyUpdateCommandTest<\/code> &#8212; \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435, \u0442\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0446\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u0443\u0440\u0441\u043e\u0432.<\/p>\n<p><code>\\App\\Tests\\Command\\CurrencyExchangeCommandTest<\/code> &#8212; \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 dataProvider&#8217;\u0430 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0438 \u0432\u0430\u043b\u044e\u0442 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0434\u043e\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 dev-\u043f\u0430\u043a\u0435\u0442\u044b<\/p>\n<pre><code class=\"bash\">cd symfony-exchange-demo echo APP_ENV=test > .env.local composer install --no-interaction php bin\/console doctrine:database:create php bin\/console doctrine:migrations:migrate --no-interaction vendor\/bin\/phpunit<\/code><\/pre>\n<p>\u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0432 Docker<\/p>\n<pre><code class=\"bash\">cd symfony-exchange-demo echo APP_ENV=test > .env.local docker compose run symfony-exchange-demo composer install --no-interaction docker compose run symfony-exchange-demo doctrine:database:create docker compose run symfony-exchange-demo doctrine:migrations:migrate --no-interaction docker compose run symfony-exchange-demo vendor\/bin\/phpunit<\/code><\/pre>\n<p>\u0412\u0435\u043b\u043a\u0430\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438\u043b\u0438 \u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u044b \ud83d\ude42<\/p>\n<\/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\/671956\/\"> https:\/\/habr.com\/ru\/post\/671956\/<\/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<p>\u0417\u0434\u0440\u0430\u0432\u0441\u0442\u0432\u0443\u0439\u0442\u0435.<br \/>\u041d\u0435\u0434\u0430\u0432\u043d\u043e \u0434\u043e\u0432\u0435\u043b\u043e\u0441\u044c \u0434\u0435\u043b\u0430\u0442\u044c \u0442\u0435\u0441\u0442\u043e\u0432\u043e\u0435 \u0437\u0430\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 Symfony &#8212; \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0435\u0440 \u0432\u0430\u043b\u044e\u0442 \u0441 \u043f\u0440\u044f\u043c\u043e\u0439 \u0438 \u043a\u0440\u043e\u0441\u0441-\u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0435\u0439. \u041f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0432\u0435\u0441\u044c\u043c\u0430 \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043e\u043c \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u043e\u0433\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043f\u043e \u0432\u0441\u0435\u043c \u043a\u0430\u043d\u043e\u043d\u0430\u043c Symfony: DI, autowiring, \u0442\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432, \u0433\u0438\u0431\u043a\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f, \u0432\u043e\u0442 \u044d\u0442\u043e \u0432\u043e\u0442 \u0432\u0441\u0451. \u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u044e\u0449\u0438\u043c &#171;\u0441\u0438\u043c\u0444\u043e\u043d\u0438\u0441\u0442\u0430\u043c&#187;.<\/p>\n<p>\u041a\u043e\u0434 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f <a href=\"https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo\" rel=\"noopener noreferrer nofollow\">https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo<\/a><\/p>\n<p>\u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u0442 &#171;\u043e\u0431\u043c\u0435\u043d \u0432\u0430\u043b\u044e\u0442\u044b&#187; \u043f\u043e \u043f\u0440\u044f\u043c\u044b\u043c \u043a\u0443\u0440\u0441\u0430\u043c (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, USD -> EUR), \u0430 \u0442\u0430\u043a\u0436\u0435 \u0447\u0435\u0440\u0435\u0437 &#171;\u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435&#187; \u0432\u0430\u043b\u044e\u0442\u044b (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, BTC -> EUR). \u0422\u0430\u043a\u0436\u0435 \u0435\u0441\u0442\u044c \u0444\u0435\u0439\u043a\u043e\u0432\u044b\u0435 \u043a\u0443\u0440\u0441\u044b \u0434\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432.<\/p>\n<p>\u041a\u0443\u0440\u0441\u044b \u0431\u0435\u0440\u0443\u0442\u0441\u044f \u0441 \u0441\u0430\u0439\u0442\u043e\u0432 <a href=\"http:\/\/ecb.europa.eu\" rel=\"noopener noreferrer nofollow\">ecb.europa.eu<\/a> (\u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u0438\u0440\u043e\u0432\u044b\u0435 \u0432\u0430\u043b\u044e\u0442\u044b \u043f\u043e \u043e\u0442\u043d\u043e\u0448\u0435\u043d\u0438\u044e \u043a EUR) \u0438 <a href=\"http:\/\/coindesk.com\" rel=\"noopener noreferrer nofollow\">coindesk.com<\/a> (BTC \u043a USD). \u0422\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u0445 \u043e\u0442\u0441\u044e\u0434\u0430 <a href=\"http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html\" rel=\"noopener noreferrer nofollow\">http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html<\/a>. \u0414\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0411\u0414 SQLite.<\/p>\n<p>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u0439 PHP \u0438\u043b\u0438 \u0432 Docker.<br \/>\u0422\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a PHP: \u0432\u0435\u0440\u0441\u0438\u044f <em>8.1<\/em>, \u043c\u043e\u0434\u0443\u043b\u0438 <em>bcmath<\/em>, <em>ctype<\/em>, <em>iconv<\/em>, <em>intl<\/em>, <em>pdo_sqlite<\/em>, <em>simplexml<\/em>, <em>sqlite3<\/em>.<\/p>\n<p>\u041d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0437\u0430\u0434\u0430\u043d\u0438\u044f \u0443 \u043c\u0435\u043d\u044f \u0431\u044b\u043b\u043e \u043c\u0430\u043b\u043e \u043e\u043f\u044b\u0442\u0430 \u0441 Symfony, \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c, \u044f \u0440\u0430\u0431\u043e\u0442\u0430\u043b \u0441 Laravel, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0434\u043e\u0440\u0430\u0431\u043e\u0442\u043a\u0438. \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 SQLite \u043d\u0430\u043b\u043e\u0436\u0438\u043b\u043e \u0441\u0432\u043e\u0438 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u0438\u044f (\u0438\u0437-\u0437\u0430 \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u044f \u043d\u0430\u0441\u0442\u043e\u044f\u0449\u0438\u0445 decimal \u0438 numeric \u0444\u043e\u0440\u043c\u0430\u0442\u043e\u0432 \u0438 INSERT IGNORE \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c &#171;\u0437\u0430\u0448\u0438\u0442\u044c&#187; \u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u044f 16,8). \u0415\u0449\u0451 \u0431\u044b\u043b \u0441\u0431\u043e\u0439 \u0441 \u0434\u0430\u0442\u0430\u043c\u0438 \u043a\u0443\u0440\u0441\u043e\u0432 \u0415\u0426\u0411, \u0438\u0437-\u0437\u0430 \u0447\u0435\u0433\u043e \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0436\u0435\u0440\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0441\u043e\u0432\u043f\u0430\u0434\u0435\u043d\u0438\u044f \u0434\u0430\u0442 \u043a\u0443\u0440\u0441\u043e\u0432, \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0439 \u0434\u043e\u0441\u0442\u0443\u043f\u044b\u0439 \u0434\u0435\u043d\u044c \u0438\u0437 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430.<\/p>\n<h3>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438<\/h3>\n<h4>\u041a\u043e\u043c\u0430\u043d\u0434\u044b<\/h4>\n<p>\u0412 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u0434\u0432\u0435 \u043a\u043e\u043d\u0441\u043e\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043c\u0430\u043d\u0434\u044b: &#171;<em>currency:update<\/em>&#187; &#8212; \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442 \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432 (<code>\\App\\Command\\CurrencyExchangeCommand<\/code>) \u0438 &#171;<em>currency:exchange<\/em>&#187; &#8212; \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043e\u0431\u043c\u0435\u043d (<code>\\App\\Command\\CurrencyUpdateCommand)<\/code>.<\/p>\n<p>\u041a\u043e\u043c\u0430\u043d\u0434\u044b \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u044e\u0442 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b, \u0432\u0430\u043b\u0438\u0434\u0438\u0440\u0443\u044e\u0442 \u0434\u0430\u043d\u043d\u044b\u0435, \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442 \u0438\u0445 \u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043b\u043e\u0432\u044f\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0438 \u043a\u0440\u0430\u0441\u0438\u0432\u043e \u0432\u044b\u0432\u043e\u0434\u044f\u0442 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432 \u043a\u043e\u043d\u0441\u043e\u043b\u044c \u0441 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u043c\u0438 exit status.<\/p>\n<p>\u0412\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0441\u0432\u043e\u0438\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f\u043c \u0447\u0435\u0440\u0435\u0437 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u044b. \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u043a\u0443\u0440\u0441\u043e\u0432 \u043f\u043e\u043c\u0435\u0447\u0435\u043d\u044b \u0442\u0435\u0433\u043e\u043c &#171;<em>app.rates_provider&#187;<\/em> \u0432 config\/services.yaml \u0438 \u043f\u043e \u044d\u0442\u043e\u043c\u0443 \u0442\u0435\u0433\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u0432 <code>\\App\\Services\\RatesUpdater<\/code>. \u041e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u043d\u0430 \u043c\u043e\u0439 \u0432\u0437\u0433\u043b\u044f\u0434.<\/p>\n<pre><code class=\"php\">App\\Providers\\CoinDeskRatesProvider:     tags: [ 'app.rates_provider' ]  App\\Providers\\EcbRatesProvider:     tags: [ 'app.rates_provider' ]  App\\Services\\RatesUpdater:     arguments:         - !tagged_iterator app.rates_provider<\/code><\/pre>\n<pre><code class=\"php\">class RatesUpdater {     public function __construct(private readonly iterable $ratesProviders, ...)     {     } ... }<\/code><\/pre>\n<h4>\u041e\u0431\u043c\u0435\u043d \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0432\u0430\u043b\u044e\u0442 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432 \u043f\u0435\u0440\u0435\u0434\u0430\u044e\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 <abbr title=\"Data Transfer Object\" type=\"abbr\">DTO<\/abbr>: <code>\\App\\Dto\\Exchange<\/code> \u0438 <code>\\App\\Dto\\Rate<\/code> \u0441\u043e\u043e\u0442\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e. \u041d\u0430 DTO \u0434\u043b\u044f \u043e\u0431\u043c\u0435\u043d\u0430 \u0432\u0430\u043b\u044e\u0442 \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f &#171;<em>AmountRequirements<\/em>&#187; &#8212; \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 \u0438 &#171;<em>ExchangeCurrencyRequirements<\/em>&#187; &#8212; \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u0432\u0430\u043b\u044e\u0442\u0435.<br \/> \u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0432\u0430\u043b\u0438\u0434\u0430\u0446\u0438\u044f \u043d\u0430\u043b\u043e\u0436\u0435\u043d\u0430 \u043d\u0430 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>\\App\\Entity\\Pair<\/code> \u0438 <code>\\App\\Entity\\Rate<\/code>.<\/p>\n<p>\u0412\u0441\u0435 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b &#8212; \u043a\u0430\u0441\u0442\u043e\u043c\u043d\u044b\u0435, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u0441\u043e\u0440\u044f\u0442\u044c \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u0435\u0439 \u043b\u0438\u0448\u043d\u0438\u043c\u0438 \u0434\u0435\u0442\u0430\u043b\u044f\u043c\u0438, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0434\u043b\u044f \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f\u044e. \u0412\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b \u0432 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 <code>src\/Validator\/<\/code>. \u0411\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0438\u0437 \u043d\u0438\u0445 &#8212; \u0441\u043e\u0441\u0442\u0430\u0432\u043d\u044b\u0435 (Compound) \u0438\u0437 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0445 \u043f\u0440\u0430\u0432\u0438\u043b. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f \u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0443 &#8212; &#171;<em>\u041d\u0435 \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430<\/em>&#171;, &#171;<em>\u0422\u0438\u043f Numeric<\/em>&#187; \u0438 &#171;<em>\u041f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/em>&#171;.<\/p>\n<pre><code class=\"php\">class AmountRequirements extends Compound {     protected function getConstraints(array $options): array     {         return [             new Assert\\NotBlank(),             new Assert\\Type(type: 'numeric', message: 'The value {{ value }} is not a valid {{ type }}'),             new Assert\\Positive(),         ];     } }<\/code><\/pre>\n<p>\u0415\u0441\u0442\u044c \u0438 \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u043b\u0438\u0434\u0430\u0442\u043e\u0440 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0430\u043b\u044e\u0442\u044b <code>\\App\\Validator\\PairCurrencyExistValidator<\/code>. \u041e\u043d \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043a \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u044e \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u0445 \u043f\u0430\u0440 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u0432 \u0411\u0414 <code>SELECT COUNT(1) FROM pair WHERE base = &lt;\u043f\u0435\u0440\u0435\u0434\u0430\u043d\u043d\u044b\u0439 \u0442\u0438\u043a\u0435\u0440 \u0432\u0430\u043b\u044e\u0442\u044b><\/code>. \u0420\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043e \u0447\u0435\u0440\u0435\u0437 Doctrine Query Builder.<\/p>\n<h4>\u041e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442<\/h4>\n<p>\u0422\u0443\u0442 \u0432\u0441\u0451 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e: <code>\\App\\Services\\RatesUpdater<\/code> \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435 \u0438\u0442\u0435\u0440\u0430\u0442\u043e\u0440 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442 \u0438 \u043f\u043e-\u043e\u0447\u0435\u0440\u0435\u0434\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 (\u0447\u0435\u0440\u0435\u0437 <em>__invoke<\/em>, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u043f\u0440\u0438\u0434\u0443\u043c\u044b\u0432\u0430\u0442\u044c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430). \u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b, \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c, \u043d\u0430\u0441\u043b\u0435\u0434\u0443\u044e\u0442 \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043a\u043b\u0430\u0441\u0441 <code>\\App\\Providers\\RatesProvider<\/code> \u0438 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044e\u0442 \u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 DTO <code>\\App\\Dto\\Rate<\/code>.<\/p>\n<p>\u0410\u0431\u0441\u0442\u0440\u0430\u043a\u0442\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 &#171;\u0445\u043e\u0434\u0438\u0442&#187; \u0437\u0430 \u043a\u0443\u0440\u0441\u0430\u043c\u0438 \u043f\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u043c\u0443 \u0432 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438 \u0438 <em>.env<\/em> \u0430\u0434\u0440\u0435\u0441\u0443, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043d\u0435\u0434\u0440\u0451\u043d \u0432 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440 \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u044b. \u041f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432, \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043f\u0430\u0440\u0441\u0438\u0442 \u0438\u0445 \u0438\u0437 Json \u0438\u043b\u0438 XML \u0432 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u043f\u0435\u0440\u0435\u0434\u0430\u0451\u0442 \u0438\u0445 \u0432 \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0435\u0440 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430. \u041f\u0430\u0440\u0441\u0435\u0440\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b \u0432 <em>src\/Parsers\/<\/em>.<\/p>\n<p>\u0414\u043b\u044f \u0442\u0435\u0441\u0442\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <code>\\App\\Providers\\FakeRatesProvider<\/code> \u0441 \u043f\u0435\u0440\u0435\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0451\u043d\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c <em>fetch<\/em> \u0438 \u043f\u0430\u0440\u043e\u0439 \u0437\u0430\u0448\u0438\u0442\u044b\u0445 \u0432 \u043d\u0435\u0433\u043e \u043a\u0443\u0440\u0441\u043e\u0432.<\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 \u0432\u0438\u0434\u0435 DTO \u043a\u0443\u0440\u0441\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u0411\u0414 \u0432 \u043f\u0440\u044f\u043c\u043e\u043c \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u0432\u0438\u0434\u0435, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0442\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0442\u043e\u0440 <code>\\App\\Services\\RatesTriangulator<\/code>. \u041e\u043d \u0441\u043e\u0437\u0434\u0430\u0451\u0442 \u0432\u0441\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0435 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u044f \u043a\u0443\u0440\u0441\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0432\u0430\u043b\u044e\u0442\u044b (\u0442.\u043d. \u043a\u0440\u043e\u0441\u0441-\u043a\u0443\u0440\u0441\u044b) \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u0445 \u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 <code>\\App\\Entity\\Pair<\/code>. <br \/>\u0422\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0446\u0438\u044f \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u0445 <a href=\"http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html\" rel=\"noopener noreferrer nofollow\">http:\/\/www.dpxo.net\/articles\/fx_rate_triangulation_sql.html<\/a> \u0438 \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u0438\u0437 \u0442\u0430\u043a\u043e\u0439 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u044b \u0441 \u0432\u0430\u043b\u044e\u0442\u043d\u044b\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0438 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u043f\u0440\u043e\u0449\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u0443\u044e\u0449\u0443\u044e \u043f\u0430\u0440\u0443 \u0434\u043b\u044f \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438, \u043d\u0435\u0436\u0435\u043b\u0438 \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u0443\u0440\u0441\u044b \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043f\u043e\u0448\u043b\u043e \u043d\u0435 \u0442\u0430\u043a, \u0442\u043e \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u0438\u043b\u0438 \u0442\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0442\u043e\u0440 \u043a\u0438\u0434\u0430\u044e\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f.<\/p>\n<h3>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f<\/h3>\n<p>\u041f\u0440\u0438 \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e PHP \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043a\u043b\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u0430\u0440\u0438\u0439, \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043f\u0430\u043a\u0435\u0442\u044b, \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0411\u0414, \u0432\u044b\u043f\u043e\u043b\u043d\u0438\u0442\u044c \u043c\u0438\u0433\u0440\u0430\u0446\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u0443\u0440\u0441\u044b \u0432\u0430\u043b\u044e\u0442<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo.git cd symfony-exchange-demo composer install --no-dev --no-interaction php bin\/console doctrine:database:create php bin\/console doctrine:migrations:migrate --no-interaction php bin\/console currency:update<\/code><\/pre>\n<p>\u0420\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e<br \/><code>php bin\/console currency:exchange &lt;amount> &lt;from> &lt;to><\/code><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<br \/><code>php bin\/console currency:exchange 2 EUR BTC<br \/><\/code>\u0434\u043e\u043b\u0436\u043d\u043e \u0432\u044b\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e<br \/><code>[OK] 2 EUR is 0.00005254 BTC<\/code><\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Docker<\/p>\n<pre><code class=\"bash\">git clone https:\/\/github.com\/vladimirmartsul\/symfony-exchange-demo.git cd symfony-exchange-demo docker compose up --build<\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0441\u0431\u043e\u0440\u043a\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u044f\u0442\u0441\u044f \u043a\u0443\u0440\u0441\u044b \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p>\u0420\u0430\u0441\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u044e<br \/><code>docker compose run symfony-exchange-demo currency:exchange &lt;amount> &lt;from> &lt;to><\/code><\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440<br \/><code>docker compose run symfony-exchange-demo currency:exchange 2 EUR BTC<\/code><\/p>\n<p>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0430\u043a\u0438\u043c \u0436\u0435 \u043a\u0430\u043a \u043f\u0440\u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0441 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u044b\u043c PHP.<\/p>\n<h3>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>\u0414\u043b\u044f \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0430 \u043f\u0430\u0440\u0430 \u0442\u0435\u0441\u0442\u043e\u0432, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0445 \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f \u0432 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0433\u043e \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u0430. \u0412 \u0442\u0435\u0441\u0442\u0430\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u043c\u043e\u043a\u0430\u043d\u044b\u0439 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p><code>\\App\\Tests\\Command\\CurrencyUpdateCommandTest<\/code> &#8212; \u043f\u0440\u043e\u0441\u0442\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0431 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0439 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435, \u0442\u0440\u0438\u0430\u043d\u0433\u0443\u043b\u044f\u0446\u0438\u0438 \u0438 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0438 \u043a\u0443\u0440\u0441\u043e\u0432.<\/p>\n<p><code>\\App\\Tests\\Command\\CurrencyExchangeCommandTest<\/code> &#8212; \u0447\u0443\u0442\u044c \u0441\u043b\u043e\u0436\u043d\u0435\u0435: \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u043a\u043e\u043d\u0432\u0435\u0440\u0442\u0430\u0446\u0438\u0438 \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 dataProvider&#8217;\u0430 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0438 \u0432\u0430\u043b\u044e\u0442 \u0438 \u043e\u0436\u0438\u0434\u0430\u0435\u043c\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c. \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0437\u0430\u043f\u0443\u0441\u043a\u0435 \u0442\u0435\u0441\u0442\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0441\u044f \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0435 \u043a\u0443\u0440\u0441\u043e\u0432 \u0432\u0430\u043b\u044e\u0442.<\/p>\n<p>\u0417\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0442\u0435\u0441\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e, \u0434\u043e\u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0432 dev-\u043f\u0430\u043a\u0435\u0442\u044b<\/p>\n<pre><code class=\"bash\">cd symfony-exchange-demo echo APP_ENV=test > .env.local composer install --no-interaction php bin\/console doctrine:database:create php bin\/console doctrine:migrations:migrate --no-interaction vendor\/bin\/phpunit<\/code><\/pre>\n<p>\u0438\u043b\u0438 \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u0432 Docker<\/p>\n<pre><code class=\"bash\">cd symfony-exchange-demo echo APP_ENV=test > .env.local docker compose run symfony-exchange-demo composer install --no-interaction docker compose run symfony-exchange-demo doctrine:database:create docker compose run symfony-exchange-demo doctrine:migrations:migrate --no-interaction docker compose run symfony-exchange-demo vendor\/bin\/phpunit<\/code><\/pre>\n<p>\u0412\u0435\u043b\u043a\u0430\u043c \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u0438\u043b\u0438 \u043f\u0443\u043b-\u0440\u0435\u043a\u0432\u0435\u0441\u0442\u044b \ud83d\ude42<\/p>\n<\/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\/671956\/\"> https:\/\/habr.com\/ru\/post\/671956\/<\/a><br \/><\/br><\/br><\/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-334637","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334637","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=334637"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/334637\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=334637"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=334637"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=334637"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}