ImsLtiTool   F
last analyzed

Complexity

Total Complexity 80

Size/Duplication

Total Lines 910
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 187
dl 0
loc 910
rs 2
c 0
b 0
f 0
wmc 80

59 Methods

Rating   Name   Duplication   Size   Complexity  
A parseCustomParams() 0 22 4
A setPrivacy() 0 11 1
A setDescription() 0 5 1
A getId() 0 3 1
A getConsumerKey() 0 3 1
A getDescription() 0 3 1
A setSharedSecret() 0 5 1
A getSharedSecret() 0 3 1
A encodeCustomParams() 0 13 3
A setParent() 0 9 1
A getLoginUrl() 0 3 1
A setRedirectUrl() 0 5 1
A setLoginUrl() 0 5 1
A setSession() 0 5 1
A getClientId() 0 3 1
A setLaunchUrl() 0 5 1
A getCourse() 0 3 1
A getPrivacy() 0 3 1
A setClientId() 0 5 1
A isActiveDeepLinking() 0 3 1
A filterSpaces() 0 5 1
A getRedirectUrl() 0 3 1
A setReplacementForUserId() 0 5 1
A getDocumentTarget() 0 3 2
A setGradebookEval() 0 5 1
A setDocumenTarget() 0 5 2
A getCustomParams() 0 3 1
A getVersionName() 0 7 2
A setLineItems() 0 5 1
A setVersion() 0 5 1
A isSharingPicture() 0 5 1
A setJwksUrl() 0 5 1
A __construct() 0 17 1
A isSharingEmail() 0 5 1
A getChildren() 0 3 1
A getChildrenInCourses() 0 5 1
A setAdvantageServices() 0 5 1
A getName() 0 3 1
A getCustomParamsAsArray() 0 16 2
A setCustomParams() 0 5 1
A getAdvantageServices() 0 12 2
A setName() 0 5 1
A getLaunchPresentation() 0 3 1
A isGlobal() 0 3 1
A setActiveDeepLinking() 0 5 1
A getLaunchUrl() 0 3 1
A getParent() 0 3 1
A getLineItems() 0 28 6
A getVersion() 0 3 1
A isSharingName() 0 5 1
A unserializePrivacy() 0 3 1
A getReplacementForUserId() 0 7 2
A getSession() 0 3 1
A getGradebookEval() 0 3 1
A setConsumerKey() 0 5 1
A getJwksUrl() 0 3 1
A filterSpecialChars() 0 19 6
A addLineItem() 0 7 1
A setCourse() 0 5 1

How to fix   Complexity   

Complex Class

Complex classes like ImsLtiTool often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use ImsLtiTool, and based on these observations, apply Extract Interface, too.

1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\PluginBundle\ImsLti\Entity;
5
6
use Chamilo\CoreBundle\Entity\Course;
7
use Chamilo\CoreBundle\Entity\GradebookEvaluation;
8
use Chamilo\CoreBundle\Entity\Session;
9
use Doctrine\Common\Collections\ArrayCollection;
10
use Doctrine\Common\Collections\Criteria;
11
use Doctrine\ORM\Mapping as ORM;
12
13
/**
14
 * Class ImsLtiTool.
15
 *
16
 * @ORM\Table(name="plugin_ims_lti_tool")
17
 * @ORM\Entity()
18
 */
