<commit_before>/* --------------------------------------------------------------------------------------------
 * Copyright (c) <NAME>. All rights reserved.
 * Licensed under the MIT License. See License.md in the project root for license information.
 * ------------------------------------------------------------------------------------------ */
"use strict";

import * as path from 'path';
import * as fs from 'fs';

import { PhpcsPathResolverBase } from './path-resolver-base';

export class ComposerPhpcsPathResolver extends PhpcsPathResolverBase {

	protected readonly _workspaceRoot: string;
	protected readonly _workingPath: string;

	protected _composerJsonPath: string;
	protected _composerLockPath: string;

	/**
	 * Class constructor.
	 *
	 * @param workspaceRoot The workspace path.
	 * @param composerJsonPath The path to composer.json.
	 */
	constructor(workspaceRoot: string, workingPath?: string) {
		super();

		this._workspaceRoot = workspaceRoot;

		if (!path.isAbsolute(workingPath)) {
			workingPath = path.join(workspaceRoot, workingPath);
		}
		this._workingPath = workingPath;
	}

	public get workspaceRoot(): string {
		return this._workspaceRoot;
	}

	public get workingPath(): string {
		return this._workingPath;
	}

	public get composerJsonPath(): string {
		if (!this._composerJsonPath) {
			this._composerJsonPath = fs.realpathSync(path.join(this.workingPath, 'composer.json'));
		}
		return this._composerJsonPath;
	}

	public get composerLockPath(): string {
		if (!this._composerLockPath) {
			this._composerLockPath = fs.realpathSync(path.join(this.workingPath, 'composer.lock'));
		}<commit_msg>Fix composer resolver working path<commit_after>/* --------------------------------------------------------------------------------------------
 * Copyright (c) <NAME>. All rights reserved.
 * Licensed under the MIT License. See License.md in the project root for license information.
 * ------------------------------------------------------------------------------------------ */
"use strict";

import * as path from 'path';
import * as fs from 'fs';

import { PhpcsPathResolverBase } from './path-resolver-base';

export class ComposerPhpcsPathResolver extends PhpcsPathResolverBase {

	protected readonly _workspaceRoot: string;
	protected readonly _workingPath: string;

	protected _composerJsonPath: string;
	protected _composerLockPath: string;

	/**
	 * Class constructor.
	 *
	 * @param workspaceRoot The workspace path.
	 * @param composerJsonPath The path to composer.json.
	 */
	constructor(workspaceRoot: string, workingPath?: string) {
		super();
		this._workspaceRoot = workspaceRoot;
		this._workingPath = path.isAbsolute(workingPath)
			? workingPath
			: path.join(workspaceRoot, workingPath).replace(/composer.json$/, '');
	}

	public get workspaceRoot(): string {
		return this._workspaceRoot;
	}

	public get workingPath(): string {
		return this._workingPath;
	}

	public get composerJsonPath(): string {
		if (!this._composerJsonPath) {
			this._composerJsonPath = fs.realpathSync(path.join(this.workingPath, 'composer.json'));
		}
		return this._composerJsonPath;
	}

	public get composerLockPath(): string {
		if (!this._composerLockPath) {
			this._composerLockPath = fs.realpathSync(path.join(this.workingPath, 'composer.lock'));
		}
{'fraction_non_alphanumeric': 0.20862435469177043, 'fraction_numerical': 0.0, 'mean_word_length': 2.7178329571106095, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3945366', 'n_tokens_mistral': 928, 'n_tokens_neox': 864, 'n_words': 232}