Completed
Push — 1.9 ( 482137...30c3e5 )
by
unknown
43:10
created

Lead::setName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 6
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
3
namespace OroCRM\Bundle\SalesBundle\Entity;
4
5
use Doctrine\ORM\Event\LifecycleEventArgs;
6
use Doctrine\ORM\Mapping as ORM;
7
use Doctrine\Common\Collections\ArrayCollection;
8
9
use Oro\Bundle\AddressBundle\Entity\Address;
10
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro;
11
use Oro\Bundle\EmailBundle\Model\EmailHolderInterface;
12
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;
13
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField;
14
use Oro\Bundle\OrganizationBundle\Entity\Organization;
15
use Oro\Bundle\UserBundle\Entity\User;
16
use Oro\Bundle\LocaleBundle\Model\FullNameInterface;
17
use Oro\Bundle\WorkflowBundle\Entity\WorkflowItem;
18
use Oro\Bundle\WorkflowBundle\Entity\WorkflowStep;
19
20
use OroCRM\Bundle\ContactBundle\Entity\Contact;
21
use OroCRM\Bundle\SalesBundle\Model\ExtendLead;
22
use OroCRM\Bundle\ChannelBundle\Model\ChannelEntityTrait;
23
use OroCRM\Bundle\ChannelBundle\Model\ChannelAwareInterface;
24
25
/**
26
 * @SuppressWarnings(PHPMD.ExcessivePublicCount)
27
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
28
 * @SuppressWarnings(PHPMD.TooManyFields)
29
 *
30
 * @ORM\Table(
31
 *      name="orocrm_sales_lead",
32
 *      indexes={@ORM\Index(name="lead_created_idx",columns={"createdAt"})}
33
 * )
34
 * @ORM\Entity(repositoryClass="OroCRM\Bundle\SalesBundle\Entity\Repository\LeadRepository")
35
 * @ORM\HasLifecycleCallbacks()
36
 * @Oro\Loggable
37
 * @Config(
38
 *      routeName="orocrm_sales_lead_index",
39
 *      routeView="orocrm_sales_lead_view",
40
 *      defaultValues={
41
 *          "entity"={
42
 *              "icon"="icon-phone"
43
 *          },
44
 *          "ownership"={
45
 *              "owner_type"="USER",
46
 *              "owner_field_name"="owner",
47
 *              "owner_column_name"="user_owner_id",
48
 *              "organization_field_name"="organization",
49
 *              "organization_column_name"="organization_id"
50
 *          },
51
 *          "security"={
52
 *              "type"="ACL",
53
 *              "group_name"=""
54
 *          },
55
 *          "form"={
56
 *              "form_type"="orocrm_sales_lead_select",
57
 *              "grid_name"="sales-lead-grid",
58
 *          },
59
 *          "dataaudit"={
60
 *              "auditable"=true
61
 *          },
62
 *          "grid"={
63
 *              "default"="sales-lead-grid",
64
 *              "context"="sales-lead-for-context-grid"
65
 *          },
66
 *          "tag"={
67
 *              "enabled"=true
68
 *          }
69
 *      }
70
 * )
71
 *
72
 * @SuppressWarnings(PHPMD.ExcessiveClassLength)
73
 */
74
class Lead extends ExtendLead implements
75
    FullNameInterface,
76
    EmailHolderInterface,
77
    ChannelAwareInterface
