43 lines
		
	
	
		
			950 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			950 B
		
	
	
	
		
			PHP
		
	
	
	
	
	
<?php
 | 
						|
 | 
						|
declare(strict_types=1);
 | 
						|
 | 
						|
namespace App\Services\QueryRequestModifiers\Post;
 | 
						|
 | 
						|
use App\Services\CacheKeyInterface;
 | 
						|
use App\Services\QueryRequestModifiers\SortDirection;
 | 
						|
use App\Services\QueryRequestModifiers\OrderableDTO;
 | 
						|
 | 
						|
/**
 | 
						|
 * @implements OrderableDTO<PostOrderDTO>
 | 
						|
 */
 | 
						|
readonly class PostOrderDTO implements CacheKeyInterface, OrderableDTO
 | 
						|
{
 | 
						|
    public function __construct(public string $column, public SortDirection $direction)
 | 
						|
    {
 | 
						|
    }
 | 
						|
 | 
						|
    public function toCacheKey(): string
 | 
						|
    {
 | 
						|
        return $this->column . '|' . $this->direction->value;
 | 
						|
    }
 | 
						|
 | 
						|
    public function getColumn(): string
 | 
						|
    {
 | 
						|
        return $this->column;
 | 
						|
    }
 | 
						|
 | 
						|
    public function getDirection(): SortDirection
 | 
						|
    {
 | 
						|
        return $this->direction;
 | 
						|
    }
 | 
						|
 | 
						|
    public static function createFromValues(string $column, SortDirection $sortDirection): OrderableDTO
 | 
						|
    {
 | 
						|
        return new self(
 | 
						|
            $column,
 | 
						|
            $sortDirection
 | 
						|
        );
 | 
						|
    }
 | 
						|
}
 |