Completed
Branch master (53fdb9)
by Mārtiņš
04:03 queued 01:53
created
src/Palladium/Component/Collection.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
     /** code that does the actualy population of data from the given array in blueprint */
54 54
     private function populateEntity($instance, $parameters)
55 55
     {
56
-        foreach ((array)$parameters as $key => $value) {
56
+        foreach ((array) $parameters as $key => $value) {
57 57
             $method = 'set' . str_replace('_', '', $key);
58 58
             if (method_exists($instance, $method)) {
59 59
                 $instance->{$method}($value);
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 
234 234
     public function offsetGet($offset)
235 235
     {
236
-        if (isset($this->indexed[$offset])){
236
+        if (isset($this->indexed[$offset])) {
237 237
             return $this->indexed[$offset];
238 238
         }
239 239
 
Please login to merge, or discard this patch.
src/Palladium/Component/DataMapper.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@
 block discarded – undo
13 13
      */
14 14
     public function applyValues($instance, array $parameters)
15 15
     {
16
-        foreach ((array)$parameters as $key => $value) {
16
+        foreach ((array) $parameters as $key => $value) {
17 17
             $method = 'set' . str_replace('_', '', $key);
18 18
             if (method_exists($instance, $method)) {
19 19
                 $instance->{$method}($value);
Please login to merge, or discard this patch.
src/Palladium/Mapper/PasswordIdentity.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -126,16 +126,16 @@
 block discarded – undo
126 126
                        token_expires_on = FROM_UNIXTIME(:token_eol)
127 127
                  WHERE identity_id = :id";
128 128
 
129
-         $statement = $this->connection->prepare($sql);
129
+            $statement = $this->connection->prepare($sql);
130 130
 
131
-         $statement->bindValue(':id', $entity->getId());
132
-         $statement->bindValue(':hash', $entity->getHash());
133
-         $statement->bindValue(':status', $entity->getStatus());
134
-         $statement->bindValue(':expires', $entity->getExpiresOn());
135
-         $statement->bindValue(':token', $entity->getToken());
136
-         $statement->bindValue(':action', $entity->getTokenAction());
137
-         $statement->bindValue(':token_eol', $entity->getTokenEndOfLife());
131
+            $statement->bindValue(':id', $entity->getId());
132
+            $statement->bindValue(':hash', $entity->getHash());
133
+            $statement->bindValue(':status', $entity->getStatus());
134
+            $statement->bindValue(':expires', $entity->getExpiresOn());
135
+            $statement->bindValue(':token', $entity->getToken());
136
+            $statement->bindValue(':action', $entity->getTokenAction());
137
+            $statement->bindValue(':token_eol', $entity->getTokenEndOfLife());
138 138
 
139
-         $statement->execute();
139
+            $statement->execute();
140 140
     }
141 141
 }
Please login to merge, or discard this patch.
src/Palladium/Mapper/IdentityCollection.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -56,16 +56,16 @@
 block discarded – undo
56 56
                    AND user_id = :user
57 57
                    AND type = :type";
58 58
 
59
-       $statement = $this->connection->prepare($sql);
59
+        $statement = $this->connection->prepare($sql);
60 60
 
61
-       $statement->bindValue(':user', $collection->getUserId());
62
-       $statement->bindValue(':status', $collection->getStatus());
63
-       $statement->bindValue(':type', $collection->getType());
61
+        $statement->bindValue(':user', $collection->getUserId());
62
+        $statement->bindValue(':status', $collection->getStatus());
63
+        $statement->bindValue(':type', $collection->getType());
64 64
 
65
-       $statement->execute();
65
+        $statement->execute();
66 66
 
67
-       foreach ($statement as $parameters) {
68
-           $collection->addBlueprint($parameters);
69
-       }
67
+        foreach ($statement as $parameters) {
68
+            $collection->addBlueprint($parameters);
69
+        }
70 70
     }
71 71
 }
Please login to merge, or discard this patch.
src/Palladium/Entity/Identity.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@
 block discarded – undo
22 22
     const ACTION_RESET = 2;
23 23
 
24 24
     const STATUS_ANY = null;
25
-    const STATUS_NEW = 1;       // not veriefoed user
26
-    const STATUS_ACTIVE = 2;    // this is the "good" state
25
+    const STATUS_NEW = 1; // not veriefoed user
26
+    const STATUS_ACTIVE = 2; // this is the "good" state
27 27
     const STATUS_DISCARDED = 3; // user logged out or changed password
28
-    const STATUS_BLOCKED = 4;   // someone tried to us an invalid auth cookie
28
+    const STATUS_BLOCKED = 4; // someone tried to us an invalid auth cookie
29 29
     const STATUS_EXPIRED = 5;
30 30
 
31 31
     const TYPE_ANY = null;
Please login to merge, or discard this patch.
src/Palladium/Entity/CookieIdentity.php 1 patch
Indentation   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -1,163 +1,163 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
- namespace Palladium\Entity;
3
+    namespace Palladium\Entity;
4 4
 
5
- use Palladium\Exception\InvalidCookieToken;
5
+    use Palladium\Exception\InvalidCookieToken;
6 6
 
7
- class CookieIdentity extends Identity
8
- {
7
+    class CookieIdentity extends Identity
8
+    {
9 9
 
10
-     const SERIES_SIZE = 16;
11
-     const KEY_SIZE = 32;
10
+        const SERIES_SIZE = 16;
11
+        const KEY_SIZE = 32;
12 12
 
13 13
 
14
-     private $series;
15
-     private $key;
16
-     private $hash;
14
+        private $series;
15
+        private $key;
16
+        private $hash;
17 17
 
18
-     protected $type = Identity::TYPE_COOKIE;
18
+        protected $type = Identity::TYPE_COOKIE;
19 19
 
20 20
 
21
-     public function setSeries($series)
22
-     {
23
-         if (empty($series)) {
24
-             $this->series = null;
25
-             return;
26
-         }
21
+        public function setSeries($series)
22
+        {
23
+            if (empty($series)) {
24
+                $this->series = null;
25
+                return;
26
+            }
27 27
 
28
-         $this->series = (string) $series;
29
-     }
28
+            $this->series = (string) $series;
29
+        }
30 30
 
31 31
 
32
-     /**
33
-      * @codeCoverageIgnore
34
-      */
35
-     public function getSeries()
36
-     {
37
-         return $this->series;
38
-     }
32
+        /**
33
+         * @codeCoverageIgnore
34
+         */
35
+        public function getSeries()
36
+        {
37
+            return $this->series;
38
+        }
39 39
 
40 40
 
41
-     /**
42
-      * Produces a hash from series to obscure it for storage.
43
-      *
44
-      * @return string
45
-      */
46
-     public function getFingerprint()
47
-     {
48
-         return hash('sha384', $this->series);
49
-     }
50
-
51
-
52
-     public function generateNewSeries()
53
-     {
54
-         $this->series = bin2hex(random_bytes(self::SERIES_SIZE));
55
-     }
56
-
57
-
58
-     /**
59
-      * Assignes a new identification key and resets a the hash.
60
-      *
61
-      * @param string $key
62
-      */
63
-     public function setKey($key)
64
-     {
65
-         $this->hash = null;
66
-
67
-         if (empty($key)) {
68
-             $this->key = null;
69
-             return;
70
-         }
71
-
72
-         $this->key = (string) $key;
73
-         $this->hash = $this->makeHash($key);
74
-     }
75
-
76
-
77
-     /**
78
-      * @codeCoverageIgnore
79
-      * @return string
80
-      */
81
-     public function getKey()
82
-     {
83
-         return $this->key;
84
-     }
85
-
86
-
87
-     /**
88
-      * Sets a new key and resets the hash.
89
-      */
90
-      public function generateNewKey()
91
-      {
92
-          $key = bin2hex(random_bytes(self::KEY_SIZE));
93
-          $this->key = $key;
94
-          $this->hash = $this->makeHash($key);
95
-      }
96
-
97
-
98
-      /**
99
-       * @codeCoverageIgnore
100
-       */
101
-     public function getHash()
102
-     {
103
-         return $this->hash;
104
-     }
105
-
106
-
107
-     private function makeHash($key)
108
-     {
109
-         return hash('sha384', $key);
110
-     }
111
-
112
-
113
-     /**
114
-      * @param string $hash
115
-      */
116
-     public function setHash($hash)
117
-     {
118
-         if (empty($hash)) {
119
-             $this->hash = null;
120
-             return;
121
-         }
122
-
123
-         $this->hash = (string) $hash;
124
-     }
125
-
126
-
127
-     public function matchKey($key)
128
-     {
129
-         return  $this->makeHash($key) === $this->hash;
130
-     }
131
-
132
-
133
-     /**
134
-      * Retrieves the identification token in a compact form.
135
-      *
136
-      * @return string|null
137
-      */
138
-     public function getCollapsedValue()
139
-     {
140
-         if (null === $this->getId()) {
141
-             return null;
142
-         }
143
-         return $this->getUserId() . '|' . $this->getSeries() . '|' . $this->getKey();
144
-     }
145
-
146
-
147
-     /**
148
-      * Populates the instance from the identification token.
149
-      *
150
-      * @param string $value
151
-      */
152
-     public function setCollapsedValue($value)
153
-     {
154
-         if (empty($value) || substr_count($value, '|') !== 2) {
155
-             throw new InvalidCookieToken;
156
-         }
157
-
158
-         list($userId, $series, $key) = explode('|', $value);
159
-         $this->setUserId($userId);
160
-         $this->setSeries($series);
161
-         $this->setKey($key);
162
-     }
163
- }
41
+        /**
42
+         * Produces a hash from series to obscure it for storage.
43
+         *
44
+         * @return string
45
+         */
46
+        public function getFingerprint()
47
+        {
48
+            return hash('sha384', $this->series);
49
+        }
50
+
51
+
52
+        public function generateNewSeries()
53
+        {
54
+            $this->series = bin2hex(random_bytes(self::SERIES_SIZE));
55
+        }
56
+
57
+
58
+        /**
59
+         * Assignes a new identification key and resets a the hash.
60
+         *
61
+         * @param string $key
62
+         */
63
+        public function setKey($key)
64
+        {
65
+            $this->hash = null;
66
+
67
+            if (empty($key)) {
68
+                $this->key = null;
69
+                return;
70
+            }
71
+
72
+            $this->key = (string) $key;
73
+            $this->hash = $this->makeHash($key);
74
+        }
75
+
76
+
77
+        /**
78
+         * @codeCoverageIgnore
79
+         * @return string
80
+         */
81
+        public function getKey()
82
+        {
83
+            return $this->key;
84
+        }
85
+
86
+
87
+        /**
88
+         * Sets a new key and resets the hash.
89
+         */
90
+        public function generateNewKey()
91
+        {
92
+            $key = bin2hex(random_bytes(self::KEY_SIZE));
93
+            $this->key = $key;
94
+            $this->hash = $this->makeHash($key);
95
+        }
96
+
97
+
98
+        /**
99
+         * @codeCoverageIgnore
100
+         */
101
+        public function getHash()
102
+        {
103
+            return $this->hash;
104
+        }
105
+
106
+
107
+        private function makeHash($key)
108
+        {
109
+            return hash('sha384', $key);
110
+        }
111
+
112
+
113
+        /**
114
+         * @param string $hash
115
+         */
116
+        public function setHash($hash)
117
+        {
118
+            if (empty($hash)) {
119
+                $this->hash = null;
120
+                return;
121
+            }
122
+
123
+            $this->hash = (string) $hash;
124
+        }
125
+
126
+
127
+        public function matchKey($key)
128
+        {
129
+            return  $this->makeHash($key) === $this->hash;
130
+        }
131
+
132
+
133
+        /**
134
+         * Retrieves the identification token in a compact form.
135
+         *
136
+         * @return string|null
137
+         */
138
+        public function getCollapsedValue()
139
+        {
140
+            if (null === $this->getId()) {
141
+                return null;
142
+            }
143
+            return $this->getUserId() . '|' . $this->getSeries() . '|' . $this->getKey();
144
+        }
145
+
146
+
147
+        /**
148
+         * Populates the instance from the identification token.
149
+         *
150
+         * @param string $value
151
+         */
152
+        public function setCollapsedValue($value)
153
+        {
154
+            if (empty($value) || substr_count($value, '|') !== 2) {
155
+                throw new InvalidCookieToken;
156
+            }
157
+
158
+            list($userId, $series, $key) = explode('|', $value);
159
+            $this->setUserId($userId);
160
+            $this->setSeries($series);
161
+            $this->setKey($key);
162
+        }
163
+    }
Please login to merge, or discard this patch.
src/Palladium/Service/Identification.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -137,7 +137,7 @@
 block discarded – undo
137 137
 
138 138
         $mapper = $this->mapperFactory->create(Mapper\CookieIdentity::class);
139 139
 
140
-        if ($identity->getExpiresOn() <  time()) {
140
+        if ($identity->getExpiresOn() < time()) {
141 141
             $identity->setStatus(Entity\Identity::STATUS_EXPIRED);
142 142
             $mapper->store($identity);
143 143
             $this->logger->info('cookie expired', [
Please login to merge, or discard this patch.