Completed
Push — master ( 664fb1...60ffba )
by
unknown
26:32
created

Opportunity   F

Complexity

Total Complexity 60

Size/Duplication

Total Lines 886
Duplicated Lines 0 %

Coupling/Cohesion

Components 4
Dependencies 4

Importance

Changes 0
Metric Value
wmc 60
lcom 4
cbo 4
dl 0
loc 886
rs 3.4285
c 0
b 0
f 0

50 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 4 1
A setLead() 0 6 1
A getLead() 0 4 1
A getBudgetAmount() 0 4 1
A setBudgetAmount() 0 7 1
A loadMultiCurrencyFields() 0 5 1
B updateMultiCurrencyFields() 0 17 5
A setBudgetAmountCurrency() 0 10 2
A setBudgetAmountValue() 0 10 2
A getBudgetAmountCurrency() 0 4 1
A getBudgetAmountValue() 0 4 1
A setCloseRevenueCurrency() 0 10 2
A setCloseRevenueValue() 0 10 2
A getCloseRevenueCurrency() 0 4 1
A getCloseRevenueValue() 0 4 1
A setCloseDate() 0 6 1
A getCloseDate() 0 4 1
A setContact() 0 6 1
A getContact() 0 4 1
A setCustomerNeed() 0 6 1
A getCustomerNeed() 0 4 1
A setProbability() 0 6 1
A getProbability() 0 4 1
A setProposedSolution() 0 6 1
A getProposedSolution() 0 4 1
A setName() 0 6 1
A getName() 0 4 1
A setCloseReason() 0 6 1
A getCloseReason() 0 4 1
A setCloseRevenue() 0 9 2
A getCloseRevenue() 0 4 1
A getCreatedAt() 0 4 1
A setCreatedAt() 0 6 1
A getUpdatedAt() 0 4 1
A setUpdatedAt() 0 6 1
A getEmail() 0 9 2
A __toString() 0 4 1
A beforeSave() 0 5 1
A beforeUpdate() 0 4 1
A getOwner() 0 4 1
A setOwner() 0 6 1
A getNotes() 0 4 1
A setNotes() 0 6 1
A setCustomer() 0 4 1
A getCustomer() 0 4 1
A setOrganization() 0 6 1
A getOrganization() 0 4 1
A removeCustomer() 0 4 1
A setClosedAt() 0 4 1
A getClosedAt() 0 4 1

How to fix   Complexity   

Complex Class

Complex classes like Opportunity 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. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

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 Opportunity, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
namespace Oro\Bundle\SalesBundle\Entity;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
use Oro\Bundle\CurrencyBundle\Entity\MultiCurrency;
8
use Oro\Bundle\CurrencyBundle\Entity\MultiCurrencyHolderInterface;
9
use Oro\Bundle\DataAuditBundle\Metadata\Annotation as Oro;
10
use Oro\Bundle\EmailBundle\Model\EmailHolderInterface;
11
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\Config;
12
use Oro\Bundle\EntityConfigBundle\Metadata\Annotation\ConfigField;
13
use Oro\Bundle\OrganizationBundle\Entity\Organization;
14
use Oro\Bundle\UserBundle\Entity\User;
15
use Oro\Bundle\ChannelBundle\Model\ChannelEntityTrait;
16
use Oro\Bundle\ContactBundle\Entity\Contact;
17
use Oro\Bundle\SalesBundle\Model\ExtendOpportunity;
18
use Oro\Bundle\ChannelBundle\Model\ChannelAwareInterface;
19
20
/**
21
 * @ORM\Entity(repositoryClass="Oro\Bundle\SalesBundle\Entity\Repository\OpportunityRepository")
22
 * @ORM\Table(
23
 *      name="orocrm_sales_opportunity",
24
 *      indexes={@ORM\Index(name="opportunity_created_idx",columns={"created_at"})}
25
 * )
26
 * @ORM\HasLifecycleCallbacks()
27
 * @Config(
28
 *      routeName="oro_sales_opportunity_index",
29
 *      routeView="oro_sales_opportunity_view",
30
 *      defaultValues={
31
 *          "entity"={
32
 *              "icon"="icon-usd"
33
 *          },
34
 *          "ownership"={
35
 *              "owner_type"="USER",
36
 *              "owner_field_name"="owner",
37
 *              "owner_column_name"="user_owner_id",
38
 *              "organization_field_name"="organization",
39
 *              "organization_column_name"="organization_id"
40
 *          },
41
 *          "security"={
42
 *              "type"="ACL",
43
 *              "group_name"="",
44
 *              "category"="sales_data",
45
 *              "field_acl_supported" = "true"
46
 *          },
47
 *          "form"={
48
 *              "form_type"="oro_sales_opportunity_select",
49
 *              "grid_name"="sales-opportunity-grid",
50
 *          },
51
 *          "dataaudit"={
52
 *              "auditable"=true,
53
 *              "immutable"=true
54
 *          },
55
 *          "grid"={
56
 *              "default"="sales-opportunity-grid",
57
 *              "context"="sales-opportunity-for-context-grid"
58
 *          },
59
 *          "tag"={
60
 *              "enabled"=true
61
 *          }
62
 *     }
63
 * )
64
 *
65
 * @SuppressWarnings(PHPMD.ExcessivePublicCount)
66
 * @SuppressWarnings(PHPMD.ExcessiveClassComplexity)
67
 */
