Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added TryCatchStrategy #2

Closed
wants to merge 13 commits into from
Closed

Added TryCatchStrategy #2

wants to merge 13 commits into from

Conversation

a-barzanti
Copy link
Contributor

No description provided.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 2c98f6b on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 2c98f6b on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

Copy link
Member

@Bilge Bilge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks very good, just a few small changes to the code. However, the documentation must also be updated before this can be accepted. Please add TryCatch to the strategy section of the README.md file.

new TryCatch(
$this->callback,
function ($e) {
if (get_class($e) === \DomainException::class) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be an instanceof check instead of a string comparison, e.g. $e instanceof DomainException.

{
/** @var TryCatch $tryCatch */
$tryCatch = (
new TryCatch(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line (and everything nested below it) should be indented one level more.

'DomainExceptionHandled'
)
)->setMapper(new Mapper);
self::assertSame(['foo','bar'], $tryCatch(['foo','bar']));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Prefer blank line before assertion block; here and in the previous test.
  • Should be a space after each comma (,) in array literal. Applies throughout this file.

return $data;
});
}
public function testTryCatch()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be blank line before starting new method.

public function __construct(Strategy $strategy, callable $handler, $expression)
{
parent::__construct($strategy);
$this->handler = $handler;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Prefer blank line after parent call.

new TryCatch(
new TryCatch(
$this->callback,
function ($e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be type hinted, e.g. Exception $e.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 836455a on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling c184fd7 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

#### Signature

```php
ToList(Strategy $strategy, callable $handler, Strategy|Mapping|array|mixed $expression)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like ToList should actually be TryCatch here.

@coveralls
Copy link

coveralls commented Dec 2, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling dcb4538 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.09%) to 98.726% when pulling 2dbbbb5 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.09%) to 98.726% when pulling 2dbbbb5 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 8f61cb2 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling a6931b3 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 29cc498 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

1 similar comment
@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 29cc498 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 9216aa2 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

@Bilge
Copy link
Member

Bilge commented Dec 5, 2016

Merged at #️⃣ 6d21f83.

Thanks @a-barzanti for your great work!

@Bilge Bilge closed this Dec 5, 2016
@coveralls
Copy link

coveralls commented Dec 5, 2016

Coverage Status

Coverage increased (+0.07%) to 98.71% when pulling 9216aa2 on a-barzanti:TryCatchStrategy into f741e7c on ScriptFUSION:master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants