@@ 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 |
@@ 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 |
@@ 130-147 (lines=18) @@ | ||
127 | return $output; |
|
128 | } |
|
129 | ||
130 | public function model(string $class, $data = null): ResourceInterface |
|
131 | { |
|
132 | $model = new $class(); |
|
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 | public function serialize(): \stdClass |
|
150 | { |