Skip to content

Conversation

@Shelob9
Copy link
Contributor

@Shelob9 Shelob9 commented May 29, 2018

In addition to #6 and #7

Discussion here: #6 (comment)

@Shelob9 Shelob9 requested a review from hellofromtonya May 29, 2018 20:36
->andReturn('mockMode');

$contentGetter = $modes->controlMode(null, $mockRestRequest);
$this->assertTrue(is_a($contentGetter, CreatePostsImplementation::class));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change this assert to use assertInstanceOf instead of the assertTrue(is_a())

$this->assertInstanceOf(CreatePostsImplementation::class, $contentGetter);

{
$modes = new Modes();
$this->assertTrue(is_a($modes->factory(''), PostsGenerator::class));
$this->assertTrue(is_a($modes->factory(PostsGenerator::class), PostsGenerator::class));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change these asserts like the one above to use assertInstanceOf:

$this->assertInstanceOf(PostsGenerator::class, $modes->factory(''));
$this->assertInstanceOf($modes->factory(PostsGenerator::class), $modes->factory(''));

->once()
->andReturn('default');

$this->assertTrue(is_a($modes->controlMode(null, $mockRestRequest), PostsGenerator::class));
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change this assert to use assertInstanceOf:

$this->assertInstanceOf(PostsGenerator::class, $modes->controlMode(null, $mockRestRequest));

->andReturn('default');

$modes->controlMode(null, $mockRestRequest);
$this->assertTrue(Filters\applied(Modes::FILTER_NAME) > 0);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Change the assert to assertGreaterThan:

$this->assertGreaterThan(0, Filters\applied(Modes::FILTER_NAME));

src/Modes.php Outdated
if (is_a($contentGetter, ContentGetterContract::class)) {
return $contentGetter;
}
switch ($mode) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is the point to this switch to be a placeholder for future extension or even discussion? In its current design, we could just return $this->factory(''); and get rid of the switch code structure.

src/Modes.php Outdated
switch ($mode) {
default:
return $this->factory('');
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

This isn't necessary as we are returning and the break will never be reached.

src/Modes.php Outdated
*/
public function factory(string $type) : ContentGetterContract
{
switch ($type) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same as above, what is the point of this switch? In its current design, it will always create a new instance of the PostsGenerator and then return it. Why not just do line 57 and remove the rest of this code?

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