Code Duplication    Length = 16-17 lines in 2 locations

core/Helper/Helper.php 2 locations

@@ 21-36 (lines=16) @@
18
	 * @param string $field_name Field name
19
	 * @return mixed
20
	 */
21
	public static function get_value( $object_id, $container_type, $field_name ) {
22
		$repository = \Carbon_Fields\Carbon_Fields::resolve( 'container_repository' );
23
		$field = $repository->get_field_in_containers( $field_name, $container_type );
24
25
		if ( ! $field ) {
26
			return '';
27
		}
28
29
		$clone = clone $field;
30
		if ( $object_id !== null ) {
31
			$clone->get_datastore()->set_object_id( $object_id );
32
		}
33
34
		$clone->load();
35
		return $clone->get_formatted_value();
36
	}
37
38
	/**
39
	 * Set value for a field
@@ 46-62 (lines=17) @@
43
	 * @param string $field_name Field name
44
	 * @param array $value Field expects a `value_set`; Complex_Field expects a `value_tree` - refer to DEVELOPMENT.md
45
	 */
46
	public static function set_value( $object_id, $container_type, $field_name, $value ) {
47
		$repository = \Carbon_Fields\Carbon_Fields::resolve( 'container_repository' );
48
		$field = $repository->get_field_in_containers( $field_name, $container_type );
49
50
		if ( ! $field ) {
51
			Incorrect_Syntax_Exception::raise( 'Could not find a field which satisfies the supplied pattern: ' . $field_name );
52
			return;
53
		}
54
		
55
		$clone = clone $field;
56
		if ( $object_id !== null ) {
57
			$clone->get_datastore()->set_object_id( $object_id );
58
		}
59
60
		$clone->set_value( $value );
61
		$clone->save();
62
	}
63
64
	/**
65
	 * Shorthand for get_post_meta().