Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Real.php
Go to the documentation of this file.
1 <?php
7 
9 
16 class Real implements FactoryInterface
17 {
21  const DEFAULT_PRECISION = "10";
22 
26  const DEFAULT_SCALE = "0";
27 
31  private $objectManager;
32 
36  private $className;
37 
44  public function __construct(
45  ObjectManagerInterface $objectManager,
46  $className = \Magento\Framework\Setup\Declaration\Schema\Dto\Columns\Real::class
47  ) {
48  $this->objectManager = $objectManager;
49  $this->className = $className;
50  }
51 
55  public function create(array $data)
56  {
57  if (!isset($data['precision'])) {
58  $data['precision'] = ($data['type'] === 'decimal') ? self::DEFAULT_PRECISION : 0;
59  }
60 
61  if (!isset($data['scale'])) {
62  $data['scale'] = ($data['type'] === 'decimal') ? self::DEFAULT_SCALE : 0;
63  }
64 
65  if (isset($data['default'])) {
66  $data['default'] = floatval($data['default']);
67  }
68 
69  return $this->objectManager->create($this->className, $data);
70  }
71 }
$objectManager
Definition: bootstrap.php:17
__construct(ObjectManagerInterface $objectManager, $className=\Magento\Framework\Setup\Declaration\Schema\Dto\Columns\Real::class)
Definition: Real.php:44