Skip to content

Commit

Permalink
Reformat code
Browse files Browse the repository at this point in the history
  • Loading branch information
AgelxNash committed Jun 3, 2018
1 parent 06988d5 commit 474ad70
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 19 deletions.
16 changes: 8 additions & 8 deletions src/Traits/SupportTrait.php
Expand Up @@ -73,7 +73,7 @@ protected function convertValue($value)
public function convertDate(int $timestamp, string $fieldType = 'DATETIME')
{
$date = false;
if (!empty($timestamp) && $timestamp > 0) {
if (! empty($timestamp) && $timestamp > 0) {
switch ($fieldType) {
case 'DATE':
$date = date('Y-m-d', $timestamp);
Expand Down Expand Up @@ -104,7 +104,7 @@ protected function prepareFields($data, $ignoreAlias = false): string
if (\is_array($data)) {
$tmp = [];
foreach ($data as $alias => $field) {
$tmp[] = ($alias !== $field && !\is_int($alias) && $ignoreAlias === false) ?
$tmp[] = ($alias !== $field && ! \is_int($alias) && $ignoreAlias === false) ?
($field . ' as `' . $alias . '`') : $field;
}

Expand Down Expand Up @@ -183,7 +183,7 @@ protected function prepareValues($data, $level = 1, $skipFieldNames = false)
}
}

if (!\is_scalar($values)) {
if (! \is_scalar($values)) {
throw (new Exceptions\InvalidFieldException('values'))
->setData($values);
}
Expand Down Expand Up @@ -227,7 +227,7 @@ protected function arrayOnlyNumeric(array $data) : bool
{
$onlyNumbers = true;
foreach ($data as $value) {
if (!\is_numeric($value)) {
if (! \is_numeric($value)) {
$onlyNumbers = false;
break;
}
Expand Down Expand Up @@ -272,7 +272,7 @@ protected function prepareFrom($data, bool $hasArray = false): string
}
$data = implode(' ', $tmp);
}
if (!is_scalar($data) || empty($data)) {
if (! is_scalar($data) || empty($data)) {
throw new Exceptions\TableNotDefinedException($data);
}

Expand All @@ -295,7 +295,7 @@ protected function prepareWhere($data): string
}
}
$data = trim($data);
if (!empty($data) && stripos($data, 'WHERE') !== 0) {
if (! empty($data) && stripos($data, 'WHERE') !== 0) {
$data = "WHERE {$data}";
}

Expand All @@ -309,7 +309,7 @@ protected function prepareWhere($data): string
protected function prepareOrder($data): string
{
$data = trim($data);
if (!empty($data) && stripos($data, 'ORDER') !== 0) {
if (! empty($data) && stripos($data, 'ORDER') !== 0) {
$data = "ORDER BY {$data}";
}

Expand All @@ -323,7 +323,7 @@ protected function prepareOrder($data): string
protected function prepareLimit($data): string
{
$data = trim($data);
if (!empty($data) && stripos($data, 'LIMIT') !== 0) {
if (! empty($data) && stripos($data, 'LIMIT') !== 0) {
$data = "LIMIT {$data}";
}

Expand Down
16 changes: 7 additions & 9 deletions tests/QueryTest.php
Expand Up @@ -40,7 +40,6 @@ protected function setUp()
$this->instance->setDebug(true)->connect();

$this->table = $this->instance->getFullTableName('site_content');

}

public function testConnect()
Expand Down Expand Up @@ -101,7 +100,7 @@ public function testOptimize()

public function testHelperMethods()
{
$result = $this->instance->query('SELECT id,pagetitle FROM '. $this->table . ' ORDER BY id ASC LIMIT 3');
$result = $this->instance->query('SELECT id,pagetitle FROM ' . $this->table . ' ORDER BY id ASC LIMIT 3');

$this->assertEquals(
['id', 'pagetitle'],
Expand Down Expand Up @@ -199,7 +198,7 @@ public function testSave()

$this->assertTrue(
$this->instance->save(
"`pagetitle`='testSave5 - ". $time . "'",
"`pagetitle`='testSave5 - " . $time . "'",
$this->table,
'id = 48'
)
Expand Down Expand Up @@ -318,7 +317,6 @@ public function testQuery()
'LIMIT 10',
])
);

}

public function testMakeArray()
Expand Down Expand Up @@ -348,7 +346,7 @@ public function testInsert()
{
$maxId = (int)$this->instance->getColumn(
'Auto_increment',
"SHOW TABLE STATUS WHERE `name`='" . $this->instance->getTableName('site_content', false) ."'"
"SHOW TABLE STATUS WHERE `name`='" . $this->instance->getTableName('site_content', false) . "'"
)[0];
$this->assertGreaterThan(
0,
Expand Down Expand Up @@ -382,7 +380,7 @@ public function testInsert()
);

$this->assertTrue(false, 'STEP 3/3 (Need QueryException)');
} catch(Database\Exceptions\QueryException $exception) {
} catch (Database\Exceptions\QueryException $exception) {
$this->assertEquals(
1062,
$exception->getCode(),
Expand All @@ -402,7 +400,7 @@ public function testMassInsert()

$this->assertTrue(
$this->instance->query(
'CREATE TABLE '. $table . ' LIKE ' . $this->table
'CREATE TABLE ' . $table . ' LIKE ' . $this->table
)
);

Expand All @@ -411,7 +409,7 @@ public function testMassInsert()
'CREATE TABLE ' . $table . ' LIKE ' . $this->table
);
$this->assertTrue(false, 'Need QueryException');
} catch(Database\Exceptions\QueryException $exception) {
} catch (Database\Exceptions\QueryException $exception) {
$this->assertEquals(
1050,
$exception->getCode()
Expand All @@ -431,7 +429,7 @@ public function testMassInsert()
try {
$this->instance->checkLastError();
$this->assertTrue(false, 'Need QueryException');
} catch(Database\Exceptions\QueryException $exception) {
} catch (Database\Exceptions\QueryException $exception) {
$this->assertTrue(true);
}

Expand Down
1 change: 0 additions & 1 deletion tests/Traits/DebugTraitTest.php
Expand Up @@ -2,7 +2,6 @@

use PHPUnit\Framework\TestCase;
use AgelxNash\Modx\Evo\Database;
use ReflectionMethod;

class DebugTraitTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/SupportTraitTest.php
Expand Up @@ -301,7 +301,7 @@ public function testConvertValue()
$this->assertThat(
$method->invoke($this->instance, $item),
$this->isType($type),
'[ STEP '. ++$step . '] Check ' . $item . ' as '. $type
'[ STEP ' . ++$step . '] Check ' . $item . ' as ' . $type
);
}
}
Expand Down

0 comments on commit 474ad70

Please sign in to comment.