CapsLock-Studio/node-deploy-server-php-pusher

View on GitHub
src/Context/Secret.php

Summary

Maintainability
A
0 mins
Test Coverage
<?php

namespace CapsLockStudio\Deploy\Pusher\Context;

class Secret
{

    private $secret;

    public function __construct($secret)
    {
        $this->secret = $secret ?: getenv("SECRET");
    }

    public function hash($json)
    {
        $json = json_decode(json_encode($json));
        $json = json_encode($json, JSON_UNESCAPED_SLASHES);

        return hash_hmac("sha1", $json, $this->secret);
    }
}