78
{
79
    use ChannelEntityTrait;
80
81
    /**
82
     * @var integer
83
     *
84
     * @ORM\Column(name="id", type="integer")
85
     * @ORM\Id
86
     * @ORM\GeneratedValue(strategy="AUTO")
87
     * @ConfigField(
88
     *  defaultValues={
89
     *      "importexport"={
90
     *          "order"=0
91
     *      }
92
     *  }
93
     * )
94
     */
95
    protected $id;
96
97
    /**
98
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\LeadStatus")
99
     * @ORM\JoinColumn(name="status_name", referencedColumnName="name")
100
     * @ConfigField(
101
     *  defaultValues={
102
     *      "importexport"={
103
     *          "order"=10,
104
     *          "short"=true
105
     *      }
106
     *  }
107
     * )
108
     */
109
    protected $status;
110
111
    /**
112
     * @var Contact
113
     *
114
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\ContactBundle\Entity\Contact")
115
     * @ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="SET NULL")
116
     * @Oro\Versioned
117
     * @ConfigField(
118
     *  defaultValues={
119
     *      "dataaudit"={"auditable"=true},
120
     *      "importexport"={
121
     *          "order"=150,
122
     *          "short"=true
123
     *      }
124
     *  }
125
     * )
126
     */
127
    protected $contact;
128
129
    /**
130
     * @var string
131
     *
132
     * @ORM\Column(name="name", type="string", length=255)
133
     * @Oro\Versioned
134
     * @ConfigField(
135
     *  defaultValues={
136
     *      "dataaudit"={"auditable"=true},
137
     *      "importexport"={
138
     *          "order"=20,
139
     *          "identity"=true
140
     *      }
141
     *  }
142
     * )
143
     */
144
    protected $name;
145
146
    /**
147
     * @var string
148
     *
149
     * @ORM\Column(name="name_prefix", type="string", length=255, nullable=true)
150
     * @Oro\Versioned
151
     * @ConfigField(
152
     *  defaultValues={
153
     *      "dataaudit"={"auditable"=true},
154
     *      "importexport"={
155
     *          "order"=30
156
     *      }
157
     *  }
158
     * )
159
     */
160
    protected $namePrefix;
161
162
    /**
163
     * @var string
164
     *
165
     * @ORM\Column(name="first_name", type="string", length=255)
166
     * @Oro\Versioned
167
     * @ConfigField(
168
     *  defaultValues={
169
     *      "dataaudit"={"auditable"=true},
170
     *      "importexport"={
171
     *          "order"=40
172
     *      }
173
     *  }
174
     * )
175
     */
176
    protected $firstName;
177
178
    /**
179
     * @var string
180
     *
181
     * @ORM\Column(name="middle_name", type="string", length=255, nullable=true)
182
     * @Oro\Versioned
183
     * @ConfigField(
184
     *  defaultValues={
185
     *      "dataaudit"={"auditable"=true},
186
     *      "importexport"={
187
     *          "order"=50
188
     *      }
189
     *  }
190
     * )
191
     */
192
    protected $middleName;
193
194
    /**
195
     * @var string
196
     *
197
     * @ORM\Column(name="last_name", type="string", length=255)
198
     * @Oro\Versioned
199
     * @ConfigField(
200
     *  defaultValues={
201
     *      "dataaudit"={"auditable"=true},
202
     *      "importexport"={
203
     *          "order"=60
204
     *      }
205
     *  }
206
     * )
207
     */
208
    protected $lastName;
209
210
    /**
211
     * @var string
212
     *
213
     * @ORM\Column(name="name_suffix", type="string", length=255, nullable=true)
214
     * @Oro\Versioned
215
     * @ConfigField(
216
     *  defaultValues={
217
     *      "dataaudit"={"auditable"=true},
218
     *      "importexport"={
219
     *          "order"=70
220
     *      }
221
     *  }
222
     * )
223
     */
224
    protected $nameSuffix;
225
226
    /**
227
     * @var string
228
     *
229
     * @ORM\Column(name="job_title", type="string", length=255, nullable=true)
230
     * @Oro\Versioned
231
     * @ConfigField(
232
     *  defaultValues={
233
     *      "dataaudit"={"auditable"=true},
234
     *      "importexport"={
235
     *          "order"=80
236
     *      }
237
     *  }
238
     * )
239
     */
240
    protected $jobTitle;
241
242
    /**
243
     * @var string
244
     *
245
     * @ORM\Column(name="phone_number", type="string", length=255, nullable=true)
246
     * @Oro\Versioned
247
     * @ConfigField(
248
     *  defaultValues={
249
     *      "dataaudit"={"auditable"=true},
250
     *      "importexport"={
251
     *          "order"=90
252
     *      }
253
     *  }
254
     * )
255
     */
256
    protected $phoneNumber;
257
258
    /**
259
     * @var string
260
     *
261
     * @ORM\Column(name="email", type="string", length=255, nullable=true)
262
     * @Oro\Versioned
263
     * @ConfigField(
264
     *      defaultValues={
265
     *          "dataaudit"={"auditable"=true},
266
     *          "importexport"={
267
     *              "order"=100
268
     *          },
269
     *          "entity"={
270
     *              "contact_information"="email"
271
     *          }
272
     *      }
273
     * )
274
     */
275
    protected $email;
276
277
    /**
278
     * @var string
279
     *
280
     * @ORM\Column(name="company_name", type="string", length=255, nullable=true)
281
     * @Oro\Versioned
282
     * @ConfigField(
283
     *  defaultValues={
284
     *      "dataaudit"={"auditable"=true},
285
     *      "importexport"={
286
     *          "order"=110
287
     *      }
288
     *  }
289
     * )
290
     */
291
    protected $companyName;
292
293
    /**
294
     * @var string
295
     *
296
     * @ORM\Column(name="website", type="string", length=255, nullable=true)
297
     * @Oro\Versioned
298
     * @ConfigField(
299
     *  defaultValues={
300
     *      "dataaudit"={"auditable"=true},
301
     *      "importexport"={
302
     *          "order"=120
303
     *      }
304
     *  }
305
     * )
306
     */
307
    protected $website;
308
309
    /**
310
     * @var integer
311
     *
312
     * @ORM\Column(name="number_of_employees", type="integer", nullable=true)
313
     * @Oro\Versioned
314
     * @ConfigField(
315
     *  defaultValues={
316
     *      "dataaudit"={"auditable"=true},
317
     *      "importexport"={
318
     *          "order"=130
319
     *      }
320
     *  }
321
     * )
322
     */
323
    protected $numberOfEmployees;
324
325
    /**
326
     * @var string
327
     *
328
     * @ORM\Column(name="industry", type="string", length=255, nullable=true)
329
     * @Oro\Versioned
330
     * @ConfigField(
331
     *  defaultValues={
332
     *      "dataaudit"={"auditable"=true},
333
     *      "importexport"={
334
     *          "order"=140
335
     *      }
336
     *  }
337
     * )
338
     */
339
    protected $industry;
340
341
    /**
342
     * @var Address
343
     *
344
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\AddressBundle\Entity\Address", cascade={"persist", "remove"})
345
     * @ORM\JoinColumn(name="address_id", referencedColumnName="id", onDelete="SET NULL", nullable=true)
346
     * @ConfigField(
347
     *  defaultValues={
348
     *      "dataaudit"={"auditable"=true},
349
     *      "importexport"={
350
     *          "order"=170,
351
     *          "full"=true
352
     *      }
353
     *  }
354
     * )
355
     */
356
    protected $address;
357
358
    /**
359
     * @var \DateTime
360
     *
361
     * @ORM\Column(type="datetime")
362
     * @ConfigField(
363
     *      defaultValues={
364
     *          "entity"={
365
     *              "label"="oro.ui.created_at"
366
     *          },
367
     *          "importexport"={
368
     *              "excluded"=true
369
     *          }
370
     *      }
371
     * )
372
     */
373
    protected $createdAt;
374
375
    /**
376
     * @var \DateTime
377
     *
378
     * @ORM\Column(type="datetime", nullable=true)
379
     * @ConfigField(
380
     *      defaultValues={
381
     *          "entity"={
382
     *              "label"="oro.ui.updated_at"
383
     *          },
384
     *          "importexport"={
385
     *              "excluded"=true
386
     *          }
387
     *      }
388
     * )
389
     */
390
    protected $updatedAt;
391
392
    /**
393
     * @var User
394
     *
395
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User")
396
     * @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL")
397
     * @Oro\Versioned
398
     * @ConfigField(
399
     *  defaultValues={
400
     *      "dataaudit"={"auditable"=true},
401
     *      "importexport"={
402
     *          "order"=180,
403
     *          "short"=true
404
     *      }
405
     *  }
406
     * )
407
     */
408
    protected $owner;
409
410
    /**
411
     * @var ArrayCollection
412
     *
413
     * @ORM\OneToMany(targetEntity="OroCRM\Bundle\SalesBundle\Entity\Opportunity", mappedBy="lead")
414
     * @ConfigField(
415
     *  defaultValues={
416
     *      "importexport"={
417
     *          "order"=190,
418
     *          "short"=true
419
     *      }
420
     *  }
421
     * )
422
     */
423
    protected $opportunities;
424
425
    /**
426
     * @var string
427
     *
428
     * @ORM\Column(name="notes", type="text", nullable=true)
429
     * @Oro\Versioned
430
     * @ConfigField(
431
     *  defaultValues={
432
     *      "dataaudit"={"auditable"=true},
433
     *      "importexport"={
434
     *          "order"=140
435
     *      }
436
     *  }
437
     * )
438
     */
439
    protected $notes;
440
441
    /**
442
     * @var WorkflowItem
443
     *
444
     * @ORM\OneToOne(targetEntity="Oro\Bundle\WorkflowBundle\Entity\WorkflowItem")
445
     * @ORM\JoinColumn(name="workflow_item_id", referencedColumnName="id", onDelete="SET NULL")
446
     */
447
    protected $workflowItem;
448
449
    /**
450
     * @var WorkflowStep
451
     *
452
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\WorkflowBundle\Entity\WorkflowStep")
453
     * @ORM\JoinColumn(name="workflow_step_id", referencedColumnName="id", onDelete="SET NULL")
454
     */
455
    protected $workflowStep;
456
457
    /**
458
     * @var Organization
459
     *
460
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization")
461
     * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL")
462
     */
463
    protected $organization;
464
465
    /**
466
     * @var B2bCustomer
467
     *
468
     * @ORM\ManyToOne(targetEntity="OroCRM\Bundle\SalesBundle\Entity\B2bCustomer", inversedBy="leads")
469
     * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="SET NULL")
470
     * @Oro\Versioned
471
     * @ConfigField(
472
     *  defaultValues={
473
     *      "dataaudit"={"auditable"=true},
474
     *      "importexport"={
475
     *          "order"=160,
476
     *          "short"=true
477
     *      }
478
     *  }
479
     * )
480
     */
481
    protected $customer;
482
483
    /**
484
     * Constructor
485
     */
486
    public function __construct()
487
    {
488
        parent::__construct();
489
490
        $this->opportunities = new ArrayCollection();
491
    }
492
493
    /**
494
     * Get id
495
     *
496
     * @return integer
497
     */
498
    public function getId()
499
    {
500
        return $this->id;
501
    }
502
503
    /**
504
     * Set topic
505
     *
506
     * @param string $name
507
     *
508
     * @return Lead
509
     */
510
    public function setName($name)
511
    {
512
        $this->name = $name;
513
514
        return $this;
515
    }
516
517
    /**
518
     * Get topic
519
     *
520
     * @return string
521
     */
522
    public function getName()
523
    {
524
        return $this->name;
525
    }
526
527
    /**
528
     * @param string $namePrefix
529
     *
530
     * @return Lead
531
     */
532
    public function setNamePrefix($namePrefix)
533
    {
534
        $this->namePrefix = $namePrefix;
535
536
        return $this;
537
    }
538
539
    /**
540
     * @return string
541
     */
542
    public function getNamePrefix()
543
    {
544
        return $this->namePrefix;
545
    }
546
547
    /**
548
     * Set first name
549
     *
550
     * @param string $firstName
551
     *
552
     * @return Lead
553
     */
554
    public function setFirstName($firstName)
555
    {
556
        $this->firstName = $firstName;
557
558
        return $this;
559
    }
560
561
    /**
562
     * Get first name
563
     *
564
     * @return string
565
     */
566
    public function getFirstName()
567
    {
568
        return $this->firstName;
569
    }
570
571
    /**
572
     * @return string
573
     */
574
    public function getMiddleName()
575
    {
576
        return $this->middleName;
577
    }
578
579
    /**
580
     * @param string $middleName
581
     *
582
     * @return Lead
583
     */
584
    public function setMiddleName($middleName)
585
    {
586
        $this->middleName = $middleName;
587
588
        return $this;
589
    }
590
591
    /**
592
     * Set last name
593
     *
594
     * @param string $lastName
595
     *
596
     * @return Lead
597
     */
598
    public function setLastName($lastName)
599
    {
600
        $this->lastName = $lastName;
601
602
        return $this;
603
    }
604
605
    /**
606
     * Get lastName
607
     *
608
     * @return string
609
     */
610
    public function getLastName()
611
    {
612
        return $this->lastName;
613
    }
614
615
    /**
616
     * @param string $nameSuffix
617
     *
618
     * @return Lead
619
     */
620
    public function setNameSuffix($nameSuffix)
621
    {
622
        $this->nameSuffix = $nameSuffix;
623
624
        return $this;
625
    }
626
627
    /**
628
     * @return string
629
     */
630
    public function getNameSuffix()
631
    {
632
        return $this->nameSuffix;
633
    }
634
635
    /**
636
     * Set job title
637
     *
638
     * @param string $jobTitle
639
     *
640
     * @return Lead
641
     */
642
    public function setJobTitle($jobTitle)
643
    {
644
        $this->jobTitle = $jobTitle;
645
646
        return $this;
647
    }
648
649
    /**
650
     * Get job title
651
     *
652
     * @return string
653
     */
654
    public function getJobTitle()
655
    {
656
        return $this->jobTitle;
657
    }
658
659
    /**
660
     * Set phone number
661
     *
662
     * @param string $phoneNumber
663
     *
664
     * @return Lead
665
     */
666
    public function setPhoneNumber($phoneNumber)
667
    {
668
        $this->phoneNumber = $phoneNumber;
669
670
        return $this;
671
    }
672
673
    /**
674
     * Get phone number
675
     *
676
     * @return string
677
     */
678
    public function getPhoneNumber()
679
    {
680
        return $this->phoneNumber;
681
    }
682
683
    /**
684
     * Set email
685
     *
686
     * @param string $email
687
     *
688
     * @return Lead
689
     */
690
    public function setEmail($email)
691
    {
692
        $this->email = $email;
693
694
        return $this;
695
    }
696
697
    /**
698
     * Get email
699
     *
700
     * @return string
701
     */
702
    public function getEmail()
703
    {
704
        return $this->email;
705
    }
706
707
    /**
708
     * Set company name
709
     *
710
     * @param string $companyName
711
     *
712
     * @return Lead
713
     */
714
    public function setCompanyName($companyName)
715
    {
716
        $this->companyName = $companyName;
717
718
        return $this;
719
    }
720
721
    /**
722
     * Get company name
723
     *
724
     * @return string
725
     */
726
    public function getCompanyName()
727
    {
728
        return $this->companyName;
729
    }
730
731
    /**
732
     * Set website
733
     *
734
     * @param string $website
735
     *
736
     * @return Lead
737
     */
738
    public function setWebsite($website)
739
    {
740
        $this->website = $website;
741
742
        return $this;
743
    }
744
745
    /**
746
     * Get website
747
     *
748
     * @return string
749
     */
750
    public function getWebsite()
751
    {
752
        return $this->website;
753
    }
754
755
    /**
756
     * Set number of employees
757
     *
758
     * @param integer $numberOfEmployees
759
     *
760
     * @return Lead
761
     */
762
    public function setNumberOfEmployees($numberOfEmployees)
763
    {
764
        $this->numberOfEmployees = $numberOfEmployees;
765
766
        return $this;
767
    }
768
769
    /**
770
     * Get number of employees
771
     *
772
     * @return integer
773
     */
774
    public function getNumberOfEmployees()
775
    {
776
        return $this->numberOfEmployees;
777
    }
778
779
    /**
780
     * Set industry
781
     *
782
     * @param string $industry
783
     *
784
     * @return Lead
785
     */
786
    public function setIndustry($industry)
787
    {
788
        $this->industry = $industry;
789
790
        return $this;
791
    }
792
793
    /**
794
     * Get industry
795
     *
796
     * @return string
797
     */
798
    public function getIndustry()
799
    {
800
        return $this->industry;
801
    }
802
803
    /**
804
     * @return LeadStatus
805
     */
806
    public function getStatus()
807
    {
808
        return $this->status;
809
    }
810
811
    /**
812
     * @param LeadStatus $status
813
     *
814
     * @return Lead
815
     */
816
    public function setStatus($status)
817
    {
818
        $this->status = $status;
819
820
        return $this;
821
    }
822
823
    /**
824
     * Get address
825
     *
826
     * @return Address
827
     */
828
    public function getAddress()
829
    {
830
        return $this->address;
831
    }
832
833
    /**
834
     * Set address
835
     *
836
     * @param Address $address
837
     *
838
     * @return Lead
839
     */
840
    public function setAddress($address)
841
    {
842
        $this->address = $address;
843
844
        return $this;
845
    }
846
847
    /**
848
     * @param Contact $contact
849
     *
850
     * @return Lead
851
     */
852
    public function setContact($contact)
853
    {
854
        $this->contact = $contact;
855
856
        return $this;
857
    }
858
859
    /**
860
     * @return Contact
861
     */
862
    public function getContact()
863
    {
864
        return $this->contact;
865
    }
866
867
    /**
868
     * Get contact created date/time
869
     *
870
     * @return \DateTime
871
     */
872
    public function getCreatedAt()
873
    {
874
        return $this->createdAt;
875
    }
876
877
    /**
878
     * @param \DateTime $created
879
     *
880
     * @return Lead
881
     */
882
    public function setCreatedAt($created)
883
    {
884
        $this->createdAt = $created;
885
886
        return $this;
887
    }
888
889
    /**
890
     * Get contact last update date/time
891
     *
892
     * @return \DateTime
893
     */
894
    public function getUpdatedAt()
895
    {
896
        return $this->updatedAt;
897
    }
898
899
    /**
900
     * @param \DateTime $updated
901
     *
902
     * @return Lead
903
     */
904
    public function setUpdatedAt($updated)
905
    {
906
        $this->updatedAt = $updated;
907
908
        return $this;
909
    }
910
911
    /**
912
     * @return string
913
     */
914
    public function __toString()
915
    {
916
        return (string) $this->getName();
917
    }
918
919
    /**
920
     * Pre persist event listener
921
     *
922
     * @ORM\PrePersist
923
     */
924
    public function beforeSave()
925
    {
926
        $this->createdAt = new \DateTime('now', new \DateTimeZone('UTC'));
927
    }
928
929
    /**
930
     * Pre update event handler
931
     * @ORM\PreUpdate
932
     */
933
    public function beforeUpdate()
934
    {
935
        $this->updatedAt = new \DateTime('now', new \DateTimeZone('UTC'));
936
    }
937
938
    /**
939
     * @return User
940
     */
941
    public function getOwner()
942
    {
943
        return $this->owner;
944
    }
945
946
    /**
947
     * @param User $owningUser
948
     *
949
     * @return Lead
950
     */
951
    public function setOwner($owningUser)
952
    {
953
        $this->owner = $owningUser;
954
955
        return $this;
956
    }
957
958
    /**
959
     * Get opportunities
960
     *
961
     * @return Opportunity[]
962
     */
963
    public function getOpportunities()
964
    {
965
        return $this->opportunities;
966
    }
967
968
    /**
969
     * Add opportunity
970
     *
971
     * @param Opportunity $opportunity
972
     *
973
     * @return Lead
974
     */
975 View Code Duplication
    public function addOpportunity(Opportunity $opportunity)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
976
    {
977
        if (!$this->opportunities->contains($opportunity)) {
978
            $opportunity->setLead($this);
979
            $this->opportunities->add($opportunity);
980
        }
981
982
        return $this;
983
    }
984
985
    /**
986
     * @param Opportunity $opportunity
987
     *
988
     * @return Lead
989
     */
990 View Code Duplication
    public function removeOpportunity(Opportunity $opportunity)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
991
    {
992
        if ($this->opportunities->contains($opportunity)) {
993
            $this->opportunities->removeElement($opportunity);
994
            $opportunity->setLead(null);
0 ignored issues
show
Documentation introduced by
null is of type null, but the function expects a object<OroCRM\Bundle\SalesBundle\Entity\Lead>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
995
        }
996
997
        return $this;
998
    }
999
1000
    /**
1001
     * @return string
1002
     */
1003
    public function getNotes()
1004
    {
1005
        return $this->notes;
1006
    }
1007
1008
    /**
1009
     * @param string $notes
1010
     *
1011
     * @return Lead
1012
     */
1013
    public function setNotes($notes)
1014
    {
1015
        $this->notes = $notes;
1016
1017
        return $this;
1018
    }
1019
1020
    /**
1021
     * @param WorkflowItem $workflowItem
1022
     *
1023
     * @return Lead
1024
     */
1025
    public function setWorkflowItem($workflowItem)
1026
    {
1027
        $this->workflowItem = $workflowItem;
1028
1029
        return $this;
1030
    }
1031
1032
    /**
1033
     * @return WorkflowItem
1034
     */
1035
    public function getWorkflowItem()
1036
    {
1037
        return $this->workflowItem;
1038
    }
1039
1040
    /**
1041
     * @param WorkflowItem $workflowStep
1042
     *
1043
     * @return Lead
1044
     */
1045
    public function setWorkflowStep($workflowStep)
1046
    {
1047
        $this->workflowStep = $workflowStep;
0 ignored issues
show
Documentation Bug introduced by
It seems like $workflowStep of type object<Oro\Bundle\Workfl...le\Entity\WorkflowItem> is incompatible with the declared type object<Oro\Bundle\Workfl...le\Entity\WorkflowStep> of property $workflowStep.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
1048
1049
        return $this;
1050
    }
1051
1052
    /**
1053
     * @return WorkflowStep
1054
     */
1055
    public function getWorkflowStep()
1056
    {
1057
        return $this->workflowStep;
1058
    }
1059
1060
    /**
1061
     * @param B2bCustomer $customer
1062
     * @TODO remove null after BAP-5248
1063
     */
1064
    public function setCustomer(B2bCustomer $customer = null)
1065
    {
1066
        $this->customer = $customer;
1067
    }
1068
1069
    /**
1070
     * @return B2bCustomer
1071
     */
1072
    public function getCustomer()
1073
    {
1074
        return $this->customer;
1075
    }
1076
1077
    /**
1078
     * @ORM\PrePersist
1079
     */
1080
    public function prePersist(LifecycleEventArgs $eventArgs)
1081
    {
1082
        if (!$this->status) {
1083
            $em = $eventArgs->getEntityManager();
1084
            /** @var LeadStatus $defaultStatus */
1085
            $defaultStatus = $em->getReference('OroCRMSalesBundle:LeadStatus', 'new');
1086
            $this->setStatus($defaultStatus);
1087
        }
1088
    }
1089
1090
    /**
1091
     * Set organization
1092
     *
1093
     * @param Organization $organization
1094
     * @return Lead
1095
     */
1096
    public function setOrganization(Organization $organization = null)
1097
    {
1098
        $this->organization = $organization;
1099
1100
        return $this;
1101
    }
1102
1103
    /**
1104
     * Get organization
1105
     *
1106
     * @return Organization
1107
     */
1108
    public function getOrganization()
1109
    {
1110
        return $this->organization;
1111
    }
1112
1113
    /**
1114
     * Remove Customer
1115
     *
1116
     * @return Lead
1117
     */
1118
    public function removeCustomer()
1119
    {
1120
        $this->customer = null;
1121
    }
1122
}
1123