Completed
Pull Request — master (#1218)
by
unknown
01:23
created
SWP/Bundle/CoreBundle/EventListener/DownloadArticleAuthorAvatarListener.php 2 patches
Indentation   +66 added lines, -66 removed lines patch added patch discarded remove patch
@@ -34,87 +34,87 @@  discard block
 block discarded – undo
34 34
 use SWP\Component\Common\Exception\UnexpectedTypeException;
35 35
 
36 36
 final class DownloadArticleAuthorAvatarListener {
37
-  /**
38
-   * @var MediaManagerInterface
39
-   */
40
-  private $authorMediaManager;
41
-
42
-  /**
43
-   * @var EntityManagerInterface
44
-   */
45
-  private $entityManager;
46
-
47
-  /**
48
-   * @var string
49
-   */
50
-  private $cacheDirectory;
51
-
52
-  public function __construct(EntityManagerInterface $entityManager, $cacheDirectory) {
37
+    /**
38
+     * @var MediaManagerInterface
39
+     */
40
+    private $authorMediaManager;
41
+
42
+    /**
43
+     * @var EntityManagerInterface
44
+     */
45
+    private $entityManager;
46
+
47
+    /**
48
+     * @var string
49
+     */
50
+    private $cacheDirectory;
51
+
52
+    public function __construct(EntityManagerInterface $entityManager, $cacheDirectory) {
53 53
     $this->entityManager = $entityManager;
54 54
     $this->cacheDirectory = $cacheDirectory;
55
-  }
55
+    }
56 56
 
57
-  /**
58
-   * @param MediaManagerInterface $authorMediaManager
59
-   */
60
-  public function setAuthorMediaManager(MediaManagerInterface $authorMediaManager) {
57
+    /**
58
+     * @param MediaManagerInterface $authorMediaManager
59
+     */
60
+    public function setAuthorMediaManager(MediaManagerInterface $authorMediaManager) {
61 61
     $this->authorMediaManager = $authorMediaManager;
62
-  }
62
+    }
63 63
 
64
-  /**
65
-   * @param GenericEvent $event
66
-   */
67
-  public function processAuthors(GenericEvent $event): void {
64
+    /**
65
+     * @param GenericEvent $event
66
+     */
67
+    public function processAuthors(GenericEvent $event): void {
68 68
     $package = $event->getSubject();
69 69
 
70 70
     if (!$package instanceof PackageInterface) {
71
-      throw new UnexpectedTypeException($package, PackageInterface::class);
71
+        throw new UnexpectedTypeException($package, PackageInterface::class);
72 72
     }
73 73
 
74 74
     $authors = [];
75 75
     /** @var ArticleAuthorInterface $packageAuthor */
76 76
     foreach ($package->getAuthors() as $packageAuthor) {
77
-      $authors[] = $this->handle($packageAuthor);
77
+        $authors[] = $this->handle($packageAuthor);
78 78
     }
79 79
     $package->setAuthors(new ArrayCollection($authors));
80
-  }
81
-
82
-  /**
83
-   * @param ArticleAuthorInterface $object
84
-   *
85
-   * @return ArticleAuthorInterface
86
-   */
87
-  private function handle(ArticleAuthorInterface $object): ArticleAuthorInterface {
80
+    }
81
+
82
+    /**
83
+     * @param ArticleAuthorInterface $object
84
+     *
85
+     * @return ArticleAuthorInterface
86
+     */
87
+    private function handle(ArticleAuthorInterface $object): ArticleAuthorInterface {
88 88
     if (null !== $object->getAvatarUrl()) {
89
-      $filesystem = new Filesystem();
90
-      $pathParts = \pathinfo($object->getAvatarUrl());
91
-      $assetId = \sha1($pathParts['filename']);
92
-      if (null !== $object->getSlug()) {
89
+        $filesystem = new Filesystem();
90
+        $pathParts = \pathinfo($object->getAvatarUrl());
91
+        $assetId = \sha1($pathParts['filename']);
92
+        if (null !== $object->getSlug()) {
93 93
         $assetId = $object->getSlug() . '_' . $assetId;
94
-      }
95
-      $existingAvatar = $this->entityManager->getRepository(Image::class)->findBy(['assetId' => $assetId]);
96
-      if (\count($existingAvatar) > 0) {
94
+        }
95
+        $existingAvatar = $this->entityManager->getRepository(Image::class)->findBy(['assetId' => $assetId]);
96
+        if (\count($existingAvatar) > 0) {
97 97
         $object->setAvatarUrl((string)\reset($existingAvatar));
98 98
 
99 99
         return $object;
100
-      }
100
+        }
101 101
 
102
-      try {
102
+        try {
103 103
         $tempDirectory = $this->cacheDirectory . \DIRECTORY_SEPARATOR . 'downloaded_avatars';
104 104
         $tempLocation = $tempDirectory . \DIRECTORY_SEPARATOR . \sha1($assetId . date('his'));
105 105
         if (!$filesystem->exists($tempDirectory)) {
106
-          $filesystem->mkdir($tempDirectory);
106
+            $filesystem->mkdir($tempDirectory);
107 107
         }
108 108
 
109 109
         $avatarUrl = $object->getAvatarUrl();
110 110
         if (strpos($avatarUrl, "http://") === 0 || strpos($avatarUrl, "https://") === 0) {
111
-          self::downloadFile($avatarUrl, $tempLocation);
111
+            self::downloadFile($avatarUrl, $tempLocation);
112 112
         } else {
113
-          $file = \file_get_contents($avatarUrl);
114
-          if (false === $file) {
113
+            $file = \file_get_contents($avatarUrl);
114
+            if (false === $file) {
115 115
             throw new \Exception('File can\'t be downloaded');
116
-          }
117
-          $filesystem->dumpFile($tempLocation, $file);
116
+            }
117
+            $filesystem->dumpFile($tempLocation, $file);
118 118
         }
119 119
 
120 120
         $uploadedFile = new UploadedFile($tempLocation,
@@ -123,29 +123,29 @@  discard block
 block discarded – undo
123 123
             \filesize($tempLocation),
124 124
             true
125 125
         );
126
-      } catch (\Exception $e) {
126
+        } catch (\Exception $e) {
127 127
         return $object;
128
-      }
129
-      /** @var Image $image */
130
-      $image = $this->authorMediaManager->handleUploadedFile($uploadedFile, $assetId);
131
-      $avatar = $this->createAuthorMedia($object, $image);
132
-      $this->entityManager->persist($avatar);
133
-      $this->entityManager->persist($image);
134
-
135
-      $object->setAvatar($avatar);
136
-      $object->setAvatarUrl((string)$image);
128
+        }
129
+        /** @var Image $image */
130
+        $image = $this->authorMediaManager->handleUploadedFile($uploadedFile, $assetId);
131
+        $avatar = $this->createAuthorMedia($object, $image);
132
+        $this->entityManager->persist($avatar);
133
+        $this->entityManager->persist($image);
134
+
135
+        $object->setAvatar($avatar);
136
+        $object->setAvatarUrl((string)$image);
137 137
     }
138 138
 
139 139
     return $object;
140
-  }
140
+    }
141 141
 
142
-  private function createAuthorMedia(ArticleAuthorInterface $articleAuthor, Image $image): AuthorMediaInterface {
142
+    private function createAuthorMedia(ArticleAuthorInterface $articleAuthor, Image $image): AuthorMediaInterface {
143 143
     return new AuthorMedia('avatar', $articleAuthor, $image);
144
-  }
144
+    }
145 145
 
146
-  private static function downloadFile($url, $location) {
146
+    private static function downloadFile($url, $location) {
147 147
     $handlerStack = HandlerStack::create(new CurlHandler());
148 148
     $client = new Client(['handler' => $handlerStack]);
149 149
     $client->request('GET', $url, ['sink' => $location]);
150
-  }
150
+    }
151 151
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -90,18 +90,18 @@  discard block
 block discarded – undo
90 90
       $pathParts = \pathinfo($object->getAvatarUrl());
91 91
       $assetId = \sha1($pathParts['filename']);
92 92
       if (null !== $object->getSlug()) {
93
-        $assetId = $object->getSlug() . '_' . $assetId;
93
+        $assetId = $object->getSlug().'_'.$assetId;
94 94
       }
95 95
       $existingAvatar = $this->entityManager->getRepository(Image::class)->findBy(['assetId' => $assetId]);
96 96
       if (\count($existingAvatar) > 0) {
97
-        $object->setAvatarUrl((string)\reset($existingAvatar));
97
+        $object->setAvatarUrl((string) \reset($existingAvatar));
98 98
 
99 99
         return $object;
100 100
       }
101 101
 
102 102
       try {
103
-        $tempDirectory = $this->cacheDirectory . \DIRECTORY_SEPARATOR . 'downloaded_avatars';
104
-        $tempLocation = $tempDirectory . \DIRECTORY_SEPARATOR . \sha1($assetId . date('his'));
103
+        $tempDirectory = $this->cacheDirectory.\DIRECTORY_SEPARATOR.'downloaded_avatars';
104
+        $tempLocation = $tempDirectory.\DIRECTORY_SEPARATOR.\sha1($assetId.date('his'));
105 105
         if (!$filesystem->exists($tempDirectory)) {
106 106
           $filesystem->mkdir($tempDirectory);
107 107
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
       $this->entityManager->persist($image);
134 134
 
135 135
       $object->setAvatar($avatar);
136
-      $object->setAvatarUrl((string)$image);
136
+      $object->setAvatarUrl((string) $image);
137 137
     }
138 138
 
139 139
     return $object;
Please login to merge, or discard this patch.
src/SWP/Bundle/MultiTenancyBundle/Context/TenantContext.php 2 patches
Indentation   +45 added lines, -45 removed lines patch added patch discarded remove patch
@@ -27,76 +27,76 @@
 block discarded – undo
27 27
  * Class TenantContext.
28 28
  */
29 29
 class TenantContext implements TenantContextInterface {
30
-  /**
31
-   * @var TenantInterface
32
-   */
33
-  protected $tenant;
34
-
35
-  /**
36
-   * @var TenantResolverInterface
37
-   */
38
-  protected $tenantResolver;
39
-
40
-  /**
41
-   * @var RequestStack
42
-   */
43
-  protected $requestStack;
44
-
45
-  /**
46
-   * @var EventDispatcherInterface
47
-   */
48
-  protected $dispatcher;
49
-
50
-  /**
51
-   * TenantContext constructor.
52
-   */
53
-  public function __construct(TenantResolverInterface  $tenantResolver, RequestStack $requestStack,
54
-                              EventDispatcherInterface $dispatcher) {
30
+    /**
31
+     * @var TenantInterface
32
+     */
33
+    protected $tenant;
34
+
35
+    /**
36
+     * @var TenantResolverInterface
37
+     */
38
+    protected $tenantResolver;
39
+
40
+    /**
41
+     * @var RequestStack
42
+     */
43
+    protected $requestStack;
44
+
45
+    /**
46
+     * @var EventDispatcherInterface
47
+     */
48
+    protected $dispatcher;
49
+
50
+    /**
51
+     * TenantContext constructor.
52
+     */
53
+    public function __construct(TenantResolverInterface  $tenantResolver, RequestStack $requestStack,
54
+                                EventDispatcherInterface $dispatcher) {
55 55
     $this->tenantResolver = $tenantResolver;
56 56
     $this->requestStack = $requestStack;
57 57
     $this->dispatcher = $dispatcher;
58
-  }
58
+    }
59 59
 
60
-  /**
61
-   * {@inheritdoc}
62
-   */
63
-  public function getTenant() {
60
+    /**
61
+     * {@inheritdoc}
62
+     */
63
+    public function getTenant() {
64 64
     if (null === $this->tenant || !$this->isHostSame()) {
65
-      $currentRequest = $this->requestStack->getCurrentRequest();
65
+        $currentRequest = $this->requestStack->getCurrentRequest();
66 66
 
67
-      if (null !== $currentRequest && false !== strpos($currentRequest->getRequestUri(), '_profiler')) {
67
+        if (null !== $currentRequest && false !== strpos($currentRequest->getRequestUri(), '_profiler')) {
68 68
         $profilerTenant = new Tenant();
69 69
         $profilerTenant->setDomainName($currentRequest->getHost());
70 70
         $this->setTenant($profilerTenant);
71 71
 
72 72
         return $this->tenant;
73
-      }
73
+        }
74 74
 
75
-      $this->setTenant($this->tenantResolver->resolve(
76
-          $currentRequest ? $currentRequest->getHost() : null
77
-      ));
75
+        $this->setTenant($this->tenantResolver->resolve(
76
+            $currentRequest ? $currentRequest->getHost() : null
77
+        ));
78 78
     }
79 79
 
80 80
     return $this->tenant;
81
-  }
81
+    }
82 82
 
83
-  /**
84
-   * {@inheritdoc}
85
-   */
86
-  public function setTenant(TenantInterface $tenant) {
83
+    /**
84
+     * {@inheritdoc}
85
+     */
86
+    public function setTenant(TenantInterface $tenant) {
87 87
     $this->tenant = $tenant;
88 88
 
89 89
     $this->dispatcher->dispatch(new GenericEvent($tenant), MultiTenancyEvents::TENANT_SET);
90
-  }
90
+    }
91 91
 
92
-  protected function isHostSame() {
92
+    protected function isHostSame() {
93 93
     if ($this->tenant == null) {
94
-      return false;
94
+        return false;
95 95
     }
96 96
 
97 97
     $currentRequest = $this->requestStack->getCurrentRequest();
98 98
     $host = $currentRequest !== null ? $currentRequest->getHost() : 'localhost';
99 99
     $tenantHost = $this->tenant->getSubdomain() ? $this->tenant->getSubdomain() . '.' . $this->tenant->getDomainName() : $this->tenant->getDomainName();
100 100
     return $host === $tenantHost;
101
-  }
101
+    }
102 102
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -96,7 +96,7 @@
 block discarded – undo
96 96
 
97 97
     $currentRequest = $this->requestStack->getCurrentRequest();
98 98
     $host = $currentRequest !== null ? $currentRequest->getHost() : 'localhost';
99
-    $tenantHost = $this->tenant->getSubdomain() ? $this->tenant->getSubdomain() . '.' . $this->tenant->getDomainName() : $this->tenant->getDomainName();
99
+    $tenantHost = $this->tenant->getSubdomain() ? $this->tenant->getSubdomain().'.'.$this->tenant->getDomainName() : $this->tenant->getDomainName();
100 100
     return $host === $tenantHost;
101 101
   }
102 102
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/UserBundle/Controller/ResetPasswordController.php 1 patch
Indentation   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -36,88 +36,88 @@  discard block
 block discarded – undo
36 36
  * @Route("/reset-password")
37 37
  */
38 38
 class ResetPasswordController extends AbstractController {
39
-  use ResetPasswordControllerTrait;
39
+    use ResetPasswordControllerTrait;
40 40
 
41
-  private ResetPasswordHelperInterface $resetPasswordHelper;
42
-  private EntityManagerInterface  $entityManager;
41
+    private ResetPasswordHelperInterface $resetPasswordHelper;
42
+    private EntityManagerInterface  $entityManager;
43 43
 
44
-  /**
45
-   * @param ResetPasswordHelperInterface $resetPasswordHelper
46
-   * @param EntityManagerInterface $entityManager
47
-   */
48
-  public function __construct(ResetPasswordHelperInterface $resetPasswordHelper,
49
-                              EntityManagerInterface       $entityManager) {
44
+    /**
45
+     * @param ResetPasswordHelperInterface $resetPasswordHelper
46
+     * @param EntityManagerInterface $entityManager
47
+     */
48
+    public function __construct(ResetPasswordHelperInterface $resetPasswordHelper,
49
+                                EntityManagerInterface       $entityManager) {
50 50
     $this->resetPasswordHelper = $resetPasswordHelper;
51 51
     $this->entityManager = $entityManager;
52
-  }
52
+    }
53 53
 
54 54
 
55
-  /**
56
-   * Display & process form to request a password reset.
57
-   *
58
-   * @Route("", name="swp_user_forgot_password_request")
59
-   */
60
-  public function request(Request $request, MailerInterface $mailer): Response {
55
+    /**
56
+     * Display & process form to request a password reset.
57
+     *
58
+     * @Route("", name="swp_user_forgot_password_request")
59
+     */
60
+    public function request(Request $request, MailerInterface $mailer): Response {
61 61
     $form = $this->createForm(ResetPasswordRequestFormType::class);
62 62
     $form->handleRequest($request);
63 63
 
64 64
     if ($form->isSubmitted() && $form->isValid()) {
65
-      return $this->processSendingPasswordResetEmail(
66
-          $form->get('email')->getData(),
67
-          $mailer
68
-      );
65
+        return $this->processSendingPasswordResetEmail(
66
+            $form->get('email')->getData(),
67
+            $mailer
68
+        );
69 69
     }
70 70
 
71 71
     return $this->render('@SWPUser/reset_password/request.html.twig', [
72 72
         'requestForm' => $form->createView(),
73 73
     ]);
74
-  }
75
-
76
-  /**
77
-   * Confirmation page after a user has requested a password reset.
78
-   *
79
-   * @Route("/check-email", name="swp_user_check_email")
80
-   */
81
-  public function checkEmail(): Response {
74
+    }
75
+
76
+    /**
77
+     * Confirmation page after a user has requested a password reset.
78
+     *
79
+     * @Route("/check-email", name="swp_user_check_email")
80
+     */
81
+    public function checkEmail(): Response {
82 82
     // We prevent users from directly accessing this page
83 83
     if (!$this->canCheckEmail()) {
84
-      return $this->redirectToRoute('swp_user_forgot_password_request');
84
+        return $this->redirectToRoute('swp_user_forgot_password_request');
85 85
     }
86 86
 
87 87
     return $this->render('@SWPUser/reset_password/check_email.html.twig', [
88 88
         'tokenLifetime' => $this->resetPasswordHelper->getTokenLifetime(),
89 89
     ]);
90
-  }
91
-
92
-  /**
93
-   * Validates and process the reset URL that the user clicked in their email.
94
-   *
95
-   * @Route("/reset/{token}", name="swp_user_reset_password")
96
-   */
97
-  public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder,
90
+    }
91
+
92
+    /**
93
+     * Validates and process the reset URL that the user clicked in their email.
94
+     *
95
+     * @Route("/reset/{token}", name="swp_user_reset_password")
96
+     */
97
+    public function reset(Request $request, UserPasswordEncoderInterface $passwordEncoder,
98 98
                         string  $token = null): Response {
99 99
     if ($token) {
100
-      // We store the token in session and remove it from the URL, to avoid the URL being
101
-      // loaded in a browser and potentially leaking the token to 3rd party JavaScript.
102
-      $this->storeTokenInSession($token);
100
+        // We store the token in session and remove it from the URL, to avoid the URL being
101
+        // loaded in a browser and potentially leaking the token to 3rd party JavaScript.
102
+        $this->storeTokenInSession($token);
103 103
 
104
-      return $this->redirectToRoute('swp_user_reset_password');
104
+        return $this->redirectToRoute('swp_user_reset_password');
105 105
     }
106 106
 
107 107
     $token = $this->getTokenFromSession();
108 108
     if (null === $token) {
109
-      throw $this->createNotFoundException('No reset password token found in the URL or in the session.');
109
+        throw $this->createNotFoundException('No reset password token found in the URL or in the session.');
110 110
     }
111 111
 
112 112
     try {
113
-      $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
113
+        $user = $this->resetPasswordHelper->validateTokenAndFetchUser($token);
114 114
     } catch (ResetPasswordExceptionInterface $e) {
115
-      $this->addFlash('reset_password_error', sprintf(
116
-          'There was a problem validating your reset request - %s',
117
-          $e->getReason()
118
-      ));
115
+        $this->addFlash('reset_password_error', sprintf(
116
+            'There was a problem validating your reset request - %s',
117
+            $e->getReason()
118
+        ));
119 119
 
120
-      return $this->redirectToRoute('swp_user_forgot_password_request');
120
+        return $this->redirectToRoute('swp_user_forgot_password_request');
121 121
     }
122 122
 
123 123
     // The token is valid; allow the user to change their password.
@@ -125,30 +125,30 @@  discard block
 block discarded – undo
125 125
     $form->handleRequest($request);
126 126
 
127 127
     if ($form->isSubmitted() && $form->isValid()) {
128
-      // A password reset token should be used only once, remove it.
129
-      $this->resetPasswordHelper->removeResetRequest($token);
128
+        // A password reset token should be used only once, remove it.
129
+        $this->resetPasswordHelper->removeResetRequest($token);
130 130
 
131
-      // Encode the plain password, and set it.
132
-      $encodedPassword = $passwordEncoder->encodePassword(
133
-          $user,
134
-          $form->get('plainPassword')->getData()
135
-      );
131
+        // Encode the plain password, and set it.
132
+        $encodedPassword = $passwordEncoder->encodePassword(
133
+            $user,
134
+            $form->get('plainPassword')->getData()
135
+        );
136 136
 
137
-      $user->setPassword($encodedPassword);
138
-      $this->entityManager->flush();
137
+        $user->setPassword($encodedPassword);
138
+        $this->entityManager->flush();
139 139
 
140
-      // The session is cleaned up after the password has been changed.
141
-      $this->cleanSessionAfterReset();
140
+        // The session is cleaned up after the password has been changed.
141
+        $this->cleanSessionAfterReset();
142 142
 
143
-      return $this->redirectToRoute('homepage');
143
+        return $this->redirectToRoute('homepage');
144 144
     }
145 145
 
146 146
     return $this->render('@SWPUser/reset_password/reset.html.twig', [
147 147
         'resetForm' => $form->createView(),
148 148
     ]);
149
-  }
149
+    }
150 150
 
151
-  private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse {
151
+    private function processSendingPasswordResetEmail(string $emailFormData, MailerInterface $mailer): RedirectResponse {
152 152
     $user = $this->entityManager->getRepository(User::class)->findOneBy([
153 153
         'email' => $emailFormData,
154 154
     ]);
@@ -158,22 +158,22 @@  discard block
 block discarded – undo
158 158
 
159 159
     // Do not reveal whether a user account was found or not.
160 160
     if (!$user) {
161
-      return $this->redirectToRoute('swp_user_check_email');
161
+        return $this->redirectToRoute('swp_user_check_email');
162 162
     }
163 163
 
164 164
     try {
165
-      $resetToken = $this->resetPasswordHelper->generateResetToken($user);
165
+        $resetToken = $this->resetPasswordHelper->generateResetToken($user);
166 166
     } catch (ResetPasswordExceptionInterface $e) {
167
-      $this->addFlash('reset_password_error', sprintf(
168
-          'There was a problem handling your password reset request - %s',
169
-          $e->getReason()
170
-      ));
167
+        $this->addFlash('reset_password_error', sprintf(
168
+            'There was a problem handling your password reset request - %s',
169
+            $e->getReason()
170
+        ));
171 171
 
172
-      return $this->redirectToRoute('swp_user_check_email');
172
+        return $this->redirectToRoute('swp_user_check_email');
173 173
     }
174 174
 
175 175
     $mailer->sendResetPasswordEmail($user, $resetToken);
176 176
 
177 177
     return $this->redirectToRoute('swp_user_check_email');
178
-  }
178
+    }
179 179
 }
Please login to merge, or discard this patch.
src/SWP/Bundle/FixturesBundle/WebTestCase.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -23,75 +23,75 @@
 block discarded – undo
23 23
 use Symfony\Bundle\FrameworkBundle\KernelBrowser;
24 24
 
25 25
 class WebTestCase extends BaseWebTestCase {
26
-  protected ?AbstractDatabaseTool $databaseTool;
27
-  private static ?KernelBrowser $client = null;
26
+    protected ?AbstractDatabaseTool $databaseTool;
27
+    private static ?KernelBrowser $client = null;
28 28
 
29
-  public function setUp(): void {
29
+    public function setUp(): void {
30 30
     if (self::$client == null) {
31
-      self::$client = parent::createClient();
31
+        self::$client = parent::createClient();
32 32
     }
33 33
     $this->databaseTool = static::getContainer()->get(DatabaseToolCollection::class)->get();
34
-  }
34
+    }
35 35
 
36
-  /**
37
-   * Initializes database.
38
-   */
39
-  protected function initDatabase() {
36
+    /**
37
+     * Initializes database.
38
+     */
39
+    protected function initDatabase() {
40 40
     $this->clearMetadataCache();
41
-  }
41
+    }
42 42
 
43
-  /**
44
-   * Clears metadata cache of the various cache drivers.
45
-   */
46
-  private function clearMetadataCache() {
43
+    /**
44
+     * Clears metadata cache of the various cache drivers.
45
+     */
46
+    private function clearMetadataCache() {
47 47
     $entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
48 48
     /** @var ClearableCache $cacheDriver */
49 49
     $cacheDriver = $entityManager->getConfiguration()->getMetadataCacheImpl();
50 50
 
51 51
     if (!$cacheDriver instanceof ArrayCache) {
52
-      $cacheDriver->deleteAll();
52
+        $cacheDriver->deleteAll();
53
+    }
53 54
     }
54
-  }
55 55
 
56
-  protected function tearDown(): void {
56
+    protected function tearDown(): void {
57 57
     unset($this->databaseTool);
58 58
     $reflection = new \ReflectionObject($this);
59 59
     foreach ($reflection->getProperties() as $prop) {
60
-      if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
60
+        if (!$prop->isStatic() && 0 !== strpos($prop->getDeclaringClass()->getName(), 'PHPUnit_')) {
61 61
         $prop->setAccessible(true);
62 62
         if ($prop->name == 'databaseTool') {
63
-          continue;
63
+            continue;
64 64
         }
65 65
         $prop->setValue($this, null);
66
-      }
66
+        }
67 67
     }
68 68
     parent::tearDown();
69
-  }
69
+    }
70 70
 
71
-  protected function loadCustomFixtures(array $fixtures) {
71
+    protected function loadCustomFixtures(array $fixtures) {
72 72
     $env = $this->getContainer()->getParameter('test_env');
73 73
 
74 74
     $registry = new FixtureRegistry();
75 75
     $registry->setEnvironment($env);
76 76
 
77 77
     return $this->databaseTool->loadFixtures($registry->getFixtures($fixtures))->getReferenceRepository();
78
-  }
78
+    }
79 79
 
80
-  public static function createClient(array $options = [], array $server = []) {
80
+    public static function createClient(array $options = [], array $server = []) {
81 81
     if (!array_key_exists('HTTP_Authorization', $server)) {
82
-      $server['HTTP_Authorization'] = base64_encode('test_token:');
82
+        $server['HTTP_Authorization'] = base64_encode('test_token:');
83 83
     }
84 84
 
85 85
     if (null === $server['HTTP_Authorization']) {
86
-      unset($server['HTTP_Authorization']);
86
+        unset($server['HTTP_Authorization']);
87 87
     }
88 88
 
89 89
     if(!array_key_exists("HTTP_HOST", $server)) {
90
-      $server['HTTP_HOST'] = 'localhost';
90
+        $server['HTTP_HOST'] = 'localhost';
91 91
     }
92 92
 
93 93
     $newClient = clone self::$client;
94 94
     $newClient->setServerParameters($server);
95 95
     return $newClient;
96
-  }
96
+    }
97 97
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -86,7 +86,7 @@
 block discarded – undo
86 86
       unset($server['HTTP_Authorization']);
87 87
     }
88 88
 
89
-    if(!array_key_exists("HTTP_HOST", $server)) {
89
+    if (!array_key_exists("HTTP_HOST", $server)) {
90 90
       $server['HTTP_HOST'] = 'localhost';
91 91
     }
92 92
 
Please login to merge, or discard this patch.