68
class Opportunity extends ExtendOpportunity implements
69
    EmailHolderInterface,
70
    ChannelAwareInterface,
71
    MultiCurrencyHolderInterface
72
{
73
    use ChannelEntityTrait;
74
75
    const INTERNAL_STATUS_CODE = 'opportunity_status';
76
77
    const STATUS_LOST = 'lost';
78
    const STATUS_WON  = 'won';
79
80
    /**
81
     * The key in system config for probability - status map
82
     */
83
    const PROBABILITIES_CONFIG_KEY = 'oro_sales.default_opportunity_probabilities';
84
85
    /**
86
     * @var int
87
     *
88
     * @ORM\Id
89
     * @ORM\Column(type="integer", name="id")
90
     * @ORM\GeneratedValue(strategy="AUTO")
91
     * @ConfigField(
92
     *  defaultValues={
93
     *      "importexport"={
94
     *          "order"=0
95
     *      }
96
     *  }
97
     * )
98
     */
99
    protected $id;
100
101
    /**
102
     * @var OpportunityCloseReason
103
     *
104
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\SalesBundle\Entity\OpportunityCloseReason")
105
     * @ORM\JoinColumn(name="close_reason_name", referencedColumnName="name")
106
     * @ConfigField(
107
     *  defaultValues={
108
     *      "dataaudit"={"auditable"=true},
109
     *      "importexport"={
110
     *          "order"=100,
111
     *          "short"=true
112
     *      }
113
     *  }
114
     * )
115
     **/
116
    protected $closeReason;
117
118
    /**
119
     * @var Contact
120
     *
121
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\ContactBundle\Entity\Contact", cascade={"persist"})
122
     * @ORM\JoinColumn(name="contact_id", referencedColumnName="id", onDelete="SET NULL")
123
     * @ConfigField(
124
     *  defaultValues={
125
     *      "dataaudit"={"auditable"=true},
126
     *      "importexport"={
127
     *          "order"=120,
128
     *          "short"=true
129
     *      },
130
     *      "form"={
131
     *          "form_type"="oro_contact_select"
132
     *      }
133
     *  }
134
     * )
135
     **/
136
    protected $contact;
137
138
    /**
139
     * @var Lead
140
     *
141
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\SalesBundle\Entity\Lead", inversedBy="opportunities")
142
     * @ORM\JoinColumn(name="lead_id", referencedColumnName="id", onDelete="SET NULL")
143
     * @ConfigField(
144
     *  defaultValues={
145
     *      "dataaudit"={"auditable"=true},
146
     *      "importexport"={
147
     *          "order"=130,
148
     *          "short"=true
149
     *      }
150
     *  }
151
     * )
152
     **/
153
    protected $lead;
154
155
    /**
156
     * @var User
157
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\UserBundle\Entity\User")
158
     * @ORM\JoinColumn(name="user_owner_id", referencedColumnName="id", onDelete="SET NULL")
159
     * @ConfigField(
160
     *  defaultValues={
161
     *      "dataaudit"={"auditable"=true, "immutable"=true},
162
     *      "importexport"={
163
     *          "order"=140,
164
     *          "short"=true
165
     *      }
166
     *  }
167
     * )
168
     */
169
    protected $owner;
170
171
    /**
172
     * @var string
173
     *
174
     * @ORM\Column(name="name", type="string", length=255, nullable=false)
175
     * @ConfigField(
176
     *  defaultValues={
177
     *      "dataaudit"={"auditable"=true},
178
     *      "importexport"={
179
     *          "order"=10,
180
     *          "identity"=true
181
     *      }
182
     *  }
183
     * )
184
     */
185
    protected $name;
186
187
    /**
188
     * @var \DateTime
189
     *
190
     * @ORM\Column(name="close_date", type="date", nullable=true)
191
     * @ConfigField(
192
     *  defaultValues={
193
     *      "dataaudit"={"auditable"=true, "immutable"=true},
194
     *      "importexport"={
195
     *          "order"=20
196
     *      }
197
     *  }
198
     * )
199
     */
200
    protected $closeDate;
201
202
    /**
203
     * @var float
204
     *
205
     * @ORM\Column(name="probability", type="percent", nullable=true)
206
     * @ConfigField(
207
     *  defaultValues={
208
     *      "form"={
209
     *          "form_type"="oro_percent",
210
     *          "form_options"={
211
     *              "constraints"={{"Range":{"min":0, "max":100}}},
212
     *          }
213
     *      },
214
     *      "dataaudit"={"auditable"=true, "immutable"=true},
215
     *      "importexport"={
216
     *          "order"=30
217
     *      }
218
     *  }
219
     * )
220
     */
221
    protected $probability;
222
223
    /**
224
     * Changes to this value object wont affect entity change set
225
     * To change persisted price value you should create and set new Multicurrency
226
     *
227
     * @var Multicurrency
228
     */
229
    protected $budgetAmount;
230
231
    /**
232
     * @var string
233
     *
234
     * @ORM\Column(name="budget_amount_currency", type="currency", length=3, nullable=true)
235
     * @ConfigField(
236
     *  defaultValues={
237
     *      "dataaudit"={"auditable"=true, "immutable"=true},
238
     *      "importexport"={
239
     *          "order"=55
240
     *      }
241
     *  }
242
     * )
243
     */
244
    protected $budgetAmountCurrency;
245
246
    /**
247
     * @var double
248
     *
249
     * @ORM\Column(name="budget_amount_value", type="money_value", nullable=true)
250
     * @ConfigField(
251
     *  defaultValues={
252
     *      "form"={
253
     *          "form_type"="oro_money",
254
     *          "form_options"={
255
     *              "constraints"={{"Range":{"min":0}}},
256
     *          }
257
     *      },
258
     *      "dataaudit"={
259
     *          "auditable"=true
260
     *      },
261
     *      "importexport"={
262
     *          "order"=50
263
     *      },
264
     *     "multicurrency"={
265
     *          "target" = "budgetAmount",
266
     *          "virtual_field" = "budgetAmountBaseCurrency"
267
     *      }
268
     *  }
269
     * )
270
     */
271
    protected $budgetAmountValue;
272
273
    /**
274
     * Changes to this value object wont affect entity change set
275
     * To change persisted price value you should create and set new Multicurrency
276
     *
277
     * @var Multicurrency
278
     */
279
    protected $closeRevenue;
280
281
    /**
282
     * @var string
283
     *
284
     * @ORM\Column(name="close_revenue_currency", type="currency", length=3, nullable=true)
285
     * @ConfigField(
286
     *  defaultValues={
287
     *      "dataaudit"={"auditable"=true, "immutable"=true},
288
     *      "importexport"={
289
     *          "order"=65
290
     *      }
291
     *  }
292
     * )
293
     */
294
    protected $closeRevenueCurrency;
295
296
    /**
297
     * @var double
298
     *
299
     * @ORM\Column(name="close_revenue_value", type="money_value", nullable=true)
300
     * @ConfigField(
301
     *  defaultValues={
302
     *      "form"={
303
     *          "form_type"="oro_money",
304
     *          "form_options"={
305
     *              "constraints"={{"Range":{"min":0}}},
306
     *          }
307
     *      },
308
     *      "dataaudit"={
309
     *          "auditable"=true
310
     *      },
311
     *      "importexport"={
312
     *          "order"=60
313
     *      },
314
     *      "multicurrency"={
315
     *          "target" = "closeRevenue",
316
     *          "virtual_field" = "closeRevenueBaseCurrency"
317
     *      }
318
     *  }
319
     * )
320
     */
321
    protected $closeRevenueValue;
322
323
    /**
324
     * @var string
325
     *
326
     * @ORM\Column(name="customer_need", type="text", nullable=true)
327
     * @ConfigField(
328
     *  defaultValues={
329
     *      "dataaudit"={"auditable"=true},
330
     *      "importexport"={
331
     *          "order"=60
332
     *      }
333
     *  }
334
     * )
335
     */
336
    protected $customerNeed;
337
338
    /**
339
     * @var string
340
     *
341
     * @ORM\Column(name="proposed_solution", type="text", nullable=true)
342
     * @ConfigField(
343
     *  defaultValues={
344
     *      "dataaudit"={"auditable"=true},
345
     *      "importexport"={
346
     *          "order"=70
347
     *      }
348
     *  }
349
     * )
350
     */
351
    protected $proposedSolution;
352
353
    /**
354
     * @var \DateTime
355
     *
356
     * @ORM\Column(name="created_at", type="datetime")
357
     * @ConfigField(
358
     *      defaultValues={
359
     *          "entity"={
360
     *              "label"="oro.ui.created_at"
361
     *          },
362
     *          "importexport"={
363
     *              "excluded"=true
364
     *          }
365
     *      }
366
     * )
367
     */
368
    protected $createdAt;
369
370
    /**
371
     * @var \DateTime
372
     *
373
     * @ORM\Column(name="updated_at", type="datetime")
374
     * @ConfigField(
375
     *      defaultValues={
376
     *          "entity"={
377
     *              "label"="oro.ui.updated_at"
378
     *          },
379
     *          "importexport"={
380
     *              "excluded"=true
381
     *          }
382
     *      }
383
     * )
384
     */
385
    protected $updatedAt;
386
387
    /**
388
     * @var string
389
     *
390
     * @ORM\Column(name="notes", type="text", nullable=true)
391
     * @ConfigField(
392
     *      defaultValues={
393
     *          "dataaudit"={
394
     *              "auditable"=true
395
     *          },
396
     *          "importexport"={
397
     *              "order"=80
398
     *          }
399
     *      }
400
     * )
401
     */
402
    protected $notes;
403
404
    /**
405
     * @var Organization
406
     *
407
     * @ORM\ManyToOne(targetEntity="Oro\Bundle\OrganizationBundle\Entity\Organization")
408
     * @ORM\JoinColumn(name="organization_id", referencedColumnName="id", onDelete="SET NULL")
409
     */
410
    protected $organization;
411
412
    /**
413
     * @var B2bCustomer
414
     *
415
     * @ORM\ManyToOne(
416
     *     targetEntity="Oro\Bundle\SalesBundle\Entity\B2bCustomer",
417
     *     inversedBy="opportunities",
418
     *     cascade={"persist"}
419
     * )
420
     * @ORM\JoinColumn(name="customer_id", referencedColumnName="id", onDelete="SET NULL")
421
     * @ConfigField(
422
     *  defaultValues={
423
     *      "dataaudit"={"auditable"=true},
424
     *      "importexport"={
425
     *          "order"=110,
426
     *          "short"=true
427
     *      },
428
     *      "form"={
429
     *          "form_type"="oro_sales_b2bcustomer_select"
430
     *      }
431
     *  }
432
     * )
433
     */
434
    protected $customer;
435
436
    /**
437
     * @var \DateTime
438
     *
439
     * @ORM\Column(type="datetime", name="closed_at", nullable=true)
440
     * @ConfigField(
441
     *  defaultValues={
442
     *      "dataaudit"={"auditable"=true, "immutable"=true},
443
     *      "importexport"={"excluded"=true, "immutable"=true}
444
     *  }
445
     * )
446
     */
447
    protected $closedAt;
448
449
    /**
450
     * @return int
451
     */
452
    public function getId()
453
    {
454
        return $this->id;
455
    }
456
457
    /**
458
     * @param  Lead        $lead
459
     * @return Opportunity
460
     */
461
    public function setLead($lead)
462
    {
463
        $this->lead = $lead;
464
465
        return $this;
466
    }
467
468
    /**
469
     * @return Lead
470
     */
471
    public function getLead()
472
    {
473
        return $this->lead;
474
    }
475
476
    /**
477
     * @return MultiCurrency|null
478
     */
479
    public function getBudgetAmount()
480
    {
481
        return $this->budgetAmount;
482
    }
483
484
    /**
485
     * @param MultiCurrency $budgetAmount|null
0 ignored issues
show
Documentation introduced by
There is no parameter named $budgetAmount|null. Did you maybe mean $budgetAmount?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
486
     * @return Opportunity
487
     */
488
    public function setBudgetAmount(MultiCurrency $budgetAmount = null)
489
    {
490
        $this->budgetAmount = $budgetAmount;
0 ignored issues
show
Documentation Bug introduced by
It seems like $budgetAmount can also be of type object<Oro\Bundle\Curren...e\Entity\MultiCurrency>. However, the property $budgetAmount is declared as type object<Oro\Bundle\SalesB...e\Entity\Multicurrency>. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
491
        $this->updateMultiCurrencyFields();
492
493
        return $this;
494
    }
495
496
    /**
497
     * @ORM\PostLoad
498
     */
499
    public function loadMultiCurrencyFields()
500
    {
501
        $this->budgetAmount = MultiCurrency::create($this->budgetAmountValue, $this->budgetAmountCurrency);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Oro\Bundle\CurrencyBund...->budgetAmountCurrency) of type object<Oro\Bundle\Curren...e\Entity\MultiCurrency> is incompatible with the declared type object<Oro\Bundle\SalesB...e\Entity\Multicurrency> of property $budgetAmount.

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...
502
        $this->closeRevenue = MultiCurrency::create($this->closeRevenueValue, $this->closeRevenueCurrency);
0 ignored issues
show
Documentation Bug introduced by
It seems like \Oro\Bundle\CurrencyBund...->closeRevenueCurrency) of type object<Oro\Bundle\Curren...e\Entity\MultiCurrency> is incompatible with the declared type object<Oro\Bundle\SalesB...e\Entity\Multicurrency> of property $closeRevenue.

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...
503
    }
