@@ 137-151 (lines=15) @@ | ||
134 | /** |
|
135 | * {@inheritDoc} |
|
136 | */ |
|
137 | public function model(string $class, $data = null): ResourceInterface |
|
138 | { |
|
139 | $model = new $class($this->client, $this->api); |
|
140 | // @codeCoverageIgnoreStart |
|
141 | if (!$model instanceof ResourceInterface) { |
|
142 | throw new \RuntimeException(sprintf('%s does not implement %s', $class, ResourceInterface::class)); |
|
143 | } |
|
144 | // @codeCoverageIgnoreEnd |
|
145 | if ($data instanceof ResponseInterface) { |
|
146 | $model->populateFromResponse($data); |
|
147 | } elseif (is_array($data)) { |
|
148 | $model->populateFromArray($data); |
|
149 | } |
|
150 | return $model; |
|
151 | } |
|
152 | } |
|
153 |
@@ 153-170 (lines=18) @@ | ||
150 | return $output; |
|
151 | } |
|
152 | ||
153 | public function model(string $class, $data = null): ResourceInterface |
|
154 | { |
|
155 | $model = new $class(); |
|
156 | ||
157 | // @codeCoverageIgnoreStart |
|
158 | if (!$model instanceof ResourceInterface) { |
|
159 | throw new \RuntimeException(sprintf('%s does not implement %s', $class, ResourceInterface::class)); |
|
160 | } |
|
161 | // @codeCoverageIgnoreEnd |
|
162 | ||
163 | if ($data instanceof ResponseInterface) { |
|
164 | $model->populateFromResponse($data); |
|
165 | } elseif (is_array($data)) { |
|
166 | $model->populateFromArray($data); |
|
167 | } |
|
168 | ||
169 | return $model; |
|
170 | } |
|
171 | ||
172 | public function serialize(): \stdClass |
|
173 | { |
@@ 130-147 (lines=18) @@ | ||
127 | /** |
|
128 | * {@inheritDoc} |
|
129 | */ |
|
130 | public function model(string $class, $data = null): ResourceInterface |
|
131 | { |
|
132 | $model = new $class($this->client, $this->api); |
|
133 | ||
134 | // @codeCoverageIgnoreStart |
|
135 | if (!$model instanceof ResourceInterface) { |
|
136 | throw new \RuntimeException(sprintf('%s does not implement %s', $class, ResourceInterface::class)); |
|
137 | } |
|
138 | // @codeCoverageIgnoreEnd |
|
139 | ||
140 | if ($data instanceof ResponseInterface) { |
|
141 | $model->populateFromResponse($data); |
|
142 | } elseif (is_array($data)) { |
|
143 | $model->populateFromArray($data); |
|
144 | } |
|
145 | ||
146 | return $model; |
|
147 | } |
|
148 | } |
|
149 |