Completed
Push — master ( 62540e...964c4e )
by Rafidison
11:21 queued 07:47
created
Manager/TagManager.php 5 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -226,6 +226,9 @@
 block discarded – undo
226 226
         }
227 227
     }
228 228
 
229
+    /**
230
+     * @param string $name
231
+     */
229 232
     public function create( $name )
230 233
     {
231 234
         $tag = new Tag();
Please login to merge, or discard this patch.
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -10,7 +10,6 @@
 block discarded – undo
10 10
 
11 11
 
12 12
 use Mykees\TagBundle\Util\Urlizer;
13
-use Doctrine\Common\Collections\ArrayCollection;
14 13
 use Doctrine\Common\Persistence\ManagerRegistry;
15 14
 use Mykees\TagBundle\Interfaces\Taggable;
16 15
 use Mykees\TagBundle\Traits\ManagerArrayTrait;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 10/12/2014
6
- * Time: 13:16
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 10/12/2014
6
+     * Time: 13:16
7
+     */
8 8
 
9 9
 namespace Mykees\TagBundle\Manager;
10 10
 
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
 
27 27
     use ManagerArrayTrait, ManagerObjectTrait;
28 28
 
29
-    public function __construct( ManagerRegistry $managerRegistry, $tag=null, $tagRelation=null )
29
+    public function __construct(ManagerRegistry $managerRegistry, $tag = null, $tagRelation = null)
30 30
     {
31 31
         $this->em = $managerRegistry->getManager();
32 32
         $this->tag = $tag ?: 'Mykees\TagBundle\Entity\Tag';
@@ -35,12 +35,12 @@  discard block
 block discarded – undo
35 35
 
36 36
 
37 37
 
38
-    public function findTagRelation( $model )
38
+    public function findTagRelation($model)
39 39
     {
40
-        if(is_array($model))
40
+        if (is_array($model))
41 41
         {
42 42
             $this->getTagRelationArray($model);
43
-        }else{
43
+        }else {
44 44
             $this->getTagRelation($model);
45 45
         }
46 46
     }
@@ -50,9 +50,9 @@  discard block
 block discarded – undo
50 50
      * @param Taggable $model
51 51
      * @param bool $onlyDeleteRelation
52 52
      */
53
-    public function deleteTagRelation( Taggable $model, $onlyDeleteRelation = false )
53
+    public function deleteTagRelation(Taggable $model, $onlyDeleteRelation = false)
54 54
     {
55
-        if($onlyDeleteRelation)
55
+        if ($onlyDeleteRelation)
56 56
         {
57 57
             $model->setRemove(true);
58 58
         }
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             ->getQuery()
67 67
             ->getResult();
68 68
 
69
-        foreach($tagRelationList as $relation)
69
+        foreach ($tagRelationList as $relation)
70 70
         {
71 71
             $this->em->remove($relation);
72 72
             $this->useless($relation->getTag()->getId());
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * Remove tag
79 79
      * @param $tag_id
80 80
      */
81
-    public function delete( $tag_id )
81
+    public function delete($tag_id)
82 82
     {
83 83
         $tag = $this->em->createQueryBuilder()
84 84
             ->select('t')
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
     public function deleteByName($name)
95 95
     {
96 96
 
97
-        if(is_array($name))
97
+        if (is_array($name))
98 98
         {
99 99
             $names = $this->findByName($name);
100
-            foreach($names as $n)
100
+            foreach ($names as $n)
101 101
             {
102 102
                 $this->em->remove($n);
103 103
             }
104 104
             $this->em->flush();
105
-        }else{
105
+        }else {
106 106
             $tag = $this->em->createQueryBuilder()
107 107
                 ->select('t')
108 108
                 ->from($this->tag, 't')
@@ -119,32 +119,32 @@  discard block
 block discarded – undo
119 119
      * Save Tag Relation and add create and save tags if don't exist
120 120
      * @param Taggable $model
121 121
      */
122
-    public function saveRelation( Taggable $model )
122
+    public function saveRelation(Taggable $model)
123 123
     {
124
-        if(!$model->getRemove())
124
+        if (!$model->getRemove())
125 125
         {
126
-            if($model->getTags()->count() > 0)
126
+            if ($model->getTags()->count() > 0)
127 127
             {
128 128
                 $addedTags = $model->getTags();
129 129
                 $model_id = $model->getModelId();
130 130
                 $model_name = $model->getModel();
131 131
                 $addNewTags = $addedTags;
132 132
 
133
-                $tagsRelationExisted = $this->findRelationByTagName($model->getTags(),$model);
133
+                $tagsRelationExisted = $this->findRelationByTagName($model->getTags(), $model);
134 134
 
135 135
                 //Remove existed Tag from collection
136
-                foreach($tagsRelationExisted as $tagExisted)
136
+                foreach ($tagsRelationExisted as $tagExisted)
137 137
                 {
138
-                    if($addedTags->exists(function($index, Tag $addedTag) use ($tagExisted)
138
+                    if ($addedTags->exists(function($index, Tag $addedTag) use ($tagExisted)
139 139
                     {
140 140
                         return $addedTag->getName() === $tagExisted->getName();
141
-                    })){
141
+                    })) {
142 142
                         $addNewTags->removeElement($tagExisted);
143 143
                     }
144 144
                 }
145 145
 
146 146
                 //Save
147
-                foreach($addNewTags as $tag)
147
+                foreach ($addNewTags as $tag)
148 148
                 {
149 149
                     $relation = new TagRelation();
150 150
                     $relation->setModel($model_name);
@@ -166,17 +166,17 @@  discard block
 block discarded – undo
166 166
      * Return Tag by a name
167 167
      * @param array $names
168 168
      */
169
-    public function findByName( $names )
169
+    public function findByName($names)
170 170
     {
171 171
         $q = $this->em->createQueryBuilder()
172 172
             ->select('t')
173
-            ->from($this->tag,'t')
173
+            ->from($this->tag, 't')
174 174
 
175 175
         ;
176
-        if(is_array($names))
176
+        if (is_array($names))
177 177
         {
178 178
             $q->where($this->em->createQueryBuilder()->expr()->in('t.name', $names));
179
-        }else{
179
+        }else {
180 180
             $q->where('t.name = :name')->setParameter('name', $names);
181 181
         }
182 182
 
@@ -189,25 +189,25 @@  discard block
 block discarded – undo
189 189
      * @param null $modelType
190 190
      * @return array
191 191
      */
192
-    public function findReferer( $slug, $modelType=null )
192
+    public function findReferer($slug, $modelType = null)
193 193
     {
194 194
         $modelRefererIds = [];
195 195
 
196 196
         $q = $this->em->createQueryBuilder()
197 197
             ->select('tr')
198
-            ->from($this->tagRelation,'tr')
199
-            ->innerJoin('tr.tag','t')
198
+            ->from($this->tagRelation, 'tr')
199
+            ->innerJoin('tr.tag', 't')
200 200
             ->addSelect('t')
201 201
             ->where('t.slug = :slug')
202
-            ->setParameter('slug',$slug)
202
+            ->setParameter('slug', $slug)
203 203
         ;
204 204
 
205
-        $query = $this->addModelTypeConstraint($q,$modelType);
205
+        $query = $this->addModelTypeConstraint($q, $modelType);
206 206
         $result = $query->getQuery()->getResult();
207 207
 
208
-        foreach($result as $tr)
208
+        foreach ($result as $tr)
209 209
         {
210
-            array_push($modelRefererIds,$tr->getModelId());
210
+            array_push($modelRefererIds, $tr->getModelId());
211 211
         }
212 212
 
213 213
         return $modelRefererIds;
@@ -220,13 +220,13 @@  discard block
 block discarded – undo
220 220
     public function useless($tag_id)
221 221
     {
222 222
         $count = $this->em->getRepository('MykeesTagBundle:TagRelation')->findCount($tag_id);
223
-        if($count < 2)
223
+        if ($count < 2)
224 224
         {
225 225
             $this->delete($tag_id);
226 226
         }
227 227
     }
228 228
 
229
-    public function create( $name )
229
+    public function create($name)
230 230
     {
231 231
         $tag = new Tag();
232 232
         $tag->setName($name);
@@ -242,25 +242,25 @@  discard block
 block discarded – undo
242 242
         return $this->em->getRepository('MykeesTagBundle:Tag')->findCount();
243 243
     }
244 244
 
245
-    public function manageTags( $names )
245
+    public function manageTags($names)
246 246
     {
247
-        foreach($names as $k=>$name)
247
+        foreach ($names as $k=>$name)
248 248
         {
249 249
             $name = trim($name);
250
-            if(!empty($name))
250
+            if (!empty($name))
251 251
             {
252 252
                 $q = $this->queryTag();
253
-                $query = $this->addNameConstraint($q,$name);
253
+                $query = $this->addNameConstraint($q, $name);
254 254
                 $tagExist = $query->getQuery()->getOneOrNullResult();
255 255
 
256
-                if(!empty($tagExist))
256
+                if (!empty($tagExist))
257 257
                 {
258 258
                     $names[$k] = $tagExist;
259
-                }else{
259
+                }else {
260 260
                     $tag = $this->create($name);
261 261
                     $names[$k] = $tag;
262 262
                 }
263
-            }else{
263
+            }else {
264 264
                 unset($names[$k]);
265 265
             }
266 266
         }
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
         if(is_array($model))
41 41
         {
42 42
             $this->getTagRelationArray($model);
43
-        }else{
43
+        } else{
44 44
             $this->getTagRelation($model);
45 45
         }
46 46
     }
@@ -102,7 +102,7 @@  discard block
 block discarded – undo
102 102
                 $this->em->remove($n);
103 103
             }
104 104
             $this->em->flush();
105
-        }else{
105
+        } else{
106 106
             $tag = $this->em->createQueryBuilder()
107 107
                 ->select('t')
108 108
                 ->from($this->tag, 't')
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
         if(is_array($names))
177 177
         {
178 178
             $q->where($this->em->createQueryBuilder()->expr()->in('t.name', $names));
179
-        }else{
179
+        } else{
180 180
             $q->where('t.name = :name')->setParameter('name', $names);
181 181
         }
182 182
 
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
                 if(!empty($tagExist))
257 257
                 {
258 258
                     $names[$k] = $tagExist;
259
-                }else{
259
+                } else{
260 260
                     $tag = $this->create($name);
261 261
                     $names[$k] = $tag;
262 262
                 }
263
-            }else{
263
+            } else{
264 264
                 unset($names[$k]);
265 265
             }
266 266
         }
Please login to merge, or discard this patch.
Traits/ManagerObjectTrait.php 4 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -86,6 +86,9 @@
 block discarded – undo
86 86
         return $datas;
87 87
     }
88 88
 
89
+    /**
90
+     * @param string $names
91
+     */
89 92
     protected function addNameConstraint(QueryBuilder $query,$names)
90 93
     {
91 94
         if($names)
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 10/12/2014
6
- * Time: 12:33
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 10/12/2014
6
+     * Time: 12:33
7
+     */
8 8
 
9 9
 namespace Mykees\TagBundle\Traits;
10 10
 
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -34,11 +34,11 @@  discard block
 block discarded – undo
34 34
      */
35 35
     protected function addTags(array $tags, Taggable $model)
36 36
     {
37
-        foreach($tags as $tag)
37
+        foreach ($tags as $tag)
38 38
         {
39
-            if(!empty($tag) && $tag instanceof Tag)
39
+            if (!empty($tag) && $tag instanceof Tag)
40 40
             {
41
-                $this->addTag($tag,$model);
41
+                $this->addTag($tag, $model);
42 42
             }
43 43
         }
44 44
     }
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
     protected function refreshTags(array $tags, Taggable $model)
52 52
     {
53 53
         $model->getTags()->clear();
54
-        $this->addTags($tags,$model);
54
+        $this->addTags($tags, $model);
55 55
     }
56 56
 
57 57
     /**
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
     {
63 63
         $query = $this->queryRelation($model);
64 64
 
65
-        return $this->refreshTags($query,$model);
65
+        return $this->refreshTags($query, $model);
66 66
     }
67 67
 
68 68
     protected function queryTag()
69 69
     {
70 70
         $query = $this->em->createQueryBuilder()
71 71
             ->select('t')
72
-            ->from($this->tag,'t')
72
+            ->from($this->tag, 't')
73 73
         ;
74 74
 
75 75
         return $query;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
     protected function slugify(array $datas)
79 79
     {
80 80
         $datas = array_unique($datas);
81
-        foreach($datas as $k=>$d)
81
+        foreach ($datas as $k=>$d)
82 82
         {
83 83
             $datas[$k] = Urlizer::urlize($d);
84 84
         }
@@ -86,34 +86,34 @@  discard block
 block discarded – undo
86 86
         return $datas;
87 87
     }
88 88
 
89
-    protected function addNameConstraint(QueryBuilder $query,$names)
89
+    protected function addNameConstraint(QueryBuilder $query, $names)
90 90
     {
91
-        if($names)
91
+        if ($names)
92 92
         {
93
-            if(is_array($names))
93
+            if (is_array($names))
94 94
             {
95 95
                 $names = $this->slugify($names);
96 96
                 $query->where($query->expr()->in('t.slug', $names));
97
-            }else{
97
+            }else {
98 98
                 $query->andWhere('t.slug = :slug')
99
-                    ->setParameter('slug',Urlizer::urlize($names))
99
+                    ->setParameter('slug', Urlizer::urlize($names))
100 100
                 ;
101 101
             }
102 102
         }
103 103
         return $query;
104 104
     }
105 105
 
106
-    protected function addModelTypeConstraint(QueryBuilder $query,$modelType)
106
+    protected function addModelTypeConstraint(QueryBuilder $query, $modelType)
107 107
     {
108
-        if($modelType)
108
+        if ($modelType)
109 109
         {
110
-            if(is_array($modelType))
110
+            if (is_array($modelType))
111 111
             {
112 112
                 $modelType = $this->slugify($modelType);
113 113
                 $query->andWhere($query->expr()->in('tr.model', $modelType));
114
-            }else{
114
+            }else {
115 115
                 $query->andWhere('tr.model = :model')
116
-                    ->setParameter('model',$modelType)
116
+                    ->setParameter('model', $modelType)
117 117
                 ;
118 118
             }
119 119
         }
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
     {
125 125
         $query = $this->em->createQueryBuilder()
126 126
             ->select('t')
127
-            ->from($this->tag,'t')
128
-            ->innerJoin('t.tagRelation','tg',Expr\Join::WITH, 'tg.model = :model AND tg.modelId = :modelId')
127
+            ->from($this->tag, 't')
128
+            ->innerJoin('t.tagRelation', 'tg', Expr\Join::WITH, 'tg.model = :model AND tg.modelId = :modelId')
129 129
             ->addSelect('tg')
130
-            ->setParameter('model',$model->getModel())
131
-            ->setParameter('modelId',$model->getModelId())
130
+            ->setParameter('model', $model->getModel())
131
+            ->setParameter('modelId', $model->getModelId())
132 132
             ->getQuery()
133 133
             ->getResult()
134 134
         ;
@@ -139,19 +139,19 @@  discard block
 block discarded – undo
139 139
     protected function findRelationByTagName(ArrayCollection $names, Taggable $model)
140 140
     {
141 141
         $slugified = [];
142
-        foreach($names as $name)
142
+        foreach ($names as $name)
143 143
         {
144 144
             $slugified[] = $name->getSlug();
145 145
         }
146 146
 
147 147
         $query = $this->em->createQueryBuilder()
148 148
             ->select('t')
149
-            ->from($this->tag,'t')
150
-            ->innerJoin('t.tagRelation','tg',Expr\Join::WITH, 'tg.model = :model AND tg.modelId = :modelId')
149
+            ->from($this->tag, 't')
150
+            ->innerJoin('t.tagRelation', 'tg', Expr\Join::WITH, 'tg.model = :model AND tg.modelId = :modelId')
151 151
             ->addSelect('tg')
152 152
             ->where($this->em->createQueryBuilder()->expr()->in('t.slug', $slugified))
153
-            ->setParameter('model',$model->getModel())
154
-            ->setParameter('modelId',$model->getModelId())
153
+            ->setParameter('model', $model->getModel())
154
+            ->setParameter('modelId', $model->getModelId())
155 155
             ->getQuery()
156 156
             ->getResult()
157 157
         ;
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
             {
95 95
                 $names = $this->slugify($names);
96 96
                 $query->where($query->expr()->in('t.slug', $names));
97
-            }else{
97
+            } else{
98 98
                 $query->andWhere('t.slug = :slug')
99 99
                     ->setParameter('slug',Urlizer::urlize($names))
100 100
                 ;
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
             {
112 112
                 $modelType = $this->slugify($modelType);
113 113
                 $query->andWhere($query->expr()->in('tr.model', $modelType));
114
-            }else{
114
+            } else{
115 115
                 $query->andWhere('tr.model = :model')
116 116
                     ->setParameter('model',$modelType)
117 117
                 ;
Please login to merge, or discard this patch.
Util/Urlizer.php 3 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -232,6 +232,7 @@
 block discarded – undo
232 232
      * Note: this function has been modified to simple return true or false
233 233
      * @author <[email protected]>
234 234
      * @param string UTF-8 encoded string
235
+     * @param string $str
235 236
      * @return boolean true if valid
236 237
      * @see http://hsivonen.iki.fi/php-utf8/
237 238
      */
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -40,13 +40,13 @@  discard block
 block discarded – undo
40 40
         $stringLength = strlen($string);
41 41
         for ($i = 0; $i < $stringLength; $i++) {
42 42
             if (ord($string[$i]) < 0x80) continue; # 0bbbbbbb
43
-            elseif ((ord($string[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
44
-            elseif ((ord($string[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
45
-            elseif ((ord($string[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
46
-            elseif ((ord($string[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
47
-            elseif ((ord($string[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
43
+            elseif ((ord($string[$i]) & 0xE0) == 0xC0) $n = 1; # 110bbbbb
44
+            elseif ((ord($string[$i]) & 0xF0) == 0xE0) $n = 2; # 1110bbbb
45
+            elseif ((ord($string[$i]) & 0xF8) == 0xF0) $n = 3; # 11110bbb
46
+            elseif ((ord($string[$i]) & 0xFC) == 0xF8) $n = 4; # 111110bb
47
+            elseif ((ord($string[$i]) & 0xFE) == 0xFC) $n = 5; # 1111110b
48 48
             else return false; # Does not match any model
49
-            for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
49
+            for ($j = 0; $j < $n; $j++) { # n bytes matching 10bbbbbb follow ?
50 50
                 if ((++$i == strlen($string)) || ((ord($string[$i]) & 0xC0) != 0x80))
51 51
                     return false;
52 52
             }
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
                 chr(196).chr(172) => 'I', chr(196).chr(173) => 'i',
124 124
                 chr(196).chr(174) => 'I', chr(196).chr(175) => 'i',
125 125
                 chr(196).chr(176) => 'I', chr(196).chr(177) => 'i',
126
-                chr(196).chr(178) => 'IJ',chr(196).chr(179) => 'ij',
126
+                chr(196).chr(178) => 'IJ', chr(196).chr(179) => 'ij',
127 127
                 chr(196).chr(180) => 'J', chr(196).chr(181) => 'j',
128 128
                 chr(196).chr(182) => 'K', chr(196).chr(183) => 'k',
129 129
                 chr(196).chr(184) => 'k', chr(196).chr(185) => 'L',
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
                 chr(197).chr(140) => 'O', chr(197).chr(141) => 'o',
140 140
                 chr(197).chr(142) => 'O', chr(197).chr(143) => 'o',
141 141
                 chr(197).chr(144) => 'O', chr(197).chr(145) => 'o',
142
-                chr(197).chr(146) => 'OE',chr(197).chr(147) => 'oe',
142
+                chr(197).chr(146) => 'OE', chr(197).chr(147) => 'oe',
143 143
                 chr(197).chr(148) => 'R', chr(197).chr(149) => 'r',
144 144
                 chr(197).chr(150) => 'R', chr(197).chr(151) => 'r',
145 145
                 chr(197).chr(152) => 'R', chr(197).chr(153) => 'r',
@@ -169,11 +169,11 @@  discard block
 block discarded – undo
169 169
                 'Ä' => 'Ae', 'ä' => 'ae', 'Ü' => 'Ue', 'ü' => 'ue',
170 170
                 'Ö' => 'Oe', 'ö' => 'oe', 'ß' => 'ss',
171 171
                 // Norwegian characters
172
-                'Å'=>'Aa','Æ'=>'Ae','Ø'=>'O','æ'=>'a','ø'=>'o','å'=>'aa'
172
+                'Å'=>'Aa', 'Æ'=>'Ae', 'Ø'=>'O', 'æ'=>'a', 'ø'=>'o', 'å'=>'aa'
173 173
             );
174 174
 
175 175
             $string = strtr($string, $chars);
176
-        } else {
176
+        }else {
177 177
             // Assume ISO-8859-1 if not UTF-8
178 178
             $chars['in'] = chr(128).chr(131).chr(138).chr(142).chr(154).chr(158)
179 179
                 .chr(159).chr(162).chr(165).chr(181).chr(192).chr(193).chr(194)
@@ -237,10 +237,10 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public static function validUtf8($str)
239 239
     {
240
-        $mState = 0;     // cached expected number of octets after the current octet
240
+        $mState = 0; // cached expected number of octets after the current octet
241 241
         // until the beginning of the next UTF8 character sequence
242
-        $mUcs4  = 0;     // cached Unicode character
243
-        $mBytes = 1;     // cached expected number of octets in the current sequence
242
+        $mUcs4  = 0; // cached Unicode character
243
+        $mBytes = 1; // cached expected number of octets in the current sequence
244 244
 
245 245
         $len = strlen($str);
246 246
         for ($i = 0; $i < $len; $i++) {
@@ -288,13 +288,13 @@  discard block
 block discarded – undo
288 288
                     $mUcs4 = ($mUcs4 & 1) << 30;
289 289
                     $mState = 5;
290 290
                     $mBytes = 6;
291
-                } else {
291
+                }else {
292 292
                     /* Current octet is neither in the US-ASCII range nor a legal first
293 293
                      * octet of a multi-octet sequence.
294 294
                      */
295 295
                     return false;
296 296
                 }
297
-            } else {
297
+            }else {
298 298
                 // When mState is non-zero, we expect a continuation of the multi-octet
299 299
                 // sequence
300 300
                 if (0x80 == (0xC0 & ($in))) {
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
                         $mUcs4  = 0;
329 329
                         $mBytes = 1;
330 330
                     }
331
-                } else {
331
+                }else {
332 332
                     /**
333 333
                      *((0xC0 & (*in) != 0x80) && (mState != 0))
334 334
                      * Incomplete multi-octet sequence.
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
     {
352 352
         if (function_exists('mb_strtolower')) {
353 353
             $text = mb_strtolower($text);
354
-        } else {
354
+        }else {
355 355
             $text = strtolower($text);
356 356
         }
357 357
 
Please login to merge, or discard this patch.
Braces   +31 added lines, -9 removed lines patch added patch discarded remove patch
@@ -39,16 +39,38 @@
 block discarded – undo
39 39
     {
40 40
         $stringLength = strlen($string);
41 41
         for ($i = 0; $i < $stringLength; $i++) {
42
-            if (ord($string[$i]) < 0x80) continue; # 0bbbbbbb
43
-            elseif ((ord($string[$i]) & 0xE0) == 0xC0) $n=1; # 110bbbbb
44
-            elseif ((ord($string[$i]) & 0xF0) == 0xE0) $n=2; # 1110bbbb
45
-            elseif ((ord($string[$i]) & 0xF8) == 0xF0) $n=3; # 11110bbb
46
-            elseif ((ord($string[$i]) & 0xFC) == 0xF8) $n=4; # 111110bb
47
-            elseif ((ord($string[$i]) & 0xFE) == 0xFC) $n=5; # 1111110b
48
-            else return false; # Does not match any model
42
+            if (ord($string[$i]) < 0x80) {
43
+                continue;
44
+            }
45
+            # 0bbbbbbb
46
+            elseif ((ord($string[$i]) & 0xE0) == 0xC0) {
47
+                $n=1;
48
+            }
49
+            # 110bbbbb
50
+            elseif ((ord($string[$i]) & 0xF0) == 0xE0) {
51
+                $n=2;
52
+            }
53
+            # 1110bbbb
54
+            elseif ((ord($string[$i]) & 0xF8) == 0xF0) {
55
+                $n=3;
56
+            }
57
+            # 11110bbb
58
+            elseif ((ord($string[$i]) & 0xFC) == 0xF8) {
59
+                $n=4;
60
+            }
61
+            # 111110bb
62
+            elseif ((ord($string[$i]) & 0xFE) == 0xFC) {
63
+                $n=5;
64
+            }
65
+            # 1111110b
66
+            else {
67
+                return false;
68
+            }
69
+            # Does not match any model
49 70
             for ($j=0; $j<$n; $j++) { # n bytes matching 10bbbbbb follow ?
50
-                if ((++$i == strlen($string)) || ((ord($string[$i]) & 0xC0) != 0x80))
51
-                    return false;
71
+                if ((++$i == strlen($string)) || ((ord($string[$i]) & 0xC0) != 0x80)) {
72
+                                    return false;
73
+                }
52 74
             }
53 75
         }
54 76
         return true;
Please login to merge, or discard this patch.
Controller/TagsController.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -11,11 +11,11 @@
 block discarded – undo
11 11
         return $this->getDoctrine()->getManager();
12 12
     }
13 13
 
14
-	/**
15
-	 * Unlink and delete a relation
16
-	 * @param $relation_id
17
-	 * @return Response
18
-	 */
14
+    /**
15
+     * Unlink and delete a relation
16
+     * @param $relation_id
17
+     * @return Response
18
+     */
19 19
     public function deleteRelationAction( $relation_id ){
20 20
         $tagRelation = $this->manage()->getRepository('MykeesTagBundle:TagRelation')->find($relation_id);
21 21
         $this->manage()->remove($tagRelation);
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
 
8 8
 class TagsController extends Controller
9 9
 {
10
-    public function manage(){
10
+    public function manage() {
11 11
         return $this->getDoctrine()->getManager();
12 12
     }
13 13
 
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * @param $relation_id
17 17
 	 * @return Response
18 18
 	 */
19
-    public function deleteRelationAction( $relation_id ){
19
+    public function deleteRelationAction($relation_id) {
20 20
         $tagRelation = $this->manage()->getRepository('MykeesTagBundle:TagRelation')->find($relation_id);
21 21
         $this->manage()->remove($tagRelation);
22 22
         $this->manage()->flush();
Please login to merge, or discard this patch.
DataFixtures/ORM/LoadTags.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 11/12/2014
6
- * Time: 15:47
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 11/12/2014
6
+     * Time: 15:47
7
+     */
8 8
 
9 9
 namespace Mykees\TagBundle\DataFixtures\ORM;
10 10
 use Doctrine\Common\DataFixtures\Doctrine;
Please login to merge, or discard this patch.
Form/TagTransformer.php 1 patch
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 05/05/2015
6
- * Time: 23:58
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 05/05/2015
6
+     * Time: 23:58
7
+     */
8 8
 
9 9
 namespace Mykees\TagBundle\Form;
10 10
 
Please login to merge, or discard this patch.
Listener/TagListener.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 10/12/2014
6
- * Time: 12:37
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 10/12/2014
6
+     * Time: 12:37
7
+     */
8 8
 
9 9
 namespace Mykees\TagBundle\Listener;
10 10
 
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -28,27 +28,27 @@  discard block
 block discarded – undo
28 28
 
29 29
     public function postFlush(PostFlushEventArgs $args)
30 30
     {
31
-        $em  = $args->getEntityManager();
31
+        $em = $args->getEntityManager();
32 32
         $uow  = $em->getUnitOfWork();
33 33
         $manager = new TagManager($this->managerRegistry);
34 34
         $tags = array();
35 35
 
36
-        foreach($uow->getIdentityMap() as $model)
36
+        foreach ($uow->getIdentityMap() as $model)
37 37
         {
38
-            foreach($model as $entity)
38
+            foreach ($model as $entity)
39 39
             {
40 40
                 if ($entity instanceof Tag) {
41 41
                     $tags[] = $entity;
42 42
                 }
43
-                if($entity instanceof Taggable)
43
+                if ($entity instanceof Taggable)
44 44
                 {
45 45
                     $this->entity = $entity;
46 46
                 }
47 47
             }
48 48
         }
49
-        if($this->entity)
49
+        if ($this->entity)
50 50
         {
51
-            if(!empty($tags))
51
+            if (!empty($tags))
52 52
             {
53 53
                 $this->entity->setTags($tags);
54 54
                 $manager->saveRelation($this->entity);
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $model = $args->getEntity();
62 62
         $manager = new TagManager($this->managerRegistry);
63 63
 
64
-        if( $model instanceof Taggable )
64
+        if ($model instanceof Taggable)
65 65
         {
66 66
             $model->setRemove(true);
67 67
             $manager->deleteTagRelation($model);
Please login to merge, or discard this patch.
Repository/TagRelationRepository.php 2 patches
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -13,22 +13,22 @@
 block discarded – undo
13 13
 class TagRelationRepository extends EntityRepository {
14 14
 
15 15
 
16
-    public function findCount($tag_id=null)
16
+    public function findCount($tag_id = null)
17 17
     {
18 18
 
19
-        if($tag_id){
19
+        if ($tag_id) {
20 20
             return $this->_em->createQueryBuilder()
21 21
                 ->select('count(tr.tag)')
22
-                ->from('Mykees\TagBundle\Entity\TagRelation','tr')
22
+                ->from('Mykees\TagBundle\Entity\TagRelation', 'tr')
23 23
                 ->where('tr.tag = :id')
24
-                ->setParameter('id',$tag_id)
24
+                ->setParameter('id', $tag_id)
25 25
                 ->getQuery()
26 26
                 ->getSingleScalarResult()
27 27
             ;
28
-        }else{
28
+        }else {
29 29
             return $this->_em->createQueryBuilder()
30 30
                 ->select('count(tr.id)')
31
-                ->from('Mykees\TagBundle\Entity\TagRelation','tr')
31
+                ->from('Mykees\TagBundle\Entity\TagRelation', 'tr')
32 32
                 ->getQuery()
33 33
                 ->getSingleScalarResult()
34 34
             ;
Please login to merge, or discard this patch.
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -25,7 +25,7 @@
 block discarded – undo
25 25
                 ->getQuery()
26 26
                 ->getSingleScalarResult()
27 27
             ;
28
-        }else{
28
+        } else{
29 29
             return $this->_em->createQueryBuilder()
30 30
                 ->select('count(tr.id)')
31 31
                 ->from('Mykees\TagBundle\Entity\TagRelation','tr')
Please login to merge, or discard this patch.
Repository/TagRepository.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1,10 +1,10 @@
 block discarded – undo
1 1
 <?php
2 2
 /**
3
- * Created by PhpStorm.
4
- * User: Rafidion Michael
5
- * Date: 11/12/2014
6
- * Time: 00:31
7
- */
3
+     * Created by PhpStorm.
4
+     * User: Rafidion Michael
5
+     * Date: 11/12/2014
6
+     * Time: 00:31
7
+     */
8 8
 
9 9
 namespace Mykees\TagBundle\Repository;
10 10
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@
 block discarded – undo
16 16
     {
17 17
         return $this->_em->createQueryBuilder()
18 18
             ->select('count(t.id)')
19
-            ->from('Mykees\TagBundle\Entity\Tag','t')
19
+            ->from('Mykees\TagBundle\Entity\Tag', 't')
20 20
             ->getQuery()
21 21
             ->getSingleScalarResult()
22 22
             ;
Please login to merge, or discard this patch.