504
505
    /**
506
     * @ORM\PrePersist
507
     * @ORM\PreUpdate
508
     *
509
     * @return void
510
     */
511
    public function updateMultiCurrencyFields()
512
    {
513
        if ($this->budgetAmount) {
514
            $this->budgetAmountValue = $this->budgetAmount->getValue();
515
            $currency = $this->budgetAmount->getValue() !== null ?
516
                $this->budgetAmount->getCurrency() :
517
                null;
518
            $this->budgetAmountCurrency = $currency;
519
        }
520
        if ($this->closeRevenue) {
521
            $this->closeRevenueValue = $this->closeRevenue->getValue();
522
            $currency = $this->closeRevenue->getValue() !== null ?
523
                $this->closeRevenue->getCurrency() :
524
                null;
525
            $this->closeRevenueCurrency = $currency;
526
        }
527
    }
528
529
    /**
530
     * @param string $currency
531
     * @return Opportunity
532
     */
533
    public function setBudgetAmountCurrency($currency)
534
    {
535
        $this->budgetAmountCurrency = $currency;
536
537
        if ($this->budgetAmount instanceof MultiCurrency) {
538
            $this->budgetAmount->setCurrency($currency);
539
        }
540
541
        return $this;
542
    }
543
544
    /**
545
     * @param string $budgetAmountValue
546
     * @return Opportunity
547
     */
