Completed
Push — master ( 68f942...d69058 )
by Rafał
18:18
created

CreateOrganizationCommandTest::getMockContainer()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 42
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 42
rs 8.8571
cc 1
eloc 31
nc 1
nop 3
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher MultiTenancy Bundle.
5
 *
6
 * Copyright 2016 Sourcefabric z.ú. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2016 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Bundle\MultiTenancyBundle\Tests\Command;
15
16
use SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand;
17
use SWP\Component\MultiTenancy\Factory\OrganizationFactoryInterface;
18
use SWP\Component\MultiTenancy\Model\Organization;
19
use SWP\Component\MultiTenancy\Model\OrganizationInterface;
20
use SWP\Component\MultiTenancy\Repository\OrganizationRepositoryInterface;
21
use Symfony\Component\Console\Application;
22
use Symfony\Component\Console\Tester\CommandTester;
23
24
class CreateOrganizationCommandTest extends \PHPUnit_Framework_TestCase
25
{
26
    private $commandTester;
27
    private $command;
28
    private $dialog;
29
30 View Code Duplication
    public function setUp()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
31
    {
32
        $application = new Application();
33
        $application->add(new CreateOrganizationCommand());
34
        $this->command = $application->get('swp:organization:create');
35
        $this->dialog = $this->command->getHelper('dialog');
36
    }
37
38
    /**
39
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
40
     */
41 View Code Duplication
    public function testExecuteWhenCreatingNewOrganization()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
42
    {
43
        $this->dialog->setInputStream($this->getInputStream("Test\n"));
44
        $this->command->setContainer($this->getMockContainer(null, new Organization(), 'Test'));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Console\Command\Command as the method setContainer() does only exist in the following sub-classes of Symfony\Component\Console\Command\Command: Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...Command\DoctrineCommand, Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...EntitiesDoctrineCommand, Doctrine\Bundle\Doctrine...tMappingDoctrineCommand, Doctrine\Bundle\Doctrine...le\Command\CacheCommand, Doctrine\Bundle\Doctrine...Command\ContainsCommand, Doctrine\Bundle\Doctrine...e\Command\DeleteCommand, Doctrine\Bundle\Doctrine...le\Command\FlushCommand, Doctrine\Bundle\Doctrine...le\Command\StatsCommand, Doctrine\Bundle\PHPCRBun...mand\LoadFixtureCommand, Doctrine\Bundle\PHPCRBun...\MigratorMigrateCommand, Doctrine\Bundle\PHPCRBun...Command\NodeDumpCommand, Doctrine\Bundle\PHPCRBun...mmand\PhpcrShellCommand, Doctrine\Bundle\PHPCRBun...d\RepositoryInitCommand, SWP\Bundle\MultiTenancyB...eateOrganizationCommand, SWP\Bundle\MultiTenancyB...and\CreateTenantCommand, SWP\Bundle\MultiTenancyB...istOrganizationsCommand, Symfony\Bundle\Framework...d\AbstractConfigCommand, Symfony\Bundle\Framework...nd\AssetsInstallCommand, Symfony\Bundle\Framework...mmand\CacheClearCommand, Symfony\Bundle\Framework...mand\CacheWarmupCommand, Symfony\Bundle\Framework...mand\ConfigDebugCommand, Symfony\Bundle\Framework...figDumpReferenceCommand, Symfony\Bundle\Framework...d\ContainerAwareCommand, Symfony\Bundle\Framework...d\ContainerDebugCommand, Symfony\Bundle\Framework...tDispatcherDebugCommand, Symfony\Bundle\Framework...uterApacheDumperCommand, Symfony\Bundle\Framework...mand\RouterDebugCommand, Symfony\Bundle\Framework...mand\RouterMatchCommand, Symfony\Bundle\Framework...e\Command\ServerCommand, Symfony\Bundle\Framework...ommand\ServerRunCommand, Symfony\Bundle\Framework...mand\ServerStartCommand, Symfony\Bundle\Framework...and\ServerStatusCommand, Symfony\Bundle\Framework...mmand\ServerStopCommand, Symfony\Bundle\Framework...TranslationDebugCommand, Symfony\Bundle\Framework...ranslationUpdateCommand. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
45
        $this->commandTester = new CommandTester($this->command);
46
        $this->commandTester->execute(['command' => $this->command->getName()]);
47
48
        $this->assertRegExp(
49
            '/Please enter name:Organization Test has been created and enabled!/',
50
            $this->commandTester->getDisplay()
51
        );
52
    }
53
54
    /**
55
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
56
     */
57 View Code Duplication
    public function testExecuteWhenCreatingDefaultOrganization()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
    {
59
        $this->command->setContainer($this->getMockContainer(null, new Organization()));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Console\Command\Command as the method setContainer() does only exist in the following sub-classes of Symfony\Component\Console\Command\Command: Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...Command\DoctrineCommand, Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...EntitiesDoctrineCommand, Doctrine\Bundle\Doctrine...tMappingDoctrineCommand, Doctrine\Bundle\Doctrine...le\Command\CacheCommand, Doctrine\Bundle\Doctrine...Command\ContainsCommand, Doctrine\Bundle\Doctrine...e\Command\DeleteCommand, Doctrine\Bundle\Doctrine...le\Command\FlushCommand, Doctrine\Bundle\Doctrine...le\Command\StatsCommand, Doctrine\Bundle\PHPCRBun...mand\LoadFixtureCommand, Doctrine\Bundle\PHPCRBun...\MigratorMigrateCommand, Doctrine\Bundle\PHPCRBun...Command\NodeDumpCommand, Doctrine\Bundle\PHPCRBun...mmand\PhpcrShellCommand, Doctrine\Bundle\PHPCRBun...d\RepositoryInitCommand, SWP\Bundle\MultiTenancyB...eateOrganizationCommand, SWP\Bundle\MultiTenancyB...and\CreateTenantCommand, SWP\Bundle\MultiTenancyB...istOrganizationsCommand, Symfony\Bundle\Framework...d\AbstractConfigCommand, Symfony\Bundle\Framework...nd\AssetsInstallCommand, Symfony\Bundle\Framework...mmand\CacheClearCommand, Symfony\Bundle\Framework...mand\CacheWarmupCommand, Symfony\Bundle\Framework...mand\ConfigDebugCommand, Symfony\Bundle\Framework...figDumpReferenceCommand, Symfony\Bundle\Framework...d\ContainerAwareCommand, Symfony\Bundle\Framework...d\ContainerDebugCommand, Symfony\Bundle\Framework...tDispatcherDebugCommand, Symfony\Bundle\Framework...uterApacheDumperCommand, Symfony\Bundle\Framework...mand\RouterDebugCommand, Symfony\Bundle\Framework...mand\RouterMatchCommand, Symfony\Bundle\Framework...e\Command\ServerCommand, Symfony\Bundle\Framework...ommand\ServerRunCommand, Symfony\Bundle\Framework...mand\ServerStartCommand, Symfony\Bundle\Framework...and\ServerStatusCommand, Symfony\Bundle\Framework...mmand\ServerStopCommand, Symfony\Bundle\Framework...TranslationDebugCommand, Symfony\Bundle\Framework...ranslationUpdateCommand. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
60
        $this->commandTester = new CommandTester($this->command);
61
62
        $this->commandTester->execute([
63
            'command' => $this->command->getName(),
64
            '--default' => true,
65
        ]);
66
67
        $this->assertRegExp(
68
            '/Organization default has been created and enabled!/',
69
            $this->commandTester->getDisplay()
70
        );
71
    }
72
73
    /**
74
     * @expectedException \InvalidArgumentException
75
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
76
     */
77 View Code Duplication
    public function testExecuteWhenDefaultTenantExists()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
78
    {
79
        $this->command->setContainer($this->getMockContainer(new Organization()));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Console\Command\Command as the method setContainer() does only exist in the following sub-classes of Symfony\Component\Console\Command\Command: Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...Command\DoctrineCommand, Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...EntitiesDoctrineCommand, Doctrine\Bundle\Doctrine...tMappingDoctrineCommand, Doctrine\Bundle\Doctrine...le\Command\CacheCommand, Doctrine\Bundle\Doctrine...Command\ContainsCommand, Doctrine\Bundle\Doctrine...e\Command\DeleteCommand, Doctrine\Bundle\Doctrine...le\Command\FlushCommand, Doctrine\Bundle\Doctrine...le\Command\StatsCommand, Doctrine\Bundle\PHPCRBun...mand\LoadFixtureCommand, Doctrine\Bundle\PHPCRBun...\MigratorMigrateCommand, Doctrine\Bundle\PHPCRBun...Command\NodeDumpCommand, Doctrine\Bundle\PHPCRBun...mmand\PhpcrShellCommand, Doctrine\Bundle\PHPCRBun...d\RepositoryInitCommand, SWP\Bundle\MultiTenancyB...eateOrganizationCommand, SWP\Bundle\MultiTenancyB...and\CreateTenantCommand, SWP\Bundle\MultiTenancyB...istOrganizationsCommand, Symfony\Bundle\Framework...d\AbstractConfigCommand, Symfony\Bundle\Framework...nd\AssetsInstallCommand, Symfony\Bundle\Framework...mmand\CacheClearCommand, Symfony\Bundle\Framework...mand\CacheWarmupCommand, Symfony\Bundle\Framework...mand\ConfigDebugCommand, Symfony\Bundle\Framework...figDumpReferenceCommand, Symfony\Bundle\Framework...d\ContainerAwareCommand, Symfony\Bundle\Framework...d\ContainerDebugCommand, Symfony\Bundle\Framework...tDispatcherDebugCommand, Symfony\Bundle\Framework...uterApacheDumperCommand, Symfony\Bundle\Framework...mand\RouterDebugCommand, Symfony\Bundle\Framework...mand\RouterMatchCommand, Symfony\Bundle\Framework...e\Command\ServerCommand, Symfony\Bundle\Framework...ommand\ServerRunCommand, Symfony\Bundle\Framework...mand\ServerStartCommand, Symfony\Bundle\Framework...and\ServerStatusCommand, Symfony\Bundle\Framework...mmand\ServerStopCommand, Symfony\Bundle\Framework...TranslationDebugCommand, Symfony\Bundle\Framework...ranslationUpdateCommand. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
80
        $this->commandTester = new CommandTester($this->command);
81
82
        $this->commandTester->execute([
83
            'command' => $this->command->getName(),
84
            '--default' => true,
85
        ]);
86
    }
87
88
    /**
89
     * @covers SWP\Bundle\MultiTenancyBundle\Command\CreateOrganizationCommand
90
     */
91 View Code Duplication
    public function testExecuteDisabledOrganization()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
92
    {
93
        $this->dialog->setInputStream($this->getInputStream("Example\n"));
94
        $this->command->setContainer($this->getMockContainer(null, new Organization(), 'Example'));
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class Symfony\Component\Console\Command\Command as the method setContainer() does only exist in the following sub-classes of Symfony\Component\Console\Command\Command: Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...Command\DoctrineCommand, Doctrine\Bundle\Doctrine...DatabaseDoctrineCommand, Doctrine\Bundle\Doctrine...EntitiesDoctrineCommand, Doctrine\Bundle\Doctrine...tMappingDoctrineCommand, Doctrine\Bundle\Doctrine...le\Command\CacheCommand, Doctrine\Bundle\Doctrine...Command\ContainsCommand, Doctrine\Bundle\Doctrine...e\Command\DeleteCommand, Doctrine\Bundle\Doctrine...le\Command\FlushCommand, Doctrine\Bundle\Doctrine...le\Command\StatsCommand, Doctrine\Bundle\PHPCRBun...mand\LoadFixtureCommand, Doctrine\Bundle\PHPCRBun...\MigratorMigrateCommand, Doctrine\Bundle\PHPCRBun...Command\NodeDumpCommand, Doctrine\Bundle\PHPCRBun...mmand\PhpcrShellCommand, Doctrine\Bundle\PHPCRBun...d\RepositoryInitCommand, SWP\Bundle\MultiTenancyB...eateOrganizationCommand, SWP\Bundle\MultiTenancyB...and\CreateTenantCommand, SWP\Bundle\MultiTenancyB...istOrganizationsCommand, Symfony\Bundle\Framework...d\AbstractConfigCommand, Symfony\Bundle\Framework...nd\AssetsInstallCommand, Symfony\Bundle\Framework...mmand\CacheClearCommand, Symfony\Bundle\Framework...mand\CacheWarmupCommand, Symfony\Bundle\Framework...mand\ConfigDebugCommand, Symfony\Bundle\Framework...figDumpReferenceCommand, Symfony\Bundle\Framework...d\ContainerAwareCommand, Symfony\Bundle\Framework...d\ContainerDebugCommand, Symfony\Bundle\Framework...tDispatcherDebugCommand, Symfony\Bundle\Framework...uterApacheDumperCommand, Symfony\Bundle\Framework...mand\RouterDebugCommand, Symfony\Bundle\Framework...mand\RouterMatchCommand, Symfony\Bundle\Framework...e\Command\ServerCommand, Symfony\Bundle\Framework...ommand\ServerRunCommand, Symfony\Bundle\Framework...mand\ServerStartCommand, Symfony\Bundle\Framework...and\ServerStatusCommand, Symfony\Bundle\Framework...mmand\ServerStopCommand, Symfony\Bundle\Framework...TranslationDebugCommand, Symfony\Bundle\Framework...ranslationUpdateCommand. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
95
        $this->commandTester = new CommandTester($this->command);
96
        $this->commandTester->execute([
97
            'command' => $this->command->getName(),
98
            '--disabled' => true,
99
        ]);
100
101
        $this->assertRegExp(
102
            '/Please enter name:Organization Example has been created and disabled!/',
103
            $this->commandTester->getDisplay()
104
        );
105
    }
106
107
    private function getMockContainer($mockOrganization = null, $mockedOrganizationInFactory = null, $name = OrganizationInterface::DEFAULT_NAME)
108
    {
109
        $mockRepo = $this->getMockBuilder(OrganizationRepositoryInterface::class)
110
            ->getMock();
111
112
        $mockRepo->expects($this->any())
113
            ->method('findOneByName')
114
            ->with($name)
115
            ->willReturn($mockOrganization);
116
117
        $mockDoctrine = $this
118
            ->getMockBuilder('Doctrine\ORM\EntityManager')
119
            ->disableOriginalConstructor()
120
            ->getMock();
121
122
        $mockDoctrine->expects($this->any())
123
            ->method('persist')
124
            ->will($this->returnValue(null));
125
        $mockDoctrine->expects($this->any())
126
            ->method('flush')
127
            ->will($this->returnValue(null));
128
129
        $mockFactory = $this->getMockBuilder(OrganizationFactoryInterface::class)
130
            ->getMock();
131
132
        $mockFactory->expects($this->any())
133
            ->method('createWithCode')
134
            ->willReturn($mockedOrganizationInFactory);
135
136
        $mockContainer = $this->getMockBuilder('Symfony\Component\DependencyInjection\Container')
137
            ->getMock();
138
139
        $mockContainer->expects($this->any())
140
            ->method('get')
141
            ->will($this->returnValueMap([
142
                ['swp.object_manager.organization', 1, $mockDoctrine],
143
                ['swp.repository.organization', 1, $mockRepo],
144
                ['swp.factory.organization', 1, $mockFactory],
145
            ]));
146
147
        return $mockContainer;
148
    }
149
150
    /**
151
     * @param $input
152
     *
153
     * @return resource
154
     */
155 View Code Duplication
    protected function getInputStream($input)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
156
    {
157
        $stream = fopen('php://memory', 'r+', false);
158
        fwrite($stream, $input);
159
        rewind($stream);
160
161
        return $stream;
162
    }
163
}
164