Skip to content

Commit

Permalink
Fix: Do not compose Attachments into Note
Browse files Browse the repository at this point in the history
  • Loading branch information
localheinz committed Aug 27, 2022
1 parent 7c3db8f commit d940e3b
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 75 deletions.
11 changes: 2 additions & 9 deletions psalm-baseline.xml
Expand Up @@ -95,8 +95,7 @@
</PossiblyInvalidArgument>
</file>
<file src="test/Unit/Inside/Domain/Obsidian/NoteTest.php">
<MixedArgument occurrences="2">
<code>$faker-&gt;fileExtension()</code>
<MixedArgument occurrences="1">
<code>$faker-&gt;fileExtension()</code>
</MixedArgument>
<MixedArgumentTypeCoercion occurrences="1">
Expand All @@ -105,7 +104,6 @@
<PossiblyInvalidArgument occurrences="1">
<code>$faker-&gt;sentences()</code>
</PossiblyInvalidArgument>
<TooManyArguments occurrences="1"/>
</file>
<file src="test/Unit/Inside/Domain/Shared/ExtensionTest.php">
<MixedArgument occurrences="4">
Expand Down Expand Up @@ -144,16 +142,11 @@
</MixedArgument>
</file>
<file src="test/Unit/Outside/Adapter/Secondary/Obsidian/NoteWriterTest.php">
<MixedArgument occurrences="8">
<code>$faker-&gt;fileExtension()</code>
<code>$faker-&gt;fileExtension()</code>
<code>$faker-&gt;fileExtension()</code>
<code>$faker-&gt;fileExtension()</code>
<MixedArgument occurrences="4">
<code>$faker-&gt;fileExtension()</code>
<code>$faker-&gt;fileExtension()</code>
<code>$faker-&gt;fileExtension()</code>
<code>$faker-&gt;fileExtension()</code>
</MixedArgument>
<TooManyArguments occurrences="4"/>
</file>
</files>
17 changes: 0 additions & 17 deletions src/Inside/Domain/Obsidian/Note.php
Expand Up @@ -20,31 +20,22 @@
*/
final class Note
{
/**
* @param array<int, Attachment> $attachments
*/
private function __construct(
private readonly Inside\Domain\Shared\FilePath $filePath,
private readonly FrontMatter $frontMatter,
private readonly Inside\Domain\Shared\Text $text,
private readonly array $attachments,
) {
}

/**
* @param array<int, Attachment> $attachments
*/
public static function create(
Inside\Domain\Shared\FilePath $filePath,
FrontMatter $frontMatter,
Inside\Domain\Shared\Text $text,
array $attachments,
): self {
return new self(
$filePath,
$frontMatter,
$text,
$attachments,
);
}

Expand All @@ -62,12 +53,4 @@ public function text(): Inside\Domain\Shared\Text
{
return $this->text;
}

/**
* @return array<int, Attachment>
*/
public function attachments(): array
{
return $this->attachments;
}
}
12 changes: 0 additions & 12 deletions test/Unit/Inside/Domain/Obsidian/NoteTest.php
Expand Up @@ -23,7 +23,6 @@
* @covers \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Obsidian\Note
*
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\DayOne\Tag
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Obsidian\Attachment
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Obsidian\FrontMatter
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Shared\BaseName
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Shared\Directory
Expand Down Expand Up @@ -52,26 +51,15 @@ public function testCreateReturnsNote(): void
$faker->sentences(),
));
$text = Inside\Domain\Shared\Text::fromString($faker->realText());
$attachments = \array_map(static function () use ($faker): Inside\Domain\Obsidian\Attachment {
return Inside\Domain\Obsidian\Attachment::create(Inside\Domain\Shared\FilePath::create(
Inside\Domain\Shared\Directory::fromString($faker->slug()),
Inside\Domain\Shared\FileName::create(
Inside\Domain\Shared\BaseName::fromString($faker->slug()),
Inside\Domain\Shared\Extension::fromString($faker->fileExtension()),
),
));
}, \range(0, 2));

$note = Inside\Domain\Obsidian\Note::create(
$filePath,
$frontMatter,
$text,
$attachments,
);

