A super easy PHP Framework for web development!
https://github.com/exacti/phacil-framework
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
1.7 KiB
92 lines
1.7 KiB
1 year ago
|
<?php
|
||
|
|
||
|
/**
|
||
|
* Copyright © 2023 ExacTI Technology Solutions. All rights reserved.
|
||
|
* GPLv3 General License.
|
||
|
* https://exacti.com.br
|
||
|
* Phacil PHP Framework - https://github.com/exacti/phacil-framework
|
||
|
*/
|
||
|
|
||
|
namespace Phacil\Framework\MagiQL\Syntax;
|
||
|
|
||
1 year ago
|
use Phacil\Framework\MagiQL\Api\Syntax\OrderBy as OrderByInterface;
|
||
|
|
||
1 year ago
|
/**
|
||
|
* Class OrderBy.
|
||
|
*/
|
||
1 year ago
|
class OrderBy implements OrderByInterface
|
||
1 year ago
|
{
|
||
|
|
||
|
/**
|
||
|
* @var Column
|
||
|
*/
|
||
|
protected $column;
|
||
|
|
||
|
/**
|
||
|
* @var string
|
||
|
*/
|
||
|
protected $direction;
|
||
|
|
||
|
/**
|
||
|
* @var bool
|
||
|
*/
|
||
|
protected $useAlias;
|
||
|
|
||
|
/**
|
||
|
* @param Column $column
|
||
|
* @param string $direction
|
||
|
*/
|
||
|
public function __construct(Column $column, $direction)
|
||
|
{
|
||
|
$this->setColumn($column);
|
||
|
$this->setDirection($direction);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return Column
|
||
|
*/
|
||
|
public function getColumn()
|
||
|
{
|
||
|
return $this->column;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param Column $column
|
||
|
*
|
||
|
* @return $this
|
||
|
*/
|
||
|
public function setColumn($column)
|
||
|
{
|
||
|
$this->column = $column;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @return string
|
||
|
*/
|
||
|
public function getDirection()
|
||
|
{
|
||
|
return $this->direction;
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
* @param string $direction
|
||
|
*
|
||
1 year ago
|
* @throws \Phacil\Framework\Exception\InvalidArgumentException
|
||
1 year ago
|
*
|
||
|
* @return $this
|
||
|
*/
|
||
|
public function setDirection($direction)
|
||
|
{
|
||
1 year ago
|
if (!in_array($direction, array(OrderByInterface::ASC, OrderByInterface::DESC))) {
|
||
|
throw new \Phacil\Framework\Exception\InvalidArgumentException(
|
||
1 year ago
|
"Specified direction '$direction' is not allowed. Only ASC or DESC are allowed."
|
||
|
);
|
||
|
}
|
||
|
$this->direction = $direction;
|
||
|
|
||
|
return $this;
|
||
|
}
|
||
|
}
|