PHP code example of codemetry / core

1. Go to this page and download the library: Download codemetry/core library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

codemetry / core example snippets


use Codemetry\Core\Analyzer;
use Codemetry\Core\Domain\AnalysisRequest;

$analyzer = new Analyzer();
$request = new AnalysisRequest(
    days: 7,
    branch: 'main',
);

$result = $analyzer->analyze('/path/to/repo', $request);

foreach ($result->windows as $mood) {
    echo "{$mood->windowLabel}: {$mood->moodLabel->value} ({$mood->moodScore}%)\n";
}

use Codemetry\Core\Signals\SignalProvider;
use Codemetry\Core\Domain\RepoSnapshot;
use Codemetry\Core\Domain\SignalSet;
use Codemetry\Core\Signals\ProviderContext;

class MyProvider implements SignalProvider
{
    public function id(): string
    {
        return 'my_provider';
    }

    public function provide(RepoSnapshot $snapshot, ProviderContext $ctx): SignalSet
    {
        // Compute and return signals
    }
}