548
    public function setBudgetAmountValue($budgetAmountValue)
549
    {
550
        $this->budgetAmountValue = $budgetAmountValue;
0 ignored issues
show
Documentation Bug introduced by
The property $budgetAmountValue was declared of type double, but $budgetAmountValue is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
551
552
        if ($this->budgetAmount instanceof MultiCurrency) {
553
            $this->budgetAmount->setValue($budgetAmountValue);
554
        }
555
556
        return $this;
557
    }
558
559
    /**
560
     * @return string
561
     */
562
    public function getBudgetAmountCurrency()
563
    {
564
        return $this->budgetAmountCurrency;
565
    }
566
567
    /**
568
     * @return float
569
     */
570
    public function getBudgetAmountValue()
571
    {
572
        return $this->budgetAmountValue;
573
    }
574
575
    /**
576
     * @param string $currency
577
     * @return Opportunity
578
     */
579
    public function setCloseRevenueCurrency($currency)
580
    {
581
        $this->closeRevenueCurrency = $currency;
582
583
        if ($this->closeRevenue instanceof MultiCurrency) {
584
            $this->closeRevenue->setCurrency($currency);
585
        }
586
587
        return $this;
588
    }
589
590
    /**
591
     * @param float $closeRevenueValue
592
     * @return Opportunity
593
     */
