Skip to content

Commit

Permalink
NotTemplate: make applicable both to TermCompareInterface and QuadCom…
Browse files Browse the repository at this point in the history
…pareInterface objects
  • Loading branch information
zozlak committed Aug 29, 2023
1 parent 0116585 commit ac611ed
Showing 1 changed file with 21 additions and 4 deletions.
25 changes: 21 additions & 4 deletions src/termTemplates/NotTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,25 +27,42 @@
namespace termTemplates;

use rdfInterface\TermCompareInterface;
use rdfInterface\QuadCompareInterface;

/**
* Provides condition negation
*
* @author zozlak
*/
class NotTemplate implements TermCompareInterface {
class NotTemplate implements TermCompareInterface, QuadCompareInterface {

private TermCompareInterface $term;
private TermCompareInterface | QuadCompareInterface $term;

public function __construct(TermCompareInterface $term) {
public function __construct(TermCompareInterface | QuadCompareInterface $term) {
$this->term = $term;
}

public function __toString(): string {
return '[not ' . $this->term . ']';
}

public function equals(TermCompareInterface $term): bool {
public function equals(TermCompareInterface | QuadCompareInterface $term): bool {
return !$this->term->equals($term);
}

public function getGraph(): TermCompareInterface | null {
return $this->term instanceof QuadCompareInterface ? $this->term->getGraph() : null;
}

public function getObject(): TermCompareInterface | null {
return $this->term instanceof QuadCompareInterface ? $this->term->getObject() : null;
}

public function getPredicate(): TermCompareInterface | null {
return $this->term instanceof QuadCompareInterface ? $this->term->getPredicate() : null;
}

public function getSubject(): TermCompareInterface | null {
return $this->term instanceof QuadCompareInterface ? $this->term->getSubject() : null;
}
}

0 comments on commit ac611ed

Please sign in to comment.