<?php
/** 
 * Переделай своё решение 8 задачи:
 * замени вывод всего текста из файла разом на 
 * построчный вывод используя yield 
 * @param string $filePath путь до файла
 * @return void  
 */  
function readLogFile(string $filePath): void {
    if (file_exists($filePath)) {
        $text = "";
        $file = fopen($filePath, "r");
        while(!feof($file)) {
            $line = fgets($file);
            $text .= $line;
        }
        fclose($file);
        print($text);
    }
    else print("Такого файла не существует.");
}

?>
</head>
<body>
    <h1>Function 1</h1>
    <?php
        $array = [
            ['price'=>10, 'count'=>2],  
            ['price'=>5, 'count'=>5],  
            ['price'=>8, 'count'=>5],  
            ['price'=>12, 'count'=>4],  
            ['price'=>8, 'count'=>4], 
        ];
        print_r($func->sortPrice($array));
    ?>

    <h1>Function 2</h1>
    <?php
        $array = [
            ['id'=>10, 'name'=>'Jhon', 'age'=>23],  
            ['id'=>32, 'name'=>'Alex', 'age'=>34],  
            ['id'=>54, 'name'=>'Bob', 'age'=>45],  
            ['id'=>6, 'name'=>'Mike', 'age'=>61],
        ];
        print_r($func->search($array, 54));
    ?>

    <h1>Function 3</h1>
    <?php
        $arr = [
            ['laravel', 'php'],
            ['codeigniter', 'php'],
            ['laravel', 'php'],
            ['c++', 'java'], 
        ];
        print_r($func->uniqElements($arr));
    ?>

    <h1>Function 4</h1>
    <?php
        $aMenu = [
            ['name' => 'Смартфоны и гаджеты','depth' => 0,],
            ['name' => 'Смартфоны, мобильные телефоны','depth' => 1,],
            ['name' => 'Планшеты','depth' => 1,],
            ['name' => 'Наушники и гарнитуры','depth' => 1,],
            ['name' => 'Компьютеры и ноутбуки','depth' => 0,],
            ['name' => 'Ноутбуки и аксессуары','depth' => 1,],
            ['name' => 'Компьютеры и мониторы','depth' => 1,],
            ['name' => 'Компьютерные комплектующие','depth' => 1,],
            ['name' => 'Техника для дома','depth' => 0,],
            ['name' => 'Техника для уборки','depth' => 1,],
            ['name' => 'Товары для ухода за одеждой','depth' => 1,],
            ['name' => 'Аксессуары для техники','depth' => 1,],
            ['name' => 'Товары для дома и кухни','depth' => 0,],
            ['name' => 'Посуда','depth' => 1,], 
        ];   
        print_r($func->prepareMenu($aMenu));
    ?>

    <h1>Function 5</h1>
    <?php
        print("<h2>До НГ: </h2>");
        print($func->howDaysToNy(new DateTimeImmutable()));
    ?>

    <h1>Function 6</h1>
    <?php
        readLogFile(__DIR__ . "/files/text.txt");
    ?>
</body>
</html>