594
    public function setCloseRevenueValue($closeRevenueValue)
595
    {
596
        $this->closeRevenueValue = $closeRevenueValue;
597
598
        if ($this->closeRevenue instanceof MultiCurrency) {
599
            $this->closeRevenue->setValue($closeRevenueValue);
600
        }
601
602
        return $this;
603
    }
604
605
    /**
606
     * @return string
607
     */
608
    public function getCloseRevenueCurrency()
609
    {
610
        return $this->closeRevenueCurrency;
611
    }
612
613
    /**
614
     * @return float
615
     */
616
    public function getCloseRevenueValue()
617
    {
618
        return $this->closeRevenueValue;
619
    }
620
621
    /**
622
     * @param  \DateTime   $closeDate
623
     * @return Opportunity
624
     */
625
    public function setCloseDate($closeDate)
626
    {
627
        $this->closeDate = $closeDate;
628
629
        return $this;
630
    }
631
632
    /**
633
     * @return \DateTime
634
     */
635
    public function getCloseDate()
636
    {
637
        return $this->closeDate;
638
    }
639
640
    /**
641
     * @param  Contact     $contact
642
     * @return Opportunity
643
     */
644
    public function setContact($contact)
645
    {
646
        $this->contact = $contact;
647
648
        return $this;
649
    }