19
class ImsLtiTool
20
{
21
    /**
22
     * @var string|null
23
     *
24
     * @ORM\Column(name="public_key", type="text", nullable=true)
25
     */
26
    public $publicKey;
27
    /**
28
     * @var int
29
     *
30
     * @ORM\Column(name="id", type="integer")
31
     * @ORM\Id
32
     * @ORM\GeneratedValue
33
     */
34
    protected $id;
35
    /**
36
     * @var string
37
     *
38
     * @ORM\Column(name="name", type="string")
39
     */
40
    private $name = '';
41
    /**
42
     * @var string|null
43
     *
44
     * @ORM\Column(name="description", type="text", nullable=true)
45
     */
46
    private $description = null;
47
    /**
48
     * @var string
49
     *
50
     * @ORM\Column(name="launch_url", type="string")
51
     */
52
    private $launchUrl = '';
53
    /**
54
     * @var string
55
     *
56
     * @ORM\Column(name="consumer_key", type="string", nullable=true)
57
     */
58
    private $consumerKey = '';
59
    /**
60
     * @var string
61
     *
62
     * @ORM\Column(name="shared_secret", type="string", nullable=true)
63
     */
64
    private $sharedSecret = '';
65
    /**
66
     * @var string|null
67
     *
68
     * @ORM\Column(name="custom_params", type="text", nullable=true)
69
     */
70
    private $customParams = null;
71
    /**
72
     * @var bool
73
     *
74
     * @ORM\Column(name="active_deep_linking", type="boolean", nullable=false, options={"default": false})
75
     */
76
    private $activeDeepLinking = false;
77
    /**
78
     * @var string|null
79
     *
80
     * @ORM\Column(name="privacy", type="text", nullable=true, options={"default": null})
81
     */
82
    private $privacy = null;
83
    /**
84
     * @var Course|null
85
     *
86
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Course")
87
     * @ORM\JoinColumn(name="c_id", referencedColumnName="id")
88
     */
89
    private $course = null;
90
    /**
91
     * @var Session|null
92
     *
93
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\Session")
94
     * @ORM\JoinColumn(name="session_id", referencedColumnName="id")
95
     */
96
    private $session = null;
97
    /**
98
     * @var GradebookEvaluation|null
99
     *
100
     * @ORM\ManyToOne(targetEntity="Chamilo\CoreBundle\Entity\GradebookEvaluation")
101
     * @ORM\JoinColumn(name="gradebook_eval_id", referencedColumnName="id", onDelete="SET NULL")
102
     */
103
    private $gradebookEval = null;
104
    /**
105
     * @var ImsLtiTool|null
106
     *
107
     * @ORM\ManyToOne(targetEntity="Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool", inversedBy="children")
108
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id", onDelete="CASCADE")
109
     */
110
    private $parent;
111
    /**
112
     * @var ArrayCollection
113
     *
114
     * @ORM\OneToMany(targetEntity="Chamilo\PluginBundle\ImsLti\Entity\ImsLtiTool", mappedBy="parent")
115
     */
116
    private $children;
117
    /**
118
     * @var string
119
     *
120
     * @ORM\Column(name="client_id", type="string", nullable=true)
121
     */
122
    private $clientId;
123
    /**
124
     * @var string|null
125
     *
126
     * @ORM\Column(name="login_url", type="string", nullable=true)
127
     */
128
    private $loginUrl;
129
130
    /**
131
     * @var string|null
132
     *
133
     * @ORM\Column(name="redirect_url", type="string", nullable=true)
134
     */
135
    private $redirectUrl;
136
137
    /**
138
     * @var string|null
139
     *
140
     * @ORM\Column(name="jwks_url", type="string", nullable=true)
141
     */
142
    private $jwksUrl;
143
144
    /**
145
     * @var array
146
     *
147
     * @ORM\Column(name="advantage_services", type="json", nullable=true)
148
     */
149
    private $advantageServices;
150
151
    /**
152
     * @var ArrayCollection
153
     *
154
     * @ORM\OneToMany(targetEntity="Chamilo\PluginBundle\ImsLti\Entity\LineItem", mappedBy="tool")
155
     */
156
    private $lineItems;
157
158
    /**
159
     * @var string
160
     *
161
     * @ORM\Column(name="version", type="string", options={"default": "lti1p1"})
162
     */
163
    private $version;
164
    /**
165
     * @var array
166
     *
167
     * @ORM\Column(name="launch_presentation", type="json")
168
     */
169
    private $launchPresentation;
170
171
    /**
172
     * @var array
173
     *
174
     * @ORM\Column(name="replacement_params", type="json")
175
     */
176
    private $replacementParams;
177
178
    /**
179
     * ImsLtiTool constructor.
180
     */
181
    public function __construct()
182
    {
183
        $this->description = null;
184
        $this->customParams = null;
185
        $this->activeDeepLinking = false;
186
        $this->course = null;
187
        $this->gradebookEval = null;
188
        $this->privacy = null;
189
        $this->children = new ArrayCollection();
190
        $this->consumerKey = null;
191
        $this->sharedSecret = null;
192
        $this->lineItems = new ArrayCollection();
193
        $this->version = \ImsLti::V_1P3;
194
        $this->launchPresentation = [
195
            'document_target' => 'iframe',
196
        ];
197
        $this->replacementParams = [];
198
    }
199
200
    /**
201
     * @return int
202
     */
203
    public function getId()
204
    {
205
        return $this->id;
206
    }
207
208
    /**
209
     * @return string
210
     */
211
    public function getName()
212
    {
213
        return $this->name;
214
    }
215
216
    /**
217
     * @param string $name
218
     *
219
     * @return ImsLtiTool
220
     */
221
    public function setName($name)
222
    {
223
        $this->name = $name;
224
225
        return $this;
226
    }
227
228
    /**
229
     * @return string|null
230
     */
231
    public function getDescription()
232
    {
233
        return $this->description;
234
    }
235
236
    /**
237
     * @param string|null $description
238
     *
239
     * @return ImsLtiTool
240
     */
241
    public function setDescription($description)
242
    {
243
        $this->description = $description;
244
245
        return $this;
246
    }
247
248
    /**
249
     * @return string
250
     */
251
    public function getLaunchUrl()
252
    {
253
        return $this->launchUrl;
254
    }
255
256
    /**
257
     * @param string $launchUrl
258
     *
259
     * @return ImsLtiTool
260
     */
261
    public function setLaunchUrl($launchUrl)
262
    {
263
        $this->launchUrl = $launchUrl;
264
265
        return $this;
266
    }
267
268
    /**
269
     * @return string|null
270
     */
271
    public function getCustomParams()
272
    {
273
        return $this->customParams;
274
    }
275
276
    /**
277
     * @param string|null $customParams
278
     *
279
     * @return ImsLtiTool
280
     */
281
    public function setCustomParams($customParams)
282
    {
283
        $this->customParams = $customParams;
284
285
        return $this;
286
    }
287
288
    /**
289
     * @return bool
290
     */
291
    public function isGlobal()
292
    {
293
        return $this->course === null;
294
    }
295
296
    /**
297
     * @return string|null
298
     */
299
    public function encodeCustomParams(array $params)
300
    {
301
        if (empty($params)) {
302
            return null;
303
        }
304
305
        $pairs = [];
306
307
        foreach ($params as $key => $value) {
308
            $pairs[] = "$key=$value";
309
        }
310
311
        return implode("\n", $pairs);
312
    }
313
314
    /**
315
     * @return array
316
     */
317
    public function getCustomParamsAsArray()
318
    {
319
        $params = [];
320
        $lines = explode("\n", $this->customParams);
321
        $lines = array_filter($lines);
322
323
        foreach ($lines as $line) {
324
            list($key, $value) = explode('=', $line, 2);
325
326
            $key = self::filterSpecialChars($key);
327
            $value = self::filterSpaces($value);
328
329
            $params[$key] = $value;
330
        }
331
332
        return $params;
333
    }
334
335
    /**
336
     * @return array
337
     */
338
    public function parseCustomParams()
339
    {
340
        if (empty($this->customParams)) {
341
            return [];
342
        }
343
344
        $params = [];
345
        $strings = explode("\n", $this->customParams);
346
347
        foreach ($strings as $string) {
348
            if (empty($string)) {
349
                continue;
350
            }
351
352
            $pairs = explode('=', $string, 2);
353
            $key = self::filterSpecialChars($pairs[0]);
354
            $value = $pairs[1];
355
356
            $params['custom_'.$key] = $value;
357
        }
358
359
        return $params;
360
    }
361
362
    /**
363
     * Get activeDeepLinking.
364
     *
365
     * @return bool
366
     */
367
    public function isActiveDeepLinking()
368
    {
369
        return $this->activeDeepLinking;
370
    }
371
372
    /**
373
     * Set activeDeepLinking.
374
     *
375
     * @param bool $activeDeepLinking
376
     *
377
     * @return ImsLtiTool
378
     */
379
    public function setActiveDeepLinking($activeDeepLinking)
380
    {
381
        $this->activeDeepLinking = $activeDeepLinking;
382
383
        return $this;
384
    }
385
386
    /**
387
     * Get course.
388
     *
389
     * @return Course|null
390
     */
391
    public function getCourse()
392
    {
393
        return $this->course;
394
    }
395
396
    /**
397
     * Set course.
398
     *
399
     * @return ImsLtiTool
400
     */
401
    public function setCourse(Course $course = null)
402
    {
403
        $this->course = $course;
404
405
        return $this;
406
    }
407
408
    /**
409
     * Get session.
410
     *
411
     * @return Session|null
412
     */
413
    public function getSession()
414
    {
415
        return $this->session;
416
    }
417
418
    /**
419
     * Set session.
420
     *
421
     * @param Session|null $course
422
     *
423
     * @return ImsLtiTool
424
     */
425
    public function setSession(Session $session = null)
426
    {
427
        $this->session = $session;
428
429
        return $this;
430
    }
431
432
    /**
433
     * Get gradebookEval.
434
     *
435
     * @return GradebookEvaluation|null
436
     */
437
    public function getGradebookEval()
438
    {
439
        return $this->gradebookEval;
440
    }
441
442
    /**
443
     * Set gradebookEval.
444
     *
445
     * @param GradebookEvaluation|null $gradebookEval
446
     *
447
     * @return ImsLtiTool
448
     */
449
    public function setGradebookEval($gradebookEval)
450
    {
451
        $this->gradebookEval = $gradebookEval;
452
453
        return $this;
454
    }
455
456
    /**
457
     * @return bool
458
     */
459
    public function isSharingName()
460
    {
461
        $unserialize = $this->unserializePrivacy();
462
463
        return (bool) $unserialize['share_name'];
464
    }
465
466
    /**
467
     * @return mixed
468
     */
469
    public function unserializePrivacy()
470
    {
471
        return \UnserializeApi::unserialize('not_allowed_classes', $this->privacy);
472
    }
473
474
    /**
475
     * @return bool
476
     */
477
    public function isSharingEmail()
478
    {
479
        $unserialize = $this->unserializePrivacy();
480
481
        return (bool) $unserialize['share_email'];
482
    }
483
484
    /**
485
     * @return bool
486
     */
487
    public function isSharingPicture()
488
    {
489
        $unserialize = $this->unserializePrivacy();
490
491
        return (bool) $unserialize['share_picture'];
492
    }
493
494
    /**
495
     * @return ImsLtiTool|null
496
     */
497
    public function getParent()
498
    {
499
        return $this->parent;
500
    }
501
502
    /**
503
     * @return ImsLtiTool
504
     */
505
    public function setParent(ImsLtiTool $parent)
506
    {
507
        $this->parent = $parent;
508
509
        $this->sharedSecret = $parent->getSharedSecret();
510
        $this->consumerKey = $parent->getConsumerKey();
511
        $this->privacy = $parent->getPrivacy();
512
513
        return $this;
514
    }
515
516
    /**
517
     * @return string
518
     */
519
    public function getSharedSecret()
520
    {
521
        return $this->sharedSecret;
522
    }
523
524
    /**
525
     * @param string $sharedSecret
526
     *
527
     * @return ImsLtiTool
528
     */
529
    public function setSharedSecret($sharedSecret)
530
    {
531
        $this->sharedSecret = $sharedSecret;
532
533
        return $this;
534
    }
535
536
    /**
537
     * @return string
538
     */
539
    public function getConsumerKey()
540
    {
541
        return $this->consumerKey;
542
    }
543
544
    /**
545
     * @param string $consumerKey
546
     *
547
     * @return ImsLtiTool
548
     */
549
    public function setConsumerKey($consumerKey)
550
    {
551
        $this->consumerKey = $consumerKey;
552
553
        return $this;
554
    }
555
556
    /**
557
     * Get privacy.
558
     *
559
     * @return string|null
560
     */
561
    public function getPrivacy()
562
    {
563
        return $this->privacy;
564
    }
565
566
    /**
567
     * Set privacy.
568
     *
569
     * @param bool $shareName
570
     * @param bool $shareEmail
571
     * @param bool $sharePicture
572
     *
573
     * @return ImsLtiTool
574
     */
575
    public function setPrivacy($shareName = false, $shareEmail = false, $sharePicture = false)
576
    {
577
        $this->privacy = serialize(
578
            [
579
                'share_name' => $shareName,
580
                'share_email' => $shareEmail,
581
                'share_picture' => $sharePicture,
582
            ]
583
        );
584
585
        return $this;
586
    }
587
588
    /**
589
     * Get loginUrl.
590
     *
591
     * @return string|null
592
     */
593
    public function getLoginUrl()
594
    {
595
        return $this->loginUrl;
596
    }
597
598
    /**
599
     * Set loginUrl.
600
     *
601
     * @param string|null $loginUrl
602
     *
603
     * @return ImsLtiTool
604
     */
605
    public function setLoginUrl($loginUrl)
606
    {
607
        $this->loginUrl = $loginUrl;
608
609
        return $this;
610
    }
611
612
    /**
613
     * Get redirectUlr.
614
     *
615
     * @return string|null
616
     */
617
    public function getRedirectUrl()
618
    {
619
        return $this->redirectUrl;
620
    }
621
622
    /**
623
     * Set redirectUrl.
624
     *
625
     * @param string|null $redirectUrl
626
     *
627
     * @return ImsLtiTool
628
     */
629
    public function setRedirectUrl($redirectUrl)
630
    {
631
        $this->redirectUrl = $redirectUrl;
632
633
        return $this;
634
    }
635
636
    /**
637
     * Get jwksUrl.
638
     *
639
     * @return string|null
640
     */
641
    public function getJwksUrl()
642
    {
643
        return $this->jwksUrl;
644
    }
645
646
    /**
647
     * Set jwksUrl.
648
     *
649
     * @param string|null $jwksUrl
650
     *
651
     * @return ImsLtiTool
652
     */
653
    public function setJwksUrl($jwksUrl)
654
    {
655
        $this->jwksUrl = $jwksUrl;
656
657
        return $this;
658
    }
659
660
    /**
661
     * Get clientId.
662
     *
663
     * @return string
664
     */
665
    public function getClientId()
666
    {
667
        return $this->clientId;
668
    }
669
670
    /**
671
     * Set clientId.
672
     *
673
     * @param string $clientId
674
     *
675
     * @return ImsLtiTool
676
     */
677
    public function setClientId($clientId)
678
    {
679
        $this->clientId = $clientId;
680
681
        return $this;
682
    }
683
684
    /**
685
     * Get advantageServices.
686
     *
687
     * @return array
688
     */
689
    public function getAdvantageServices()
690
    {
691
        if (empty($this->advantageServices)) {
692
            $this->advantageServices = [];
693
        }
694
695
        return array_merge(
696
            [
697
                'ags' => \LtiAssignmentGradesService::AGS_NONE,
698
                'nrps' => \LtiNamesRoleProvisioningService::NRPS_NONE,
699
            ],
700
            $this->advantageServices
701
        );
702
    }
703
704
    /**
705
     * Set advantageServices.
706
     *
707
     * @param array $advantageServices
708
     *
709
     * @return ImsLtiTool
710
     */
711
    public function setAdvantageServices($advantageServices)
712
    {
713
        $this->advantageServices = $advantageServices;
714
715
        return $this;
716
    }
717
718
    /**
719
     * Add LineItem to lineItems.
720
     *
721
     * @return $this
722
     */
723
    public function addLineItem(LineItem $lineItem)
724
    {
725
        $lineItem->setTool($this);
726
727
        $this->lineItems[] = $lineItem;
728
729
        return $this;
730
    }
731
732
    /**
733
     * @param int    $resourceLinkId
734
     * @param int    $resourceId
735
     * @param string $tag
736
     * @param int    $limit
737
     * @param int    $page
738
     *
739
     * @return ArrayCollection
740
     */
741
    public function getLineItems($resourceLinkId = 0, $resourceId = 0, $tag = '', $limit = 0, $page = 1)
742
    {
743
        $criteria = Criteria::create();
744
745
        if ($resourceLinkId) {
746
            $criteria->andWhere(Criteria::expr()->eq('tool', $resourceId));
747
        }
748
749
        if ($resourceId) {
750
            $criteria->andWhere(Criteria::expr()->eq('tool', $resourceId));
751
        }
752
753
        if (!empty($tag)) {
754
            $criteria->andWhere(Criteria::expr()->eq('tag', $tag));
755
        }
756
757
        $limit = (int) $limit;
758
        $page = (int) $page;
759
760
        if ($limit > 0) {
761
            $criteria->setMaxResults($limit);
762
763
            if ($page > 0) {
764
                $criteria->setFirstResult($page * $limit);
765
            }
766
        }
767
768
        return $this->lineItems->matching($criteria);
769
    }
770
771
    /**
772
     * Set lineItems.
773
     *
774
     * @return $this
775
     */
776
    public function setLineItems(ArrayCollection $lineItems)
777
    {
778
        $this->lineItems = $lineItems;
779
780
        return $this;
781
    }
782
783
    /**
784
     * Get version.
785
     *
786
     * @return string
787
     */
788
    public function getVersion()
789
    {
790
        return $this->version;
791
    }
792
793
    /**
794
     * Set version.
795
     *
796
     * @param string $version
797
     *
798
     * @return ImsLtiTool
799
     */
800
    public function setVersion($version)
801
    {
802
        $this->version = $version;
803
804
        return $this;
805
    }
806
807
    /**
808
     * @return string
809
     */
810
    public function getVersionName()
811
    {
812
        if (\ImsLti::V_1P1 === $this->version) {
813
            return 'LTI 1.0 / 1.1';
814
        }
815
816
        return 'LTI 1.3';
817
    }
818
819
    /**
820
     * @return ArrayCollection
821
     */
822
    public function getChildren()
823
    {
824
        return $this->children;
825
    }
826
827
    /**
828
     * @param string $target
829
     *
830
     * @return $this
831
     */
832
    public function setDocumenTarget($target)
833
    {
834
        $this->launchPresentation['document_target'] = in_array($target, ['iframe', 'window']) ? $target : 'iframe';
835
836
        return $this;
837
    }
838
839
    /**
840
     * @return string
841
     */
842
    public function getDocumentTarget()
843
    {
844
        return $this->launchPresentation['document_target'] ?: 'iframe';
845
    }
846
847
    /**
848
     * @return array
849
     */
850
    public function getLaunchPresentation()
851
    {
852
        return $this->launchPresentation;
853
    }
854
855
    /**
856
     * @param string $replacement
857
     *
858
     * @return ImsLtiTool
859
     */
860
    public function setReplacementForUserId($replacement)
861
    {
862
        $this->replacementParams['user_id'] = $replacement;
863
864
        return $this;
865
    }
866
867
    /**
868
     * @return string|null
869
     */
870
    public function getReplacementForUserId()
871
    {
872
        if (!empty($this->replacementParams['user_id'])) {
873
            return $this->replacementParams['user_id'];
874
        }
875
876
        return null;
877
    }
878
879
    /**
880
     * @return ArrayCollection
881
     */
882
    public function getChildrenInCourses(array $coursesId)
883
    {
884
        return $this->children->filter(
885
            function (ImsLtiTool $child) use ($coursesId) {
886
                return in_array($child->getCourse()->getId(), $coursesId);
887
            }
888
        );
889
    }
890
891
    /**
892
     * Map the key from custom param.
893
     *
894
     * @param string $key
895
     *
896
     * @return string
897
     */
898
    private static function filterSpecialChars($key)
899
    {
900
        $newKey = '';
901
        $key = strtolower($key);
902
        $split = str_split($key);
903
904
        foreach ($split as $char) {
905
            if (
906
                ($char >= 'a' && $char <= 'z') || ($char >= '0' && $char <= '9')
907
            ) {
908
                $newKey .= $char;
909
910
                continue;
911
            }
912
913
            $newKey .= '_';
914
        }
915
916
        return $newKey;
917
    }
918
919
    /**
920
     * @param string $value
921
     *
922
     * @return string
923
     */
924
    private static function filterSpaces($value)
925
    {
926
        $newValue = preg_replace('/\s+/', ' ', $value);
927
928
        return trim($newValue);
929
    }
930
}
931