Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot committed Sep 14, 2023
1 parent d9f901c commit a4b3659
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 83 deletions.
2 changes: 0 additions & 2 deletions src/Expression/AppendCallbackExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* the LICENSE file that was distributed with this source code.
*/


declare(strict_types=1);

namespace Cacing69\Cquery\Expression;
Expand All @@ -35,7 +34,6 @@ public function __construct(string $raw)
$extractRefNode = new DefinerExtractor($extract[1]);

if (preg_match('/^\s*append\(\s*([a-z0-9_]*\(.+\))\s*\)$/', $raw, $extract)) {

$extractChild = $this->extractChild($extract[1]);
$_childCallback = $extractChild->getExpression()->getCallback();

Expand Down
1 change: 0 additions & 1 deletion src/Expression/DoubleQuotesCallbackExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* the LICENSE file that was distributed with this source code.
*/


declare(strict_types=1);

namespace Cacing69\Cquery\Expression;
Expand Down
2 changes: 0 additions & 2 deletions src/Expression/StaticFloatCallbackExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* the LICENSE file that was distributed with this source code.
*/


declare(strict_types=1);

namespace Cacing69\Cquery\Expression;
Expand All @@ -34,7 +33,6 @@ public function __construct(string $raw)
$this->callback = function ($value) use ($raw) {
preg_match(self::$signature, $raw, $_extract);


return floatval($_extract[1]);
};

Expand Down
2 changes: 0 additions & 2 deletions src/Expression/StaticIntCallbackExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
* the LICENSE file that was distributed with this source code.
*/


declare(strict_types=1);

namespace Cacing69\Cquery\Expression;
Expand All @@ -34,7 +33,6 @@ public function __construct(string $raw)
$this->callback = function ($value) use ($raw) {
preg_match(self::$signature, $raw, $_extract);


return intval($_extract[1]);
};

Expand Down
7 changes: 2 additions & 5 deletions src/Trait/HasDomCrawlerGetter.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public function get(): Collection
$_data = $_data->extract($filterExepression->getCallMethodParameter());
} elseif ($filterExepression->getCallMethod() === 'filter') {
throw new CqueryException("filter on `{$filterExepression->getCallMethod()}` not yet available");

} elseif ($filterExepression->getCallMethod() === 'static') {
throw new CqueryException("filter on `{$filterExepression->getCallMethod()}` not yet available");
} elseif ($filterExepression->getCallMethod() === 'static.extract') {
Expand Down Expand Up @@ -104,7 +103,6 @@ public function get(): Collection
->each(function (Crawler $node, $i) use (&$_data, $definer) {
$node->filter($definer->getExpression()->getRef())->each(function (Crawler $_node, $_i) use ($i, &$_data, $definer) {
if (is_array($definer->getExpression()->getCallMethodParameter()) && count($definer->getExpression()->getCallMethodParameter()) === 1) {

$__callParameter = $definer->getExpression()->getCallMethodParameter()[0];

$__text = null;
Expand All @@ -115,7 +113,7 @@ public function get(): Collection
$__text = $_node->attr($__callParameter);
}

if($definer->getExpression()->getCallback()) {
if ($definer->getExpression()->getCallback()) {
$__callbackFilterEach = $definer->getExpression()->getCallback();
$__text = $__callbackFilterEach($__text);
}
Expand Down Expand Up @@ -144,7 +142,7 @@ public function get(): Collection
->filterXPath($definer->getExpression()->getNodeXpath())
->extract($definer->getExpression()->getCallMethodParameter());

if(count($_static) > 1) {
if (count($_static) > 1) {
throw new CqueryException('you cannot append if there was multiple element exist on your document');
}

Expand Down Expand Up @@ -177,7 +175,6 @@ public function get(): Collection
});

// throw new CqueryException("error query definer, there are no matching rows each column.");

} elseif (count($_data ?? []) > $_bound) {
// if(!($definer->getExpression() instanceof AppendNodeCallbackExpression)) {
throw new CqueryException('error query definer, there are no matching rows each column.');
Expand Down
11 changes: 3 additions & 8 deletions tests/SampleOnlineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

final class SampleOnlineTest extends TestCase
{

/**
* @group ignore
*/
/**
* @group ignore
*/
public function testGetGoogleTitle()
{
$data = new Cquery(GOOGLE);
Expand All @@ -39,7 +38,6 @@ public function testGetGoogleTitle()
/**
* @group ignore
*/

public function testHttpBinTestWithActions()
{
$data = new Cquery(HTTP_BIN_TEST_K6_FORM_POST);
Expand Down Expand Up @@ -86,7 +84,6 @@ public function testGetAndLimitUserAgents()
/**
* @group ignore
*/

public function testClickLinkOnSemver()
{
$data = new Cquery(SEMVER_ORG);
Expand Down Expand Up @@ -116,7 +113,6 @@ public function testClickLinkOnSemver()
/**
* @group ignore
*/

public function testFormSearchOnWikipedia()
{
$data = new Cquery(WIKIPEDIA);
Expand All @@ -143,7 +139,6 @@ public function testFormSearchOnWikipedia()
/**
* @group ignore
*/

public function testFormSearchOnWikipediaButWithClickFirst()
{
$data = new Cquery(WIKIPEDIA);
Expand Down
126 changes: 63 additions & 63 deletions tests/SampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1349,15 +1349,15 @@ public function testWithAppendUsedSelector()

$this->assertCount(9, $result);

$this->assertSame("MAIN TITLE", $result[0]["head"]);
$this->assertSame("MAIN TITLE", $result[1]["head"]);
$this->assertSame("MAIN TITLE", $result[2]["head"]);
$this->assertSame("MAIN TITLE", $result[3]["head"]);
$this->assertSame("MAIN TITLE", $result[4]["head"]);
$this->assertSame("MAIN TITLE", $result[5]["head"]);
$this->assertSame("MAIN TITLE", $result[6]["head"]);
$this->assertSame("MAIN TITLE", $result[7]["head"]);
$this->assertSame("MAIN TITLE", $result[8]["head"]);
$this->assertSame('MAIN TITLE', $result[0]['head']);
$this->assertSame('MAIN TITLE', $result[1]['head']);
$this->assertSame('MAIN TITLE', $result[2]['head']);
$this->assertSame('MAIN TITLE', $result[3]['head']);
$this->assertSame('MAIN TITLE', $result[4]['head']);
$this->assertSame('MAIN TITLE', $result[5]['head']);
$this->assertSame('MAIN TITLE', $result[6]['head']);
$this->assertSame('MAIN TITLE', $result[7]['head']);
$this->assertSame('MAIN TITLE', $result[8]['head']);
}

public function testWithAppendNestedUsedSelector()
Expand All @@ -1375,15 +1375,15 @@ public function testWithAppendNestedUsedSelector()

$this->assertCount(9, $result);

$this->assertSame("main-txt content-title", $result[0]["head_class"]);
$this->assertSame("main-txt content-title", $result[1]["head_class"]);
$this->assertSame("main-txt content-title", $result[2]["head_class"]);
$this->assertSame("main-txt content-title", $result[3]["head_class"]);
$this->assertSame("main-txt content-title", $result[4]["head_class"]);
$this->assertSame("main-txt content-title", $result[5]["head_class"]);
$this->assertSame("main-txt content-title", $result[6]["head_class"]);
$this->assertSame("main-txt content-title", $result[7]["head_class"]);
$this->assertSame("main-txt content-title", $result[8]["head_class"]);
$this->assertSame('main-txt content-title', $result[0]['head_class']);
$this->assertSame('main-txt content-title', $result[1]['head_class']);
$this->assertSame('main-txt content-title', $result[2]['head_class']);
$this->assertSame('main-txt content-title', $result[3]['head_class']);
$this->assertSame('main-txt content-title', $result[4]['head_class']);
$this->assertSame('main-txt content-title', $result[5]['head_class']);
$this->assertSame('main-txt content-title', $result[6]['head_class']);
$this->assertSame('main-txt content-title', $result[7]['head_class']);
$this->assertSame('main-txt content-title', $result[8]['head_class']);
}

public function testWithIntWithAppendExpressionUsedSelector()
Expand All @@ -1401,15 +1401,15 @@ public function testWithIntWithAppendExpressionUsedSelector()

$this->assertCount(9, $result);

$this->assertSame(9, $result[0]["head_id"]);
$this->assertSame(9, $result[1]["head_id"]);
$this->assertSame(9, $result[2]["head_id"]);
$this->assertSame(9, $result[3]["head_id"]);
$this->assertSame(9, $result[4]["head_id"]);
$this->assertSame(9, $result[5]["head_id"]);
$this->assertSame(9, $result[6]["head_id"]);
$this->assertSame(9, $result[7]["head_id"]);
$this->assertSame(9, $result[8]["head_id"]);
$this->assertSame(9, $result[0]['head_id']);
$this->assertSame(9, $result[1]['head_id']);
$this->assertSame(9, $result[2]['head_id']);
$this->assertSame(9, $result[3]['head_id']);
$this->assertSame(9, $result[4]['head_id']);
$this->assertSame(9, $result[5]['head_id']);
$this->assertSame(9, $result[6]['head_id']);
$this->assertSame(9, $result[7]['head_id']);
$this->assertSame(9, $result[8]['head_id']);
}

public function testWithAppendWithIntExpressionUsedSelector()
Expand All @@ -1427,15 +1427,15 @@ public function testWithAppendWithIntExpressionUsedSelector()

$this->assertCount(9, $result);

$this->assertSame(9, $result[0]["head_id"]);
$this->assertSame(9, $result[1]["head_id"]);
$this->assertSame(9, $result[2]["head_id"]);
$this->assertSame(9, $result[3]["head_id"]);
$this->assertSame(9, $result[4]["head_id"]);
$this->assertSame(9, $result[5]["head_id"]);
$this->assertSame(9, $result[6]["head_id"]);
$this->assertSame(9, $result[7]["head_id"]);
$this->assertSame(9, $result[8]["head_id"]);
$this->assertSame(9, $result[0]['head_id']);
$this->assertSame(9, $result[1]['head_id']);
$this->assertSame(9, $result[2]['head_id']);
$this->assertSame(9, $result[3]['head_id']);
$this->assertSame(9, $result[4]['head_id']);
$this->assertSame(9, $result[5]['head_id']);
$this->assertSame(9, $result[6]['head_id']);
$this->assertSame(9, $result[7]['head_id']);
$this->assertSame(9, $result[8]['head_id']);
}

public function testWithAppendWithDoubleQupteExpression()
Expand All @@ -1453,15 +1453,15 @@ public function testWithAppendWithDoubleQupteExpression()

$this->assertCount(9, $result);

$this->assertSame("staticValue", $result[0]["static_value"]);
$this->assertSame("staticValue", $result[1]["static_value"]);
$this->assertSame("staticValue", $result[2]["static_value"]);
$this->assertSame("staticValue", $result[3]["static_value"]);
$this->assertSame("staticValue", $result[4]["static_value"]);
$this->assertSame("staticValue", $result[5]["static_value"]);
$this->assertSame("staticValue", $result[6]["static_value"]);
$this->assertSame("staticValue", $result[7]["static_value"]);
$this->assertSame("staticValue", $result[8]["static_value"]);
$this->assertSame('staticValue', $result[0]['static_value']);
$this->assertSame('staticValue', $result[1]['static_value']);
$this->assertSame('staticValue', $result[2]['static_value']);
$this->assertSame('staticValue', $result[3]['static_value']);
$this->assertSame('staticValue', $result[4]['static_value']);
$this->assertSame('staticValue', $result[5]['static_value']);
$this->assertSame('staticValue', $result[6]['static_value']);
$this->assertSame('staticValue', $result[7]['static_value']);
$this->assertSame('staticValue', $result[8]['static_value']);
}

public function testWithStaticNumericExpression()
Expand All @@ -1479,15 +1479,15 @@ public function testWithStaticNumericExpression()

$this->assertCount(9, $result);

$this->assertSame(19, $result[0]["static_number"]);
$this->assertSame(19, $result[1]["static_number"]);
$this->assertSame(19, $result[2]["static_number"]);
$this->assertSame(19, $result[3]["static_number"]);
$this->assertSame(19, $result[4]["static_number"]);
$this->assertSame(19, $result[5]["static_number"]);
$this->assertSame(19, $result[6]["static_number"]);
$this->assertSame(19, $result[7]["static_number"]);
$this->assertSame(19, $result[8]["static_number"]);
$this->assertSame(19, $result[0]['static_number']);
$this->assertSame(19, $result[1]['static_number']);
$this->assertSame(19, $result[2]['static_number']);
$this->assertSame(19, $result[3]['static_number']);
$this->assertSame(19, $result[4]['static_number']);
$this->assertSame(19, $result[5]['static_number']);
$this->assertSame(19, $result[6]['static_number']);
$this->assertSame(19, $result[7]['static_number']);
$this->assertSame(19, $result[8]['static_number']);
}

public function testWithStaticFloatExpression()
Expand All @@ -1505,15 +1505,15 @@ public function testWithStaticFloatExpression()

$this->assertCount(9, $result);

$this->assertSame(1.9, $result[0]["static_number"]);
$this->assertSame(1.9, $result[1]["static_number"]);
$this->assertSame(1.9, $result[2]["static_number"]);
$this->assertSame(1.9, $result[3]["static_number"]);
$this->assertSame(1.9, $result[4]["static_number"]);
$this->assertSame(1.9, $result[5]["static_number"]);
$this->assertSame(1.9, $result[6]["static_number"]);
$this->assertSame(1.9, $result[7]["static_number"]);
$this->assertSame(1.9, $result[8]["static_number"]);
$this->assertSame(1.9, $result[0]['static_number']);
$this->assertSame(1.9, $result[1]['static_number']);
$this->assertSame(1.9, $result[2]['static_number']);
$this->assertSame(1.9, $result[3]['static_number']);
$this->assertSame(1.9, $result[4]['static_number']);
$this->assertSame(1.9, $result[5]['static_number']);
$this->assertSame(1.9, $result[6]['static_number']);
$this->assertSame(1.9, $result[7]['static_number']);
$this->assertSame(1.9, $result[8]['static_number']);
}

public function testWithFilterNested()
Expand Down

0 comments on commit a4b3659

Please sign in to comment.