650
651
    /**
652
     * @return Contact
653
     */
654
    public function getContact()
655
    {
656
        return $this->contact;
657
    }
658
659
    /**
660
     * @param  string      $customerNeed
661
     * @return Opportunity
662
     */
663
    public function setCustomerNeed($customerNeed)
664
    {
665
        $this->customerNeed = $customerNeed;
666
667
        return $this;
668
    }
669
670
    /**
671
     * @return string
672
     */
673
    public function getCustomerNeed()
674
    {
675
        return $this->customerNeed;
676
    }
677
678
    /**
679
     * @param  float       $probability
680
     * @return Opportunity
681
     */
682
    public function setProbability($probability)
683
    {
684
        $this->probability = $probability;
685
686
        return $this;
687
    }
688
689
    /**
690
     * @return float
691
     */
692
    public function getProbability()
693
    {
694
        return $this->probability;
695
    }
696
697
    /**
698
     * @param  string      $proposedSolution
699
     * @return Opportunity
700
     */
701
    public function setProposedSolution($proposedSolution)
702
    {
703
        $this->proposedSolution = $proposedSolution;
704
705
        return $this;
706
    }
707
708
    /**
709
     * @return string
710
     */
711
    public function getProposedSolution()
712
    {
713
        return $this->proposedSolution;
714
    }
715
716
    /**
717
     * @param  string      $name
718
     * @return Opportunity
719
     */
720
    public function setName($name)
721
    {
722
        $this->name = $name;
723
724
        return $this;
725
    }
726
727
    /**
728
     * @return string
729
     */
730
    public function getName()
731
    {
732
        return $this->name;
733
    }
734
735
    /**
736
     * @param  OpportunityCloseReason $closeReason
737
     * @return Opportunity
738
     */
739
    public function setCloseReason($closeReason)
740
    {
741
        $this->closeReason = $closeReason;
742
743
        return $this;
744
    }
745
746
    /**
747
     * @return OpportunityCloseReason
748
     */
749
    public function getCloseReason()
750
    {
751
        return $this->closeReason;
752
    }
753
754
    /**
755
     * @param MultiCurrency $closeRevenue|null
0 ignored issues
show
Documentation introduced by
There is no parameter named $closeRevenue|null. Did you maybe mean $closeRevenue?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
756
     * @return Opportunity
757
     */
758
    public function setCloseRevenue(MultiCurrency $closeRevenue = null)
