Skip to content

Commit

Permalink
Merge pull request #4 from awssat/analysis-qBg0jO
Browse files Browse the repository at this point in the history
Apply fixes from StyleCI
  • Loading branch information
abdumu authored Nov 21, 2017
2 parents cd24b32 + 28c8b34 commit ca1b060
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/StrHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class StrHelper
protected $falseElseTriggered = false;

/**
* Initate the class
* Initate the class.
*
* @param string $value given string
*/
Expand All @@ -19,7 +19,7 @@ public function __construct($value = '')
}

/**
* The door to the magic
* The door to the magic.
*
* @param string $methodName name of called method
* @param array $arguments arguments of called method
Expand Down
1 change: 1 addition & 0 deletions src/functions.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?php

use Awssat\StrHelper\StrHelper;

/**
Expand Down
32 changes: 14 additions & 18 deletions tests/StrHelperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function do_can_bring_magic_twice()
str('<html>hi</html>')->do('strip_tags')
);
}

/** @test */
public function do_can_bring_magic_even_better()
{
Expand All @@ -90,28 +90,27 @@ public function do_can_bring_magic_even_better()
str('<b>boo</b>')->stripTags()
);
}



/** @test */
public function test_if_with_built_in_functions()
{
$result = str('<html>hi</html>')
->ifStrReplace('hi', 'welcome')
->upper();

$this->assertEquals('<HTML>WELCOME</HTML>', $result);
}

/** @test */
public function test_if2_with_built_in_functions()
{
$result = str('<html>howdy</html>')
->ifStrReplace('hi', 'welcome')
->upper();

$this->assertEquals('<html>howdy</html>', $result);
}

/** @test */
public function test_if_endif_with_built_in_functions()
{
Expand All @@ -121,17 +120,15 @@ public function test_if_endif_with_built_in_functions()
->endif()
->stripTags()
->lower();


$this->assertEquals('howdy', $result);
}



/** @test */
public function test_if_else_endif_with_built_in_functions()
{
$result = [];

foreach (['hi', 'WELCOME'] as $word) {
$result[] = str($word)
->ifContains('hi')
Expand All @@ -146,36 +143,35 @@ public function test_if_else_endif_with_built_in_functions()

$this->assertEquals('HI you :) welcome aboard :)', implode(' ', $result));
}



/** @test */
public function test_built_in_functions()
{
foreach ([
'strpos' => [
'wife', //str
['i'], //params
'1' //expectted
'1', //expectted
],
'strReplace' => [
'once',
['c', 'z'],
'onze'
'onze',
],
'str_replace' => [
'twice',
['c', 'x'],
'twixe'
'twixe',
],
'strrchr' => [
'life is an illusion',
['a'],
'an illusion'
'an illusion',
],
'explode' => [
'a b c d',
[' '],
function_exists('collect') ? collect(['a', 'b', 'c', 'd']) : ['a', 'b', 'c', 'd']
function_exists('collect') ? collect(['a', 'b', 'c', 'd']) : ['a', 'b', 'c', 'd'],
],
] as $func=>$data) {
$this->assertEquals($data[2], str($data[0])->{$func}(...$data[1]));
Expand Down

0 comments on commit ca1b060

Please sign in to comment.