Skip to content

Commit

Permalink
thusfar
Browse files Browse the repository at this point in the history
  • Loading branch information
bobmagicii committed Nov 16, 2023
1 parent ce78b86 commit 51c8dbf
Showing 1 changed file with 36 additions and 65 deletions.
101 changes: 36 additions & 65 deletions src/Nether/Database/Coda/Equals.php
@@ -1,91 +1,62 @@
<?php

namespace Nether\Database\Coda;
use \Nether;

use \Exception;
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

use Nether\Common;

use Stringable;

////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

class Equals
extends Nether\Database\Coda {
/*//
probably the most simple operation we can create a coda for. this class
mearly lets you assign if the value must be equal or not equal to the
specified field. the thing is, several other codas are going to be extending
this one.
//*/

protected
$Equal = true;
/*//
defines if this is a positive or negative comparison.
//*/
implements
Stringable,
Common\Interfaces\ToString {

public function
GetEqual() {
/*//
@return bool
return if we are currently planning for equality or not.
//*/
use
Common\Package\StringableAsToString;

return $this->Equal;
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

public function
SetEqual($State) {
/*//
@argv bool
@return self
set if this ia positive or negative comparison.
//*/

$this->Equal = $State;
return $this;
}
public string
$Field;

////////////////////////////////
////////////////////////////////
public string
$Value;

public function
Is() {
/*//
@return self
force this comparison to be positive.
//*/
public bool
$Is;

return $this->SetEqual(true);
}
////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////

public function
Not() {
/*//
force this comparison to be negative.
//*/
__Construct(string $Field, string $Value, bool $Is) {

return $this->SetEqual(false);
$this->Field = $Field;
$this->Value = $Value;
$this->Is = $Is;

return;
}

////////////////////////////////
////////////////////////////////
////////////////////////////////////////////////////////////////
// IMPLEMENTS Common\Interfaces ////////////////////////////////

public function
Render_Generic() {
/*//
provide the rendering for an equality condition.
//*/

$this->RequireDatabase();

if(is_object($this->Value) || is_array($this->Value))
throw new Exception('value must be a literal value.');
ToString():
string {

return sprintf(
'%s%s%s',
$this->Field,
(($this->Equal)?('='):('!=')),
((strpos($this->Value,':')===0)?
($this->Value):
($this->Database->Escape($this->Value))
)
($this->Is ? '=' : '!='),
$this->Value
);
}

Expand Down

0 comments on commit 51c8dbf

Please sign in to comment.