759
    {
760
        if ($closeRevenue) {
761
            $this->closeRevenue = $closeRevenue;
0 ignored issues
show
Documentation Bug introduced by
It seems like $closeRevenue of type object<Oro\Bundle\Curren...e\Entity\MultiCurrency> is incompatible with the declared type object<Oro\Bundle\SalesB...e\Entity\Multicurrency> of property $closeRevenue.

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...
762
            $this->updateMultiCurrencyFields();
763
        }
764
765
        return $this;
766
    }
767
768
    /**
769
     * @return MultiCurrency|null
770
     */
771
    public function getCloseRevenue()
772
    {
773
        return $this->closeRevenue;
774
    }
775
776
    /**
777
     * @return \DateTime
778
     */
779
    public function getCreatedAt()
780
    {
781
        return $this->createdAt;
782
    }
783
784
    /**
785
     * @param  \DateTime   $created
786
     * @return Opportunity
787
     */
788
    public function setCreatedAt($created)
789
    {
790
        $this->createdAt = $created;
791
792
        return $this;
793
    }
794
795
    /**
796
     * @return \DateTime
797
     */
798
    public function getUpdatedAt()
799
    {
800
        return $this->updatedAt;
801
    }
802
803
    /**
804
     * @param  \DateTime   $updated
805
     * @return Opportunity
806
     */
807
    public function setUpdatedAt($updated)
808
    {
809
        $this->updatedAt = $updated;
810
811
        return $this;
812
    }
813
814
    /**
815
     * Get the primary email address of the related contact
816
     *
817
     * @return string
818
     */
819
    public function getEmail()
820
    {
821
        $contact = $this->getContact();
822
        if (!$contact) {
823
            return null;
824
        }
825
826
        return $contact->getEmail();
827
    }
828
829
    public function __toString()
830
    {
831
        return (string) $this->getName();
832
    }
833
    /**
834
     * @ORM\PrePersist
835
     */
836
    public function beforeSave()
837
    {
838
        $this->createdAt = new \DateTime('now', new \DateTimeZone('UTC'));
839
        $this->beforeUpdate();
840
    }
841
842
    /**
843
     * @ORM\PreUpdate
844
     */
845
    public function beforeUpdate()
846
    {
847
        $this->updatedAt = new \DateTime('now', new \DateTimeZone('UTC'));
848
    }
849
850
    /**
851
     * @return User
852
     */
853
    public function getOwner()
854
    {
855
        return $this->owner;
856
    }
857
858
    /**
859
     * @param  User        $owningUser
860
     * @return Opportunity
861
     */
862
    public function setOwner($owningUser)
863
    {
864
        $this->owner = $owningUser;
865
866
        return $this;
867
    }
868
869
    /**
870
     * @return string
871
     */
872
    public function getNotes()
873
    {
874
        return $this->notes;
875
    }
876
877
    /**
878
     * @param  string      $notes
879
     * @return Opportunity
880
     */
881
    public function setNotes($notes)
882
    {
883
        $this->notes = $notes;
884
885
        return $this;
886
    }
887
888
    /**
889
     * @param B2bCustomer $customer
890
     * @TODO remove null after BAP-5248
891
     */
892
    public function setCustomer(B2bCustomer $customer = null)
893
    {
894
        $this->customer = $customer;
895
    }
896
897
    /**
898
     * @return B2bCustomer
899
     */
900
    public function getCustomer()
901
    {
902
        return $this->customer;
903
    }
904
905
    /**
906
     * Set organization
907
     *
908
     * @param Organization $organization
909
     * @return Opportunity
910
     */
911
    public function setOrganization(Organization $organization = null)
912
    {
913
        $this->organization = $organization;
914
915
        return $this;
916
    }
917
918
    /**
919
     * Get organization
920
     *
921
     * @return Organization
922
     */
923
    public function getOrganization()
924
    {
925
        return $this->organization;
926
    }
927
928
    /**
929
     * Remove Customer
930
     *
931
     * @return Lead
932
     */
933
    public function removeCustomer()
934
    {
935
        $this->customer = null;
936
    }
937
938
    /**
939
     * @param \DateTime $closedAt
940
     */
941
    public function setClosedAt(\DateTime $closedAt = null)
942
    {
943
        $this->closedAt = $closedAt;
944
    }
945
946
    /**
947
     * @return \DateTime
948
     */
949
    public function getClosedAt()
950
    {
951
        return $this->closedAt;
952
    }
953
}
954