diff --git a/.idea/sonarlint.xml b/.idea/sonarlint.xml new file mode 100644 index 0000000000000000000000000000000000000000..6817efeb806673c27939b45f68807db3538c69e1 --- /dev/null +++ b/.idea/sonarlint.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/0/0/001fdc7418679b6419e44b1142ab051819764ece b/.idea/sonarlint/issuestore/0/0/001fdc7418679b6419e44b1142ab051819764ece new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/4/3/43dcb35f966f0fa054ba7993783bf64ca2be218c b/.idea/sonarlint/issuestore/4/3/43dcb35f966f0fa054ba7993783bf64ca2be218c new file mode 100644 index 0000000000000000000000000000000000000000..7521a9c188aefafc4a009e15922443e00d7b41d2 --- /dev/null +++ b/.idea/sonarlint/issuestore/4/3/43dcb35f966f0fa054ba7993783bf64ca2be218c @@ -0,0 +1,3 @@ + +php:S112"FDefine and throw a dedicated exception instead of using a generic one.(ۄ81J$47edde45-6969-4470-9c01-b4077dd7b5f4 +php:S112"FDefine and throw a dedicated exception instead of using a generic one.(ۄ81J$5eb02a27-89bd-4e34-8e30-b9f86d63a21d \ No newline at end of file diff --git a/.idea/sonarlint/issuestore/6/0/6037d4b4b463114752d4470f297faf20f6eb091f b/.idea/sonarlint/issuestore/6/0/6037d4b4b463114752d4470f297faf20f6eb091f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/6/7/672311d2a7e203158feec05c65a1596673272747 b/.idea/sonarlint/issuestore/6/7/672311d2a7e203158feec05c65a1596673272747 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/6/e/6e70b6a94de880e98216f758f5f903c70ccf92d9 b/.idea/sonarlint/issuestore/6/e/6e70b6a94de880e98216f758f5f903c70ccf92d9 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/8/7/87042d1f46b57381244d70e7a42feeb7710727dc b/.idea/sonarlint/issuestore/8/7/87042d1f46b57381244d70e7a42feeb7710727dc new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/a/5/a5cc2925ca8258af241be7e5b0381edf30266302 b/.idea/sonarlint/issuestore/a/5/a5cc2925ca8258af241be7e5b0381edf30266302 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/b/a/baef02989dedf0ec859f7bce087a69f29bef2b72 b/.idea/sonarlint/issuestore/b/a/baef02989dedf0ec859f7bce087a69f29bef2b72 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/c/5/c5d6e48c28c17a397cf53caa8389f831b393980f b/.idea/sonarlint/issuestore/c/5/c5d6e48c28c17a397cf53caa8389f831b393980f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/d/3/d355caa07ac4b7aa5002c909a2c1d4a6319cf7e9 b/.idea/sonarlint/issuestore/d/3/d355caa07ac4b7aa5002c909a2c1d4a6319cf7e9 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/issuestore/f/d/fdb03812440437b51cbe4b19e899bfc5f72972fc b/.idea/sonarlint/issuestore/f/d/fdb03812440437b51cbe4b19e899bfc5f72972fc new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/0/0/001fdc7418679b6419e44b1142ab051819764ece b/.idea/sonarlint/securityhotspotstore/0/0/001fdc7418679b6419e44b1142ab051819764ece new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/4/3/43dcb35f966f0fa054ba7993783bf64ca2be218c b/.idea/sonarlint/securityhotspotstore/4/3/43dcb35f966f0fa054ba7993783bf64ca2be218c new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/6/0/6037d4b4b463114752d4470f297faf20f6eb091f b/.idea/sonarlint/securityhotspotstore/6/0/6037d4b4b463114752d4470f297faf20f6eb091f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/6/7/672311d2a7e203158feec05c65a1596673272747 b/.idea/sonarlint/securityhotspotstore/6/7/672311d2a7e203158feec05c65a1596673272747 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/6/e/6e70b6a94de880e98216f758f5f903c70ccf92d9 b/.idea/sonarlint/securityhotspotstore/6/e/6e70b6a94de880e98216f758f5f903c70ccf92d9 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/8/7/87042d1f46b57381244d70e7a42feeb7710727dc b/.idea/sonarlint/securityhotspotstore/8/7/87042d1f46b57381244d70e7a42feeb7710727dc new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/a/5/a5cc2925ca8258af241be7e5b0381edf30266302 b/.idea/sonarlint/securityhotspotstore/a/5/a5cc2925ca8258af241be7e5b0381edf30266302 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/b/a/baef02989dedf0ec859f7bce087a69f29bef2b72 b/.idea/sonarlint/securityhotspotstore/b/a/baef02989dedf0ec859f7bce087a69f29bef2b72 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/c/5/c5d6e48c28c17a397cf53caa8389f831b393980f b/.idea/sonarlint/securityhotspotstore/c/5/c5d6e48c28c17a397cf53caa8389f831b393980f new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/d/3/d355caa07ac4b7aa5002c909a2c1d4a6319cf7e9 b/.idea/sonarlint/securityhotspotstore/d/3/d355caa07ac4b7aa5002c909a2c1d4a6319cf7e9 new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/.idea/sonarlint/securityhotspotstore/f/d/fdb03812440437b51cbe4b19e899bfc5f72972fc b/.idea/sonarlint/securityhotspotstore/f/d/fdb03812440437b51cbe4b19e899bfc5f72972fc new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/composer.lock b/composer.lock index 7c3d7d009589953b5e2b126a74597e743a9df0fa..dff4a3147e578c558155a4ff40ab5a75b62c209b 100644 --- a/composer.lock +++ b/composer.lock @@ -1070,16 +1070,16 @@ }, { "name": "doctrine/orm", - "version": "3.1.1", + "version": "3.1.2", "source": { "type": "git", "url": "https://github.com/doctrine/orm.git", - "reference": "9c560713925ac5859342e6ff370c4c997acf2fd4" + "reference": "f79d166a4e844beb9389f23bdb44abdbf58cec38" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/doctrine/orm/zipball/9c560713925ac5859342e6ff370c4c997acf2fd4", - "reference": "9c560713925ac5859342e6ff370c4c997acf2fd4", + "url": "https://api.github.com/repos/doctrine/orm/zipball/f79d166a4e844beb9389f23bdb44abdbf58cec38", + "reference": "f79d166a4e844beb9389f23bdb44abdbf58cec38", "shasum": "" }, "require": { @@ -1152,9 +1152,9 @@ ], "support": { "issues": "https://github.com/doctrine/orm/issues", - "source": "https://github.com/doctrine/orm/tree/3.1.1" + "source": "https://github.com/doctrine/orm/tree/3.1.2" }, - "time": "2024-03-21T11:37:52+00:00" + "time": "2024-04-15T14:20:40+00:00" }, { "name": "doctrine/persistence", diff --git a/src/Action/Functions.php b/src/Action/Functions.php index b91efe4ec867b3095a18e30f5ea518aaf379c09a..f6f73001c1726eaa272d72dad82fcf7c5be9100c 100644 --- a/src/Action/Functions.php +++ b/src/Action/Functions.php @@ -156,4 +156,26 @@ class Functions } throw new RuntimeException("File not found: $filePath"); } + + /** + * Переделай своё решение 8 задачи: + * замени вывод всего текста из файла разом на + * построчный вывод используя yield + * @param string $filePath путь до файла + * @return iterable + */ + + public function readFileLineByLine(string $filePath): iterable + { + if (file_exists($filePath)) { + $file = fopen($filePath, 'rb'); + while(!feof($file)) { + yield fgets($file); + } + fclose($file); + } + else { + throw new RuntimeException("File not found: $filePath"); + } + } } \ No newline at end of file diff --git a/src/Controller/HomeController.php b/src/Controller/HomeController.php index 0570b8c12483ca4d268fe202b76e3957a5570358..8cc2dfd8709576713e8fc72bb17694eefe1f86da 100644 --- a/src/Controller/HomeController.php +++ b/src/Controller/HomeController.php @@ -103,4 +103,17 @@ class HomeController extends AbstractController $response->setEncodingOptions(JSON_UNESCAPED_UNICODE); return $response; } + + #[Route('/readFileLineByLine', name: 'readFileLineByLine')] + public function readFileLineByLine(Request $request): Response // text.txt + { + $file = $request->files->get('file'); + $text = ""; + foreach ($this->functions->readFileLineByLine($file->getRealPath()) as $line) { + $text .= $line; + } + $response = new JsonResponse($text); + $response->setEncodingOptions(JSON_UNESCAPED_UNICODE); + return $response; + } }