Completed
Branch master (0dfbed)
by Benedikt
07:50
created
src/Helpers/BasicEnum.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
@@ -32,9 +32,9 @@  discard block
 block discarded – undo
32 32
    * @param bool $strict if yes type checks are performed
33 33
    * @throws ValueNotValid if the value is not valid
34 34
    */
35
-  public static function ensureValidValue($value, bool $strict = true): void
35
+  public static function ensureValidValue( $value, bool $strict = true ): void
36 36
   {
37
-    if (!self::isValidValue($value, $strict)) {
37
+    if ( !self::isValidValue($value, $strict) ) {
38 38
       throw new ValueNotValid($value, get_called_class());
39 39
     }
40 40
   }
@@ -55,17 +55,17 @@  discard block
 block discarded – undo
55 55
    * @return mixed the corresponding value
56 56
    * @throws ValueNotValid if the name is not valid
57 57
    */
58
-  public static function getValue(string $name, bool $strict = false)
58
+  public static function getValue( string $name, bool $strict = false )
59 59
   {
60 60
     $constants = self::getConstants();
61
-    if ($strict) {
62
-      if (array_key_exists($name, $constants)) {
61
+    if ( $strict ) {
62
+      if ( array_key_exists($name, $constants) ) {
63 63
         return $constants[$name];
64 64
       }
65 65
     } else {
66 66
       $mapping = self::getCaseMapping();
67 67
       $key = strtolower($name);
68
-      if (array_key_exists($key, $mapping)) {
68
+      if ( array_key_exists($key, $mapping) ) {
69 69
         return $constants[$mapping[$key]];
70 70
       }
71 71
     }
@@ -88,11 +88,11 @@  discard block
 block discarded – undo
88 88
    * @param bool $strict if yes check is done case sensitive and otherwise case insensitive
89 89
    * @return bool true if the name is part of the enum and false otherwise
90 90
    */
91
-  public static function isValidName(string $name, bool $strict = false): bool
91
+  public static function isValidName( string $name, bool $strict = false ): bool
92 92
   {
93 93
     $constants = self::getConstants();
94 94
 
95
-    if ($strict) {
95
+    if ( $strict ) {
96 96
       return array_key_exists($name, $constants);
97 97
     }
98 98
 
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
    * @param bool $strict if yes type checks are performed
107 107
    * @return bool true if the value is part of the enum and false otherwise
108 108
    */
109
-  public static function isValidValue($value, bool $strict = true): bool
109
+  public static function isValidValue( $value, bool $strict = true ): bool
110 110
   {
111 111
     $values = self::getValues();
112 112
     return in_array($value, $values, $strict);
@@ -121,13 +121,13 @@  discard block
 block discarded – undo
121 121
    */
122 122
   private static function getCaseMapping(): array
123 123
   {
124
-    if (self::$constCacheArrayCaseMapping == NULL) {
124
+    if ( self::$constCacheArrayCaseMapping == NULL ) {
125 125
       self::$constCacheArrayCaseMapping = [];
126 126
     }
127 127
     $calledClass = get_called_class();
128
-    if (!array_key_exists($calledClass, self::$constCacheArrayCaseMapping)) {
128
+    if ( !array_key_exists($calledClass, self::$constCacheArrayCaseMapping) ) {
129 129
       self::$constCacheArrayCaseMapping[$calledClass] = [];
130
-      foreach (self::getNames() as $name) {
130
+      foreach ( self::getNames() as $name ) {
131 131
         self::$constCacheArrayCaseMapping[$calledClass][strtolower($name)] = $name;
132 132
       }
133 133
     }
@@ -141,11 +141,11 @@  discard block
 block discarded – undo
141 141
    */
142 142
   private static function getConstants(): array
143 143
   {
144
-    if (self::$constCacheArray == NULL) {
144
+    if ( self::$constCacheArray == NULL ) {
145 145
       self::$constCacheArray = [];
146 146
     }
147 147
     $calledClass = get_called_class();
148
-    if (!array_key_exists($calledClass, self::$constCacheArray)) {
148
+    if ( !array_key_exists($calledClass, self::$constCacheArray) ) {
149 149
       // ReflectionException => whe know that calledClass is a valid class since it is the result of get_called_class
150 150
       /** @noinspection PhpUnhandledExceptionInspection */
151 151
       $reflect = new \ReflectionClass($calledClass);
Please login to merge, or discard this patch.
src/Providers/FmLibServiceProvider.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
    */
45 45
   public function boot()
46 46
   {
47
-    include __DIR__ . '/../routes.php';
47
+    include __DIR__.'/../routes.php';
48 48
   }
49 49
 
50 50
   /** @noinspection PhpDocMissingThrowsInspection */ //\Doctrine\DBAL\DBALException
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
       Handler::class
64 64
     );
65 65
 
66
-    if ($this->app->environment() !== 'production') {
67
-      if (class_exists('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider')) {
66
+    if ( $this->app->environment() !== 'production' ) {
67
+      if ( class_exists('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider') ) {
68 68
         $this->app->register('\Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider');
69 69
       }
70 70
     }
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
     $this->app->register(GedmoExtensionsServiceProvider::class);
78 78
     $this->app->register(JwtAuthGuardServiceProvider::class);
79 79
 
80
-    $this->app->singleton(DynamicServiceLoadingServiceInterface::class, function (Container $app) {
80
+    $this->app->singleton(DynamicServiceLoadingServiceInterface::class, function( Container $app ) {
81 81
       return new DynamicServiceLoadingService($app);
82 82
     });
83 83
 
84
-    $this->app->singleton(RankingSystemServiceInterface::class, function (Container $app) {
84
+    $this->app->singleton(RankingSystemServiceInterface::class, function( Container $app ) {
85 85
       return new RankingSystemService($app->make(DynamicServiceLoadingServiceInterface::class),
86 86
         $app->make(EntityManagerInterface::class));
87 87
     });
88 88
 
89
-    $this->app->singleton(EloRankingInterface::class, function (Container $app) {
89
+    $this->app->singleton(EloRankingInterface::class, function( Container $app ) {
90 90
       $timeService = new RecursiveEndStartTimeService();
91 91
       $entityComparer = new EntityComparerByTimeStartTimeAndLocalIdentifier($timeService);
92 92
       return new EloRanking($app->make(EntityManagerInterface::class), $timeService, $entityComparer);
Please login to merge, or discard this patch.
src/TestHelpers/LumenTestCase.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Class TestCase
@@ -28,21 +28,21 @@  discard block
 block discarded – undo
28 28
    * @param mixed[] $enumProperties the enum properties to check, property name maps to an info array, which contains
29 29
    *                                the enum name and the default value
30 30
    */
31
-  protected function checkProperties(array $data, $object, array $properties, array $enumProperties = [])
31
+  protected function checkProperties( array $data, $object, array $properties, array $enumProperties = [] )
32 32
   {
33
-    foreach ($properties as $property => $default) {
34
-      $getter = 'get' . ucfirst($property);
35
-      if (!method_exists($object, $getter)) {
36
-        $getter = 'is' . ucfirst($property);
33
+    foreach ( $properties as $property => $default ) {
34
+      $getter = 'get'.ucfirst($property);
35
+      if ( !method_exists($object, $getter) ) {
36
+        $getter = 'is'.ucfirst($property);
37 37
       }
38 38
       $transformer = null;
39
-      if (is_array($default) && array_key_exists('transformer', $default)) {
39
+      if ( is_array($default) && array_key_exists('transformer', $default) ) {
40 40
         $transformer = $default['transformer'];
41 41
         $default = $default['default'];
42 42
       }
43
-      if (array_key_exists($property, $data)) {
43
+      if ( array_key_exists($property, $data) ) {
44 44
         $value = $data[$property];
45
-        if ($transformer != null) {
45
+        if ( $transformer != null ) {
46 46
           $value = $transformer($value);
47 47
         }
48 48
         self::assertEquals($value, $object->$getter());
@@ -51,11 +51,11 @@  discard block
 block discarded – undo
51 51
       }
52 52
     }
53 53
 
54
-    foreach ($enumProperties as $property => $info) {
54
+    foreach ( $enumProperties as $property => $info ) {
55 55
       $enumClass = $info['enum'];
56 56
       $default = $info['default'];
57
-      $getter = 'get' . ucfirst($property);
58
-      if (array_key_exists($property, $data)) {
57
+      $getter = 'get'.ucfirst($property);
58
+      if ( array_key_exists($property, $data) ) {
59 59
         $name = $data[$property];
60 60
         /** @noinspection PhpUndefinedMethodInspection */
61 61
         self::assertEquals($enumClass::getValue($name), $object->$getter());
Please login to merge, or discard this patch.
src/TestHelpers/AuthenticatedTestCase.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Created by PhpStorm.
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
    * @param array $headers the request headers
45 45
    * @return $this
46 46
    */
47
-  protected function jsonAuth(string $method, string $uri, array $data = [], array $headers = [])
47
+  protected function jsonAuth( string $method, string $uri, array $data = [], array $headers = [] )
48 48
   {
49
-    $headers['Authorization'] = 'Bearer ' . $this->token;
49
+    $headers['Authorization'] = 'Bearer '.$this->token;
50 50
     return $this->json($method, $uri, $data, $headers);
51 51
   }
52 52
 
Please login to merge, or discard this patch.
src/TestHelpers/DatabaseTestCase.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 
4 4
 /**
5 5
  * Class DatabaseTestCase
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
    * @param string $dataName test data name
40 40
    * @param bool $clear
41 41
    */
42
-  public function __construct($name = null, array $data = [], $dataName = '', $clear = false)
42
+  public function __construct( $name = null, array $data = [], $dataName = '', $clear = false )
43 43
   {
44 44
     parent::__construct($name, $data, $dataName);
45 45
     srand(3); //always use the same faker values to get reproducibility
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
     $connection = EntityManager::getConnection();
62 62
     $connection->query(sprintf('SET FOREIGN_KEY_CHECKS = 0;'));
63 63
     $tables = $connection->getSchemaManager()->listTables();
64
-    foreach ($tables as $table) {
64
+    foreach ( $tables as $table ) {
65 65
       $sql = sprintf('TRUNCATE TABLE %s', $table->getName());
66 66
       $connection->query($sql);
67 67
     }
@@ -73,10 +73,10 @@  discard block
 block discarded – undo
73 73
    * @param int $number the number of players
74 74
    * @return Player[] the created player array
75 75
    */
76
-  protected function createPlayers(int $number = 1): array
76
+  protected function createPlayers( int $number = 1 ): array
77 77
   {
78 78
     $result = [];
79
-    for ($i = 0; $i < $number; $i++) {
79
+    for ( $i = 0; $i < $number; $i++ ) {
80 80
       $result[] = entity(Player::class)->create();
81 81
     }
82 82
     return $result;
@@ -88,13 +88,13 @@  discard block
 block discarded – undo
88 88
    * @param int $playerPerTeam the number of players per team
89 89
    * @return Team[] the created team array
90 90
    */
91
-  protected function createTeams(int $number, $playerPerTeam = 1): array
91
+  protected function createTeams( int $number, $playerPerTeam = 1 ): array
92 92
   {
93 93
     $result = [];
94
-    for ($i = 0; $i < $number; $i++) {
94
+    for ( $i = 0; $i < $number; $i++ ) {
95 95
       /** @var Team $team */
96 96
       $team = entity(Team::class)->create(['startNumber' => $i + 1, 'rank' => $number - $i]);
97
-      foreach ($this->createPlayers($playerPerTeam) as $player) {
97
+      foreach ( $this->createPlayers($playerPerTeam) as $player ) {
98 98
         $team->getPlayers()->add($player);
99 99
       }
100 100
       $result[] = $team;
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
     srand(3); //always use the same faker values to get reproducibility
138 138
     $clear = $this->clear;
139 139
     parent::setUpTraits();
140
-    if ($clear) {
140
+    if ( $clear ) {
141 141
       $this->clearDatabase();
142 142
       $this->workOnDatabaseSetUp();
143 143
     } else {
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
       EntityManager::beginTransaction();
147 147
     }
148 148
 
149
-    $this->beforeApplicationDestroyed(function () use ($clear) {
150
-      if ($clear) {
149
+    $this->beforeApplicationDestroyed(function() use ($clear) {
150
+      if ( $clear ) {
151 151
         $this->workOnDatabaseDestroy();
152 152
         $this->clearDatabase();
153 153
       } else {
Please login to merge, or discard this patch.
src/TestHelpers/ReflectionMethods.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
    * @param mixed[] $args the arguments for the method
25 25
    * @return mixed the return value of the method
26 26
    */
27
-  protected static function callProtectedMethod($object, string $method, array $args = [])
27
+  protected static function callProtectedMethod( $object, string $method, array $args = [] )
28 28
   {
29 29
     // ReflectionException => get_class is a valid class
30 30
     /** @noinspection PhpUnhandledExceptionInspection */
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
    * @return \ReflectionMethod the accessible method object
39 39
    * @throws \ReflectionException the given class does not exist
40 40
    */
41
-  protected static function getMethod(string $class, string $name): \ReflectionMethod
41
+  protected static function getMethod( string $class, string $name ): \ReflectionMethod
42 42
   {
43 43
     $class = new \ReflectionClass($class);
44 44
     $method = $class->getMethod($name);
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
    * @return \ReflectionProperty the accessible property object
54 54
    * @throws \ReflectionException the given class does not exist
55 55
    */
56
-  protected static function getProperty(string $class, string $name): \ReflectionProperty
56
+  protected static function getProperty( string $class, string $name ): \ReflectionProperty
57 57
   {
58 58
     $class = new \ReflectionClass($class);
59 59
     /** @noinspection PhpStatementHasEmptyBodyInspection */
60
-    while (!$class->hasProperty($name) && ($class = $class->getParentClass()) !== null) {
60
+    while ( !$class->hasProperty($name) && ($class = $class->getParentClass()) !== null ) {
61 61
     }
62 62
     $property = $class->getProperty($name);
63 63
     $property->setAccessible(true);
Please login to merge, or discard this patch.
src/TestHelpers/UnitTestCase.php 1 patch
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
@@ -32,10 +32,10 @@  discard block
 block discarded – undo
32 32
    * @param array $methodResults a dictionary mapping method names to results of this methods
33 33
    * @return MockObject the configured stub
34 34
    */
35
-  protected function createStub(string $class, array $methodResults): MockObject
35
+  protected function createStub( string $class, array $methodResults ): MockObject
36 36
   {
37 37
     $entity = $this->createMock($class);
38
-    foreach ($methodResults as $method => $result) {
38
+    foreach ( $methodResults as $method => $result ) {
39 39
       $entity->method($method)->willReturn($result);
40 40
     }
41 41
     return $entity;
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
    * @param string $getterMethod the name of the getter method
49 49
    * @return \PHPUnit\Framework\MockObject\MockObject the mocked instance
50 50
    */
51
-  protected function createStubWithId(string $class, $entityId = "entity-id", $getterMethod = 'getId')
51
+  protected function createStubWithId( string $class, $entityId = "entity-id", $getterMethod = 'getId' )
52 52
   {
53 53
     return $this->createStub($class, [$getterMethod => $entityId]);
54 54
   }
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
    * @param string[] $otherMockedMethods list of other methods to mock
62 62
    * @return MockObject the mocked entity manager
63 63
    */
64
-  protected function getEntityManagerMockForQuery(array $result, ?string $expectedQuery = null,
65
-                                                  array $otherMockedMethods = [])
64
+  protected function getEntityManagerMockForQuery( array $result, ?string $expectedQuery = null,
65
+                                                  array $otherMockedMethods = [] )
66 66
   {
67 67
     $entityManager = $this->getMockForAbstractClass(EntityManager::class, [], '',
68 68
       false, true, true, array_merge($otherMockedMethods, ['createQueryBuilder']));
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
       '', true, true, true, ['getQuery']);
71 71
     $query = $this->createMock(AbstractQuery::class);
72 72
     $query->expects(static::once())->method('getResult')->willReturn($result);
73
-    if ($expectedQuery !== null) {
73
+    if ( $expectedQuery !== null ) {
74 74
       $queryBuilder->expects(static::once())->method('getQuery')->willReturnCallback(
75
-        function () use ($queryBuilder, $query, $expectedQuery) {
75
+        function() use ($queryBuilder, $query, $expectedQuery) {
76 76
           /** @var QueryBuilder $queryBuilder */
77 77
           self::assertEquals($expectedQuery, $queryBuilder->getDQL());
78 78
           return $query;
@@ -93,14 +93,14 @@  discard block
 block discarded – undo
93 93
    * @param string[] $mockedMethods the methods to mock in the class
94 94
    * @return MockObject the mocked object
95 95
    */
96
-  protected final function getMockWithMockedArguments(string $className, array $arguments = [],
97
-                                                      array $mockedMethods = []): MockObject
96
+  protected final function getMockWithMockedArguments( string $className, array $arguments = [],
97
+                                                      array $mockedMethods = [] ): MockObject
98 98
   {
99 99
     /** @noinspection PhpUnhandledExceptionInspection */
100 100
     $reflection = new \ReflectionClass($className);
101 101
     $params = $reflection->getConstructor()->getParameters();
102 102
     $allArguments = $arguments;
103
-    for ($i = count($arguments); $i < count($params); $i++) {
103
+    for ( $i = count($arguments); $i < count($params); $i++ ) {
104 104
       $allArguments[] = $this->createMock($params[$i]->getClass()->name);
105 105
     }
106 106
     return $this->getMockForAbstractClass($className, $allArguments, '', true, true, true, $mockedMethods);
@@ -114,13 +114,13 @@  discard block
 block discarded – undo
114 114
    * @param array $arguments the arguments to use for the constructor
115 115
    * @return mixed an instance of the given class
116 116
    */
117
-  protected final function getObjectWithMockedArguments($className, array $arguments = [])
117
+  protected final function getObjectWithMockedArguments( $className, array $arguments = [] )
118 118
   {
119 119
     /** @noinspection PhpUnhandledExceptionInspection */
120 120
     $reflection = new \ReflectionClass($className);
121 121
     $params = $reflection->getConstructor()->getParameters();
122 122
     $allArguments = $arguments;
123
-    for ($i = count($arguments); $i < count($params); $i++) {
123
+    for ( $i = count($arguments); $i < count($params); $i++ ) {
124 124
       $allArguments[$i] = $this->createMock($params[$i]->getClass()->name);
125 125
     }
126 126
     return new $className(...$allArguments);
Please login to merge, or discard this patch.
src/TestHelpers/OnlyTestLogging.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
Please login to merge, or discard this patch.
src/TestHelpers/TestEnum.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@
 block discarded – undo
1 1
 <?php
2
-declare(strict_types=1);
2
+declare(strict_types = 1);
3 3
 /**
4 4
  * Created by PhpStorm.
5 5
  * User: benedikt
Please login to merge, or discard this patch.