Blame view

vendor/yiisoft/multiparser/Parser.php 1016 Bytes
6215a30d   Mihail   add converter int...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
  <?php
  /**
   * Created by PhpStorm.
   * User: Cibermag
   * Date: 04.09.2015
   * Time: 18:25
   */
  
  namespace yii\multiparser;
  
  abstract class Parser
  {
      public $converter_conf  = [];
      protected $converter = NULL;
  
      public function setup()
      {
          $this->setupConverter();
      }
  
      protected function setupConverter()
      {
          $converter = ObjectCreator::build( $this->converter_conf );
          if ( $converter instanceof ConverterInterface ) {
  
              $this->converter = $converter;
  
          }
  
      }
  
      public abstract function read();
  
      /**
       * @param $arr
       * @return mixed
       * преобразовует значения прочитанного массива в нужные типы, согласно конфигурации конвертера
       */
      protected function convert( $arr )
      {
          if ($this->converter !== NULL) {
  
              $arr = $this->converter->convertByConfiguration( $arr, $this->converter_conf );
  
          }
  
  
          return $arr;
  
      }
  }