self::assertSame($filePath, $note->filePath());
self::assertSame($frontMatter, $note->frontMatter());
self::assertSame($text, $note->text());
self::assertSame($attachments, $note->attachments());
}
}
37 changes: 0 additions & 37 deletions test/Unit/Outside/Adapter/Secondary/Obsidian/NoteWriterTest.php
Expand Up @@ -23,7 +23,6 @@
*
* @covers \Ergebnis\DayOneToObsidianConverter\Outside\Adapter\Secondary\Obsidian\NoteWriter
*
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Obsidian\Attachment
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Obsidian\FrontMatter
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Obsidian\Note
* @uses \Ergebnis\DayOneToObsidianConverter\Inside\Domain\Shared\BaseName
Expand Down Expand Up @@ -64,15 +63,6 @@ public function testWriteWriteNoteWhenNoteDoesNotHaveFrontMatterAndDirectoryDoes
),
Inside\Domain\Obsidian\FrontMatter::fromArray([]),
Inside\Domain\Shared\Text::fromString($faker->realText()),
\array_map(static function () use ($faker): Inside\Domain\Obsidian\Attachment {
return Inside\Domain\Obsidian\Attachment::create(Inside\Domain\Shared\FilePath::create(
Inside\Domain\Shared\Directory::fromString($faker->slug()),
Inside\Domain\Shared\FileName::create(
Inside\Domain\Shared\BaseName::fromString($faker->slug()),
Inside\Domain\Shared\Extension::fromString($faker->fileExtension()),
),
));
}, \range(0, 2)),
);

$noteWriter = new Outside\Adapter\Secondary\Obsidian\NoteWriter();
Expand Down Expand Up @@ -100,15 +90,6 @@ public function testWriteWriteNoteWhenNoteDoesNotHaveFrontMatterAndDirectoryExis
),
Inside\Domain\Obsidian\FrontMatter::fromArray([]),
Inside\Domain\Shared\Text::fromString($faker->realText()),
\array_map(static function () use ($faker): Inside\Domain\Obsidian\Attachment {
return Inside\Domain\Obsidian\Attachment::create(Inside\Domain\Shared\FilePath::create(
Inside\Domain\Shared\Directory::fromString($faker->slug()),
Inside\Domain\Shared\FileName::create(
Inside\Domain\Shared\BaseName::fromString($faker->slug()),
Inside\Domain\Shared\Extension::fromString($faker->fileExtension()),
),
));
}, \range(0, 2)),
);

self::fileSystem()->mkdir($note->filePath()->directory()->toString());
Expand Down Expand Up @@ -176,15 +157,6 @@ public function testWriteWriteNoteWhenNoteHasFrontMatterAndDirectoryDoesNotExist
],
]),
Inside\Domain\Shared\Text::fromString($faker->realText()),
\array_map(static function () use ($faker): Inside\Domain\Obsidian\Attachment {
return Inside\Domain\Obsidian\Attachment::create(Inside\Domain\Shared\FilePath::create(
Inside\Domain\Shared\Directory::fromString($faker->slug()),
Inside\Domain\Shared\FileName::create(
Inside\Domain\Shared\BaseName::fromString($faker->slug()),
Inside\Domain\Shared\Extension::fromString($faker->fileExtension()),
),
));
}, \range(0, 2)),
);

$noteWriter = new Outside\Adapter\Secondary\Obsidian\NoteWriter();
Expand Down Expand Up @@ -288,15 +260,6 @@ public function testWriteWriteNoteWhenNoteHasFrontMatterAndDirectoryExists(): vo
],
]),
Inside\Domain\Shared\Text::fromString($faker->realText()),
\array_map(static function () use ($faker): Inside\Domain\Obsidian\Attachment {
return Inside\Domain\Obsidian\Attachment::create(Inside\Domain\Shared\FilePath::create(
Inside\Domain\Shared\Directory::fromString($faker->slug()),
Inside\Domain\Shared\FileName::create(
Inside\Domain\Shared\BaseName::fromString($faker->slug()),
Inside\Domain\Shared\Extension::fromString($faker->fileExtension()),
),
));
}, \range(0, 2)),
);

self::fileSystem()->mkdir($note->filePath()->directory()->toString());
Expand Down

0 comments on commit d940e3b

Please sign in to comment.