Skip to content

Commit

Permalink
Style autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
davidrans committed Aug 20, 2024
1 parent 883c9a0 commit 7727816
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 11 deletions.
16 changes: 9 additions & 7 deletions QueryGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class QueryGenerator {
'STRAIGHT_JOIN',
'SQL_SMALL_RESULT', 'SQL_BIG_RESULT', 'SQL_BUFFER_RESULT',
'SQL_CACHE', 'SQL_NO_CACHE',
'SQL_CALC_FOUND_ROWS'
'SQL_CALC_FOUND_ROWS',
],
'insert' => ['LOW_PRIORITY', 'DELAYED', 'HIGH_PRIORITY', 'IGNORE'],
'replace' => ['LOW_PRIORITY', 'DELAYED'],
Expand Down Expand Up @@ -285,21 +285,22 @@ public function __call(string $method, array $args) {
throw new Exception("Method \"$method\" does not exist.");
}

$requiresArgument = (isset(self::$methods[$method]['requiresArgument']) ?
self::$methods[$method]['requiresArgument'] : false);
$requiresArgument = (isset(self::$methods[$method]['requiresArgument'])
? self::$methods[$method]['requiresArgument']
: false);

if ($requiresArgument && count($args) < 1) {
throw new Exception("Missing argument 1 (\$clauses) for $method()");
} else if (count($args) < 2) {
$clauses = reset($args);
$params = [];
} else {
list($clauses, $params) = $args;
[$clauses, $params] = $args;
}

if ($clauses instanceOf QueryGenerator) {
if ($clauses instanceof self) {
$clauses->skipValidation();
list($clauses, $params) = $clauses->build(/* $skipClauses = */ true);
[$clauses, $params] = $clauses->build(/* $skipClauses = */ true);
}

if (!is_array($clauses)) {
Expand Down Expand Up @@ -391,7 +392,8 @@ private function assertCompleteQuery(): void {
if (!$primaryMethod) {
$primaryClauseStr = implode("', '", $this->getPrimaryClauses());
throw new MissingPrimaryClauseException(
"Missing primary clause. One of '$primaryClauseStr' needed.");
"Missing primary clause. One of '$primaryClauseStr' needed."
);
}

$minimumClauses = self::$minimumClauses[$primaryMethod];
Expand Down
8 changes: 4 additions & 4 deletions QueryGeneratorTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require("./QueryGenerator.php");
require "./QueryGenerator.php";

/**
* Designed to work with PHPUnit
Expand Down Expand Up @@ -116,7 +116,7 @@ public function testBigQuery(): void {
$qGen->from(['table1', 'table2']);
$qGen->join([
'INNER JOIN table3 USING (asdf)',
'OUTER JOIN table4 ON foo = bar'
'OUTER JOIN table4 ON foo = bar',
]);
$qGen->where(['where1', 'where2 OR where3']);
$qGen->group(['group1', 'group2']);
Expand Down Expand Up @@ -242,11 +242,11 @@ public function testOnDuplicate(): void {
}

public function assertQuery(QueryGenerator $qGen, string $expectedQuery, array $expectedParams): void {
list($actualQuery, $actualParams) = $qGen->build();
[$actualQuery, $actualParams] = $qGen->build();
$this->assertEquals($expectedQuery, $actualQuery);
$this->assertEquals($expectedParams, $actualParams);

list($actualQuery, $actualParams) = $qGen->skipValidation()->build();
[$actualQuery, $actualParams] = $qGen->skipValidation()->build();
$this->assertEquals($expectedQuery, $actualQuery);
$this->assertEquals($expectedParams, $actualParams);
}
Expand Down

0 comments on commit 7727816

Please sign in to comment.