Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions src/Ci/ClaudeCode.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php

declare(strict_types=1);

namespace OndraM\CiDetector\Ci;

use OndraM\CiDetector\CiDetector;
use OndraM\CiDetector\Env;
use OndraM\CiDetector\TrinaryLogic;

class ClaudeCode extends AbstractCi
{
public static function isDetected(Env $env): bool
{
return $env->get('CLAUDECODE') === '1';
}

public function getCiName(): string
{
return CiDetector::CI_CLAUDECODE;
}

public function isPullRequest(): TrinaryLogic
{
return TrinaryLogic::createMaybe();
}

public function getBuildNumber(): string
{
return '';
}

public function getBuildUrl(): string
{
return '';
}

public function getCommit(): string
{
return '';
}

public function getBranch(): string
{
return '';
}

public function getTargetBranch(): string
{
return '';
}

public function getRepositoryName(): string
{
return '';
}

public function getRepositoryUrl(): string
{
return '';
}
}
2 changes: 2 additions & 0 deletions src/CiDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class CiDetector implements CiDetectorInterface
public const CI_BITBUCKET_PIPELINES = 'Bitbucket Pipelines';
public const CI_BUDDY = 'Buddy';
public const CI_CIRCLE = 'CircleCI';
public const CI_CLAUDECODE = 'Claude Code';
public const CI_CODESHIP = 'Codeship';
public const CI_CONTINUOUSPHP = 'continuousphp';
public const CI_DRONE = 'drone';
Expand Down Expand Up @@ -87,6 +88,7 @@ protected function getCiServers(): array
Ci\TeamCity::class,
Ci\Travis::class,
Ci\Wercker::class,
Ci\ClaudeCode::class,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be sorted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure thing, done 👍

];
}

Expand Down
36 changes: 36 additions & 0 deletions tests/phpt/Ci/CiDetector_ClaudeCode.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
--TEST--
Claude Code: Detect properties

--ENV--
CLAUDECODE=1

--FILE--
<?php

require __DIR__ . '/../../../vendor/autoload.php';

\OndraM\CiDetector\Ci\PropertiesPrinterHelper::printAllProperties();

--EXPECT--
Is CI detected:
bool(true)
Class:
string(31) "OndraM\CiDetector\Ci\ClaudeCode"
CI name:
string(11) "Claude Code"
Is pull request:
string(5) "Maybe"
Build number:
string(0) ""
Build url:
string(0) ""
Commit:
string(0) ""
Branch:
string(0) ""
Target branch:
string(0) ""
Repository name:
string(0) ""
Repository url:
string(0) ""

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline at the end of the file?

Comment thread
sanmai marked this conversation as resolved.
Outdated
17 changes: 17 additions & 0 deletions tests/phpt/Ci/CiDetector_ClaudeCode_not_detected.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
--TEST--
Claude Code: Do not detect ClaudeCode if not set

--ENV--
CLAUDECODE=0

--FILE--
<?php

require __DIR__ . '/../../../vendor/autoload.php';

$ciDetector = new \OndraM\CiDetector\CiDetector();

var_dump($ciDetector->isCiDetected());

--EXPECT--
bool(false)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

newline at the end of the file?

Comment thread
sanmai marked this conversation as resolved.
Outdated