# StatusService

> Reports the state of each file tracked in scaffold-lock.json against the disk and the current provider stubs, and the provider files not tracked yet as pending.

[API reference](/docs/api/index.md) › [Scaffold](/docs/extensions/scaffold/reference/index.md) › [Services](/docs/extensions/scaffold/reference/services/index.md) › StatusService

| final class | `PHPForge\Scaffold\Services\StatusService` |
| --- | --- |
| Source | [`src/Services/StatusService.php`](https://github.com/php-forge/scaffold/blob/main/src/Services/StatusService.php#L37) |

Reports the state of each file tracked in `scaffold-lock.json` against the disk and the current provider stubs, and
the provider files not tracked yet as `pending`.

## Methods

| Method | Description | Defined by |
| --- | --- | --- |
| [`run()`](#method-run) | Renders the status of all files tracked in `scaffold-lock.json` of the project, as a table followed by a summary line or as a JSON document, with notices and provider version drift on stderr. | `StatusService` |

## Method details

### run() <span id="method-run"></span>

```php
public function run(PHPForge\Scaffold\Config\ProjectContext $context, PHPForge\Scaffold\Console\OutputWriter $out, bool $json = false, bool $exitCode = false): int
```

Renders the status of all files tracked in `scaffold-lock.json` of the project, as a table followed by a
summary line or as a JSON document, with notices and provider version drift on stderr.

**Parameters**

| Parameter | Type | Description |
| --- | --- | --- |
| `$context` | [`PHPForge\Scaffold\Config\ProjectContext`](/docs/extensions/scaffold/reference/config/projectcontext/index.md) | Project to inspect. |
| `$out` | [`PHPForge\Scaffold\Console\OutputWriter`](/docs/extensions/scaffold/reference/console/outputwriter/index.md) | Output sink. |
| `$json` | `bool` | Whether to print only the JSON document on stdout. |
| `$exitCode` | `bool` | Whether to return `1` when any file is neither `synced` nor `ejected`, `pending` included. |

**Returns**

`int`: `1` when any file is in the `error` state, or with `$exitCode` when any file is neither `synced` nor `ejected`; `0` otherwise.

**Throws**

- [`RuntimeException`](https://www.php.net/manual/en/class.runtimeexception.php): when the lock file cannot be read or the JSON document cannot be encoded.