<?php

class ACCJ_Scope {
    public $company = false;
    public $project = false;
    public $unit = false;

    public function __construct(array $scopes_data) {
        if (isset($scopes_data['scope_company']) && $scopes_data['scope_company']) {
            $this->company = true;
        }
        if (isset($scopes_data['scope_project']) && $scopes_data['scope_project']) {
            $this->project = true;
        }
        if (isset($scopes_data['scope_unit']) && $scopes_data['scope_unit']) {
            $this->unit = true;
        }
    }

    public function has_company_scope() {
        return $this->company;
    }

    public function has_project_scope() {
        return $this->project;
    }

    public function has_unit_scope() {
        return $this->unit;
    }

    public function get_active_scopes() {
        $active_scopes = [];
        if ($this->company) $active_scopes[] = 'company';
        if ($this->project) $active_scopes[] = 'project';
        if ($this->unit) $active_scopes[] = 'unit';
        return $active_scopes;
    }
}
