diff --git a/src/Actions/HowDaysToNYAction.php b/src/Actions/HowDaysToNYAction.php new file mode 100644 index 0000000000000000000000000000000000000000..3c133ed921bc0eeaa7d38b13f083b3315a846786 --- /dev/null +++ b/src/Actions/HowDaysToNYAction.php @@ -0,0 +1,20 @@ +modify('first day of Jan +1 year'); + + return (int) $dateOfNY->diff($date)->format('%a'); + } +} \ No newline at end of file diff --git a/src/Controller/HowDaysToNYController.php b/src/Controller/HowDaysToNYController.php new file mode 100644 index 0000000000000000000000000000000000000000..8311dcef842015f0f0fcbafea037d03fd26f89be --- /dev/null +++ b/src/Controller/HowDaysToNYController.php @@ -0,0 +1,25 @@ +act($request->serialise())); + } +} diff --git a/src/Controller/SortPriceController.php b/src/Controller/SortPriceController.php index 313d3dc8c22d4304111a09bcec01e3a5b1bab5da..0f1d250b6c31ea3f0dee3f4581c722d10adb2cdf 100644 --- a/src/Controller/SortPriceController.php +++ b/src/Controller/SortPriceController.php @@ -3,28 +3,22 @@ namespace App\Controller; use App\Actions\SortPriceAction; -use App\Entity\PricesEntity; use App\Requests\PricesRequest; -use App\Service\ValidationService; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Component\HttpFoundation\JsonResponse; -use Symfony\Component\HttpFoundation\Request; use Symfony\Component\Routing\Attribute\Route; class SortPriceController extends AbstractController { /** * Контроллер волняет сортировку массива по убыванию цены используя sortPrice - * @param Request $request + * @param PricesRequest $request * @param SortPriceAction $action * @return JsonResponse */ #[Route('/sort/price', name: 'app_sort_price', methods: ['POST'])] public function index(PricesRequest $request, SortPriceAction $action): JsonResponse { - return new JsonResponse( - $action->act($request->serialise()), - 200 - ); + return new JsonResponse($action->act($request->serialise())); } } diff --git a/src/Requests/BeforeNYDateRequest.php b/src/Requests/BeforeNYDateRequest.php new file mode 100644 index 0000000000000000000000000000000000000000..445bc20f34656a0551f6a13947206872e4db6aa6 --- /dev/null +++ b/src/Requests/BeforeNYDateRequest.php @@ -0,0 +1,19 @@ +date); + } +}