1 | <?php |
||
24 | class Dump implements DumpInterface |
||
25 | { |
||
26 | /** |
||
27 | * SQL chunk size |
||
28 | */ |
||
29 | const MAX_SQL_SIZE = 1e6; |
||
30 | |||
31 | /** |
||
32 | * @var Adapter |
||
33 | */ |
||
34 | protected $adapter; |
||
35 | |||
36 | /** |
||
37 | * @var PlatformInterface |
||
38 | */ |
||
39 | protected $dumpPlatform; |
||
40 | |||
41 | /** |
||
42 | * @param AdapterInterface|Adapter $adapter |
||
43 | */ |
||
44 | public function __construct($adapter) |
||
48 | |||
49 | /** |
||
50 | * @param AdapterInterface|Adapter $adapter |
||
51 | * @return $this |
||
52 | * @throws Exception\InvalidArgumentException |
||
53 | */ |
||
54 | protected function setAdapter($adapter) |
||
55 | { |
||
56 | if ($adapter instanceof AdapterInterface) { |
||
57 | $adapter = new Adapter($adapter); |
||
58 | |||
59 | } elseif (!($adapter instanceof Adapter)) { |
||
60 | throw new Exception\InvalidArgumentException('Expected Db\Adapter or Dump\Adapter'); |
||
61 | } |
||
62 | |||
63 | $this->adapter = $adapter; |
||
64 | return $this; |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * @return PlatformInterface |
||
69 | */ |
||
70 | public function getDumpPlatform() |
||
77 | |||
78 | /** |
||
79 | * @param PlatformInterface $dumpPlatform |
||
80 | * @return $this |
||
81 | */ |
||
82 | public function setDumpPlatform(PlatformInterface $dumpPlatform = null) |
||
94 | |||
95 | /** |
||
96 | * Return new file object |
||
97 | * |
||
98 | * Prepend file path with `compress.zlib://` wrapper to use compression. |
||
99 | * |
||
100 | * @param string $filePath |
||
101 | * @return File |
||
102 | * @throws Exception\RuntimeException |
||
103 | */ |
||
104 | public function createOutputFile($filePath) |
||
116 | |||
117 | /** |
||
118 | * Return new sql file object |
||
119 | * |
||
120 | * Prepend file path with `compress.zlib://` wrapper to use compression. |
||
121 | * |
||
122 | * @param string $filePath |
||
123 | * @return SqlFile |
||
124 | * @throws Exception\RuntimeException |
||
125 | */ |
||
126 | public function createInputFile($filePath) |
||
138 | |||
139 | /** |
||
140 | * @param string $filePath |
||
141 | * @return $this |
||
142 | */ |
||
143 | public function save($filePath) |
||
149 | |||
150 | /** |
||
151 | * @param File $file |
||
152 | * @return $this |
||
153 | */ |
||
154 | public function write(File $file) |
||
170 | |||
171 | /** |
||
172 | * @param string $filePath |
||
173 | * @return $this |
||
174 | */ |
||
175 | public function load($filePath) |
||
181 | |||
182 | /** |
||
183 | * @param SqlInterface $file |
||
184 | * @return $this |
||
185 | */ |
||
186 | public function read(SqlInterface $file) |
||
193 | } |
||
194 |
If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:
If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.